/* Generated by Cython 0.23.4 */

#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_23_4"
#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_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)
#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]))
#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
#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
  #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


#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; 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_Int(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 && __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 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/core.pyx",
  "cupy/core/elementwise.pxi",
  "cupy/core/carray.pxi",
  "cupy/core/reduction.pxi",
  "stringsource",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_4cupy_4cuda_6device_Device;
struct __pyx_obj_4cupy_4cuda_6memory_Memory;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer;
struct __pyx_obj_4cupy_4cuda_6memory_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":23
 * ###############################################################################
 * 
 * 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_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_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":313
 *         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":512
 *         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":552
 *     # 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":564
 *     # 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":582
 *     # 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":595
 *     # 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":606
 *             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":618
 *             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":629
 *             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":643
 *     # 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":655
 *     # 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":667
 *         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":679
 *     # 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":689
 *         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":700
 *         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":711
 *         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":723
 *     # 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":726
 *         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":1083
 *         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":1103
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to cuda.ndarray.
 * 
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set {
  int __pyx_n;
  PyObject *stream;
};

/* "cupy/core/core.pyx":1129
 *             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":1183
 *         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":776
 * 
 * 
 * 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":446
 * 
 * 
 * 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":1364
 * # -----------------------------------------------------------------------------
 * 
 * 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 ndim
 */
struct __pyx_opt_args_4cupy_4core_4core_array {
  int __pyx_n;
  PyObject *dtype;
  int copy;
  Py_ssize_t ndmin;
};

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

/* "cupy/core/core.pyx":1408
 * # -----------------------------------------------------------------------------
 * 
 * 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":1511
 *         self.values = tuple(broadcasted)
 * 
 * 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":1578
 * # -----------------------------------------------------------------------------
 * 
 * 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":1680
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if axis is None:
 *         a = a.ravel()
 */
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":1723
 * 
 * 
 * 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":1757
 * # -----------------------------------------------------------------------------
 * 
 * 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 a_is_vec, 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":1981
 * # -----------------------------------------------------------------------------
 * 
 * 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":2239
 * # -----------------------------------------------------------------------------
 * 
 * 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":2263
 * 
 * 
 * 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_fixed(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;
};

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


/* "memory.pxd":59
 * 
 * 
 * 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":31
 * 
 * 
 * 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":218
 * 
 * 
 * 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":410
 * 
 * 
 * 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":1431
 * 
 * 
 * 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":388
 * 
 * @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":392
 *     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":661
 * 
 *     """
 *     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":670
 *         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":673
 *             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":271
 * 
 * @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":279
 *               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_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":59
 * 
 * 
 * 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_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":31
 * 
 * 
 * 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) --- */
#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)

#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

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

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

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

#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

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

#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

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

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

static CYTHON_INLINE Py_ssize_t __Pyx_mod_Py_ssize_t(Py_ssize_t, Py_ssize_t);

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

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);

#define UNARY_NEG_WOULD_OVERFLOW(x)\
        (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static double __Pyx__PyObject_AsDouble(PyObject* obj);
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj)\
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
 likely(PyInt_CheckExact(obj)) ?\
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj)\
((likely(PyFloat_CheckExact(obj))) ?\
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

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

#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

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb);
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);

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

#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

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

#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

#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

#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

#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

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static CYTHON_INLINE int __Pyx_IterFinish(void);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

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

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

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
}

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

#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

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

#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

#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

#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

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

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);

#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

static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc);

static int __Pyx_SetVtable(PyObject *dict, void *vtable);

static void* __Pyx_GetVtable(PyObject *dict);

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

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

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

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __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);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

#include <new>

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

#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

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

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

static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

static int __Pyx_patch_abc(void);

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

static int __Pyx_check_binary_version(void);

#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

static PyObject *__Pyx_ImportModule(const char *name);

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

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

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

/* Module declarations from 'cupy.cuda.cublas' */
static int (*__pyx_f_4cupy_4cuda_6cublas_getPointerMode)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_setPointerMode)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sdot)(size_t, int, size_t, int, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_ddot)(size_t, int, size_t, int, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemv)(size_t, 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_dgemv)(size_t, 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_sger)(size_t, int, int, float, size_t, int, size_t, int, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dger)(size_t, int, int, double, size_t, int, size_t, int, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_sgemm)(size_t, int, int, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6cublas_dgemm)(size_t, int, int, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int __pyx_skip_dispatch); /*proto*/

/* 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__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 *); /*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__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 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__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_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_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*/
#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_property;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_NotImplemented;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_oct;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_open;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_map;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_sum;
static char __pyx_k_0[] = "0";
static char __pyx_k_B[] = "B->?";
static char __pyx_k_H[] = "H->?";
static char __pyx_k_I[] = "I->?";
static char __pyx_k_L[] = "L->?";
static char __pyx_k_Q[] = "Q->?";
static char __pyx_k_T[] = "T";
static char __pyx_k_a[] = "a";
static char __pyx_k_b[] = "b";
static char __pyx_k_d[] = "d";
static char __pyx_k_e[] = "e->?";
static char __pyx_k_f[] = "f";
static char __pyx_k_h[] = "h->?";
static char __pyx_k_i[] = "i";
static char __pyx_k_k[] = "k";
static char __pyx_k_l[] = "?->l";
static char __pyx_k_m[] = "m";
static char __pyx_k_n[] = "n";
static char __pyx_k_p[] = "p";
static char __pyx_k_q[] = "q->?";
static char __pyx_k_s[] = "%s";
static char __pyx_k_t[] = "t";
static char __pyx_k_u[] = "u";
static char __pyx_k_x[] = "x";
static char __pyx_k_BB[] = "BB->?";
static char __pyx_k_HH[] = "HH->?";
static char __pyx_k_II[] = "II->?";
static char __pyx_k_LL[] = "LL->?";
static char __pyx_k_QQ[] = "QQ->?";
static char __pyx_k__4[] = "";
static char __pyx_k_bb[] = "bb->?";
static char __pyx_k_dd[] = "dd->?";
static char __pyx_k_ee[] = "ee->?";
static char __pyx_k_ff[] = "ff->?";
static char __pyx_k_hh[] = "hh->?";
static char __pyx_k_ii[] = "ii->?";
static char __pyx_k_ll[] = "ll->?";
static char __pyx_k_op[] = "op";
static char __pyx_k_os[] = "os";
static char __pyx_k_qq[] = "qq->?";
static char __pyx_k_B_B[] = "B->B";
static char __pyx_k_B_L[] = "B->L";
static char __pyx_k_B_d[] = "B->d";
static char __pyx_k_B_l[] = "B->l";
static char __pyx_k_H_H[] = "H->H";
static char __pyx_k_H_L[] = "H->L";
static char __pyx_k_H_d[] = "H->d";
static char __pyx_k_H_l[] = "H->l";
static char __pyx_k_I_I[] = "I->I";
static char __pyx_k_I_L[] = "I->L";
static char __pyx_k_I_d[] = "I->d";
static char __pyx_k_I_l[] = "I->l";
static char __pyx_k_L_L[] = "L->L";
static char __pyx_k_L_d[] = "L->d";
static char __pyx_k_L_l[] = "L->l";
static char __pyx_k_PY3[] = "PY3";
static char __pyx_k_Q_Q[] = "Q->Q";
static char __pyx_k_Q_d[] = "Q->d";
static char __pyx_k_Q_l[] = "Q->l";
static char __pyx_k__19[] = ", ";
static char __pyx_k__20[] = ",";
static char __pyx_k__30[] = "\n";
static char __pyx_k__39[] = "->";
static char __pyx_k__65[] = "\077\077->?";
static char __pyx_k_a_b[] = "a & b";
static char __pyx_k_add[] = "add";
static char __pyx_k_all[] = "all";
static char __pyx_k_any[] = "any";
static char __pyx_k_arr[] = "arr";
static char __pyx_k_b_b[] = "b->b";
static char __pyx_k_d_2[] = "d->?";
static char __pyx_k_d_3[] = "?->d";
static char __pyx_k_d_d[] = "d->d";
static char __pyx_k_d_l[] = "d->l";
static char __pyx_k_doc[] = "doc";
static char __pyx_k_e_e[] = "e->e";
static char __pyx_k_e_l[] = "e->l";
static char __pyx_k_f_2[] = "f->?";
static char __pyx_k_f_f[] = "f->f";
static char __pyx_k_f_l[] = "f->l";
static char __pyx_k_fid[] = "fid";
static char __pyx_k_fmt[] = "fmt";
static char __pyx_k_get[] = "get";
static char __pyx_k_h_d[] = "h->d";
static char __pyx_k_h_h[] = "h->h";
static char __pyx_k_h_l[] = "h->l";
static char __pyx_k_hex[] = "hex";
static char __pyx_k_i_2[] = "i->?";
static char __pyx_k_i_d[] = "i->d";
static char __pyx_k_i_i[] = "i->i";
static char __pyx_k_i_l[] = "i->l";
static char __pyx_k_in0[] = "in0";
static char __pyx_k_int[] = "int";
static char __pyx_k_l_2[] = "l->?";
static char __pyx_k_l_d[] = "l->d";
static char __pyx_k_l_l[] = "l->l";
static char __pyx_k_map[] = "map";
static char __pyx_k_max[] = "max";
static char __pyx_k_min[] = "min";
static char __pyx_k_nin[] = "nin";
static char __pyx_k_obj[] = "obj";
static char __pyx_k_oct[] = "oct";
static char __pyx_k_ops[] = "ops";
static char __pyx_k_out[] = "out";
static char __pyx_k_pop[] = "pop";
static char __pyx_k_q_d[] = "q->d";
static char __pyx_k_q_l[] = "q->l";
static char __pyx_k_q_q[] = "q->q";
static char __pyx_k_raw[] = "_raw_";
static char __pyx_k_ret[] = "ret";
static char __pyx_k_ror[] = "__ror__";
static char __pyx_k_s_2[] = "s";
static char __pyx_k_s_s[] = "%s->%s";
static char __pyx_k_sep[] = "sep";
static char __pyx_k_set[] = "set";
static char __pyx_k_six[] = "six";
static char __pyx_k_std[] = "std";
static char __pyx_k_sum[] = "sum";
static char __pyx_k_sys[] = "sys";
static char __pyx_k_var[] = "var";
static char __pyx_k_zip[] = "zip";
static char __pyx_k_BB_B[] = "BB->B";
static char __pyx_k_BB_d[] = "BB->d";
static char __pyx_k_HH_H[] = "HH->H";
static char __pyx_k_HH_d[] = "HH->d";
static char __pyx_k_II_I[] = "II->I";
static char __pyx_k_II_d[] = "II->d";
static char __pyx_k_LL_L[] = "LL->L";
static char __pyx_k_LL_d[] = "LL->d";
static char __pyx_k_QQ_Q[] = "QQ->Q";
static char __pyx_k_QQ_d[] = "QQ->d";
static char __pyx_k__108[] = "_";
static char __pyx_k__127[] = "?->?";
static char __pyx_k__142[] = "&";
static char __pyx_k__143[] = "|";
static char __pyx_k__144[] = "^";
static char __pyx_k__148[] = "<<";
static char __pyx_k__149[] = ">>";
static char __pyx_k__152[] = ">";
static char __pyx_k__153[] = ">=";
static char __pyx_k__154[] = "<";
static char __pyx_k__155[] = "<=";
static char __pyx_k__156[] = "==";
static char __pyx_k__157[] = "!=";
static char __pyx_k__169[] = "+";
static char __pyx_k__173[] = "*";
static char __pyx_k__184[] = "-";
static char __pyx_k__206[] = "\077\077?->?";
static char __pyx_k_arch[] = "arch";
static char __pyx_k_args[] = "args";
static char __pyx_k_axis[] = "axis";
static char __pyx_k_bb_b[] = "bb->b";
static char __pyx_k_bb_d[] = "bb->d";
static char __pyx_k_bool[] = "bool_";
static char __pyx_k_call[] = "__call__";
static char __pyx_k_char[] = "char";
static char __pyx_k_clip[] = "clip";
static char __pyx_k_copy[] = "copy";
static char __pyx_k_cuda[] = "cuda";
static char __pyx_k_cupy[] = "cupy_";
static char __pyx_k_dd_d[] = "dd->d";
static char __pyx_k_ddof[] = "ddof";
static char __pyx_k_dump[] = "dump";
static char __pyx_k_ee_e[] = "ee->e";
static char __pyx_k_exit[] = "__exit__";
static char __pyx_k_ff_f[] = "ff->f";
static char __pyx_k_file[] = "__file__";
static char __pyx_k_fill[] = "fill";
static char __pyx_k_hh_d[] = "hh->d";
static char __pyx_k_hh_h[] = "hh->h";
static char __pyx_k_ii_d[] = "ii->d";
static char __pyx_k_ii_i[] = "ii->i";
static char __pyx_k_init[] = "__init__";
static char __pyx_k_int8[] = "int8";
static char __pyx_k_join[] = "join";
static char __pyx_k_kern[] = "kern";
static char __pyx_k_kind[] = "kind";
static char __pyx_k_less[] = "less";
static char __pyx_k_ll_d[] = "ll->d";
static char __pyx_k_ll_l[] = "ll->l";
static char __pyx_k_long[] = "__long__";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_mean[] = "mean";
static char __pyx_k_name[] = "name";
static char __pyx_k_ndim[] = "ndim";
static char __pyx_k_nout[] = "nout";
static char __pyx_k_open[] = "open";
static char __pyx_k_path[] = "path";
static char __pyx_k_prod[] = "prod";
static char __pyx_k_qq_d[] = "qq->d";
static char __pyx_k_qq_q[] = "qq->q";
static char __pyx_k_radd[] = "__radd__";
static char __pyx_k_rand[] = "__rand__";
static char __pyx_k_rdiv[] = "__rdiv__";
static char __pyx_k_read[] = "read";
static char __pyx_k_repr[] = "__repr__";
static char __pyx_k_rmod[] = "__rmod__";
static char __pyx_k_rmul[] = "__rmul__";
static char __pyx_k_rpow[] = "__rpow__";
static char __pyx_k_rsub[] = "__rsub__";
static char __pyx_k_rxor[] = "__rxor__";
static char __pyx_k_self[] = "self";
static char __pyx_k_send[] = "send";
static char __pyx_k_size[] = "size";
static char __pyx_k_step[] = "step";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_take[] = "take";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_true[] = "true";
static char __pyx_k_type[] = "type";
static char __pyx_k_util[] = "util";
static char __pyx_k_view[] = "view";
static char __pyx_k_BBB_B[] = "BBB->B";
static char __pyx_k_BB_BB[] = "BB->BB";
static char __pyx_k_B_B_2[] = "B?->B";
static char __pyx_k_Flags[] = "Flags";
static char __pyx_k_HHH_H[] = "HHH->H";
static char __pyx_k_HH_HH[] = "HH->HH";
static char __pyx_k_H_H_2[] = "H?->H";
static char __pyx_k_III_I[] = "III->I";
static char __pyx_k_II_II[] = "II->II";
static char __pyx_k_I_I_2[] = "I?->I";
static char __pyx_k_LLL_L[] = "LLL->L";
static char __pyx_k_LL_LL[] = "LL->LL";
static char __pyx_k_L_L_2[] = "L?->L";
static char __pyx_k_QQQ_Q[] = "QQQ->Q";
static char __pyx_k_QQ_QQ[] = "QQ->QQ";
static char __pyx_k_Q_Q_2[] = "Q?->Q";
static char __pyx_k_T_in0[] = "T in0";
static char __pyx_k_T_out[] = "T out";
static char __pyx_k_U_out[] = "U out";
static char __pyx_k_a_b_2[] = "a | b";
static char __pyx_k_a_b_3[] = "a + b";
static char __pyx_k_a_b_4[] = "a * b";
static char __pyx_k_a_max[] = "a_max";
static char __pyx_k_a_min[] = "a_min";
static char __pyx_k_array[] = "array";
static char __pyx_k_axis1[] = "axis1";
static char __pyx_k_axis2[] = "axis2";
static char __pyx_k_b_b_2[] = "b?->b";
static char __pyx_k_bb_bb[] = "bb->bb";
static char __pyx_k_bbb_b[] = "bbb->b";
static char __pyx_k_broad[] = "broad";
static char __pyx_k_close[] = "close";
static char __pyx_k_const[] = "const ";
static char __pyx_k_ctype[] = "ctype";
static char __pyx_k_d_d_2[] = "d?->d";
static char __pyx_k_dd_dd[] = "dd->dd";
static char __pyx_k_ddd_d[] = "ddd->d";
static char __pyx_k_doc_2[] = "__doc__";
static char __pyx_k_dtype[] = "dtype";
static char __pyx_k_dumps[] = "dumps";
static char __pyx_k_e_e_2[] = "e?->e";
static char __pyx_k_ee_ee[] = "ee->ee";
static char __pyx_k_eee_e[] = "eee->e";
static char __pyx_k_empty[] = "empty";
static char __pyx_k_enter[] = "__enter__";
static char __pyx_k_equal[] = "equal";
static char __pyx_k_f_f_2[] = "f?->f";
static char __pyx_k_false[] = "false";
static char __pyx_k_ff_ff[] = "ff->ff";
static char __pyx_k_fff_f[] = "fff->f";
static char __pyx_k_flags[] = "flags";
static char __pyx_k_float[] = "float";
static char __pyx_k_h_h_2[] = "h?->h";
static char __pyx_k_hh_hh[] = "hh->hh";
static char __pyx_k_hhh_h[] = "hhh->h";
static char __pyx_k_i_i_2[] = "i?->i";
static char __pyx_k_ii_ii[] = "ii->ii";
static char __pyx_k_iii_i[] = "iii->i";
static char __pyx_k_int16[] = "int16";
static char __pyx_k_int32[] = "int32";
static char __pyx_k_int64[] = "int64";
static char __pyx_k_items[] = "items";
static char __pyx_k_l_l_2[] = "l?->l";
static char __pyx_k_ll_ll[] = "ll->ll";
static char __pyx_k_lll_l[] = "lll->l";
static char __pyx_k_moves[] = "moves";
static char __pyx_k_nargs[] = "nargs";
static char __pyx_k_ndmin[] = "ndmin";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_ops_2[] = "_ops";
static char __pyx_k_param[] = "param";
static char __pyx_k_power[] = "power";
static char __pyx_k_q_q_2[] = "q?->q";
static char __pyx_k_qq_qq[] = "qq->qq";
static char __pyx_k_qqq_q[] = "qqq->q";
static char __pyx_k_range[] = "range";
static char __pyx_k_ravel[] = "ravel";
static char __pyx_k_raw_2[] = "raw";
static char __pyx_k_raxis[] = "raxis";
static char __pyx_k_shape[] = "shape";
static char __pyx_k_short[] = "short";
static char __pyx_k_split[] = "split";
static char __pyx_k_start[] = "start";
static char __pyx_k_std_2[] = "_std";
static char __pyx_k_strip[] = "strip";
static char __pyx_k_throw[] = "throw";
static char __pyx_k_trace[] = "trace";
static char __pyx_k_trans[] = "trans";
static char __pyx_k_types[] = "types";
static char __pyx_k_ufunc[] = "ufunc";
static char __pyx_k_uint8[] = "uint8";
static char __pyx_k_var_2[] = "_var";
static char __pyx_k_T_in_d[] = "T in%d";
static char __pyx_k_T_out0[] = "T out0";
static char __pyx_k_append[] = "append";
static char __pyx_k_argmax[] = "argmax";
static char __pyx_k_argmin[] = "argmin";
static char __pyx_k_arrays[] = "arrays";
static char __pyx_k_astype[] = "astype";
static char __pyx_k_bool_2[] = "bool";
static char __pyx_k_ctypes[] = "ctypes";
static char __pyx_k_cupy_2[] = "cupy";
static char __pyx_k_device[] = "device";
static char __pyx_k_divide[] = "divide";
static char __pyx_k_divmod[] = "divmod";
static char __pyx_k_double[] = "double";
static char __pyx_k_extend[] = "extend";
static char __pyx_k_format[] = "format";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_in_str[] = "in_str";
static char __pyx_k_invert[] = "invert";
static char __pyx_k_kernel[] = "kernel";
static char __pyx_k_kwargs[] = "kwargs";
static char __pyx_k_memptr[] = "memptr";
static char __pyx_k_module[] = "__module__";
static char __pyx_k_n_args[] = "n_args";
static char __pyx_k_nbytes[] = "nbytes";
static char __pyx_k_object[] = "object";
static char __pyx_k_offset[] = "offset";
static char __pyx_k_out0_a[] = "out0 = a";
static char __pyx_k_params[] = "params";
static char __pyx_k_repeat[] = "repeat";
static char __pyx_k_rundim[] = "rundim";
static char __pyx_k_source[] = "source";
static char __pyx_k_stream[] = "stream";
static char __pyx_k_string[] = "string";
static char __pyx_k_tofile[] = "tofile";
static char __pyx_k_tolist[] = "tolist";
static char __pyx_k_uint16[] = "uint16";
static char __pyx_k_uint32[] = "uint32";
static char __pyx_k_uint64[] = "uint64";
static char __pyx_k_unsafe[] = "unsafe";
static char __pyx_k_T_out_d[] = "T out%d";
static char __pyx_k_cPickle[] = "cPickle";
static char __pyx_k_casting[] = "casting";
static char __pyx_k_cstruct[] = "cstruct";
static char __pyx_k_data_as[] = "data_as";
static char __pyx_k_dirname[] = "dirname";
static char __pyx_k_flatten[] = "flatten";
static char __pyx_k_float16[] = "float16";
static char __pyx_k_float32[] = "float32";
static char __pyx_k_float64[] = "float64";
static char __pyx_k_genexpr[] = "genexpr";
static char __pyx_k_greater[] = "greater";
static char __pyx_k_in_args[] = "in_args";
static char __pyx_k_indexer[] = "indexer";
static char __pyx_k_indices[] = "indices";
static char __pyx_k_integer[] = "integer";
static char __pyx_k_memoize[] = "memoize";
static char __pyx_k_ndarray[] = "ndarray";
static char __pyx_k_newaxis[] = "newaxis";
static char __pyx_k_no_bool[] = "no_bool";
static char __pyx_k_options[] = "options";
static char __pyx_k_out_str[] = "out_str";
static char __pyx_k_prepare[] = "__prepare__";
static char __pyx_k_rdivmod[] = "__rdivmod__";
static char __pyx_k_repeats[] = "repeats";
static char __pyx_k_reshape[] = "_reshape";
static char __pyx_k_rlshift[] = "__rlshift__";
static char __pyx_k_routine[] = "routine";
static char __pyx_k_rrshift[] = "__rrshift__";
static char __pyx_k_s_s_s_s[] = "%s%s %s%s";
static char __pyx_k_six_zip[] = "six_zip";
static char __pyx_k_squeeze[] = "squeeze";
static char __pyx_k_strides[] = "strides";
static char __pyx_k_ufunc_s[] = "<ufunc '%s'>";
static char __pyx_k_CIndexer[] = "CIndexer";
static char __pyx_k_Ellipsis[] = "Ellipsis";
static char __pyx_k_Sequence[] = "Sequence";
static char __pyx_k_Template[] = "Template";
static char __pyx_k_absolute[] = "absolute";
static char __pyx_k_c_void_p[] = "c_void_p";
static char __pyx_k_can_cast[] = "can_cast";
static char __pyx_k_cupy_all[] = "cupy_all";
static char __pyx_k_cupy_any[] = "cupy_any";
static char __pyx_k_cupy_max[] = "cupy_max";
static char __pyx_k_cupy_min[] = "cupy_min";
static char __pyx_k_cupy_sum[] = "cupy_sum";
static char __pyx_k_diagonal[] = "diagonal";
static char __pyx_k_identity[] = "identity";
static char __pyx_k_in_shape[] = "in_shape";
static char __pyx_k_in_types[] = "in_types";
static char __pyx_k_is_const[] = "is_const";
static char __pyx_k_isscalar[] = "isscalar";
static char __pyx_k_itemsize[] = "itemsize";
static char __pyx_k_keepdims[] = "keepdims";
static char __pyx_k_map_expr[] = "map_expr";
static char __pyx_k_multiply[] = "multiply";
static char __pyx_k_negative[] = "negative";
static char __pyx_k_newshape[] = "newshape";
static char __pyx_k_out0_in0[] = "out0 = in0";
static char __pyx_k_out_args[] = "out_args";
static char __pyx_k_params_2[] = "_params";
static char __pyx_k_preamble[] = "preamble";
static char __pyx_k_property[] = "property";
static char __pyx_k_qualname[] = "__qualname__";
static char __pyx_k_rtruediv[] = "__rtruediv__";
static char __pyx_k_subtract[] = "subtract";
static char __pyx_k_swapaxes[] = "swapaxes";
static char __pyx_k_var_core[] = "_var_core";
static char __pyx_k_Exception[] = "Exception";
static char __pyx_k_TypeError[] = "TypeError";
static char __pyx_k_args_info[] = "args_info";
static char __pyx_k_cachd_dir[] = "cachd_dir";
static char __pyx_k_cupy_clip[] = "cupy_clip";
static char __pyx_k_cupy_copy[] = "cupy_copy";
static char __pyx_k_cupy_core[] = "cupy.core";
static char __pyx_k_cupy_mean[] = "cupy_mean";
static char __pyx_k_cupy_prod[] = "cupy_prod";
static char __pyx_k_cupy_sqrt[] = "cupy_sqrt";
static char __pyx_k_cupy_take[] = "cupy_take";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_in_params[] = "in_params";
static char __pyx_k_long_long[] = "long long";
static char __pyx_k_loop_prep[] = "loop_prep";
static char __pyx_k_metaclass[] = "__metaclass__";
static char __pyx_k_not_equal[] = "not_equal";
static char __pyx_k_operation[] = "operation";
static char __pyx_k_out_shape[] = "out_shape";
static char __pyx_k_out_types[] = "out_types";
static char __pyx_k_remainder[] = "remainder";
static char __pyx_k_reshape_2[] = "reshape";
static char __pyx_k_ret_shape[] = "ret_shape";
static char __pyx_k_rfloordiv[] = "__rfloordiv__";
static char __pyx_k_same_kind[] = "same_kind";
static char __pyx_k_transpose[] = "_transpose";
static char __pyx_k_type_dict[] = "type_dict";
static char __pyx_k_CArray_s_d[] = "CArray<%s, %d>";
static char __pyx_k_CIndexer_d[] = "CIndexer<%d>";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_after_loop[] = "after_loop";
static char __pyx_k_bit_length[] = "bit_length";
static char __pyx_k_bitwise_or[] = "bitwise_or";
static char __pyx_k_block_size[] = "block_size";
static char __pyx_k_carray_cuh[] = "carray.cuh";
static char __pyx_k_clp2_count[] = "clp2_count";
static char __pyx_k_cupy_power[] = "cupy_power";
static char __pyx_k_in_indexer[] = "in_indexer";
static char __pyx_k_inout_args[] = "inout_args";
static char __pyx_k_input_expr[] = "input_expr";
static char __pyx_k_left_shift[] = "left_shift";
static char __pyx_k_less_equal[] = "less_equal";
static char __pyx_k_min_max_st[] = "min_max_st";
static char __pyx_k_my_max_a_b[] = "my_max(a, b)";
static char __pyx_k_my_min_a_b[] = "my_min(a, b)";
static char __pyx_k_out0_in0_2[] = "out0 = !in0";
static char __pyx_k_out0_in0_3[] = "out0 = ~in0";
static char __pyx_k_out0_in0_4[] = "out0 = -in0";
static char __pyx_k_out_params[] = "out_params";
static char __pyx_k_preamble_2[] = "_preamble";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_shared_mem[] = "shared_mem";
static char __pyx_k_sqrt_fixed[] = "sqrt_fixed";
static char __pyx_k_substitute[] = "substitute";
static char __pyx_k_bitwise_and[] = "bitwise_and";
static char __pyx_k_bitwise_xor[] = "bitwise_xor";
static char __pyx_k_broad_shape[] = "broad_shape";
static char __pyx_k_collections[] = "collections";
static char __pyx_k_cupy_argmax[] = "cupy_argmax";
static char __pyx_k_cupy_argmin[] = "cupy_argmin";
static char __pyx_k_cupy_divide[] = "cupy_divide";
static char __pyx_k_cupy_divmod[] = "cupy_divmod";
static char __pyx_k_cupy_invert[] = "cupy_invert";
static char __pyx_k_in_params_2[] = "_in_params";
static char __pyx_k_out_alpha_a[] = "out = alpha * a";
static char __pyx_k_out_indexer[] = "out_indexer";
static char __pyx_k_output_expr[] = "output_expr";
static char __pyx_k_reduce_dims[] = "reduce_dims";
static char __pyx_k_reduce_expr[] = "reduce_expr";
static char __pyx_k_reduce_type[] = "reduce_type";
static char __pyx_k_right_shift[] = "right_shift";
static char __pyx_k_signed_char[] = "signed char";
static char __pyx_k_transpose_2[] = "transpose";
static char __pyx_k_true_divide[] = "true_divide";
static char __pyx_k_typedef_s_s[] = "typedef %s %s;";
static char __pyx_k_ufunc_types[] = "ufunc.types";
static char __pyx_k_Axes_overrun[] = "Axes overrun";
static char __pyx_k_Axis_overrun[] = "Axis overrun";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_Wrong_type_s[] = "Wrong type %s";
static char __pyx_k_block_stride[] = "block_stride";
static char __pyx_k_create_ufunc[] = "create_ufunc";
static char __pyx_k_floor_divide[] = "floor_divide";
static char __pyx_k_in_arg_dtype[] = "in_arg_dtype";
static char __pyx_k_input_expr_2[] = "_input_expr";
static char __pyx_k_out0_a_index[] = "out0 = a.index";
static char __pyx_k_out0_a_value[] = "out0 = a.value";
static char __pyx_k_out0_in0_in1[] = "out0 = in0 / in1";
static char __pyx_k_out_params_2[] = "_out_params";
static char __pyx_k_pre_map_expr[] = "pre_map_expr";
static char __pyx_k_reduced_view[] = "reduced_view";
static char __pyx_k_ufunc___call[] = "ufunc.__call__";
static char __pyx_k_ufunc___init[] = "ufunc.__init__";
static char __pyx_k_ufunc___repr[] = "ufunc.__repr__";
static char __pyx_k_unsigned_int[] = "unsigned int";
static char __pyx_k_version_info[] = "version_info";
static char __pyx_k_CIndexer__ind[] = "CIndexer _ind";
static char __pyx_k_bhilqBHILQefd[] = "?bhilqBHILQefd";
static char __pyx_k_cupy_absolute[] = "cupy_absolute";
static char __pyx_k_cupy_negative[] = "cupy_negative";
static char __pyx_k_dfeqlihbQLIHB[] = "dfeqlihbQLIHB?";
static char __pyx_k_dtype_is_None[] = "dtype is None";
static char __pyx_k_greater_equal[] = "greater_equal";
static char __pyx_k_in_args_dtype[] = "in_args_dtype";
static char __pyx_k_integer_types[] = "integer_types";
static char __pyx_k_kernel_params[] = "kernel_params";
static char __pyx_k_linear_launch[] = "linear_launch";
static char __pyx_k_my_argmax_a_b[] = "my_argmax(a, b)";
static char __pyx_k_my_argmin_a_b[] = "my_argmin(a, b)";
static char __pyx_k_out0_fabs_in0[] = "out0 = fabs(in0)";
static char __pyx_k_out0_sqrt_in0[] = "out0 = sqrt(in0)";
static char __pyx_k_out_arg_dtype[] = "out_arg_dtype";
static char __pyx_k_out_clp2_size[] = "out_clp2_size";
static char __pyx_k_output_expr_2[] = "_output_expr";
static char __pyx_k_post_map_expr[] = "post_map_expr";
static char __pyx_k_reduce_kernel[] = "reduce_kernel";
static char __pyx_k_routine_cache[] = "_routine_cache";
static char __pyx_k_type_preamble[] = "type_preamble";
static char __pyx_k_unknown_ctype[] = "unknown_ctype";
static char __pyx_k_unsigned_char[] = "unsigned char";
static char __pyx_k_x_mean_x_mean[] = "(x - mean) * (x - mean)";
static char __pyx_k_0_1__raw__1__i[] = "{0} &{1} = _raw_{1}[_i];";
static char __pyx_k_AttributeError[] = "AttributeError";
static char __pyx_k_NotImplemented[] = "NotImplemented";
static char __pyx_k_Shape_mismatch[] = "Shape mismatch";
static char __pyx_k_Syntax_error_s[] = "Syntax error: %s";
static char __pyx_k_array_priority[] = "__array_priority__";
static char __pyx_k_cupy_core_core[] = "cupy.core.core";
static char __pyx_k_cupy_remainder[] = "cupy_remainder";
static char __pyx_k_get_param_info[] = "_get_param_info";
static char __pyx_k_min_max_st_in0[] = "min_max_st(in0)";
static char __pyx_k_out0_fabsf_in0[] = "out0 = fabsf(in0)";
static char __pyx_k_out0_in0_s_in1[] = "out0 = in0 %s in1";
static char __pyx_k_out_args_dtype[] = "out_args_dtype";
static char __pyx_k_types_preamble[] = "types_preamble";
static char __pyx_k_unsigned_short[] = "unsigned short";
static char __pyx_k_ReductionKernel[] = "ReductionKernel";
static char __pyx_k_cupy_copy_where[] = "cupy_copy_where";
static char __pyx_k_cupy_take_0axis[] = "cupy_take_0axis";
static char __pyx_k_for_each_device[] = "for_each_device";
static char __pyx_k_if_in1_out0_in0[] = "if (in1) out0 = in0";
static char __pyx_k_cupy_true_divide[] = "cupy_true_divide";
static char __pyx_k_elementwise_copy[] = "elementwise_copy";
static char __pyx_k_find_common_type[] = "find_common_type";
static char __pyx_k_get_ufunc_kernel[] = "_get_ufunc_kernel";
static char __pyx_k_in_ndarray_types[] = "in_ndarray_types";
static char __pyx_k_out0_pow_in0_in1[] = "out0 = pow(in0, in1)";
static char __pyx_k_Axis_out_of_range[] = "Axis out of range";
static char __pyx_k_Unknown_keyword_s[] = "Unknown keyword \"%s\"";
static char __pyx_k_Wrong_arguments_s[] = "Wrong arguments %s";
static char __pyx_k_ascontiguousarray[] = "ascontiguousarray";
static char __pyx_k_cupy_floor_divide[] = "cupy_floor_divide";
static char __pyx_k_min_max_st_in0__J[] = "min_max_st(in0, _J)";
static char __pyx_k_out0_powf_in0_in1[] = "out0 = powf(in0, in1)";
static char __pyx_k_out_ndarray_types[] = "out_ndarray_types";
static char __pyx_k_update_contiguity[] = "_update_contiguity";
static char __pyx_k_Illegal_conditions[] = "Illegal conditions";
static char __pyx_k_S_x_T_mean_T_alpha[] = "S x, T mean, T alpha";
static char __pyx_k_Unsupported_type_s[] = "Unsupported type %s";
static char __pyx_k_compile_with_cache[] = "compile_with_cache";
static char __pyx_k_decide_params_type[] = "_decide_params_type";
static char __pyx_k_elementwise_copy_2[] = "_elementwise_copy";
static char __pyx_k_incompatible_shape[] = "incompatible shape";
static char __pyx_k_out0_in0_0_in0_in0[] = "out0 = in0 > 0 ? in0 : -in0";
static char __pyx_k_unsigned_long_long[] = "unsigned long long";
static char __pyx_k_Broadcasting_failed[] = "Broadcasting failed";
static char __pyx_k_Cannot_use_out_in_s[] = "Cannot use 'out' in %s";
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
static char __pyx_k_Unsupported_dtype_s[] = "Unsupported dtype %s";
static char __pyx_k_int32__block_stride[] = "int32 _block_stride";
static char __pyx_k_typedef_s_in_d_type[] = "typedef %s in%d_type;";
static char __pyx_k_update_c_contiguity[] = "_update_c_contiguity";
static char __pyx_k_update_f_contiguity[] = "_update_f_contiguity";
static char __pyx_k_Invalid_axes_value_s[] = "Invalid axes value: %s";
static char __pyx_k_Invalid_index_type_s[] = "Invalid index type: %s";
static char __pyx_k_const_0_1__raw__1__j[] = "const {0} {1} = _raw_{1}[_j];";
static char __pyx_k_get_reduction_kernel[] = "_get_reduction_kernel";
static char __pyx_k_t_n__raw__n__ind_get[] = "{t} &{n} = _raw_{n}[_ind.get()];";
static char __pyx_k_typedef_s_out_d_type[] = "typedef %s out%d_type;";
static char __pyx_k_Output_dtype_mismatch[] = "Output dtype mismatch";
static char __pyx_k_Output_shape_mismatch[] = "Output shape mismatch";
static char __pyx_k_len_of_unsized_object[] = "len() of unsized object";
static char __pyx_k_len_shape_len_strides[] = "len(shape) != len(strides)";
static char __pyx_k_set_shape_and_strides[] = "_set_shape_and_strides";
static char __pyx_k_update_c_contiguity_2[] = "update_c_contiguity";
static char __pyx_k_Loop_size_is_Undecided[] = "Loop size is Undecided";
static char __pyx_k_ReductionKernel___call[] = "ReductionKernel.__call__";
static char __pyx_k_ReductionKernel___init[] = "ReductionKernel.__init__";
static char __pyx_k_elementwise_copy_where[] = "_elementwise_copy_where";
static char __pyx_k_get_elementwise_kernel[] = "_get_elementwise_kernel";
static char __pyx_k_Axis_dimension_mismatch[] = "Axis dimension mismatch";
static char __pyx_k_Out_shape_is_mismatched[] = "Out shape is mismatched";
static char __pyx_k_Type_is_mismatched_s_s_s[] = "Type is mismatched. %s %s %s";
static char __pyx_k_elementwise_copy_where_2[] = "elementwise_copy_where";
static char __pyx_k_out0_min_in2_max_in1_in0[] = "out0 = min(in2, max(in1, in0))";
static char __pyx_k_out_a_indices_rdim_i_rdim[] = "\n      out = a[indices * rdim + i % rdim];\n    ";
static char __pyx_k_simple_reduction_function[] = "simple_reduction_function";
static char __pyx_k_Type_is_mismatched_s_s_s_s[] = "Type is mismatched. %s %s %s %s";
static char __pyx_k_const_t_n__raw__n__ind_get[] = "const {t} {n} = _raw_{n}[_ind.get()];";
static char __pyx_k_out0__floor_divide_in0_in1[] = "out0 = _floor_divide(in0, in1)";
static char __pyx_k_1_out_0__raw_out_0__ind_get[] = "{1} &out{0} = _raw_out{0}[_ind.get()];";
static char __pyx_k_array_cannot_be_set_to_array[] = "{} array cannot be set to {} array";
static char __pyx_k_raw_T_a_S_indices_int32_rdim[] = "raw T a, S indices, int32 rdim";
static char __pyx_k_Wrong_type_of_arguments_for_s[] = "Wrong type of arguments for %s";
static char __pyx_k_get_simple_elementwise_kernel[] = "_get_simple_elementwise_kernel";
static char __pyx_k_get_simple_reduction_function[] = "_get_simple_reduction_function";
static char __pyx_k_ufunc___init___locals_genexpr[] = "ufunc.__init__.<locals>.genexpr";
static char __pyx_k_Output_array_size_is_Undecided[] = "Output array size is Undecided";
static char __pyx_k_repeats_should_not_be_negative[] = "'repeats' should not be negative: {}";
static char __pyx_k_struct_min_max_st_type_in0_raw[] = "\nstruct min_max_st{\n    type_in0_raw value;\n    int index;\n    __device__ min_max_st() : index(-1) { }\n    __device__ min_max_st(type_in0_raw v) : value(v), index(0) { }\n    __device__ min_max_st(type_in0_raw v, int i) : value(v), index(i) { }\n};\n__device__ min_max_st my_min(const min_max_st& a, const min_max_st& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    return min_max_st(min(a.value, b.value));\n}\n__device__ min_max_st my_max(const min_max_st& a, const min_max_st& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    return min_max_st(max(a.value, b.value));\n}\n__device__ min_max_st my_argmin(const min_max_st& a, const min_max_st& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value) return min_max_st(a.value, min(a.index, b.index));\n    return (a.value <= b.value) ? a : b;\n}\n__device__ min_max_st my_argmax(const min_max_st& a, const min_max_st& b) {\n    if (a.index == -1) return b;\n    if (b.index == -1) return a;\n    if (a.value == b.value) return min_max_st(a.value, min(a.index, b.index));\n    return (a.value >= b.value) ? a : b;\n}";
static 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 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 char __pyx_k_Input_type_must_be_cupy_ndarray[] = "Input type must be cupy.ndarray";
static char __pyx_k_Only_one_Ellipsis_is_allowed_in[] = "Only one Ellipsis is allowed in index";
static 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 char __pyx_k_Specified_size_can_be_used_only[] = "Specified 'size' can be used only if all of the ndarray are 'raw'.";
static char __pyx_k_Subtracts_arguments_elementwise[] = "Subtracts arguments elementwise.\n\n    .. seealso:: :data:`numpy.subtract`\n\n    ";
static char __pyx_k_Wrong_number_of_arguments_for_s[] = "Wrong number of arguments for %s";
static char __pyx_k_axis_should_be_specified_if_rep[] = "'axis' should be specified if 'repeats' is sequence";
static char __pyx_k_const_in_0__type_in_0__raw_in_0[] = "const in{0}_type in{0} = _raw_in{0}[_ind.get()];";
static char __pyx_k_const_type_in0_raw_in0__raw_in0[] = "const type_in0_raw in0 = _raw_in0[_in_ind.get()];";
static char __pyx_k_get_elementwise_kernel_locals_g[] = "_get_elementwise_kernel.<locals>.genexpr";
static char __pyx_k_get_reduction_kernel_locals_gen[] = "_get_reduction_kernel.<locals>.genexpr";
static char __pyx_k_home_beam2d_chainer_cupy_core_c[] = "/home/beam2d/chainer/cupy/core/core.pyx";
static char __pyx_k_home_beam2d_chainer_cupy_core_e[] = "/home/beam2d/chainer/cupy/core/elementwise.pxi";
static char __pyx_k_home_beam2d_chainer_cupy_core_r[] = "/home/beam2d/chainer/cupy/core/reduction.pxi";
static 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 char __pyx_k_int_li_i_rdim_cdim_int_ri_i_rdi[] = "\n      int li = i / (rdim * cdim);\n      int ri = i % rdim;\n      out = a[(li * adim + indices) * rdim + ri];\n    ";
static char __pyx_k_out0_rint_pow_double_in0_double[] = "out0 = rint(pow((double)in0, (double)in1))";
static 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 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 char __pyx_k_repeats_and_axis_of_a_should_be[] = "'repeats' and 'axis' of 'a' should be same length: {} != {}";
static char __pyx_k_repeats_should_be_int_or_sequen[] = "'repeats' should be int or sequence: {}";
static 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      int _j_stride = ${block_size} * _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        for (int _j = _i + _j_offset, _J = _J_offset;\n             _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 char __pyx_k_Adds_two_arrays_elementwise_seea[] = "Adds two arrays elementwise.\n\n    .. seealso:: :data:`numpy.add`\n\n    ";
static char __pyx_k_Advanced_indexing_is_not_support[] = "Advanced indexing is not supported";
static 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 char __pyx_k_CIndexer__in_ind_CIndexer__out_i[] = "CIndexer _in_ind, CIndexer _out_ind";
static char __pyx_k_Can_not_use_i_as_a_parameter_nam[] = "Can not use 'i' as a parameter name";
static char __pyx_k_Cannot_set_to_non_contiguous_arr[] = "Cannot set to non-contiguous array";
static char __pyx_k_Cannot_specify_out_as_both_a_pos[] = "Cannot specify 'out' as both a positional and keyword argument";
static char __pyx_k_Cannot_squeeze_dimension_of_size[] = "Cannot squeeze dimension of size > 1";
static 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 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 char __pyx_k_Computes_the_remainder_of_Python[] = "Computes the remainder of Python division elementwise.\n\n    .. seealso:: :data:`numpy.remainder`\n\n    ";
static char __pyx_k_Computes_x1_x2_elementwise_seeal[] = "Computes ``x1 ** x2`` elementwise.\n\n    .. seealso:: :data:`numpy.power`\n\n    ";
static char __pyx_k_Divides_arguments_elementwise_se[] = "Divides arguments elementwise.\n\n    .. seealso:: :data:`numpy.divide`\n\n    ";
static char __pyx_k_Elementwise_absolute_value_funct[] = "Elementwise absolute value function.\n\n    .. seealso:: :data:`numpy.absolute`\n\n    ";
static 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 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 char __pyx_k_Index_s_is_out_of_bounds_for_axi[] = "Index %s is out of bounds for axis %s with size %s";
static char __pyx_k_Lengths_of_axes_Setter_of_this_p[] = "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        ";
static char __pyx_k_Multiplies_two_arrays_elementwis[] = "Multiplies two arrays elementwise.\n\n    .. seealso:: :data:`numpy.multiply`\n\n    ";
static char __pyx_k_Negative_dimensions_are_not_allo[] = "Negative dimensions are not allowed";
static char __pyx_k_Only_numpy_ndarray_can_be_set_to[] = "Only numpy.ndarray can be set to cupy.ndarray";
static char __pyx_k_Output_arguments_must_be_cupy_nd[] = "Output arguments must be cupy.ndarray";
static char __pyx_k_Output_arguments_type_must_be_cu[] = "Output arguments type must be cupy.ndarray";
static char __pyx_k_Output_array_has_an_invalid_size[] = "Output array has an invalid size";
static char __pyx_k_Output_array_must_be_C_contiguou[] = "Output array must be C-contiguous";
static char __pyx_k_Takes_numerical_negative_element[] = "Takes numerical negative elementwise.\n\n    .. seealso:: :data:`numpy.negative`\n\n    ";
static char __pyx_k_Tests_elementwise_if_x1_x2_seeal[] = "Tests elementwise if ``x1 > x2``.\n\n    .. seealso:: :data:`numpy.greater`\n\n    ";
static 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 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 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 resued 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 to\n            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 char __pyx_k_all_elements_of_repeats_should_n[] = "all elements of 'repeats' should not be negative: {}";
static char __pyx_k_cannot_dot_zero_sized_and_non_ze[] = "cannot dot zero-sized and non-zero-sized arrays";
static char __pyx_k_cannot_specify_out_as_both_a_pos[] = "cannot specify 'out' as both a positional and keyword argument";
static char __pyx_k_out0_a__in_ind_size__out_ind_siz[] = "out0 = a / (_in_ind.size() / _out_ind.size())";
static char __pyx_k_out0_in0__floor_divide_in0_in1_i[] = "out0 = in0 - _floor_divide(in0, in1) * in1";
static char __pyx_k_out0_in1_0_0_floor_double_in0_do[] = "out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)";
static char __pyx_k_out0_out0_type_in0_out0_type_in1[] = "out0 = (out0_type)in0 / (out0_type)in1";
static 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 char __pyx_k_raw_T_a_S_indices_int32_cdim_int[] = "raw T a, S indices, int32 cdim, int32 rdim, int32 adim";
static char __pyx_k_simple_reduction_function___call[] = "simple_reduction_function.__call__";
static char __pyx_k_simple_reduction_function___init[] = "simple_reduction_function.__init__";
static char __pyx_k_type_out0_raw_out0__raw_out0__ou[] = "type_out0_raw &out0 = _raw_out0[_out_ind.get()];";
static char __pyx_k_typedef_s_type_in0_raw_typedef_s[] = "typedef %s type_in0_raw; typedef %s type_out0_raw;";
static char __pyx_k_zero_size_array_to_reduction_ope[] = "zero-size array to reduction operation %s which has no identity";
static 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 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 char __pyx_k_Tests_elementwise_if_x1_x2_seeal_3[] = "Tests elementwise if ``x1 < x2``.\n\n    .. seealso:: :data:`numpy.less`\n\n    ";
static 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 char __pyx_k_Tests_elementwise_if_x1_x2_seeal_5[] = "Tests elementwise if ``x1 == x2``.\n\n    .. seealso:: :data:`numpy.equal`\n\n    ";
static char __pyx_k_Tests_elementwise_if_x1_x2_seeal_6[] = "Tests elementwise if ``x1 != x2``.\n\n    .. seealso:: :data:`numpy.equal`\n\n    ";
static 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_Advanced_indexing_is_not_support;
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_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_squeeze_dimension_of_size;
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_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_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_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_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_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_kp_s_Subtracts_arguments_elementwise;
static PyObject *__pyx_kp_s_Syntax_error_s;
static PyObject *__pyx_n_s_T;
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__108;
static PyObject *__pyx_kp_s__127;
static PyObject *__pyx_kp_s__142;
static PyObject *__pyx_kp_s__143;
static PyObject *__pyx_kp_s__144;
static PyObject *__pyx_kp_s__148;
static PyObject *__pyx_kp_s__149;
static PyObject *__pyx_kp_s__152;
static PyObject *__pyx_kp_s__153;
static PyObject *__pyx_kp_s__154;
static PyObject *__pyx_kp_s__155;
static PyObject *__pyx_kp_s__156;
static PyObject *__pyx_kp_s__157;
static PyObject *__pyx_kp_s__169;
static PyObject *__pyx_kp_s__173;
static PyObject *__pyx_kp_s__184;
static PyObject *__pyx_kp_s__19;
static PyObject *__pyx_kp_s__20;
static PyObject *__pyx_kp_s__206;
static PyObject *__pyx_kp_s__30;
static PyObject *__pyx_kp_s__39;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_kp_s__65;
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_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_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_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_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_size;
static PyObject *__pyx_n_s_block_stride;
static PyObject *__pyx_n_s_bool;
static PyObject *__pyx_n_s_bool_2;
static PyObject *__pyx_n_s_broad;
static PyObject *__pyx_n_s_broad_shape;
static PyObject *__pyx_n_s_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_dot_zero_sized_and_non_ze;
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_cstruct;
static PyObject *__pyx_n_s_ctype;
static PyObject *__pyx_n_s_ctypes;
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_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_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_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_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_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_e;
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_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_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_chainer_cupy_core_c;
static PyObject *__pyx_kp_s_home_beam2d_chainer_cupy_core_e;
static PyObject *__pyx_kp_s_home_beam2d_chainer_cupy_core_r;
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_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_kp_s_incompatible_shape;
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_n_s_int;
static PyObject *__pyx_n_s_int16;
static PyObject *__pyx_n_s_int32;
static PyObject *__pyx_kp_s_int32__block_stride;
static PyObject *__pyx_n_s_int64;
static PyObject *__pyx_n_s_int8;
static PyObject *__pyx_kp_s_int_li_i_rdim_cdim_int_ri_i_rdi;
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_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_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_n_s_min_max_st;
static PyObject *__pyx_kp_s_min_max_st_in0;
static PyObject *__pyx_kp_s_min_max_st_in0__J;
static PyObject *__pyx_n_s_module;
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_argmin_a_b;
static PyObject *__pyx_kp_s_my_max_a_b;
static PyObject *__pyx_kp_s_my_min_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_nargs;
static PyObject *__pyx_n_s_nbytes;
static PyObject *__pyx_n_s_ndarray;
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_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_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_s_in1;
static PyObject *__pyx_kp_s_out0_in1_0_0_floor_double_in0_do;
static PyObject *__pyx_kp_s_out0_min_in2_max_in1_in0;
static PyObject *__pyx_kp_s_out0_out0_type_in0_out0_type_in1;
static PyObject *__pyx_kp_s_out0_pow_in0_in1;
static PyObject *__pyx_kp_s_out0_powf_in0_in1;
static PyObject *__pyx_kp_s_out0_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_a_indices_rdim_i_rdim;
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;
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_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_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_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_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_shape;
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_source;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_sqrt_fixed;
static PyObject *__pyx_n_s_squeeze;
static PyObject *__pyx_n_s_start;
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_kp_s_struct_min_max_st_type_in0_raw;
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_n_s_test;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_tofile;
static PyObject *__pyx_n_s_tolist;
static PyObject *__pyx_n_s_trace;
static PyObject *__pyx_n_s_trans;
static PyObject *__pyx_n_s_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_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_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_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_2flags(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_4strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_6ndim(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_8itemsize(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_10nbytes(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_12T(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_14cstruct(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_16tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_18tofile(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_20dump(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_file); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_22dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_24astype(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_26copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_28view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_30fill(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_32_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_34reshape(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_shape); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_36_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_38transpose(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axes); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_40swapaxes(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_42flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_44ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_46squeeze(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_axis); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_48take(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_50repeat(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_52diagonal(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_54max(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_56argmax(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_58min(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_60argmin(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_62clip(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_64trace(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_66sum(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_68mean(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_70var(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_72std(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_74prod(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_76all(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_78any(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_80__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_82__nonzero__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_84__neg__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_86__pos__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_88__abs__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_90__invert__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_92__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_94__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_96__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_146__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_148__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_150__reduce__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_152__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_154__len__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_156__getitem__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_slices); /* proto */
static int __pyx_pf_4cupy_4core_4core_7ndarray_158__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_160__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_162__long__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_164__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_166__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_168__hex__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
#endif
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_170__repr__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_172__str__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_174dot(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_176device(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_178get(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_stream); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_180set(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_182reduced_view(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_184_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_186_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_188_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_190_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_2ndim(struct __pyx_obj_4cupy_4core_4core_Indexer *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4core_4core_7Indexer_4cstruct(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_56_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_58_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_60_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_62_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_64dot(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_66tensordot_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_68_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_70_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_72create_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_74_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_76_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_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_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_512;
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__10;
static PyObject *__pyx_slice__59;
static PyObject *__pyx_slice__64;
static PyObject *__pyx_slice__69;
static PyObject *__pyx_slice__74;
static PyObject *__pyx_slice__75;
static PyObject *__pyx_slice__76;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_tuple__111;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__115;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__119;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__129;
static PyObject *__pyx_tuple__131;
static PyObject *__pyx_tuple__132;
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__145;
static PyObject *__pyx_tuple__146;
static PyObject *__pyx_tuple__147;
static PyObject *__pyx_tuple__150;
static PyObject *__pyx_tuple__151;
static PyObject *__pyx_tuple__158;
static PyObject *__pyx_tuple__159;
static PyObject *__pyx_tuple__160;
static PyObject *__pyx_tuple__161;
static PyObject *__pyx_tuple__162;
static PyObject *__pyx_tuple__163;
static PyObject *__pyx_tuple__164;
static PyObject *__pyx_tuple__165;
static PyObject *__pyx_tuple__166;
static PyObject *__pyx_tuple__167;
static PyObject *__pyx_tuple__168;
static PyObject *__pyx_tuple__170;
static PyObject *__pyx_tuple__171;
static PyObject *__pyx_tuple__172;
static PyObject *__pyx_tuple__174;
static PyObject *__pyx_tuple__175;
static PyObject *__pyx_tuple__176;
static PyObject *__pyx_tuple__177;
static PyObject *__pyx_tuple__178;
static PyObject *__pyx_tuple__179;
static PyObject *__pyx_tuple__180;
static PyObject *__pyx_tuple__181;
static PyObject *__pyx_tuple__182;
static PyObject *__pyx_tuple__183;
static PyObject *__pyx_tuple__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__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_codeobj__96;
static PyObject *__pyx_codeobj__98;
static PyObject *__pyx_codeobj__100;
static PyObject *__pyx_codeobj__102;
static PyObject *__pyx_codeobj__104;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__110;
static PyObject *__pyx_codeobj__112;
static PyObject *__pyx_codeobj__114;
static PyObject *__pyx_codeobj__116;
static PyObject *__pyx_codeobj__118;
static PyObject *__pyx_codeobj__121;
static PyObject *__pyx_codeobj__123;
static PyObject *__pyx_codeobj__126;
static PyObject *__pyx_codeobj__130;
static PyObject *__pyx_codeobj__133;

/* "cupy/core/core.pyx":25
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_should_use_rop", 0);

  /* "cupy/core/core.pyx":26
 * @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_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":27
 * 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_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_yp = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":28
 *     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_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __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":25
 * 
 * @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":74
 * 
 * 
 *     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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __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) {
  CYTHON_UNUSED size_t __pyx_v_ndim;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/core.pyx":76
 *     def __init__(self, shape, dtype=float, memptr=None):
 *         cdef Py_ssize_t size
 *         self._shape = internal.get_size(shape)             # <<<<<<<<<<<<<<
 *         ndim = self._shape.size()
 *         for x in self._shape:
 */
  __pyx_t_1 = __pyx_f_4cupy_4core_8internal_get_size(__pyx_v_shape, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->_shape = __pyx_t_2;

  /* "cupy/core/core.pyx":77
 *         cdef Py_ssize_t size
 *         self._shape = internal.get_size(shape)
 *         ndim = self._shape.size()             # <<<<<<<<<<<<<<
 *         for x in self._shape:
 *             if x < 0:
 */
  __pyx_v_ndim = __pyx_v_self->_shape.size();

  /* "cupy/core/core.pyx":78
 *         self._shape = internal.get_size(shape)
 *         ndim = self._shape.size()
 *         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":79
 *         ndim = self._shape.size()
 *         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":80
 *         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_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

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

  /* "cupy/core/core.pyx":81
 *             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_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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":82
 *                 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":84
 *         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_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":83
 *         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_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_strides = __pyx_t_2;

  /* "cupy/core/core.pyx":86
 *             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":87
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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":86
 *             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":89
 *             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_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __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":90
 *         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":92
 *         self.base = None
 * 
 *         self._c_contiguous = True             # <<<<<<<<<<<<<<
 *         self._update_f_contiguity()
 * 
 */
  __pyx_v_self->_c_contiguous = 1;

  /* "cupy/core/core.pyx":93
 * 
 *         self._c_contiguous = True
 *         self._update_f_contiguity()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/core/core.pyx":74
 * 
 * 
 *     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_3flags(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_2flags[] = "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        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_3flags(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("flags (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_2flags(((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_2flags(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("flags", 0);

  /* "cupy/core/core.pyx":114
 * 
 *         """
 *         return flags.Flags(self._c_contiguous, self._f_contiguous,             # <<<<<<<<<<<<<<
 *                            self.base is not None)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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 not 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_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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", __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __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_5strides(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_4strides[] = "Strides of axes in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.strides`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_5strides(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("strides (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_4strides(((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_4strides(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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("strides", 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_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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", __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_7ndim(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_6ndim[] = "Number of dimensions.\n\n        ``a.ndim`` is equivalent to ``len(a.shape)``.\n\n        .. seealso:: :attr:`numpy.ndarray.ndim`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_7ndim(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ndim (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_6ndim(((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_6ndim(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ndim", 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_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __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", __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_9itemsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_8itemsize[] = "Size of each element in bytes.\n\n        .. seealso:: :attr:`numpy.ndarray.itemsize`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_9itemsize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("itemsize (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_8itemsize(((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(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("itemsize", 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_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __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", __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_11nbytes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_10nbytes[] = "Size of whole elements in bytes.\n\n        It does not count skips between elements.\n\n        .. seealso:: :attr:`numpy.ndarray.nbytes`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_11nbytes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nbytes (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_10nbytes(((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_10nbytes(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("nbytes", 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_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __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", __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_13T(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_12T[] = "Shape-reversed view of the array.\n\n        If ndim < 2, then this is just a reference to the array itself.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_13T(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("T (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_12T(((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_12T(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("T", 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_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __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", __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_15cstruct(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_14cstruct[] = "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        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_15cstruct(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cstruct (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_14cstruct(((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_14cstruct(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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cstruct", 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_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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", __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_17tolist(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_17tolist)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __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_17tolist(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_16tolist[] = "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_17tolist(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_16tolist(((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_16tolist(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_19tofile(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_19tofile)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_19tofile(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_18tofile[] = "Writes the array to a file.\n\n        .. seealso:: :meth:`numpy.ndarray.tolist`\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_19tofile(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_18tofile(((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_18tofile(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_21dump(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_21dump)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __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_21dump(PyObject *__pyx_v_self, PyObject *__pyx_v_file); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_20dump[] = "Dumps a pickle of the array to a file.\n\n        Dumped file can be read back to cupy.ndarray by\n        :func:`cupy.load`.\n\n        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_21dump(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_20dump(((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_20dump(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_23dumps(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __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_23dumps)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_23dumps(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_22dumps[] = "Dumps a pickle of the array to a string.";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_23dumps(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_22dumps(((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_22dumps(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_25astype(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_25astype)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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_25astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_24astype[] = "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_25astype(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_copy = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __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_24astype(((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_24astype(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_27copy(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;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_27copy)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __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:
 *             a = ascontiguousarray(self)
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_v_a = __pyx_v_self;

  /* "cupy/core/core.pyx":305
 * 
 *         a = self
 *         if not self._c_contiguous:             # <<<<<<<<<<<<<<
 *             a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 */
  __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:
 *             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_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __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":307
 *         if not self._c_contiguous:
 *             a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():             # <<<<<<<<<<<<<<
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)
 */
    __pyx_t_5 = ((__pyx_v_a->data->device->id == __pyx_f_4cupy_4cuda_6device_get_device_id(0)) != 0);
    if (__pyx_t_5) {

      /* "cupy/core/core.pyx":308
 *             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":307
 *         if not self._c_contiguous:
 *             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:             # <<<<<<<<<<<<<<
 *             a = ascontiguousarray(self)
 *             if a.data.device.id == device.get_device_id():
 */
  }

  /* "cupy/core/core.pyx":309
 *             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_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __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_a->dtype);
  __Pyx_GIVEREF(__pyx_v_a->dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_a->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_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __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":310
 *                 return a
 *         newarray = ndarray(a.shape, a.dtype)
 *         newarray.data.copy_from_device(a.data, a.nbytes)             # <<<<<<<<<<<<<<
 *         return newarray
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_a->data);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __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_1), __pyx_t_6, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __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":311
 *         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_27copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_26copy[] = "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_27copy(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_26copy(((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_26copy(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":313
 *         return newarray
 * 
 *     cpdef ndarray view(self, dtype=None):             # <<<<<<<<<<<<<<
 *         """Returns a view of the array.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_29view(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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_29view)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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":330
 *         # 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_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":331
 *         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":332
 *         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":333
 *         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":334
 *         v._shape = self._shape
 *         v._strides = self._strides
 *         v._c_contiguous = self._c_contiguous             # <<<<<<<<<<<<<<
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.dtype
 */
  __pyx_t_8 = __pyx_v_self->_c_contiguous;
  __pyx_v_v->_c_contiguous = __pyx_t_8;

  /* "cupy/core/core.pyx":335
 *         v._strides = self._strides
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous             # <<<<<<<<<<<<<<
 *         v.dtype = self.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":336
 *         v._c_contiguous = self._c_contiguous
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.dtype             # <<<<<<<<<<<<<<
 *         v.data = self.data
 *         v.base = self.base if self.base is not None else self
 */
  __pyx_t_1 = __pyx_v_self->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_v->dtype);
  __Pyx_DECREF(__pyx_v_v->dtype);
  __pyx_v_v->dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":337
 *         v._f_contiguous = self._f_contiguous
 *         v.dtype = self.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":338
 *         v.dtype = self.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":339
 *         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":313
 *         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_29view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_28view[] = "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_29view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __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_28view(((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_28view(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":344
 *     # TODO(okuta): Implement setflags
 * 
 *     cpdef fill(self, value):             # <<<<<<<<<<<<<<
 *         """Fills the array with a scalar value.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_31fill(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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __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_31fill)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __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":353
 * 
 *         """
 *         elementwise_copy(value, self, dtype=self.dtype)             # <<<<<<<<<<<<<<
 * 
 *     # -------------------------------------------------------------------------
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_value);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":344
 *     # 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_31fill(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_30fill[] = "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_31fill(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_30fill(((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_30fill(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":358
 *     # 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_33_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_33_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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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":361
 *         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_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_shape = __pyx_t_7;

  /* "cupy/core/core.pyx":362
 *         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":363
 *         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_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __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":362
 *         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":365
 *             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_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_strides = __pyx_t_7;

  /* "cupy/core/core.pyx":366
 * 
 *         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":367
 *         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_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __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":366
 * 
 *         strides = _get_strides_for_nocopy_reshape(self, shape)
 *         if strides.size() == shape.size():             # <<<<<<<<<<<<<<
 *             newarray = self.view()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":369
 *             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_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __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
 *         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_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_strides = __pyx_t_7;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":372
 *             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_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "cupy/core/core.pyx":373
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":374
 *         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":358
 *     # 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_33_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_33_reshape(PyObject *__pyx_v_self, PyObject *__pyx_arg_shape) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __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_32_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_32_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":376
 *         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_35reshape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_34reshape[] = "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_35reshape(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_34reshape(((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_34reshape(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reshape", 0);
  __Pyx_INCREF(__pyx_v_shape);

  /* "cupy/core/core.pyx":385
 *         """
 *         # 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_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __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":386
 *         # 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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __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":385
 *         """
 *         # 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":387
 *         if len(shape) == 1 and cpython.PySequence_Check(shape[0]):
 *             shape = shape[0]
 *         return self._reshape(shape)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_shape); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":376
 *         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":392
 *     # 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_37_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_37_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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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":397
 *         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":398
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __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":399
 *         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":400
 *         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_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":401
 *         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_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":402
 *             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":403
 *             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":404
 *             ret._c_contiguous = self._f_contiguous
 *             ret._f_contiguous = self._c_contiguous
 *             return ret             # <<<<<<<<<<<<<<
 * 
 *         if 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":399
 *         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":406
 *             return ret
 * 
 *         if axes.size() != ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 */
  __pyx_t_7 = ((__pyx_v_axes.size() != __pyx_v_ndim) != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":407
 * 
 *         if 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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

  /* "cupy/core/core.pyx":409
 *             raise ValueError('Invalid axes value: %s' % str(axes))
 * 
 *         for i in range(ndim):             # <<<<<<<<<<<<<<
 *             a_axes.push_back(i)
 *             axis = <Py_ssize_t?>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":410
 * 
 *         for i in range(ndim):
 *             a_axes.push_back(i)             # <<<<<<<<<<<<<<
 *             axis = <Py_ssize_t?>axes[i]
 *             if axis < -ndim or axis >= ndim:
 */
    try {
      __pyx_v_a_axes.push_back(__pyx_v_i);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

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

    /* "cupy/core/core.pyx":412
 *             a_axes.push_back(i)
 *             axis = <Py_ssize_t?>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":413
 *             axis = <Py_ssize_t?>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__5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

    /* "cupy/core/core.pyx":414
 *             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_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_axes[__pyx_v_i]) = __Pyx_mod_Py_ssize_t(__pyx_v_axis, __pyx_v_ndim);
  }

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

  /* "cupy/core/core.pyx":418
 *         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_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":419
 *             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":420
 *         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_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":421
 *         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_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":422
 *             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":423
 *             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":424
 *             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":419
 *             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":426
 *             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_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PySet_Add(__pyx_t_2, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __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":427
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

  /* "cupy/core/core.pyx":429
 *             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":430
 * 
 *         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":431
 *         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":432
 *         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_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":433
 *         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_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":431
 *         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":434
 *             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_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":435
 *             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":392
 *     # 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_37_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_37_transpose(PyObject *__pyx_v_self, PyObject *__pyx_arg_axes) {
  std::vector<Py_ssize_t>  __pyx_v_axes;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_36_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_36_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":437
 *         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_39transpose(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_38transpose[] = "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_39transpose(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_38transpose(((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_38transpose(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transpose", 0);
  __Pyx_INCREF(__pyx_v_axes);

  /* "cupy/core/core.pyx":448
 *         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_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":449
 *         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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_a = __pyx_t_3;
    __pyx_t_3 = 0;

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

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

    /* "cupy/core/core.pyx":448
 *         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":454
 *             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_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":437
 *         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":456
 *         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_41swapaxes(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_41swapaxes)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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":464
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_7;

  /* "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:             # <<<<<<<<<<<<<<
 *             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":467
 *         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__6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "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:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis out of range')
 *         axis1 %= ndim
 */
  }

  /* "cupy/core/core.pyx":468
 *         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_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_axis1 = __Pyx_mod_Py_ssize_t(__pyx_v_axis1, __pyx_v_ndim);

  /* "cupy/core/core.pyx":469
 *             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_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_axis2 = __Pyx_mod_Py_ssize_t(__pyx_v_axis2, __pyx_v_ndim);

  /* "cupy/core/core.pyx":470
 *         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":471
 *         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_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "cupy/core/core.pyx":472
 *         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":473
 *             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_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __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":456
 *         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_41swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_40swapaxes[] = "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_41swapaxes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  Py_ssize_t __pyx_v_axis1;
  Py_ssize_t __pyx_v_axis2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swapaxes") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_axis2 = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_axis2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __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_40swapaxes(((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_40swapaxes(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":475
 *         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_43flatten(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __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_43flatten)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __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":487
 *         """
 *         # 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":488
 *         # 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_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __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":487
 *         """
 *         # TODO(beam2d): Support ordering option
 *         if self._c_contiguous:             # <<<<<<<<<<<<<<
 *             newarray = self.copy()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":490
 *             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_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __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":491
 *         else:
 *             newarray = ndarray(self.shape, self.dtype)
 *             elementwise_copy(self, newarray)             # <<<<<<<<<<<<<<
 * 
 *         newarray._shape.assign(1, self.size)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __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":493
 *             elementwise_copy(self, newarray)
 * 
 *         newarray._shape.assign(1, self.size)             # <<<<<<<<<<<<<<
 *         newarray._strides.assign(1, self.itemsize)
 *         newarray._c_contiguous = True
 */
  __pyx_v_newarray->_shape.assign(1, __pyx_v_self->size);

  /* "cupy/core/core.pyx":494
 * 
 *         newarray._shape.assign(1, self.size)
 *         newarray._strides.assign(1, 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_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_newarray->_strides.assign(1, __pyx_t_6);

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

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

  /* "cupy/core/core.pyx":497
 *         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":475
 *         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_43flatten(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_42flatten[] = "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_43flatten(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_42flatten(((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_42flatten(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":499
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattend into one dimension.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_45ravel(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __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_45ravel)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __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":509
 *         # 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_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":510
 *         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_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __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":499
 *         return newarray
 * 
 *     cpdef ndarray ravel(self):             # <<<<<<<<<<<<<<
 *         """Returns an array flattend 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_45ravel(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_44ravel[] = "Returns an array flattend 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_45ravel(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_44ravel(((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_44ravel(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":512
 *         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_47squeeze(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<Py_ssize_t>  __pyx_v_vec_axis;
  std::vector<Py_ssize_t>  __pyx_v_newshape;
  std::vector<Py_ssize_t>  __pyx_v_newstrides;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_n;
  size_t __pyx_v_i;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_v = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  size_t __pyx_t_8;
  size_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  std::vector<Py_ssize_t>  __pyx_t_11;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray__set_shape_and_strides __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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_47squeeze)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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":522
 *         cdef vector.vector[Py_ssize_t] vec_axis, newshape, newstrides
 *         cdef Py_ssize_t j, n
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             for i in range(self._shape.size()):
 *                 n = self._shape[i]
 */
  __pyx_t_6 = (__pyx_v_axis == Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":523
 *         cdef Py_ssize_t j, n
 *         if axis is None:
 *             for i in range(self._shape.size()):             # <<<<<<<<<<<<<<
 *                 n = self._shape[i]
 *                 if n == 1:
 */
    __pyx_t_8 = __pyx_v_self->_shape.size();
    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":524
 *         if axis is None:
 *             for i in range(self._shape.size()):
 *                 n = self._shape[i]             # <<<<<<<<<<<<<<
 *                 if n == 1:
 *                     vec_axis.push_back(i)
 */
      __pyx_v_n = (__pyx_v_self->_shape[__pyx_v_i]);

      /* "cupy/core/core.pyx":525
 *             for i in range(self._shape.size()):
 *                 n = self._shape[i]
 *                 if n == 1:             # <<<<<<<<<<<<<<
 *                     vec_axis.push_back(i)
 *         elif isinstance(axis, int):
 */
      __pyx_t_7 = ((__pyx_v_n == 1) != 0);
      if (__pyx_t_7) {

        /* "cupy/core/core.pyx":526
 *                 n = self._shape[i]
 *                 if n == 1:
 *                     vec_axis.push_back(i)             # <<<<<<<<<<<<<<
 *         elif isinstance(axis, int):
 *             vec_axis.push_back(axis)
 */
        try {
          __pyx_v_vec_axis.push_back(__pyx_v_i);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }

        /* "cupy/core/core.pyx":525
 *             for i in range(self._shape.size()):
 *                 n = self._shape[i]
 *                 if n == 1:             # <<<<<<<<<<<<<<
 *                     vec_axis.push_back(i)
 *         elif isinstance(axis, int):
 */
      }
    }

    /* "cupy/core/core.pyx":522
 *         cdef vector.vector[Py_ssize_t] vec_axis, newshape, newstrides
 *         cdef Py_ssize_t j, n
 *         if axis is None:             # <<<<<<<<<<<<<<
 *             for i in range(self._shape.size()):
 *                 n = self._shape[i]
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":527
 *                 if n == 1:
 *                     vec_axis.push_back(i)
 *         elif isinstance(axis, int):             # <<<<<<<<<<<<<<
 *             vec_axis.push_back(axis)
 *         else:
 */
  __pyx_t_7 = PyInt_Check(__pyx_v_axis); 
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":528
 *                     vec_axis.push_back(i)
 *         elif isinstance(axis, int):
 *             vec_axis.push_back(axis)             # <<<<<<<<<<<<<<
 *         else:
 *             vec_axis = axis
 */
    __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_axis); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    try {
      __pyx_v_vec_axis.push_back(__pyx_t_10);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":527
 *                 if n == 1:
 *                     vec_axis.push_back(i)
 *         elif isinstance(axis, int):             # <<<<<<<<<<<<<<
 *             vec_axis.push_back(axis)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":530
 *             vec_axis.push_back(axis)
 *         else:
 *             vec_axis = axis             # <<<<<<<<<<<<<<
 * 
 *         if vec_axis.size() == 0:
 */
  /*else*/ {
    __pyx_t_11 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_axis); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_vec_axis = __pyx_t_11;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":532
 *             vec_axis = axis
 * 
 *         if vec_axis.size() == 0:             # <<<<<<<<<<<<<<
 *             return self
 *         j = 0
 */
  __pyx_t_6 = ((__pyx_v_vec_axis.size() == 0) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":533
 * 
 *         if vec_axis.size() == 0:
 *             return self             # <<<<<<<<<<<<<<
 *         j = 0
 *         for i in range(self._shape.size()):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":532
 *             vec_axis = axis
 * 
 *         if vec_axis.size() == 0:             # <<<<<<<<<<<<<<
 *             return self
 *         j = 0
 */
  }

  /* "cupy/core/core.pyx":534
 *         if vec_axis.size() == 0:
 *             return self
 *         j = 0             # <<<<<<<<<<<<<<
 *         for i in range(self._shape.size()):
 *             n = self._shape[i]
 */
  __pyx_v_j = 0;

  /* "cupy/core/core.pyx":535
 *             return self
 *         j = 0
 *         for i in range(self._shape.size()):             # <<<<<<<<<<<<<<
 *             n = self._shape[i]
 *             if j < vec_axis.size() and i == vec_axis[j]:
 */
  __pyx_t_8 = __pyx_v_self->_shape.size();
  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":536
 *         j = 0
 *         for i in range(self._shape.size()):
 *             n = self._shape[i]             # <<<<<<<<<<<<<<
 *             if j < vec_axis.size() and i == vec_axis[j]:
 *                 if n != 1:
 */
    __pyx_v_n = (__pyx_v_self->_shape[__pyx_v_i]);

    /* "cupy/core/core.pyx":537
 *         for i in range(self._shape.size()):
 *             n = self._shape[i]
 *             if j < vec_axis.size() and i == vec_axis[j]:             # <<<<<<<<<<<<<<
 *                 if n != 1:
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')
 */
    __pyx_t_7 = ((__pyx_v_j < __pyx_v_vec_axis.size()) != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_i == (__pyx_v_vec_axis[__pyx_v_j])) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_6) {

      /* "cupy/core/core.pyx":538
 *             n = self._shape[i]
 *             if j < vec_axis.size() and i == vec_axis[j]:
 *                 if n != 1:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')
 *                 j += 1
 */
      __pyx_t_6 = ((__pyx_v_n != 1) != 0);
      if (__pyx_t_6) {

        /* "cupy/core/core.pyx":539
 *             if j < vec_axis.size() and i == vec_axis[j]:
 *                 if n != 1:
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')             # <<<<<<<<<<<<<<
 *                 j += 1
 *             else:
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/core.pyx":538
 *             n = self._shape[i]
 *             if j < vec_axis.size() and i == vec_axis[j]:
 *                 if n != 1:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')
 *                 j += 1
 */
      }

      /* "cupy/core/core.pyx":540
 *                 if n != 1:
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')
 *                 j += 1             # <<<<<<<<<<<<<<
 *             else:
 *                 newshape.push_back(n)
 */
      __pyx_v_j = (__pyx_v_j + 1);

      /* "cupy/core/core.pyx":537
 *         for i in range(self._shape.size()):
 *             n = self._shape[i]
 *             if j < vec_axis.size() and i == vec_axis[j]:             # <<<<<<<<<<<<<<
 *                 if n != 1:
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')
 */
      goto __pyx_L10;
    }

    /* "cupy/core/core.pyx":542
 *                 j += 1
 *             else:
 *                 newshape.push_back(n)             # <<<<<<<<<<<<<<
 *                 newstrides.push_back(self._strides[i])
 * 
 */
    /*else*/ {
      try {
        __pyx_v_newshape.push_back(__pyx_v_n);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "cupy/core/core.pyx":543
 *             else:
 *                 newshape.push_back(n)
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    __pyx_L10:;
  }

  /* "cupy/core/core.pyx":545
 *                 newstrides.push_back(self._strides[i])
 * 
 *         v = self.view()             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(newshape, newstrides, False)
 *         return v
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":546
 * 
 *         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_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->_set_shape_and_strides(__pyx_v_v, __pyx_v_newshape, __pyx_v_newstrides, 0, &__pyx_t_12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":547
 *         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":512
 *         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((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_47squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_46squeeze[] = "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_47squeeze(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_axis = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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_46squeeze(((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_46squeeze(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":552
 *     # 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_49take(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_49take)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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":560
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __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":552
 *     # 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_49take(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_48take[] = "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_49take(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_48take(((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_48take(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":564
 *     # 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_51repeat(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __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_51repeat)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __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":571
 *             :meth:`numpy.ndarray.repeat`
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":564
 *     # 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_51repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_50repeat[] = "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        ";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_51repeat(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_repeats = 0;
  PyObject *__pyx_v_axis = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __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_50repeat(((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_50repeat(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":582
 *     # 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_53diagonal(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_53diagonal)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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":590
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __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":582
 *     # 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_53diagonal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_52diagonal[] = "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_53diagonal(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __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_52diagonal(((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_52diagonal(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":595
 *     # 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_55max(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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_55max)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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":603
 * 
 *         """
 *         return _amax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":604
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":603
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __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":595
 *     # 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_55max(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_54max[] = "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_55max(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __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_54max(((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_54max(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":606
 *             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_57argmax(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":607
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":606
 *             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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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_57argmax)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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":615
 * 
 *         """
 *         return _argmax(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":616
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":615
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __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":606
 *             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_57argmax(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_56argmax[] = "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_57argmax(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":607
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __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_56argmax(((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":606
 *             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_56argmax(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":618
 *             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_59min(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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_59min)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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":626
 * 
 *         """
 *         return _amin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":627
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":626
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __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":618
 *             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_59min(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_58min[] = "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_59min(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __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_58min(((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_58min(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":629
 *             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_61argmin(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":630
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":629
 *             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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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_61argmin)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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":638
 * 
 *         """
 *         return _argmin(             # <<<<<<<<<<<<<<
 *             self, axis=axis, out=out, dtype=dtype, keepdims=keepdims)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));

  /* "cupy/core/core.pyx":639
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":638
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __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":629
 *             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_61argmin(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_60argmin[] = "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_61argmin(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":630
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __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_60argmin(((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":629
 *             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_60argmin(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":643
 *     # 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_63clip(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_63clip)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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":651
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __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":643
 *     # 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_63clip(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_62clip[] = "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_63clip(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __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_62clip(((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_62clip(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":655
 *     # 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_65trace(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":656
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":655
 *     # 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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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_65trace)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __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":665
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __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":655
 *     # 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_65trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_64trace[] = "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_65trace(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":656
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __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_64trace(((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":655
 *     # 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_64trace(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":667
 *         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_67sum(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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_67sum)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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":675
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __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":667
 *         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_67sum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_66sum[] = "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_67sum(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __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_66sum(((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_66sum(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":679
 *     # 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_69mean(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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_69mean)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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":687
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __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":679
 *     # 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_69mean(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_68mean[] = "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_69mean(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __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_68mean(((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_68mean(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":689
 *         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_71var(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":690
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":689
 *         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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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_71var)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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":698
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __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":689
 *         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_71var(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_70var[] = "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_71var(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":690
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __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_70var(((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":689
 *         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_70var(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":700
 *         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_73std(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":701
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":700
 *         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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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_73std)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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":709
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __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":700
 *         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_73std(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_72std[] = "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_73std(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":701
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __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_72std(((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":700
 *         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_72std(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":711
 *         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_75prod(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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_75prod)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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":719
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __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":711
 *         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_75prod(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_74prod[] = "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_75prod(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __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_74prod(((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_74prod(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":723
 *     # 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_77all(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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_77all)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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":724
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __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":723
 *     # 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_77all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_77all(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __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_76all(((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_76all(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":726
 *         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_79any(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_79any)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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":727
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __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":726
 *         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_79any(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_79any(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_78any(((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_78any(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":734
 *     # 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_81__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_81__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_80__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_80__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "cupy/core/core.pyx":735
 * 
 *     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":736
 *     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_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __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":735
 * 
 *     def __richcmp__(object self, object other, int op):
 *         if op == 0:             # <<<<<<<<<<<<<<
 *             return less(self, other)
 *         if op == 1:
 */
  }

  /* "cupy/core/core.pyx":737
 *         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":738
 *             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_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __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":737
 *         if op == 0:
 *             return less(self, other)
 *         if op == 1:             # <<<<<<<<<<<<<<
 *             return less_equal(self, other)
 *         if op == 2:
 */
  }

  /* "cupy/core/core.pyx":739
 *         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":740
 *             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_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __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":739
 *         if op == 1:
 *             return less_equal(self, other)
 *         if op == 2:             # <<<<<<<<<<<<<<
 *             return equal(self, other)
 *         if op == 3:
 */
  }

  /* "cupy/core/core.pyx":741
 *         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":742
 *             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_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __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":741
 *         if op == 2:
 *             return equal(self, other)
 *         if op == 3:             # <<<<<<<<<<<<<<
 *             return not_equal(self, other)
 *         if op == 4:
 */
  }

  /* "cupy/core/core.pyx":743
 *         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":744
 *             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_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __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":743
 *         if op == 3:
 *             return not_equal(self, other)
 *         if op == 4:             # <<<<<<<<<<<<<<
 *             return greater(self, other)
 *         if op == 5:
 */
  }

  /* "cupy/core/core.pyx":745
 *         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":746
 *             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_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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":745
 *         if op == 4:
 *             return greater(self, other)
 *         if op == 5:             # <<<<<<<<<<<<<<
 *             return greater_equal(self, other)
 *         return NotImplemented
 */
  }

  /* "cupy/core/core.pyx":747
 *         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":734
 *     # 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":751
 *     # 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_83__nonzero__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_83__nonzero__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__nonzero__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_82__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_82__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__nonzero__", 0);

  /* "cupy/core/core.pyx":752
 * 
 *     def __nonzero__(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             return False
 *         elif self.size == 1:
 */
  switch (__pyx_v_self->size) {
    case 0:

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

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

    /* "cupy/core/core.pyx":755
 *             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_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = (!(!__pyx_t_2));
    goto __pyx_L0;

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

    /* "cupy/core/core.pyx":757
 *             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":759
 *             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_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_85__neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__neg__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_84__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_84__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__neg__", 0);

  /* "cupy/core/core.pyx":764
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __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":763
 *     # 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":766
 *         return negative(self)
 * 
 *     def __pos__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__pos__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_87__pos__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pos__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_86__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_86__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":767
 * 
 *     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":766
 *         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":769
 *         return self
 * 
 *     def __abs__(self):             # <<<<<<<<<<<<<<
 *         return absolute(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_89__abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__abs__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_88__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_88__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__abs__", 0);

  /* "cupy/core/core.pyx":770
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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":769
 *         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":772
 *         return absolute(self)
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return invert(self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_91__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__invert__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_90__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_90__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__invert__", 0);

  /* "cupy/core/core.pyx":773
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __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":772
 *         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":777
 *     # 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_93__add__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_93__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_92__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_92__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__add__", 0);

  /* "cupy/core/core.pyx":778
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":779
 *     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_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __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":778
 * 
 *     def __add__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__radd__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":781
 *             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_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __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":777
 *     # 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":783
 *             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_95__sub__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_95__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_94__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_94__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__sub__", 0);

  /* "cupy/core/core.pyx":784
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":785
 *     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_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __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":784
 * 
 *     def __sub__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rsub__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":787
 *             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_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __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":783
 *             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":789
 *             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_97__mul__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_97__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_96__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_96__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mul__", 0);

  /* "cupy/core/core.pyx":790
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":791
 *     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_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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":790
 * 
 *     def __mul__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmul__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":793
 *             return y.__rmul__(x)
 *         else:
 *             return multiply(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def __div__(x, y):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __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":789
 *             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":795
 *             return multiply(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_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_99__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__div__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_98__div__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_98__div__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__div__", 0);

  /* "cupy/core/core.pyx":796
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":797
 *     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_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __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":796
 * 
 *     def __div__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":799
 *             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_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __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":795
 *             return multiply(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":801
 *             return divide(x, y)
 * 
 *     def __truediv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rtruediv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__truediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_100__truediv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__truediv__", 0);

  /* "cupy/core/core.pyx":802
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":803
 *     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_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __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":802
 * 
 *     def __truediv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rtruediv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":805
 *             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_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __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":801
 *             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":807
 *             return true_divide(x, y)
 * 
 *     def __floordiv__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rfloordiv__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__floordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_102__floordiv__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__floordiv__", 0);

  /* "cupy/core/core.pyx":808
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":809
 *     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_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __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":808
 * 
 *     def __floordiv__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rfloordiv__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":811
 *             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_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __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":807
 *             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":813
 *             return floor_divide(x, y)
 * 
 *     def __mod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_105__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__mod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_104__mod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__mod__", 0);

  /* "cupy/core/core.pyx":814
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":815
 *     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_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __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":814
 * 
 *     def __mod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":817
 *             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_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __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":813
 *             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":819
 *             return remainder(x, y)
 * 
 *     def __divmod__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rdivmod__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__divmod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_106__divmod__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__divmod__", 0);

  /* "cupy/core/core.pyx":820
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":821
 *     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_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __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":820
 * 
 *     def __divmod__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rdivmod__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":823
 *             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_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __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":819
 *             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":825
 *             return divmod(x, y)
 * 
 *     def __pow__(x, y, modulo):             # <<<<<<<<<<<<<<
 *         # Note that we ignore the modulo argument as well as NumPy.
 *         if _should_use_rop(x, y):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_109__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), ((PyObject *)__pyx_v_modulo));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_108__pow__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, CYTHON_UNUSED PyObject *__pyx_v_modulo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pow__", 0);

  /* "cupy/core/core.pyx":827
 *     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_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":828
 *         # 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_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __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":827
 *     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":830
 *             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_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __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":825
 *             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":832
 *             return power(x, y)
 * 
 *     def __lshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rlshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_110__lshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__lshift__", 0);

  /* "cupy/core/core.pyx":833
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":834
 *     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_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __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":833
 * 
 *     def __lshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rlshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":836
 *             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_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __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":832
 *             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":838
 *             return left_shift(x, y)
 * 
 *     def __rshift__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rrshift__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__rshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_112__rshift__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__rshift__", 0);

  /* "cupy/core/core.pyx":839
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":840
 *     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_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __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":839
 * 
 *     def __rshift__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rrshift__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":842
 *             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_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __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":838
 *             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":844
 *             return right_shift(x, y)
 * 
 *     def __and__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rand__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_115__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__and__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_114__and__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_114__and__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__and__", 0);

  /* "cupy/core/core.pyx":845
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":846
 *     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_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __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":845
 * 
 *     def __and__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rand__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":848
 *             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_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __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":844
 *             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":850
 *             return bitwise_and(x, y)
 * 
 *     def __or__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__ror__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_117__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__or__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_116__or__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_116__or__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__or__", 0);

  /* "cupy/core/core.pyx":851
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":852
 *     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_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __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":851
 * 
 *     def __or__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__ror__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":854
 *             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_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __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":850
 *             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":856
 *             return bitwise_or(x, y)
 * 
 *     def __xor__(x, y):             # <<<<<<<<<<<<<<
 *         if _should_use_rop(x, y):
 *             return y.__rxor__(x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_119__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__xor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_118__xor__(PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__xor__", 0);

  /* "cupy/core/core.pyx":857
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":858
 *     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_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __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":857
 * 
 *     def __xor__(x, y):
 *         if _should_use_rop(x, y):             # <<<<<<<<<<<<<<
 *             return y.__rxor__(x)
 *         else:
 */
  }

  /* "cupy/core/core.pyx":860
 *             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_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __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":856
 *             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":864
 *     # Arithmetic, in-place:
 * 
 *     def __iadd__(self, other):             # <<<<<<<<<<<<<<
 *         return add(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_120__iadd__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iadd__", 0);

  /* "cupy/core/core.pyx":865
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __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":864
 *     # 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":867
 *         return add(self, other, self)
 * 
 *     def __isub__(self, other):             # <<<<<<<<<<<<<<
 *         return subtract(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_123__isub__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_122__isub__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__isub__", 0);

  /* "cupy/core/core.pyx":868
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __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":867
 *         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":870
 *         return subtract(self, other, self)
 * 
 *     def __imul__(self, other):             # <<<<<<<<<<<<<<
 *         return multiply(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_125__imul__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_124__imul__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__imul__", 0);

  /* "cupy/core/core.pyx":871
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __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":870
 *         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":873
 *         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_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
#endif /*!(#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY)*/

#if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_126__idiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__idiv__", 0);

  /* "cupy/core/core.pyx":874
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __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":873
 *         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":876
 *         return divide(self, other, self)
 * 
 *     def __itruediv__(self, other):             # <<<<<<<<<<<<<<
 *         return true_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__itruediv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_128__itruediv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__itruediv__", 0);

  /* "cupy/core/core.pyx":877
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __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":876
 *         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":879
 *         return true_divide(self, other, self)
 * 
 *     def __ifloordiv__(self, other):             # <<<<<<<<<<<<<<
 *         return floor_divide(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ifloordiv__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_130__ifloordiv__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ifloordiv__", 0);

  /* "cupy/core/core.pyx":880
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __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":879
 *         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":882
 *         return floor_divide(self, other, self)
 * 
 *     def __imod__(self, other):             # <<<<<<<<<<<<<<
 *         return remainder(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_133__imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__imod__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_132__imod__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__imod__", 0);

  /* "cupy/core/core.pyx":883
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __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":882
 *         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":885
 *         return remainder(self, other, self)
 * 
 *     def __ipow__(self, other):             # <<<<<<<<<<<<<<
 *         return power(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ipow__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_134__ipow__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ipow__", 0);

  /* "cupy/core/core.pyx":886
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __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":885
 *         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":888
 *         return power(self, other, self)
 * 
 *     def __ilshift__(self, other):             # <<<<<<<<<<<<<<
 *         return left_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ilshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_136__ilshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ilshift__", 0);

  /* "cupy/core/core.pyx":889
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __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":888
 *         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":891
 *         return left_shift(self, other, self)
 * 
 *     def __irshift__(self, other):             # <<<<<<<<<<<<<<
 *         return right_shift(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__irshift__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_138__irshift__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__irshift__", 0);

  /* "cupy/core/core.pyx":892
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __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":891
 *         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":894
 *         return right_shift(self, other, self)
 * 
 *     def __iand__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_and(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_141__iand__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iand__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_140__iand__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__iand__", 0);

  /* "cupy/core/core.pyx":895
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __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":894
 *         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":897
 *         return bitwise_and(self, other, self)
 * 
 *     def __ior__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_or(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_143__ior__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ior__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_142__ior__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ior__", 0);

  /* "cupy/core/core.pyx":898
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __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":897
 *         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":900
 *         return bitwise_or(self, other, self)
 * 
 *     def __ixor__(self, other):             # <<<<<<<<<<<<<<
 *         return bitwise_xor(self, other, self)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__ixor__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_self), ((PyObject *)__pyx_v_other));

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

static PyObject *__pyx_pf_4cupy_4core_4core_7ndarray_144__ixor__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__ixor__", 0);

  /* "cupy/core/core.pyx":901
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __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":900
 *         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":908
 *     # For standard library functions:
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         return self.copy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_147__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_146__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_146__copy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__copy__", 0);

  /* "cupy/core/core.pyx":909
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_149__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_148__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_148__deepcopy__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "cupy/core/core.pyx":912
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":911
 *         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":914
 *         return self.copy()
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return array, (self.get(),)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_151__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_150__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_150__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "cupy/core/core.pyx":915
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __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":914
 *         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":921
 *     # 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_153__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_153__array__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __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_152__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_152__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__array__", 0);

  /* "cupy/core/core.pyx":922
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __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":923
 *     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":922
 * 
 *     def __array__(self, dtype=None):
 *         if dtype is None or self.dtype == dtype:             # <<<<<<<<<<<<<<
 *             return self
 *         else:
 */
  }

  /* "cupy/core/core.pyx":925
 *             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_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "cupy/core/core.pyx":921
 *     # 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":931
 *     # 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_155__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pw_4cupy_4core_4core_7ndarray_155__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_154__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_154__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "cupy/core/core.pyx":932
 * 
 *     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":933
 *     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__8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

  /* "cupy/core/core.pyx":934
 *         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":931
 *     # 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":936
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         # It supports the basic indexing (by slices, ints or Ellipsis) only.
 *         # TODO(beam2d): Support the advanced indexing of NumPy.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_157__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_157__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_156__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_156__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;
  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;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);
  __Pyx_INCREF(__pyx_v_slices);

  /* "cupy/core/core.pyx":942
 *         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":943
 *         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_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __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":942
 *         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":945
 *             slices = [slices]
 *         else:
 *             slices = list(slices)             # <<<<<<<<<<<<<<
 * 
 *         for s in slices:
 */
  /*else*/ {
    __pyx_t_3 = PySequence_List(__pyx_v_slices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __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":947
 *             slices = list(slices)
 * 
 *         for s in slices:             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 raise ValueError('Advanced indexing is not supported')
 */
  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_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __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":948
 * 
 *         for s in slices:
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Advanced indexing is not supported')
 * 
 */
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":949
 *         for s in slices:
 *             if isinstance(s, ndarray):
 *                 raise ValueError('Advanced indexing is not supported')             # <<<<<<<<<<<<<<
 * 
 *         # Expand ellipsis into empty slices
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":948
 * 
 *         for s in slices:
 *             if isinstance(s, ndarray):             # <<<<<<<<<<<<<<
 *                 raise ValueError('Advanced indexing is not supported')
 * 
 */
    }

    /* "cupy/core/core.pyx":947
 *             slices = list(slices)
 * 
 *         for s in slices:             # <<<<<<<<<<<<<<
 *             if isinstance(s, ndarray):
 *                 raise ValueError('Advanced indexing is not supported')
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":952
 * 
 *         # 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":953
 *         # Expand ellipsis into empty slices
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0             # <<<<<<<<<<<<<<
 *         for i, s in enumerate(slices):
 *             if s == newaxis:
 */
  __pyx_v_n_newaxes = 0;
  __pyx_v_n_ellipses = 0;

  /* "cupy/core/core.pyx":954
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s == newaxis:
 *                 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_7 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/core/core.pyx":955
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s == newaxis:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s == Ellipsis:
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_s, __pyx_v_4cupy_4core_4core_newaxis, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":956
 *         for i, s in enumerate(slices):
 *             if s == newaxis:
 *                 n_newaxes += 1             # <<<<<<<<<<<<<<
 *             elif s == Ellipsis:
 *                 n_ellipses += 1
 */
      __pyx_v_n_newaxes = (__pyx_v_n_newaxes + 1);

      /* "cupy/core/core.pyx":955
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):
 *             if s == newaxis:             # <<<<<<<<<<<<<<
 *                 n_newaxes += 1
 *             elif s == Ellipsis:
 */
      goto __pyx_L9;
    }

    /* "cupy/core/core.pyx":957
 *             if s == newaxis:
 *                 n_newaxes += 1
 *             elif s == Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_s, __pyx_builtin_Ellipsis, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":958
 *                 n_newaxes += 1
 *             elif s == Ellipsis:
 *                 n_ellipses += 1             # <<<<<<<<<<<<<<
 *                 ellipsis = i
 *         ndim = self._shape.size()
 */
      __pyx_v_n_ellipses = (__pyx_v_n_ellipses + 1);

      /* "cupy/core/core.pyx":959
 *             elif s == Ellipsis:
 *                 n_ellipses += 1
 *                 ellipsis = i             # <<<<<<<<<<<<<<
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]
 */
      __pyx_v_ellipsis = __pyx_v_i;

      /* "cupy/core/core.pyx":957
 *             if s == newaxis:
 *                 n_newaxes += 1
 *             elif s == Ellipsis:             # <<<<<<<<<<<<<<
 *                 n_ellipses += 1
 *                 ellipsis = i
 */
    }
    __pyx_L9:;

    /* "cupy/core/core.pyx":954
 *         ellipsis = -1
 *         n_newaxes = n_ellipses = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s == newaxis:
 *                 n_newaxes += 1
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":960
 *                 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":961
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_slice__10);
  __pyx_v_noneslices = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":962
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:             # <<<<<<<<<<<<<<
 *             if n_ellipses > 1:
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 */
  __pyx_t_1 = ((__pyx_v_n_ellipses > 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":963
 *         noneslices = [slice(None)]
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Only one Ellipsis is allowed in index')
 *             ellipsis_size = ndim - (<Py_ssize_t>len(slices) - n_newaxes - 1)
 */
    __pyx_t_1 = ((__pyx_v_n_ellipses > 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":964
 *         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__11, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":963
 *         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":965
 *             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_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_ellipsis_size = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":966
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":962
 *         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":968
 *             slices[ellipsis:ellipsis + 1] = noneslices * ellipsis_size
 * 
 *         slices += noneslices * (ndim - <Py_ssize_t>len(slices) + n_newaxes)             # <<<<<<<<<<<<<<
 * 
 *         # Create new shape and stride
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_slices); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyNumber_Multiply(__pyx_v_noneslices, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_slices, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_slices, __pyx_t_3);
  __pyx_t_3 = 0;

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

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

  /* "cupy/core/core.pyx":973
 *         j = 0
 *         offset = 0
 *         for i, s in enumerate(slices):             # <<<<<<<<<<<<<<
 *             if s is newaxis:
 *                 shape.push_back(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_7 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_slices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

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

      /* "cupy/core/core.pyx":975
 *         for i, s in enumerate(slices):
 *             if s is newaxis:
 *                 shape.push_back(1)             # <<<<<<<<<<<<<<
 *                 if j < ndim:
 *                     strides.push_back(self._strides[j])
 */
      try {
        __pyx_v_shape.push_back(1);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "cupy/core/core.pyx":976
 *             if s is newaxis:
 *                 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":977
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }

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

      /* "cupy/core/core.pyx":978
 *                 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":979
 *                     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_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }

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

      /* "cupy/core/core.pyx":981
 *                     strides.push_back(self._strides[ndim - 1])
 *                 else:
 *                     strides.push_back(self.itemsize)             # <<<<<<<<<<<<<<
 *             elif isinstance(s, slice):
 *                 s = internal.complete_slice(s, self._shape[j])
 */
      /*else*/ {
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        try {
          __pyx_v_strides.push_back(__pyx_t_8);
        } catch(...) {
          __Pyx_CppExn2PyErr();
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
      }
      __pyx_L15:;

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

    /* "cupy/core/core.pyx":982
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             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":983
 *                     strides.push_back(self.itemsize)
 *             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_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __pyx_f_4cupy_4core_8internal_complete_slice(((PyObject*)__pyx_v_s), (__pyx_v_self->_shape[__pyx_v_j]), 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "cupy/core/core.pyx":984
 *             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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_s_start = __pyx_t_8;

      /* "cupy/core/core.pyx":985
 *                 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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_stop); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_s_stop = __pyx_t_8;

      /* "cupy/core/core.pyx":986
 *                 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_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_step); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_s_step = __pyx_t_8;

      /* "cupy/core/core.pyx":987
 *                 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":988
 *                 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_8 = ((__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_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __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_8))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_8, __pyx_v_s_step) + 1);

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

      /* "cupy/core/core.pyx":990
 *                     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_8 = ((__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_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __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_8))) {
          PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_dim = (__Pyx_div_Py_ssize_t(__pyx_t_8, __pyx_v_s_step) + 1);
      }
      __pyx_L16:;

      /* "cupy/core/core.pyx":992
 *                     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_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "cupy/core/core.pyx":993
 * 
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "cupy/core/core.pyx":995
 *                 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":996
 * 
 *                 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":982
 *                 else:
 *                     strides.push_back(self.itemsize)
 *             elif isinstance(s, slice):             # <<<<<<<<<<<<<<
 *                 s = internal.complete_slice(s, self._shape[j])
 *                 s_start = s.start
 */
      goto __pyx_L14;
    }

    /* "cupy/core/core.pyx":997
 *                 offset += s_start * self._strides[j]
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_s); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_s);
      __Pyx_GIVEREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_s);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __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_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":998
 *                 j += 1
 *             elif numpy.isscalar(s):
 *                 ind = int(s)             # <<<<<<<<<<<<<<
 *                 if ind < 0:
 *                     ind += self._shape[j]
 */
      __pyx_t_6 = PyNumber_Int(__pyx_v_s); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_ind = __pyx_t_8;

      /* "cupy/core/core.pyx":999
 *             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":1000
 *                 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 size %s' \
 */
        __pyx_v_ind = (__pyx_v_ind + (__pyx_v_self->_shape[__pyx_v_j]));

        /* "cupy/core/core.pyx":999
 *             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":1001
 *                 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":1003
 *                 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_6 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = PyInt_FromSsize_t((__pyx_v_self->_shape[__pyx_v_j])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_v_s);
        __Pyx_GIVEREF(__pyx_v_s);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_s);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_10);
        __pyx_t_6 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Index_s_is_out_of_bounds_for_axi, __pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_v_msg = ((PyObject*)__pyx_t_10);
        __pyx_t_10 = 0;

        /* "cupy/core/core.pyx":1004
 *                     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_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_v_msg);
        __Pyx_GIVEREF(__pyx_v_msg);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_msg);
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_Raise(__pyx_t_11, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/core.pyx":1001
 *                 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":1005
 *                           % (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":1006
 *                     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":997
 *                 offset += s_start * self._strides[j]
 *                 j += 1
 *             elif numpy.isscalar(s):             # <<<<<<<<<<<<<<
 *                 ind = int(s)
 *                 if ind < 0:
 */
      goto __pyx_L14;
    }

    /* "cupy/core/core.pyx":1008
 *                 j += 1
 *             else:
 *                 raise TypeError('Invalid index type: %s' % type(slices[i]))             # <<<<<<<<<<<<<<
 * 
 *         v = self.view()
 */
    /*else*/ {
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_slices, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_index_type_s, ((PyObject *)Py_TYPE(__pyx_t_11))); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __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 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L14:;

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

  /* "cupy/core/core.pyx":1010
 *                 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_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1011
 * 
 *         v = self.view()
 *         v.data = self.data + offset             # <<<<<<<<<<<<<<
 *         v._set_shape_and_strides(shape, strides)
 *         return v
 */
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PyNumber_Add(((PyObject *)__pyx_v_self->data), __pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_10);
  __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_10);
  __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":1012
 *         v = self.view()
 *         v.data = self.data + offset
 *         v._set_shape_and_strides(shape, strides)             # <<<<<<<<<<<<<<
 *         return v
 * 
 */
  __pyx_t_10 = ((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_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cupy/core/core.pyx":1013
 *         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":936
 *         return self._shape[0]
 * 
 *     def __getitem__(self, slices):             # <<<<<<<<<<<<<<
 *         # It supports the basic indexing (by slices, ints or Ellipsis) only.
 *         # TODO(beam2d): Support the advanced indexing of NumPy.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_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_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":1015
 *         return v
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         cdef ndarray v, x, y
 *         v = self[slices]
 */

/* Python wrapper */
static int __pyx_pw_4cupy_4core_4core_7ndarray_159__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_slices, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_4core_4core_7ndarray_159__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_158__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_158__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;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setitem__", 0);

  /* "cupy/core/core.pyx":1017
 *     def __setitem__(self, slices, value):
 *         cdef ndarray v, x, y
 *         v = self[slices]             # <<<<<<<<<<<<<<
 *         if isinstance(value, ndarray):
 *             y, x = broadcast(v, value).values
 */
  __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_slices); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_v = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

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

    /* "cupy/core/core.pyx":1019
 *         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_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_v));
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_value);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_broadcast), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = ((struct __pyx_obj_4cupy_4core_4core_broadcast *)__pyx_t_4)->values;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

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

    /* "cupy/core/core.pyx":1021
 *             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_2 = (__pyx_f_4cupy_4core_8internal_vector_equal(__pyx_v_y->_strides, __pyx_v_x->_strides, 0) != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;

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

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

        /* "cupy/core/core.pyx":1023
 *                     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":1022
 *             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":1024
 *                 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_2 = (__pyx_v_y->_c_contiguous != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_3 = __pyx_t_2;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_x->dtype, __pyx_v_y->dtype, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = __pyx_t_2;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_3) {

        /* "cupy/core/core.pyx":1025
 *                     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_1 = ((PyObject *)__pyx_v_x->data);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer *)__pyx_v_y->data->__pyx_vtab)->copy_from(__pyx_v_y->data, __pyx_t_1, __pyx_t_6, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __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":1026
 *                 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":1024
 *                 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":1020
 *         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":1027
 *                     y.data.copy_from(x.data, x.nbytes)
 *                     return
 *             elementwise_copy(x, y)             # <<<<<<<<<<<<<<
 *         else:
 *             v.fill(value)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_x));
    __Pyx_INCREF(((PyObject *)__pyx_v_y));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, ((PyObject *)__pyx_v_y));
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __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":1018
 *         cdef ndarray v, x, y
 *         v = self[slices]
 *         if isinstance(value, ndarray):             # <<<<<<<<<<<<<<
 *             y, x = broadcast(v, value).values
 *             if (internal.vector_equal(y._shape, x._shape) and
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1029
 *             elementwise_copy(x, y)
 *         else:
 *             v.fill(value)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta): Implement __getslice__
 */
  /*else*/ {
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_v->__pyx_vtab)->fill(__pyx_v_v, __pyx_v_value, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1015
 *         return v
 * 
 *     def __setitem__(self, slices, value):             # <<<<<<<<<<<<<<
 *         cdef ndarray v, x, y
 *         v = self[slices]
 */

  /* function exit code */
  __pyx_r = 0;
  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_8);
  __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_RefNannyFinishContext();
  return __pyx_r;
}

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161__int__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_161__int__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__int__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_160__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_160__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__int__", 0);

  /* "cupy/core/core.pyx":1038
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __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":1037
 *     # 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":1041
 * 
 *     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_163__long__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_163__long__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__long__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_162__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_162__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__long__", 0);

  /* "cupy/core/core.pyx":1043
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __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":1041
 * 
 *     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":1045
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__float__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_165__float__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__float__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_164__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_164__float__(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  double __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__float__", 0);

  /* "cupy/core/core.pyx":1046
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_AsDouble(__pyx_t_1); if (unlikely(__pyx_t_2 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1045
 *             return self.get().__long__()
 * 
 *     def __float__(self):             # <<<<<<<<<<<<<<
 *         return float(self.get())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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":1048
 *         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_167__oct__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_167__oct__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__oct__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_166__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_166__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__oct__", 0);

  /* "cupy/core/core.pyx":1049
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __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":1048
 *         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":1051
 *         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_169__hex__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_169__hex__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__hex__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_168__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_168__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__hex__", 0);

  /* "cupy/core/core.pyx":1052
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __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":1051
 *         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":1056
 *     # String representations:
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_171__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_170__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_170__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "cupy/core/core.pyx":1057
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __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":1056
 *     # 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":1059
 *         return repr(self.get())
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return str(self.get())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_173__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_172__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_172__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "cupy/core/core.pyx":1060
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __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":1059
 *         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":1065
 *     # 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_175dot(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_174dot[] = "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_175dot(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_174dot(((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_174dot(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("dot", 0);

  /* "cupy/core/core.pyx":1073
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1065
 *     # 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":1079
 *     # -------------------------------------------------------------------------
 *     @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_177device(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_176device[] = "CUDA device on which this array resides.";
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_177device(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("device (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7ndarray_176device(((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_176device(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("device", 0);

  /* "cupy/core/core.pyx":1081
 *     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":1079
 *     # -------------------------------------------------------------------------
 *     @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":1083
 *         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_179get(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __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_179get)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __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":1094
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __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":1095
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_self->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __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":1096
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __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":1097
 *         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":1098
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1097
 *         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":1100
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1101
 *         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":1083
 *         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_179get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_178get[] = "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_179get(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stream = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __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_178get(((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_178get(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1103
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to cuda.ndarray.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_181set(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __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_181set)) {
      __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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __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":1112
 * 
 *         """
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __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":1113
 *         """
 *         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__12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1112
 * 
 *         """
 *         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":1114
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1115
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);

    /* "cupy/core/core.pyx":1116
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __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":1115
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1114
 *         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":1117
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1118
 *                 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__13, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1117
 *             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":1119
 *         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":1120
 *             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__14, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1119
 *         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":1122
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __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":1123
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __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":1124
 *         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":1125
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1124
 *         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":1127
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L7:;

  /* "cupy/core/core.pyx":1103
 *         return a_cpu
 * 
 *     cpdef set(self, arr, stream=None):             # <<<<<<<<<<<<<<
 *         """Copies an array on the host memory to cuda.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_181set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_180set[] = "Copies an array on the host memory to cuda.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_181set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arr = 0;
  PyObject *__pyx_v_stream = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __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_180set(((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_180set(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1129
 *             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_183reduced_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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_183reduced_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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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":1142
 *         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":1143
 *         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":1144
 *         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":1143
 *         cdef Py_ssize_t ndim
 *         ndim = self._shape.size()
 *         if ndim <= 1:             # <<<<<<<<<<<<<<
 *             return self
 *         internal.get_reduced_dims(
 */
  }

  /* "cupy/core/core.pyx":1146
 *             return self
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)             # <<<<<<<<<<<<<<
 *         if ndim == shape.size():
 *             return self
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1145
 *         if ndim <= 1:
 *             return self
 *         internal.get_reduced_dims(             # <<<<<<<<<<<<<<
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == 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":1147
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_6 = ((__pyx_v_ndim == __pyx_v_shape.size()) != 0);
  if (__pyx_t_6) {

    /* "cupy/core/core.pyx":1148
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == 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":1147
 *         internal.get_reduced_dims(
 *             self._shape, self._strides, self.itemsize, shape, strides)
 *         if ndim == shape.size():             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "cupy/core/core.pyx":1150
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __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":1151
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1152
 *         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":1129
 *             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_183reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_7ndarray_182reduced_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_183reduced_view(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_dtype = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __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_182reduced_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_182reduced_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1154
 *         return view
 * 
 *     cpdef _update_c_contiguity(self):             # <<<<<<<<<<<<<<
 *         if self.size == 0:
 *             self._c_contiguous = True
 */

static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __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_185_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_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __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":1155
 * 
 *     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":1156
 *     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":1157
 *         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":1155
 * 
 *     cpdef _update_c_contiguity(self):
 *         if self.size == 0:             # <<<<<<<<<<<<<<
 *             self._c_contiguous = True
 *             return
 */
  }

  /* "cupy/core/core.pyx":1159
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1158
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_c_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1154
 *         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_185_update_c_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_185_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_184_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_184_update_c_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1161
 *             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_187_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __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_187_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_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __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":1164
 *         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":1165
 *         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":1166
 *         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":1164
 *         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":1167
 *             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":1168
 *             return
 *         if self._c_contiguous:
 *             count = 0             # <<<<<<<<<<<<<<
 *             for i in self._shape:
 *                 if i == 1:
 */
    __pyx_v_count = 0;

    /* "cupy/core/core.pyx":1169
 *         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":1170
 *             count = 0
 *             for i in self._shape:
 *                 if i == 1:             # <<<<<<<<<<<<<<
 *                     count += 1
 *             self._f_contiguous = self._shape.size() - count <= 1
 */
      __pyx_t_5 = ((__pyx_v_i == 1) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":1171
 *             for i in self._shape:
 *                 if i == 1:
 *                     count += 1             # <<<<<<<<<<<<<<
 *             self._f_contiguous = self._shape.size() - count <= 1
 *             return
 */
        __pyx_v_count = (__pyx_v_count + 1);

        /* "cupy/core/core.pyx":1170
 *             count = 0
 *             for i in self._shape:
 *                 if i == 1:             # <<<<<<<<<<<<<<
 *                     count += 1
 *             self._f_contiguous = self._shape.size() - count <= 1
 */
      }

      /* "cupy/core/core.pyx":1169
 *         if self._c_contiguous:
 *             count = 0
 *             for i in self._shape:             # <<<<<<<<<<<<<<
 *                 if i == 1:
 *                     count += 1
 */
    }

    /* "cupy/core/core.pyx":1172
 *                 if i == 1:
 *                     count += 1
 *             self._f_contiguous = self._shape.size() - count <= 1             # <<<<<<<<<<<<<<
 *             return
 *         rev_shape.assign(self._shape.rbegin(), self._shape.rend())
 */
    __pyx_v_self->_f_contiguous = ((__pyx_v_self->_shape.size() - __pyx_v_count) <= 1);

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

  /* "cupy/core/core.pyx":1174
 *             self._f_contiguous = 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_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1175
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1177
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1177; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1176
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_f_contiguous = __pyx_t_5;

  /* "cupy/core/core.pyx":1161
 *             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_187_update_f_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_187_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_186_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_186_update_f_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1179
 *            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_189_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_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_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __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":1180
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1181
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1179
 *            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_189_update_contiguity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_189_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_188_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_188_update_contiguity(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1183
 *         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_191_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":1185
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1183
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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":1186
 *                                  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":1187
 *                                  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__15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1186
 *                                  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":1188
 *         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":1189
 *             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":1190
 *         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":1191
 *         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":1192
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1191
 *         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":1194
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":1183
 *         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_191_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7ndarray_191_set_shape_and_strides(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  std::vector<Py_ssize_t>  __pyx_v_shape;
  std::vector<Py_ssize_t>  __pyx_v_strides;
  int __pyx_v_update_c_contiguity;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_strides = __pyx_convert_vector_from_py_Py_ssize_t(values[1]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "cupy/core/core.pyx":1185
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __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_190_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":1183
 *         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_190_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":64
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":65
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __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":66
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __pyx_convert_vector_from_py_Py_ssize_t(__pyx_v_value); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __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":67
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":68
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":69
 *         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":70
 *         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":71
 *         readonly object dtype
 *         readonly memory.MemoryPointer data
 *         readonly ndarray base             # <<<<<<<<<<<<<<
 * 
 * 
 */

/* 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":1201
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_strides_for_nocopy_reshape", 0);

  /* "cupy/core/core.pyx":1205
 *     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":1206
 *     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":1207
 *     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":1206
 *     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":1209
 *         return newstrides
 * 
 *     itemsize = a.itemsize             # <<<<<<<<<<<<<<
 *     if size == 1:
 *         newstrides.assign(newshape.size(), itemsize)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_itemsize = __pyx_t_1;

  /* "cupy/core/core.pyx":1210
 * 
 *     itemsize = a.itemsize
 *     if size == 1:             # <<<<<<<<<<<<<<
 *         newstrides.assign(newshape.size(), itemsize)
 *         return newstrides
 */
  __pyx_t_2 = ((__pyx_v_size == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1211
 *     itemsize = a.itemsize
 *     if size == 1:
 *         newstrides.assign(newshape.size(), itemsize)             # <<<<<<<<<<<<<<
 *         return newstrides
 * 
 */
    __pyx_v_newstrides.assign(__pyx_v_newshape.size(), __pyx_v_itemsize);

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

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

  /* "cupy/core/core.pyx":1219
 *     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":1220
 *     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":1221
 *     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":1222
 *     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":1223
 *     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":1224
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

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

    /* "cupy/core/core.pyx":1226
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __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":1227
 *             continue
 *         if dim >= ndim or shape[dim] % size != 0:
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             break
 *         shape[dim] //= size
 */
      __pyx_v_newstrides.clear();

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

    /* "cupy/core/core.pyx":1229
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (__pyx_v_shape[__pyx_t_1]) = __Pyx_div_Py_ssize_t(__pyx_t_6, __pyx_v_size);

    /* "cupy/core/core.pyx":1230
 *             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":1231
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

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

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

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

  /* "cupy/core/core.pyx":1201
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __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 int 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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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) {
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":20
 * 
 *     def __init__(self, ndarray arr):
 *         cdef int 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_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __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 int 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 int 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_3 = __pyx_v_arr->size;
  __pyx_v_self->val.size = __pyx_t_3;

  /* "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_4 = 0; __pyx_t_4 < __pyx_t_2; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "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 int 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 int 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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __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) {
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/carray.pxi":39
 * 
 *     def __init__(self, Py_ssize_t size, tuple shape):
 *         self.val.size = size             # <<<<<<<<<<<<<<
 *         cdef int 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 int 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_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __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 int 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_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_GetItemInt_Tuple(__pyx_v_shape, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __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 int 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "to_cindexer") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_3ndim(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_3ndim(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ndim (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_2ndim(((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_2ndim(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ndim", 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_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __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", __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_5cstruct(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_7Indexer_5cstruct(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cstruct (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4core_4core_7Indexer_4cstruct(((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_4cstruct(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cstruct", 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_filename = __pyx_f[2]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __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", __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_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_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_ErrRestore(__pyx_t_9, __pyx_t_4, __pyx_t_3);
              __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
              {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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_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_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__16, NULL);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_options), (&PyTuple_Type), 1, "options", 1))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __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__17, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_params, __pyx_v_params) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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__18, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames, __pyx_v_dtype); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  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 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __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_v_dev_id = __pyx_f_4cupy_4cuda_6device_get_device_id(0);

  /* "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_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_4);
    __pyx_t_4 = 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_5 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_arg)), __pyx_v_4cupy_4core_4core__python_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "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_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      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);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_arg); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_INCREF(__pyx_v_arg);
        __Pyx_GIVEREF(__pyx_v_arg);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_arg);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_4);
      __pyx_t_4 = 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_6 = (__Pyx_PySequence_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_arg)), __pyx_v_4cupy_4core_4core__numpy_scalar_type_set, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {
      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_5 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_ptype_4cupy_4core_4core_ndarray); 
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "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_filename = __pyx_f[1]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = ((PyObject *)((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arg)->data->device);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_arr_dev, ((struct __pyx_obj_4cupy_4cuda_6device_Device *)__pyx_t_4));
      __pyx_t_4 = 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_5 = (((PyObject *)__pyx_v_arr_dev) != Py_None);
      __pyx_t_10 = (__pyx_t_5 != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_6 = __pyx_t_10;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_10 = ((__pyx_v_arr_dev->id != __pyx_v_dev_id) != 0);
      __pyx_t_6 = __pyx_t_10;
      __pyx_L7_bool_binop_done:;
      if (__pyx_t_6) {

        /* "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_4 = __Pyx_PyInt_From_int(__pyx_v_arr_dev->id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
        __pyx_t_4 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Array_device_must_be_same_as_the, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 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_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __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 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __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_7 = PyNumber_Add(__pyx_v_4cupy_4core_4core__python_scalar_type, __pyx_v_4cupy_4core_4core__numpy_scalar_type); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyObject_IsInstance(__pyx_v_arg, __pyx_t_7); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_10 = (__pyx_t_6 != 0);
    if (__pyx_t_10) {

      /* "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_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      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);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __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(((PyObject *)Py_TYPE(__pyx_v_arg)));
        __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_arg)));
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, ((PyObject *)Py_TYPE(__pyx_v_arg)));
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __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_arg); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_arg);
        __Pyx_GIVEREF(__pyx_v_arg);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_arg);
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_7);
      __pyx_t_7 = 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_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_arg, __pyx_v_4cupy_4core_4core__numpy_scalar_type, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (unlikely(!(__pyx_t_10 != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __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_7 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_type_s, ((PyObject *)Py_TYPE(__pyx_v_arg))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __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_12 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_v_arg); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __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_4);
  __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._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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  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_filename = __pyx_f[1]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_params); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __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__19, __pyx_v_ret); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args_info), (&PyTuple_Type), 1, "args_info", 1))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  size_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;
  Py_ssize_t __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __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(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(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(args_strides.size()):
 */
    }

    /* "cupy/core/elementwise.pxi":173
 *         if vecshape[i - 1] == 1:
 *             continue
 *         for j in range(args_strides.size()):             # <<<<<<<<<<<<<<
 *             if args_strides[j][i] * vecshape[i] != args_strides[j][i - 1]:
 *                 cnt += 1
 */
    __pyx_t_8 = __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(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(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(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(1, vecshape[axis])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __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(1, 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(1, vecshape[axis])             # <<<<<<<<<<<<<<
 *         ret = []
 *         for i, a in enumerate(args):
 */
    __pyx_v_newshape.assign(1, (__pyx_v_vecshape[__pyx_v_axis]));

    /* "cupy/core/elementwise.pxi":189
 *     if cnt == 1:
 *         newshape.assign(1, 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_filename = __pyx_f[1]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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(1, 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_filename = __pyx_f[1]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __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(1, arr._strides[axis])
 */
        if (!(likely(((__pyx_v_a) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_a, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __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(1, arr._strides[axis])
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 */
        __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_filename = __pyx_f[1]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __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(1, arr._strides[axis])             # <<<<<<<<<<<<<<
 *                 arr._set_shape_and_strides(newshape, newstrides, False)
 *                 a = arr
 */
        __pyx_v_newstrides.assign(1, (__pyx_v_arr->_strides[__pyx_v_axis]));

        /* "cupy/core/elementwise.pxi":195
 *                 arr = arr.view()
 *                 newstrides.assign(1, 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_filename = __pyx_f[1]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "cupy/core/elementwise.pxi":196
 *                 newstrides.assign(1, 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":197
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":190
 *         newshape.assign(1, 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":198
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __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(1, vecshape[axis])
 *         ret = []
 */
  }

  /* "cupy/core/elementwise.pxi":200
 *         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":201
 * 
 *     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":202
 *     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_filename = __pyx_f[1]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

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

  /* "cupy/core/elementwise.pxi":203
 *         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_filename = __pyx_f[1]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ret = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/elementwise.pxi":204
 *             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_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_10 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __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":205
 *     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":206
 *     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_filename = __pyx_f[1]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __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":207
 *         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_filename = __pyx_f[1]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __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":208
 *             arr = a
 *             arr = arr.view()
 *             newstrides.clear()             # <<<<<<<<<<<<<<
 *             for i in range(ndim):
 *                 if vecshape[i] != 1:
 */
      __pyx_v_newstrides.clear();

      /* "cupy/core/elementwise.pxi":209
 *             arr = arr.view()
 *             newstrides.clear()
 *             for i in range(ndim):             # <<<<<<<<<<<<<<
 *                 if vecshape[i] != 1:
 *                     newstrides.push_back(arr._strides[i])
 */
      __pyx_t_9 = __pyx_v_ndim;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_9; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

        /* "cupy/core/elementwise.pxi":210
 *             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":211
 *             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_filename = __pyx_f[1]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }

          /* "cupy/core/elementwise.pxi":210
 *             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":212
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

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

    /* "cupy/core/elementwise.pxi":214
 *             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_filename = __pyx_f[1]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":204
 *             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":215
 *             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_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_reduce_dims") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":226
 *         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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":227
 * 
 *     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":228
 *     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":229
 *         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":230
 *         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":231
 *         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":232
 *         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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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":233
 *         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_filename = __pyx_f[1]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((__pyx_t_5 < 2) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":234
 *         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_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":233
 *         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":236
 *             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_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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":237
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_8) {
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":239
 *         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_filename = __pyx_f[1]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((__pyx_t_5 == 1) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/elementwise.pxi":240
 *             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_filename = __pyx_f[1]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __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":239
 *         if t == 'CIndexer':
 *             pass
 *         elif len(t) == 1:             # <<<<<<<<<<<<<<
 *             self.ctype = t
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/core/elementwise.pxi":242
 *             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_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __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":243
 *         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_filename = __pyx_f[1]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __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":244
 *             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_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "cupy/core/elementwise.pxi":245
 *             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_filename = __pyx_f[1]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":244
 *             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":246
 *             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_filename = __pyx_f[1]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __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":248
 *             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_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __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":249
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_8) {

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

    /* "cupy/core/elementwise.pxi":252
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L11:;

    /* "cupy/core/elementwise.pxi":248
 *             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":226
 *         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":220
 * 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":221
 *     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":222
 *         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":223
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->raw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":224
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":256
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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 *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_param_info", 0);

  /* "cupy/core/elementwise.pxi":257
 * @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_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 == 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":258
 * 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":257
 * @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":259
 *     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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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__21, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __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":256
 * 
 * @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":263
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_decide_params_type", 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:
 *         assert len(out_params) == len(out_args_dtype)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_type_dict = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":265
 * 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_filename = __pyx_f[1]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":266
 *     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_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyObject_Length(__pyx_v_out_args_dtype); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (unlikely(!((__pyx_t_3 == __pyx_t_4) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    #endif

    /* "cupy/core/elementwise.pxi":267
 *     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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __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":268
 *         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":269
 *         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__22, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/elementwise.pxi":268
 *         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":270
 *             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_filename = __pyx_f[1]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __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":271
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":273
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":272
 *             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_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "cupy/core/elementwise.pxi":271
 *                 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":270
 *             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":274
 *                     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_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __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":275
 *                         '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_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __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":276
 *             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_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":279
 *                     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_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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":278
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "cupy/core/elementwise.pxi":277
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "cupy/core/elementwise.pxi":276
 *             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":274
 *                     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":281
 *                             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_filename = __pyx_f[1]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_1, __pyx_v_a) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_L9:;

      /* "cupy/core/elementwise.pxi":267
 *     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":265
 * 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":283
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Length(__pyx_v_in_args_dtype); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(!((__pyx_t_4 == __pyx_t_3) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "cupy/core/elementwise.pxi":284
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_unknown_ctype = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "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:
 *             if p.dtype is None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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":286
 *     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":287
 *     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_filename = __pyx_f[1]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __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":288
 *         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_filename = __pyx_f[1]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cupy/core/elementwise.pxi":287
 *     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":286
 *     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":290
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __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":291
 *         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_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_2) {

          /* "cupy/core/elementwise.pxi":293
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "cupy/core/elementwise.pxi":292
 *             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_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "cupy/core/elementwise.pxi":291
 *         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":290
 *                 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":294
 *                     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_filename = __pyx_f[1]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __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":295
 *                         '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_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __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":296
 *             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_filename = __pyx_f[1]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_11) {

          /* "cupy/core/elementwise.pxi":299
 *                     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_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __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":298
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "cupy/core/elementwise.pxi":297
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

          /* "cupy/core/elementwise.pxi":296
 *             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":294
 *                     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":301
 *                             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_filename = __pyx_f[1]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        if (unlikely(PyDict_SetItem(__pyx_v_type_dict, __pyx_t_5, __pyx_v_a) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_L18:;
    }
    __pyx_L16:;

    /* "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:
 *             if p.dtype is None:
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":303
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":304
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __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":303
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":304
 * 
 *     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":303
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __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":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])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/elementwise.pxi":306
 *                       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_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __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":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])
 *     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_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":306
 *                       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":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])
 *     return in_types, out_types, tuple(type_dict.items())
 */
  __pyx_t_1 = PyList_AsTuple(((PyObject*)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __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":307
 *     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_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __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":263
 * 
 * @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":310
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_broadcast", 0);

  /* "cupy/core/elementwise.pxi":314
 *     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_filename = __pyx_f[1]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_value = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":315
 *     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":316
 *     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":317
 *     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_filename = __pyx_f[1]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __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":318
 *     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_filename = __pyx_f[1]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __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":319
 *     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_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __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":320
 *         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":321
 *         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":322
 *         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_filename = __pyx_f[1]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":320
 *         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":324
 *             value.append(a)
 *         else:
 *             is_none = True             # <<<<<<<<<<<<<<
 *             value.append(None)
 * 
 */
    /*else*/ {
      __pyx_v_is_none = 1;

      /* "cupy/core/elementwise.pxi":325
 *         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_filename = __pyx_f[1]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L5:;
  }

  /* "cupy/core/elementwise.pxi":327
 *             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":328
 * 
 *     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":329
 *     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__23, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":328
 * 
 *     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":327
 *             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":332
 *                              "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":333
 *     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__24, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":332
 *                              "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":334
 *         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_filename = __pyx_f[1]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __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":335
 *             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_filename = __pyx_f[1]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __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":336
 *     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_filename = __pyx_f[1]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __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":337
 *     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_filename = __pyx_f[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __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":338
 *     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":339
 *         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_filename = __pyx_f[1]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __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":338
 *     for i in range(len(args)):
 *         a = brod.values[i]
 *         if a is None:             # <<<<<<<<<<<<<<
 *             a = args[i]
 *         value.append(a)
 */
    }

    /* "cupy/core/elementwise.pxi":340
 *         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_filename = __pyx_f[1]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/elementwise.pxi":341
 *             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_filename = __pyx_f[1]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __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":310
 * 
 * 
 * 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":344
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_out_args", 0);

  /* "cupy/core/elementwise.pxi":346
 * 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":347
 *                         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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __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":346
 * 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":349
 *         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_filename = __pyx_f[1]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __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":350
 * 
 *     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":351
 *     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__25, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":350
 * 
 *     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":353
 *             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_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":354
 *                 '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__26, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":353
 *             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":355
 *         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_filename = __pyx_f[1]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __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":356
 *             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_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_casting, __pyx_v_casting) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __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":359
 *             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_filename = __pyx_f[1]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);

      /* "cupy/core/elementwise.pxi":360
 *                   '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_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":361
 *                   '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_filename = __pyx_f[1]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":362
 *                       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_filename = __pyx_f[1]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __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":363
 *                       a.dtype.char,
 *                       casting)
 *             raise TypeError(msg)             # <<<<<<<<<<<<<<
 *     return out_args
 * 
 */
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":356
 *             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":349
 *         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":364
 *                       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":344
 * 
 * 
 * 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":367
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params):
 *     cdef ParameterInfo p
 */

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_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_out_args_with_params", 0);

  /* "cupy/core/elementwise.pxi":370
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw:
 */
  __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":371
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __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":372
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      __pyx_t_2 = (__pyx_v_p->raw != 0);
      if (__pyx_t_2) {

        /* "cupy/core/elementwise.pxi":373
 *         for p in out_params:
 *             if p.raw:
 *                 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__27, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/elementwise.pxi":372
 *     if not out_args:
 *         for p in out_params:
 *             if p.raw:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Output array size is Undecided')
 *         return [ndarray(out_shape, t) for t in out_types]
 */
      }

      /* "cupy/core/elementwise.pxi":371
 *     cdef ParameterInfo p
 *     if not out_args:
 *         for p in out_params:             # <<<<<<<<<<<<<<
 *             if p.raw:
 *                 raise ValueError('Output array size is Undecided')
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":374
 *             if p.raw:
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __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":370
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params):
 *     cdef ParameterInfo p
 *     if not out_args:             # <<<<<<<<<<<<<<
 *         for p in out_params:
 *             if p.raw:
 */
  }

  /* "cupy/core/elementwise.pxi":376
 *         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_filename = __pyx_f[1]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v_out_params); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __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":377
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __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":378
 *     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_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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":379
 *         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":380
 *         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__28, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":379
 *         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":382
 *             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_L13_bool_binop_done;
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_1) {

      /* "cupy/core/elementwise.pxi":383
 *                 '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__29, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":382
 *             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":384
 *         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":367
 * 
 * 
 * cdef list _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *         list out_args, tuple out_types, tuple out_shape, tuple out_params):
 *     cdef ParameterInfo p
 */

  /* 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":388
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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":392
 *     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
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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 *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_types)) { __Pyx_RaiseClosureNameError("types"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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":388
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":390
 * 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_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":392
 *     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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":391
 *                             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__30, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __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":393
 *     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__30); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __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":395
 *     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_filename = __pyx_f[1]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":396
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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":397
 *     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_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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":398
 *     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_filename = __pyx_f[1]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_9) {

        /* "cupy/core/elementwise.pxi":399
 *         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":398
 *     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":401
 *                 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":402
 *             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_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_t, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_n, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/core/elementwise.pxi":397
 *     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":396
 * 
 *     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":403
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":404
 *             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__30, __pyx_v_op); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __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":405
 *     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_filename = __pyx_f[1]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":407
 *     return _get_simple_elementwise_kernel(
 *         kernel_params, operation, name,
 *         preamble, **dict(kwargs))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":405
 *     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_filename = __pyx_f[1]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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":388
 * 
 * @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":459
 *         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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":460
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __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":459
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/elementwise.pxi":461
 *     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_filename = __pyx_f[1]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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":462
 *                  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_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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":463
 *         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_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nin = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":464
 *         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_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->nout = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":465
 *         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":466
 *         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_filename = __pyx_f[1]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __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":467
 *         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_filename = __pyx_f[1]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __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":468
 *         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_filename = __pyx_f[1]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __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":469
 *         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_filename = __pyx_f[1]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __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":470
 *         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_filename = __pyx_f[1]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->reduce_dims = __pyx_t_6;

  /* "cupy/core/elementwise.pxi":471
 *         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_filename = __pyx_f[1]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __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":472
 *         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_filename = __pyx_f[1]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyFrozenSet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __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":473
 *         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_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __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":474
 *         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_filename = __pyx_f[1]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/core/elementwise.pxi":475
 *         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__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":474
 *         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":459
 *         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":477
 *             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 ndims are not compatible. It\n        means that single ElementwiseKernel object may be compiled into\n        multiple kernel binaries.\n\n        Args:\n            args: Argumens 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;
  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 *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":499
 *         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_filename = __pyx_f[1]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __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":500
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":501
 *         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_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":500
 * 
 *         size = kwargs.pop('size', None)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":503
 *             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_filename = __pyx_f[1]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/elementwise.pxi":504
 * 
 *         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":505
 *         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_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":504
 * 
 *         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":506
 *         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_filename = __pyx_f[1]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __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":508
 *         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_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __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":509
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_in_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":510
 *         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_filename = __pyx_f[1]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_out_args = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":513
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":514
 *         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_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __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":513
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":514
 *         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":512
 *         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_filename = __pyx_f[1]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __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":515
 *             [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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __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":517
 *         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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "cupy/core/elementwise.pxi":519
 *         in_types, out_types, types = _decide_params_type(
 *             self.in_params, self.out_params,
 *             in_ndarray_types, out_ndarray_types)             # <<<<<<<<<<<<<<
 * 
 *         out_args = _get_out_args_with_params(
 */
  __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L12_unpacking_done:;
  }

  /* "cupy/core/elementwise.pxi":517
 *         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":522
 * 
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params)             # <<<<<<<<<<<<<<
 *         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_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_self->out_params;
  __Pyx_INCREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":521
 *             in_ndarray_types, out_ndarray_types)
 * 
 *         out_args = _get_out_args_with_params(             # <<<<<<<<<<<<<<
 *             out_args, out_types, shape, self.out_params)
 *         if self.nout == 1:
 */
  __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)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __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":523
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->nout == 1) != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":524
 *             out_args, out_types, shape, self.out_params)
 *         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_filename = __pyx_f[1]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":523
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, shape, self.out_params)
 *         if self.nout == 1:             # <<<<<<<<<<<<<<
 *             ret = out_args[0]
 *         else:
 */
    goto __pyx_L13;
  }

  /* "cupy/core/elementwise.pxi":526
 *             ret = out_args[0]
 *         else:
 *             ret = tuple(out_args)             # <<<<<<<<<<<<<<
 * 
 *         if size is not None:
 */
  /*else*/ {
    __pyx_t_9 = PySequence_Tuple(__pyx_v_out_args); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_v_ret = __pyx_t_9;
    __pyx_t_9 = 0;
  }
  __pyx_L13:;

  /* "cupy/core/elementwise.pxi":528
 *             ret = tuple(out_args)
 * 
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 * 
 */
  __pyx_t_3 = (__pyx_v_size != Py_None);
  __pyx_t_5 = (__pyx_t_3 != 0);
  if (__pyx_t_5) {

    /* "cupy/core/elementwise.pxi":529
 * 
 *         if size is not None:
 *             shape = size,             # <<<<<<<<<<<<<<
 * 
 *         if 0 in shape:
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_size);
    __Pyx_GIVEREF(__pyx_v_size);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_size);
    __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "cupy/core/elementwise.pxi":528
 *             ret = tuple(out_args)
 * 
 *         if size is not None:             # <<<<<<<<<<<<<<
 *             shape = size,
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":531
 *             shape = size,
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (__pyx_t_5 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":532
 * 
 *         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":531
 *             shape = size,
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":534
 *             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_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;

  /* "cupy/core/elementwise.pxi":535
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __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":534
 *             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_11 = PyObject_GetItem(__pyx_v_in_types, __pyx_v_i); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_x); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_x);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_6 = __pyx_t_8;
      __pyx_t_8 = 0;
    }
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":535
 * 
 *         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":536
 *         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_filename = __pyx_f[1]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __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":538
 *         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":540
 *         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_filename = __pyx_f[1]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":539
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __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":538
 *         inout_args += out_args
 * 
 *         if self.reduce_dims:             # <<<<<<<<<<<<<<
 *             inout_args, shape = _reduce_dims(
 *                 inout_args, self.params, shape)
 */
  }

  /* "cupy/core/elementwise.pxi":541
 *             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_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __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":542
 *                 inout_args, self.params, shape)
 *         indexer = Indexer(shape)
 *         inout_args.append(indexer)             # <<<<<<<<<<<<<<
 * 
 *         args_info = _get_args_info(inout_args)
 */
  __pyx_t_14 = __Pyx_PyObject_Append(__pyx_v_inout_args, ((PyObject *)__pyx_v_indexer)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":544
 *         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_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_args_info = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":545
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":547
 *         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_filename = __pyx_f[1]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __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":545
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":548
 *             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_filename = __pyx_f[1]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":549
 *             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":477
 *             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_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __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":447
 * 
 *     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":448
 *     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":449
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":450
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":451
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":452
 *         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":453
 *         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":454
 *         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":455
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":456
 *         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":457
 *         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":553
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_ufunc_kernel", 0);
  __Pyx_INCREF(__pyx_v_preamble);

  /* "cupy/core/elementwise.pxi":555
 * 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_filename = __pyx_f[1]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":557
 *     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_filename = __pyx_f[1]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":558
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":559
 *     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_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __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":560
 *     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_filename = __pyx_f[1]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":561
 *     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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 561; __pyx_clineno = __LINE__; goto __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":563
 *         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_filename = __pyx_f[1]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __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":562
 *         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_filename = __pyx_f[1]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/core/elementwise.pxi":561
 *     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":559
 *     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":565
 *                 '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_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __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":566
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":567
 *     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_filename = __pyx_f[1]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);

    /* "cupy/core/elementwise.pxi":568
 *         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_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __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":567
 *     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_filename = __pyx_f[1]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":565
 *                 '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":570
 *             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_filename = __pyx_f[1]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":571
 * 
 *     op.append(routine)
 *     operation = '\n'.join(op)             # <<<<<<<<<<<<<<
 * 
 *     types.append(preamble)
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__30, __pyx_v_op); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_operation = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":573
 *     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_filename = __pyx_f[1]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":574
 * 
 *     types.append(preamble)
 *     preamble = '\n'.join(types)             # <<<<<<<<<<<<<<
 * 
 *     return _get_simple_elementwise_kernel(
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__30, __pyx_v_types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __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":576
 *     preamble = '\n'.join(types)
 * 
 *     return _get_simple_elementwise_kernel(             # <<<<<<<<<<<<<<
 *         kernel_params, operation, name, preamble)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "cupy/core/elementwise.pxi":577
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/core/elementwise.pxi":553
 * 
 * @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":580
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_guess_routine_from_in_types", 0);

  /* "cupy/core/elementwise.pxi":583
 *     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_filename = __pyx_f[1]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_in_types); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n = __pyx_t_1;

  /* "cupy/core/elementwise.pxi":584
 *     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_filename = __pyx_f[1]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __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":585
 *     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_filename = __pyx_f[1]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":586
 *     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_filename = __pyx_f[1]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":587
 *     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":588
 *         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_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __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":589
 *         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":588
 *         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":591
 *                 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":585
 *     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":592
 *         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":580
 * 
 * 
 * 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":595
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_guess_routine_from_dtype", 0);

  /* "cupy/core/elementwise.pxi":597
 * 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_filename = __pyx_f[1]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_op, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":598
 *     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_filename = __pyx_f[1]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_op_types, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/elementwise.pxi":599
 *     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_filename = __pyx_f[1]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __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":600
 *         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_filename = __pyx_f[1]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {

        /* "cupy/core/elementwise.pxi":601
 *         for t in op_types:
 *             if t != dtype:
 *                 break             # <<<<<<<<<<<<<<
 *         else:
 *             return op
 */
        goto __pyx_L6_break;

        /* "cupy/core/elementwise.pxi":600
 *         op_types = op[1]
 *         for t in op_types:
 *             if t != dtype:             # <<<<<<<<<<<<<<
 *                 break
 *         else:
 */
      }

      /* "cupy/core/elementwise.pxi":599
 *     for op in ops:
 *         op_types = op[1]
 *         for t in op_types:             # <<<<<<<<<<<<<<
 *             if t != dtype:
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/core/elementwise.pxi":603
 *                 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":599
 *     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":597
 * 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":604
 *         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":595
 * 
 * 
 * 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":607
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_should_use_min_scalar", 0);

  /* "cupy/core/elementwise.pxi":610
 *     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":611
 *     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":612
 *     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":613
 *     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_filename = __pyx_f[1]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __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":614
 *     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_filename = __pyx_f[1]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_i, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_kind = __pyx_t_5;

    /* "cupy/core/elementwise.pxi":615
 *     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":616
 *         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":617
 *         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":615
 *     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":619
 *             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":613
 *     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":620
 *         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":621
 *             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":622
 *     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":607
 * 
 * 
 * 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":625
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_guess_routine", 0);

  /* "cupy/core/elementwise.pxi":626
 * 
 * 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":627
 * 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_filename = __pyx_f[1]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_use_raw_value = __pyx_t_2;

    /* "cupy/core/elementwise.pxi":628
 *     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":629
 *         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_filename = __pyx_f[1]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = PyList_AsTuple(__pyx_v_in_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_in_types = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "cupy/core/elementwise.pxi":630
 *         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":628
 *     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":632
 *             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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __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":633
 *         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_filename = __pyx_f[1]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_op = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_L4:;

    /* "cupy/core/elementwise.pxi":635
 *             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":636
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __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":637
 *         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":638
 *             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_filename = __pyx_f[1]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_in_types, __pyx_v_op) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/elementwise.pxi":637
 *         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":635
 *             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":626
 * 
 * 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":640
 *                 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_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_cache, __pyx_v_dtype, __pyx_empty_tuple); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_op = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/core/elementwise.pxi":641
 *     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":642
 *         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_filename = __pyx_f[1]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __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":643
 *         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_filename = __pyx_f[1]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_dtype, __pyx_v_op) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":641
 *     else:
 *         op = cache.get(dtype, ())
 *         if op is ():             # <<<<<<<<<<<<<<
 *             op = _guess_routine_from_dtype(ops, dtype)
 *             cache[dtype] = op
 */
    }
  }
  __pyx_L3:;

  /* "cupy/core/elementwise.pxi":645
 *             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_filename = __pyx_f[1]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "cupy/core/elementwise.pxi":646
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_op);
    __pyx_r = ((PyObject*)__pyx_v_op);
    goto __pyx_L0;

    /* "cupy/core/elementwise.pxi":645
 *             cache[dtype] = op
 * 
 *     if op:             # <<<<<<<<<<<<<<
 *         return op
 *     raise TypeError('Wrong type of arguments for %s' % name)
 */
  }

  /* "cupy/core/elementwise.pxi":647
 *     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_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":625
 * 
 * 
 * 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":661
 * 
 *     """
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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":670
 *         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
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":671
 *         _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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __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":670
 *         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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":671
 *         _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":670
 *         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":673
 *             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
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":674
 *         _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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __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":673
 *             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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":674
 *         _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":673
 *             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":661
 * 
 *     """
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":662
 *     """
 *     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_filename = __pyx_f[1]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":663
 *     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_filename = __pyx_f[1]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":664
 *         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_filename = __pyx_f[1]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":665
 *         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_filename = __pyx_f[1]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nargs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":666
 *         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_filename = __pyx_f[1]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":667
 *         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_filename = __pyx_f[1]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":668
 *         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_filename = __pyx_f[1]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":670
 *         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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":669
 *         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_filename = __pyx_f[1]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __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":673
 *             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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/elementwise.pxi":672
 *             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_filename = __pyx_f[1]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __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":675
 *             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_filename = __pyx_f[1]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":676
 *             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__34, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __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":675
 *             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_filename = __pyx_f[1]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":677
 *         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_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":661
 * 
 *     """
 *     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":679
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "cupy/core/elementwise.pxi":680
 * 
 *     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_filename = __pyx_f[1]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __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":679
 *         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":683
 * 
 *     @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("types", 0);

  /* "cupy/core/elementwise.pxi":690
 * 
 *         """
 *         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_filename = __pyx_f[1]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":691
 *         """
 *         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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __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":692
 *         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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __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":693
 *         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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __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":694
 *             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_filename = __pyx_f[1]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":691
 *         """
 *         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":695
 *             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":683
 * 
 *     @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":697
 *         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 cupy.ndarray object or\n                a scalar. The output arguments can be omitted or be specified\n                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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);
  __Pyx_INCREF(__pyx_v_args);

  /* "cupy/core/elementwise.pxi":715
 *         cdef function.Function kern
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavie 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_filename = __pyx_f[1]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __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":716
 * 
 *         out = kwargs.pop('out', None)
 *         dtype = kwargs.pop('dtype', None)             # <<<<<<<<<<<<<<
 *         # Note default behavie 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_filename = __pyx_f[1]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __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":718
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavie 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_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __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":719
 *         # Note default behavie 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":720
 *         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_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __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":719
 *         # Note default behavie 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":721
 *         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_filename = __pyx_f[1]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":722
 *             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_filename = __pyx_f[1]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":721
 *         if dtype is not None:
 *             dtype = numpy.dtype(dtype).type
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":724
 *             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_filename = __pyx_f[1]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n_args = __pyx_t_7;

  /* "cupy/core/elementwise.pxi":725
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __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":726
 *         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_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/elementwise.pxi":725
 * 
 *         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":728
 *             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_filename = __pyx_f[1]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __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":729
 * 
 *         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":730
 *         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_filename = __pyx_f[1]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_in_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":731
 *         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_filename = __pyx_f[1]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nin); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_out_args = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/core/elementwise.pxi":729
 * 
 *         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":733
 *             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_filename = __pyx_f[1]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/elementwise.pxi":734
 *         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_filename = __pyx_f[1]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":733
 *             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":735
 *             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_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {

      /* "cupy/core/elementwise.pxi":736
 *                 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__38, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/elementwise.pxi":735
 *             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":739
 *                                  "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_filename = __pyx_f[1]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_in_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":740
 * 
 *             in_args = list(args)
 *             out_args = _preprocess_args((out,))             # <<<<<<<<<<<<<<
 *             args += out_args
 * 
 */
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __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":741
 *             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_filename = __pyx_f[1]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __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":743
 *             args += out_args
 * 
 *         broad = broadcast(*args)             # <<<<<<<<<<<<<<
 *         shape = broad.shape
 * 
 */
  __pyx_t_5 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __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":744
 * 
 *         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":747
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":746
 *         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_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __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":749
 *             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_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __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":750
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "cupy/core/elementwise.pxi":751
 *         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_filename = __pyx_f[1]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cupy/core/elementwise.pxi":750
 * 
 *         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":753
 *             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_filename = __pyx_f[1]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L11:;

  /* "cupy/core/elementwise.pxi":755
 *             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_filename = __pyx_f[1]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/core/elementwise.pxi":756
 * 
 *         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":755
 *             ret = tuple(out_args)
 * 
 *         if 0 in shape:             # <<<<<<<<<<<<<<
 *             return ret
 * 
 */
  }

  /* "cupy/core/elementwise.pxi":758
 *             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_filename = __pyx_f[1]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_inout_args = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":759
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __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":760
 *         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_filename = __pyx_f[1]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyObject_GetItem(__pyx_v_broad->values, __pyx_v_i); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __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":761
 *         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_filename = __pyx_f[1]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/elementwise.pxi":759
 * 
 *         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":762
 *             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_filename = __pyx_f[1]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __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":763
 *             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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_params_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __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":764
 *         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_filename = __pyx_f[1]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __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":765
 *         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_filename = __pyx_f[1]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":766
 *         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_filename = __pyx_f[1]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_args_info = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":768
 *         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_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/elementwise.pxi":770
 *         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_filename = __pyx_f[1]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __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":768
 *         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_filename = __pyx_f[1]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_kern = ((struct __pyx_obj_4cupy_4cuda_8function_Function *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":772
 *             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_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/elementwise.pxi":773
 * 
 *         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":697
 *         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":776
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":777
 * 
 * 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_filename = __pyx_f[1]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/elementwise.pxi":778
 * 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_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __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":779
 *     _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":780
 *     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":781
 *         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":779
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/elementwise.pxi":783
 *             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_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __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":785
 *             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_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __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":786
 * 
 *         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_filename = __pyx_f[1]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((__pyx_t_10 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/elementwise.pxi":787
 *         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_filename = __pyx_f[1]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __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":786
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L8;
    }

    /* "cupy/core/elementwise.pxi":789
 *             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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __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":790
 *         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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __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":791
 *             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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_13 = PySequence_ITEM(__pyx_t_7, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __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":792
 *         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_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cupy/core/elementwise.pxi":778
 * 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":794
 *         _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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __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":776
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[1]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[1]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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__41, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name, __pyx_v_name) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __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__42, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = PyList_AsTuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_axis") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axis), (&PyTuple_Type), 1, "axis", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_raxis), (&PyTuple_Type), 1, "raxis", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __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__43, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = PyObject_GetItem(__pyx_v_shape, __pyx_v_i); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trans), (&PyTuple_Type), 1, "trans", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (unlikely(__pyx_v_in_args == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_v_in_args); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_args), (&PyList_Type), 1, "out_args", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "in_indexer", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_indexer), __pyx_ptype_4cupy_4core_4core_Indexer, 1, "out_indexer", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_params), (&PyTuple_Type), 1, "params", 1))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __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":189
 * class simple_reduction_function(object):
 * 
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":190
 * 
 *     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_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":191
 *     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_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":192
 *         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_filename = __pyx_f[3]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":193
 *         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_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":194
 *         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_filename = __pyx_f[3]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":195
 *         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_filename = __pyx_f[3]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":196
 *         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_filename = __pyx_f[3]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __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":197
 *         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_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __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":199
 *         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_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":200
 *         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_filename = __pyx_f[3]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/reduction.pxi":201
 *             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__46, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":199
 *         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_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __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":202
 *             _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_filename = __pyx_f[3]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":201
 *             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_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __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":198
 *         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_filename = __pyx_f[3]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":203
 *                 '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_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":204
 *             _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_filename = __pyx_f[3]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":205
 *         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_filename = __pyx_f[3]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":189
 * class simple_reduction_function(object):
 * 
 *     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":207
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":208
 * 
 *     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":209
 *     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__48, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":208
 * 
 *     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":210
 *         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_filename = __pyx_f[3]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __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":212
 *         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_filename = __pyx_f[3]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":211
 *             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_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":210
 *         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":213
 *             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":214
 *                               ' %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_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __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":213
 *             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":216
 *             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_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __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":217
 * 
 *         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":218
 *         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_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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":219
 *         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_filename = __pyx_f[3]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_out_args = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/core/reduction.pxi":217
 * 
 *         in_args = [a]
 *         if out is None:             # <<<<<<<<<<<<<<
 *             a = _preprocess_args((a,))[0]
 *             out_args = []
 */
    goto __pyx_L8;
  }

  /* "cupy/core/reduction.pxi":221
 *             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_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __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":222
 *         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_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __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":225
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_routine_cache); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ops_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":224
 *             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_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __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":227
 *             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_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __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":228
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __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":229
 *         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_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __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":230
 *         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_filename = __pyx_f[3]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":231
 *         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_filename = __pyx_f[3]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((__pyx_t_8 == 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/reduction.pxi":232
 *         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_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L0;

      /* "cupy/core/reduction.pxi":231
 *         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":233
 *             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_filename = __pyx_f[3]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":230
 *         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":236
 * 
 *         in_args, in_shape = _get_trans_args(
 *             in_args, axis + raxis, in_args[0].shape, None)             # <<<<<<<<<<<<<<
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":235
 *             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_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __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":238
 *             in_args, axis + raxis, in_args[0].shape, None)
 * 
 *         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":239
 * 
 *         block_size = 512
 *         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_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __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":240
 *         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_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __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":243
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":244
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __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":243
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __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":245
 *         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_filename = __pyx_f[3]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __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":248
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":249
 *         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_filename = __pyx_f[3]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":247
 *         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_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __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":250
 *             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_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_args_info = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":252
 *         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_filename = __pyx_f[3]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":253
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":254
 *         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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":255
 *             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_filename = __pyx_f[3]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":256
 *             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_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __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":259
 * 
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_shared_mem = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":261
 *         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_filename = __pyx_f[3]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/core/reduction.pxi":262
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "cupy/core/reduction.pxi":263
 *         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_filename = __pyx_f[3]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __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":265
 *             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_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = PyList_GET_SIZE(__pyx_v_out_args); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = ((__pyx_t_8 == 1) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/reduction.pxi":266
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":265
 *             inout_args, shared_mem, block_size)
 * 
 *         if len(out_args) == 1:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 *         return tuple(out_args)
 */
  }

  /* "cupy/core/reduction.pxi":267
 *         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_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_AsTuple(__pyx_v_out_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":207
 *         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":271
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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":279
 *               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
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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 *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":280
 *     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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __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":279
 *               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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":280
 *     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":279
 *               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":271
 * 
 * @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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":275
 *         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_filename = __pyx_f[3]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_kernel_params = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":276
 *         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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_six_zip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __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":277
 *     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_filename = __pyx_f[3]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __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":276
 *         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_filename = __pyx_f[3]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/reduction.pxi":277
 *     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":276
 *         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":279
 *               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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":278
 *     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__30, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __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":282
 *         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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/reduction.pxi":283
 *     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_filename = __pyx_f[3]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_10) {

      /* "cupy/core/reduction.pxi":282
 *         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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/reduction.pxi":283
 *     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":281
 *         '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__30, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __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":285
 *          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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":286
 *     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_filename = __pyx_f[3]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __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":285
 *          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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/core/reduction.pxi":286
 *     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":284
 *         ['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__30, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __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":288
 *          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":291
 *         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_filename = __pyx_f[3]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":271
 * 
 * @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":325
 * 
 *     """
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":327
 *     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":328
 *                  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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __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":325
 * 
 *     """
 *     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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/reduction.pxi":329
 *                  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_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":330
 *                  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_filename = __pyx_f[3]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":331
 *         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_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nin, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":332
 *         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_filename = __pyx_f[3]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nout, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":333
 *         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_filename = __pyx_f[3]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":335
 *         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_filename = __pyx_f[3]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __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":336
 *         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_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/core/reduction.pxi":335
 *         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_filename = __pyx_f[3]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __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":337
 *             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_filename = __pyx_f[3]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":336
 *         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_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __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":334
 *         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_filename = __pyx_f[3]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/reduction.pxi":338
 *             _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_filename = __pyx_f[3]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":339
 *             _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_filename = __pyx_f[3]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":340
 *         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_filename = __pyx_f[3]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":341
 *         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_filename = __pyx_f[3]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":342
 *         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_filename = __pyx_f[3]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":343
 *         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_filename = __pyx_f[3]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":344
 *         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_filename = __pyx_f[3]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":345
 *         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":346
 *         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_filename = __pyx_f[3]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/core/reduction.pxi":345
 *         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":348
 *             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_filename = __pyx_f[3]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "cupy/core/reduction.pxi":349
 *         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_filename = __pyx_f[3]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":325
 * 
 *     """
 *     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":351
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __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 *);
  PyObject *__pyx_t_13 = NULL;
  long __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "cupy/core/reduction.pxi":368
 *         """
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __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":369
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __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":370
 *         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_filename = __pyx_f[3]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __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":371
 *         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_filename = __pyx_f[3]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":372
 *         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_filename = __pyx_f[3]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":371
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:             # <<<<<<<<<<<<<<
 *             raise TypeError('Wrong arguments %s' % kwargs)
 * 
 */
  }

  /* "cupy/core/reduction.pxi":374
 *             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_filename = __pyx_f[3]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_n_args = __pyx_t_4;

  /* "cupy/core/reduction.pxi":375
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __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":376
 *         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_filename = __pyx_f[3]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":375
 * 
 *         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":378
 *             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_filename = __pyx_f[3]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __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":379
 * 
 *         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":380
 *         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_filename = __pyx_f[3]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":381
 *         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__54, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/reduction.pxi":380
 *         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":382
 *             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_filename = __pyx_f[3]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((__pyx_t_4 != 0) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":383
 *                 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__55, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/reduction.pxi":382
 *             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":385
 *                 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_filename = __pyx_f[3]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __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":379
 * 
 *         out_args = list(args[self.nin:])
 *         if out is not None:             # <<<<<<<<<<<<<<
 *             if self.nout != 1:
 *                 raise NotImplementedError('')
 */
  }

  /* "cupy/core/reduction.pxi":387
 *             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_filename = __pyx_f[3]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __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":388
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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":389
 *         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_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __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":391
 *         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_filename = __pyx_f[3]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __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":393
 *         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_filename = __pyx_f[3]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/reduction.pxi":392
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/reduction.pxi":391
 *         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":396
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":397
 *         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_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __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":396
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":397
 *         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":395
 *                               ' %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_filename = __pyx_f[3]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __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":399
 *              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_filename = __pyx_f[3]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":400
 *         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_filename = __pyx_f[3]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __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":399
 *              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_filename = __pyx_f[3]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/core/reduction.pxi":400
 *         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":398
 *             [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_filename = __pyx_f[3]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __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":401
 *             [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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/reduction.pxi":402
 *              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_filename = __pyx_f[3]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":403
 *         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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L18_unpacking_done:;
  }

  /* "cupy/core/reduction.pxi":401
 *             [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":405
 *             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_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __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":406
 * 
 *         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)
 */
  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_filename = __pyx_f[3]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_keepdims); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_out_shape = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":408
 *         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)             # <<<<<<<<<<<<<<
 *         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_filename = __pyx_f[3]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_out_params); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":407
 *         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)
 *         if 0 in out_shape:
 */
  __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)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __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":409
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params)
 *         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_filename = __pyx_f[3]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (__pyx_t_6 != 0);
  if (__pyx_t_3) {

    /* "cupy/core/reduction.pxi":410
 *             out_args, out_types, out_shape, self.out_params)
 *         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_filename = __pyx_f[3]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_r = __pyx_t_11;
    __pyx_t_11 = 0;
    goto __pyx_L0;

    /* "cupy/core/reduction.pxi":409
 *         out_args = _get_out_args_with_params(
 *             out_args, out_types, out_shape, self.out_params)
 *         if 0 in out_shape:             # <<<<<<<<<<<<<<
 *             return out_args[0]
 * 
 */
  }

  /* "cupy/core/reduction.pxi":412
 *             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_filename = __pyx_f[3]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":413
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __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":412
 *             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_filename = __pyx_f[3]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_x);
        __Pyx_GIVEREF(__pyx_v_x);
        PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_x);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 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_filename = __pyx_f[3]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/reduction.pxi":413
 * 
 *         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":415
 *                    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_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = PyNumber_Add(__pyx_v_axis, __pyx_v_raxis); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_params); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":414
 *         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_filename = __pyx_f[3]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __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":417
 *             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":418
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __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":419
 *         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_filename = __pyx_f[3]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __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":422
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":423
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __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":422
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __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":424
 *         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_filename = __pyx_f[3]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_14 = 1;
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __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_14); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __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":427
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":428
 *         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_filename = __pyx_f[3]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_dims); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":426
 *         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_filename = __pyx_f[3]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __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":429
 *             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_filename = __pyx_f[3]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_args_info = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":431
 *         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_filename = __pyx_f[3]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":432
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/core/reduction.pxi":433
 *         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_filename = __pyx_f[3]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_identity); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);

  /* "cupy/core/reduction.pxi":434
 *             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_filename = __pyx_f[3]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reduce_expr); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_post_map_expr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_16);

  /* "cupy/core/reduction.pxi":435
 *             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_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_preamble); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_options); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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_20 = PyTuple_New(12+__pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_20);
  if (__pyx_t_19) {
    __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_4, __pyx_t_9);
  __Pyx_INCREF(__pyx_v_args_info);
  __Pyx_GIVEREF(__pyx_v_args_info);
  PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_4, __pyx_v_args_info);
  __Pyx_INCREF(__pyx_v_types);
  __Pyx_GIVEREF(__pyx_v_types);
  PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_4, __pyx_v_types);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_20, 3+__pyx_t_4, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_v_block_size);
  PyTuple_SET_ITEM(__pyx_t_20, 4+__pyx_t_4, __pyx_v_block_size);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_20, 5+__pyx_t_4, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_20, 6+__pyx_t_4, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_20, 7+__pyx_t_4, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_20, 8+__pyx_t_4, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_20, 9+__pyx_t_4, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_20, 10+__pyx_t_4, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_20, 11+__pyx_t_4, __pyx_t_18);
  __pyx_t_9 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_13 = 0;
  __pyx_t_10 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_18 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_20, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_kern = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":438
 * 
 *         # 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_filename = __pyx_f[3]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_shared_mem = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":440
 *         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_filename = __pyx_f[3]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/reduction.pxi":441
 * 
 *         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_20 = PyInt_FromSsize_t(__pyx_v_out_indexer->size); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_18 = PyNumber_Add(__pyx_t_20, __pyx_v_block_stride); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = __Pyx_PyInt_SubtractObjC(__pyx_t_18, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  __pyx_t_18 = PyNumber_FloorDivide(__pyx_t_20, __pyx_v_block_stride); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = PyNumber_Multiply(__pyx_t_18, __pyx_v_block_size); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

  /* "cupy/core/reduction.pxi":442
 *         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_18 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_18)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_18);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_17 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  if (__pyx_t_18) {
    __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_18); __pyx_t_18 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_20);
  PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_4, __pyx_t_20);
  __Pyx_INCREF(__pyx_v_inout_args);
  __Pyx_GIVEREF(__pyx_v_inout_args);
  PyTuple_SET_ITEM(__pyx_t_17, 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_17, 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_17, 3+__pyx_t_4, __pyx_v_block_size);
  __pyx_t_20 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/reduction.pxi":443
 *             (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_filename = __pyx_f[3]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/core/reduction.pxi":351
 *         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_13);
  __Pyx_XDECREF(__pyx_t_15);
  __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_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":446
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":448
 * 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_filename = __pyx_f[3]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__ops = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/reduction.pxi":449
 *                             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_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __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":450
 *     _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":451
 *     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":452
 *         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":450
 *     _ops = []
 *     for t in ops:
 *         if not isinstance(t, tuple):             # <<<<<<<<<<<<<<
 *             typ = t
 *             rt = routine
 */
      goto __pyx_L5;
    }

    /* "cupy/core/reduction.pxi":454
 *             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_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __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":455
 *         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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_six_zip); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __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":457
 *             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_filename = __pyx_f[3]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __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":458
 * 
 *         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_filename = __pyx_f[3]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((__pyx_t_11 == 1) != 0);
    if (__pyx_t_6) {

      /* "cupy/core/reduction.pxi":459
 *         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_filename = __pyx_f[3]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __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":458
 * 
 *         types = typ.split('->')
 *         if len(types) == 1:             # <<<<<<<<<<<<<<
 *             in_types = out_types = tuple(types)
 *         else:
 */
      goto __pyx_L14;
    }

    /* "cupy/core/reduction.pxi":461
 *             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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __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":462
 *         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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
      } else {
        __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __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":463
 *             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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __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":464
 *         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_filename = __pyx_f[3]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/reduction.pxi":449
 *                             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":466
 *         _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_filename = __pyx_f[3]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __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":446
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[3]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[3]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1255
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("elementwise_copy", 0);

  /* "cupy/core/core.pyx":1256
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1257
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __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":1255
 * 
 * 
 * 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":1267
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("elementwise_copy_where", 0);

  /* "cupy/core/core.pyx":1268
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1269
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __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":1267
 * 
 * 
 * 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":1364
 * # -----------------------------------------------------------------------------
 * 
 * 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 ndim
 */

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);
  Py_ssize_t __pyx_v_ndim;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a = 0;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1368
 *     cdef Py_ssize_t ndim
 *     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":1369
 *     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":1370
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __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":1369
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):
 *         if dtype is None:             # <<<<<<<<<<<<<<
 *             dtype = obj.dtype
 *         a = obj.astype(dtype, copy)
 */
    }

    /* "cupy/core/core.pyx":1371
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_a = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1373
 *         a = obj.astype(dtype, copy)
 * 
 *         ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 */
    __pyx_v_ndim = __pyx_v_a->_shape.size();

    /* "cupy/core/core.pyx":1374
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *         return a
 */
    __pyx_t_1 = ((__pyx_v_ndmin > __pyx_v_ndim) != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1375
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
      __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_ndmin - __pyx_v_ndim)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyNumber_Multiply(__pyx_tuple__57, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/core/core.pyx":1374
 * 
 *         ndim = a._shape.size()
 *         if ndmin > ndim:             # <<<<<<<<<<<<<<
 *             a.shape = (1,) * (ndmin - ndim) + a.shape
 *         return a
 */
    }

    /* "cupy/core/core.pyx":1376
 *         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":1368
 *     cdef Py_ssize_t ndim
 *     cdef ndarray a
 *     if isinstance(obj, ndarray):             # <<<<<<<<<<<<<<
 *         if dtype is None:
 *             dtype = obj.dtype
 */
  }

  /* "cupy/core/core.pyx":1378
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_ndmin); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_ndmin, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __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":1379
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __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":1380
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1379
 *     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":1381
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1382
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __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":1381
 *         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":1383
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __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":1384
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __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":1385
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1386
 *         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":1385
 *         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":1388
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __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":1364
 * # -----------------------------------------------------------------------------
 * 
 * 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 ndim
 */

  /* 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_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1391
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         dtype = a.dtype
 */

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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1392
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
  __pyx_t_1 = (__pyx_v_dtype == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1393
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:
 *         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":1392
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):
 *     if dtype is None:             # <<<<<<<<<<<<<<
 *         dtype = a.dtype
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1395
 *         dtype = a.dtype
 *     else:
 *         dtype = numpy.dtype(dtype)             # <<<<<<<<<<<<<<
 * 
 *     if dtype == a.dtype and a._c_contiguous:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __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;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1397
 *         dtype = numpy.dtype(dtype)
 * 
 *     if dtype == a.dtype and a._c_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
  __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_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_a->_c_contiguous != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1398
 * 
 *     if dtype == a.dtype and a._c_contiguous:
 *         return a             # <<<<<<<<<<<<<<
 *     else:
 *         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":1397
 *         dtype = numpy.dtype(dtype)
 * 
 *     if dtype == a.dtype and a._c_contiguous:             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
  }

  /* "cupy/core/core.pyx":1400
 *         return a
 *     else:
 *         newarray = ndarray(a.shape, dtype)             # <<<<<<<<<<<<<<
 *         elementwise_copy(a, newarray)
 *         return newarray
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __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":1401
 *     else:
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __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":1402
 *         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":1391
 * 
 * 
 * cpdef ndarray ascontiguousarray(ndarray a, dtype=None):             # <<<<<<<<<<<<<<
 *     if dtype is None:
 *         dtype = a.dtype
 */

  /* 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1408
 * # -----------------------------------------------------------------------------
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1409
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/core/core.pyx":1411
 *     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":1412
 *     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":1411
 *     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":1413
 *     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":1414
 *         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":1413
 *     if axis < 0:
 *         axis += ndim
 *     if start < 0:             # <<<<<<<<<<<<<<
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 */
  }

  /* "cupy/core/core.pyx":1415
 *     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":1416
 *         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__58, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1415
 *     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":1417
 *     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":1418
 *         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":1417
 *     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":1419
 *     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":1420
 *         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":1419
 *     if axis < start:
 *         start -= 1
 *     if axis == start:             # <<<<<<<<<<<<<<
 *         return a
 *     if ndim == 2:
 */
  }

  /* "cupy/core/core.pyx":1421
 *     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":1422
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __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":1421
 *     if axis == start:
 *         return a
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         return a._transpose(axes)
 * 
 */
  }

  /* "cupy/core/core.pyx":1424
 *         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":1425
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "cupy/core/core.pyx":1426
 *     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":1427
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1428
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __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":1408
 * # -----------------------------------------------------------------------------
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1456
 *         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;
  size_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  size_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/core/core.pyx":1461
 *         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__59;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_rev = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1463
 *         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":1464
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __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":1465
 *         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":1466
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 continue             # <<<<<<<<<<<<<<
 *             a = x
 *             self.nd = max(self.nd, a._shape.size())
 */
      goto __pyx_L3_continue;

      /* "cupy/core/core.pyx":1465
 *         self.nd = 0
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
    }

    /* "cupy/core/core.pyx":1467
 *             if not isinstance(x, ndarray):
 *                 continue
 *             a = x             # <<<<<<<<<<<<<<
 *             self.nd = max(self.nd, 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_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __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":1468
 *                 continue
 *             a = x
 *             self.nd = max(self.nd, a._shape.size())             # <<<<<<<<<<<<<<
 *             r_shape.assign(a._shape.rbegin(), a._shape.rend())
 *             shape_arr.push_back(r_shape)
 */
    __pyx_t_6 = __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":1469
 *             a = x
 *             self.nd = max(self.nd, 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_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1470
 *             self.nd = max(self.nd, 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_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1464
 * 
 *         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":1472
 *             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":1473
 * 
 *         r_shape.clear()
 *         for i in range(self.nd):             # <<<<<<<<<<<<<<
 *             ss = 0
 *             for j in range(shape_arr.size()):
 */
  __pyx_t_2 = __pyx_v_self->nd;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_2; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "cupy/core/core.pyx":1474
 *         r_shape.clear()
 *         for i in range(self.nd):
 *             ss = 0             # <<<<<<<<<<<<<<
 *             for j in range(shape_arr.size()):
 *                 if i < shape_arr[j].size():
 */
    __pyx_v_ss = 0;

    /* "cupy/core/core.pyx":1475
 *         for i in range(self.nd):
 *             ss = 0
 *             for j in range(shape_arr.size()):             # <<<<<<<<<<<<<<
 *                 if i < shape_arr[j].size():
 *                     s = shape_arr[j][i]
 */
    __pyx_t_8 = __pyx_v_shape_arr.size();
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_j = __pyx_t_9;

      /* "cupy/core/core.pyx":1476
 *             ss = 0
 *             for j in range(shape_arr.size()):
 *                 if i < shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     ss = max(ss, s)
 */
      __pyx_t_5 = ((__pyx_v_i < (__pyx_v_shape_arr[__pyx_v_j]).size()) != 0);
      if (__pyx_t_5) {

        /* "cupy/core/core.pyx":1477
 *             for j in range(shape_arr.size()):
 *                 if i < 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":1478
 *                 if i < shape_arr[j].size():
 *                     s = shape_arr[j][i]
 *                     ss = max(ss, s)             # <<<<<<<<<<<<<<
 *             r_shape.push_back(ss)
 * 
 */
        __pyx_t_10 = __pyx_v_s;
        __pyx_t_11 = __pyx_v_ss;
        if (((__pyx_t_10 > __pyx_t_11) != 0)) {
          __pyx_t_12 = __pyx_t_10;
        } else {
          __pyx_t_12 = __pyx_t_11;
        }
        __pyx_v_ss = __pyx_t_12;

        /* "cupy/core/core.pyx":1476
 *             ss = 0
 *             for j in range(shape_arr.size()):
 *                 if i < shape_arr[j].size():             # <<<<<<<<<<<<<<
 *                     s = shape_arr[j][i]
 *                     ss = max(ss, s)
 */
      }
    }

    /* "cupy/core/core.pyx":1479
 *                     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_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "cupy/core/core.pyx":1481
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1482
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __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":1483
 *         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":1485
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_broadcasted = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1486
 * 
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __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":1487
 *         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":1488
 *         for x in arrays:
 *             if not isinstance(x, ndarray):
 *                 broadcasted.append(x)             # <<<<<<<<<<<<<<
 *                 continue
 *             a = x
 */
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_broadcasted, __pyx_v_x); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1489
 *             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":1487
 *         broadcasted = []
 *         for x in arrays:
 *             if not isinstance(x, ndarray):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(x)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":1490
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __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":1491
 *                 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":1492
 *             a = x
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_a)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1493
 *             if internal.vector_equal(a._shape, shape):
 *                 broadcasted.append(a)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             r_strides.assign(self.nd, 0)
 */
      goto __pyx_L11_continue;

      /* "cupy/core/core.pyx":1491
 *                 continue
 *             a = x
 *             if internal.vector_equal(a._shape, shape):             # <<<<<<<<<<<<<<
 *                 broadcasted.append(a)
 *                 continue
 */
    }

    /* "cupy/core/core.pyx":1495
 *                 continue
 * 
 *             r_strides.assign(self.nd, 0)             # <<<<<<<<<<<<<<
 *             a_ndim = a._shape.size()
 *             for i in range(a_ndim):
 */
    __pyx_v_r_strides.assign(__pyx_v_self->nd, 0);

    /* "cupy/core/core.pyx":1496
 * 
 *             r_strides.assign(self.nd, 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":1497
 *             r_strides.assign(self.nd, 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_7 = __pyx_v_a_ndim;
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_7; __pyx_t_9+=1) {
      __pyx_v_i = __pyx_t_9;

      /* "cupy/core/core.pyx":1498
 *             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":1499
 *             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":1500
 *                 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":1499
 *             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":1501
 *                 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":1502
 *                     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__60, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/core.pyx":1501
 *                 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":1504
 *                     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_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1505
 * 
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __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":1506
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/core/core.pyx":1507
 *             view = a.view()
 *             view._set_shape_and_strides(shape, strides)
 *             broadcasted.append(view)             # <<<<<<<<<<<<<<
 * 
 *         self.values = tuple(broadcasted)
 */
    __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_broadcasted, ((PyObject *)__pyx_v_view)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1486
 * 
 *         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":1509
 *             broadcasted.append(view)
 * 
 *         self.values = tuple(broadcasted)             # <<<<<<<<<<<<<<
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):
 */
  __pyx_t_3 = PyList_AsTuple(__pyx_v_broadcasted); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __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":1456
 *         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":1451
 * 
 *     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":1452
 *     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":1453
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1454
 *         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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->nd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1511
 *         self.values = tuple(broadcasted)
 * 
 * cpdef ndarray _repeat(ndarray a, repeats, axis=None):             # <<<<<<<<<<<<<<
 *     """Repeat arrays along an axis.
 * 
 */

static PyObject *__pyx_pw_4cupy_4core_4core_57_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1526
 *     """
 *     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":1527
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1529
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __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":1528
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1527
 *     cdef ndarray ret
 *     if isinstance(repeats, int):
 *         if repeats < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "'repeats' should not be negative: {}".format(repeats))
 */
    }

    /* "cupy/core/core.pyx":1530
 *             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":1531
 *                 "'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_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __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":1532
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1532; __pyx_clineno = __LINE__; goto __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":1533
 *             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":1534
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/core.pyx":1533
 *             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":1535
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1535; __pyx_clineno = __LINE__; goto __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":1530
 *             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":1537
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __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":1526
 *     """
 *     cdef ndarray ret
 *     if isinstance(repeats, int):             # <<<<<<<<<<<<<<
 *         if repeats < 0:
 *             raise ValueError(
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1538
 * 
 *         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":1539
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1539; __pyx_clineno = __LINE__; goto __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":1540
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_1) {

        /* "cupy/core/core.pyx":1543
 *                 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_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __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":1541
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1541; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1541; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "cupy/core/core.pyx":1540
 *     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":1539
 *         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":1544
 *                     "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":1545
 *                     .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__63, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1544
 *                     "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":1547
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_axis); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1550
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_v_axis); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __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":1548
 *                 "'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_filename = __pyx_f[0]; __pyx_lineno = 1548; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1548; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1547
 *             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":1538
 * 
 *         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":1552
 *                 .format(a.shape[axis], len(repeats)))
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 */
  /*else*/ {

    /* "cupy/core/core.pyx":1553
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __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":1552
 *                 .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_filename = __pyx_f[0]; __pyx_lineno = 1552; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1552; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1555
 *             "'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_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1556
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1556; __pyx_clineno = __LINE__; goto __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":1555
 *             "'repeats' should be int or sequence: {}".format(repeats))
 * 
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += a.ndim
 * 
 */
  }

  /* "cupy/core/core.pyx":1558
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __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":1559
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":1560
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __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":1561
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyList_New(1 * ((__pyx_t_8<0) ? 0:__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __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__64);
      __Pyx_GIVEREF(__pyx_slice__64);
      PyList_SET_ITEM(__pyx_t_6, __pyx_temp, __pyx_slice__64);
    }
  }
  __pyx_v_a_index = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1562
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_ret_index = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1563
 *     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":1564
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyInt_FromSsize_t((__pyx_v_a->_shape[__pyx_t_7])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1564; __pyx_clineno = __LINE__; goto __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":1565
 *     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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1566
 *     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":1565
 *     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":1567
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1568
 *             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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/core/core.pyx":1570
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_6, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __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":1571
 *         # 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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __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":1564
 *     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":1572
 *         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":1511
 *         self.values = tuple(broadcasted)
 * 
 * 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_57_repeat(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4core_4core_56_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_57_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_56_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_56_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1578
 * # -----------------------------------------------------------------------------
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):             # <<<<<<<<<<<<<<
 *     types = () if no_bool else ('??->?',)
 *     return create_ufunc(
 */

static PyObject *__pyx_pw_4cupy_4core_4core_59_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1579
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_t_1 = __pyx_empty_tuple;
  } else {
    __Pyx_INCREF(__pyx_tuple__66);
    __pyx_t_1 = __pyx_tuple__66;
  }
  __pyx_v_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1580
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1581
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":1582
 *     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__67); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":1584
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":1580
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __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":1585
 *                  'LL->L', 'qq->q', 'QQ->Q'),
 *         'out0 = in0 %s in1' % op,
 *         doc=doc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_doc, __pyx_v_doc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1580
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __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":1578
 * # -----------------------------------------------------------------------------
 * 
 * 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_59_create_bit_op(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_59_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __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_58_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_58_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1680
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if axis is None:
 *         a = a.ravel()
 */

static PyObject *__pyx_pw_4cupy_4core_4core_61_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_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
  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;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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((PyObject *)__pyx_v_out);

  /* "cupy/core/core.pyx":1681
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1682
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     if axis is None:
 *         a = a.ravel()             # <<<<<<<<<<<<<<
 *         lshape = ()
 *         rshape = ()
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->ravel(__pyx_v_a, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1683
 *     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":1684
 *         a = a.ravel()
 *         lshape = ()
 *         rshape = ()             # <<<<<<<<<<<<<<
 *         adim = 1
 *     else:
 */
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_v_rshape = __pyx_empty_tuple;

    /* "cupy/core/core.pyx":1685
 *         lshape = ()
 *         rshape = ()
 *         adim = 1             # <<<<<<<<<<<<<<
 *     else:
 *         if axis >= a.ndim:
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_adim = __pyx_int_1;

    /* "cupy/core/core.pyx":1681
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *         lshape = ()
 */
    goto __pyx_L3;
  }

  /* "cupy/core/core.pyx":1687
 *         adim = 1
 *     else:
 *         if axis >= a.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *         lshape = a.shape[:axis]
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_axis, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __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_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1688
 *     else:
 *         if axis >= a.ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]
 */
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1687
 *         adim = 1
 *     else:
 *         if axis >= a.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError('Axis overrun')
 *         lshape = a.shape[:axis]
 */
    }

    /* "cupy/core/core.pyx":1689
 *         if axis >= a.ndim:
 *             raise ValueError('Axis overrun')
 *         lshape = a.shape[:axis]             # <<<<<<<<<<<<<<
 *         rshape = a.shape[axis + 1:]
 *         adim = a.shape[axis]
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, 0, NULL, &__pyx_v_axis, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_lshape = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1690
 *             raise ValueError('Axis overrun')
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]             # <<<<<<<<<<<<<<
 *         adim = a.shape[axis]
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_axis, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, 0, &__pyx_t_4, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_rshape = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1691
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]
 *         adim = a.shape[axis]             # <<<<<<<<<<<<<<
 * 
 *     if numpy.isscalar(indices):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_v_axis); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_adim = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "cupy/core/core.pyx":1693
 *         adim = a.shape[axis]
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isscalar); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __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_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_indices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __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_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __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_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1694
 * 
 *     if numpy.isscalar(indices):
 *         if axis is not None:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, axis)
 *         if out is None:
 */
    __pyx_t_2 = (__pyx_v_axis != Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "cupy/core/core.pyx":1695
 *     if numpy.isscalar(indices):
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_t_7, 0, NULL)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __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":1694
 * 
 *     if numpy.isscalar(indices):
 *         if axis is not None:             # <<<<<<<<<<<<<<
 *             a = rollaxis(a, axis)
 *         if out is None:
 */
    }

    /* "cupy/core/core.pyx":1696
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    __pyx_t_1 = (((PyObject *)__pyx_v_out) == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1697
 *             a = rollaxis(a, axis)
 *         if out is None:
 *             return a[indices].copy()             # <<<<<<<<<<<<<<
 *         else:
 *             out[:] = a[indices]
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __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 && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_3) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;
      goto __pyx_L0;

      /* "cupy/core/core.pyx":1696
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 *         if out is None:             # <<<<<<<<<<<<<<
 *             return a[indices].copy()
 *         else:
 */
    }

    /* "cupy/core/core.pyx":1699
 *             return a[indices].copy()
 *         else:
 *             out[:] = a[indices]             # <<<<<<<<<<<<<<
 *             return out
 *     elif not isinstance(indices, ndarray):
 */
    /*else*/ {
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_a), __pyx_v_indices); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_out), __pyx_t_4, 0, 0, NULL, NULL, &__pyx_slice__69, 0, 0, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1700
 *         else:
 *             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":1693
 *         adim = a.shape[axis]
 * 
 *     if numpy.isscalar(indices):             # <<<<<<<<<<<<<<
 *         if axis is not None:
 *             a = rollaxis(a, axis)
 */
  }

  /* "cupy/core/core.pyx":1701
 *             out[:] = a[indices]
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_indices, __pyx_ptype_4cupy_4core_4core_ndarray); 
  __pyx_t_1 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1702
 *             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_4 = ((PyObject *)__pyx_f_4cupy_4core_4core_array(__pyx_v_indices, 0, &__pyx_t_8)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1701
 *             out[:] = a[indices]
 *             return out
 *     elif not isinstance(indices, ndarray):             # <<<<<<<<<<<<<<
 *         indices = array(indices, dtype=int)
 * 
 */
  }

  /* "cupy/core/core.pyx":1704
 *         indices = array(indices, dtype=int)
 * 
 *     out_shape = lshape + indices.shape + rshape             # <<<<<<<<<<<<<<
 *     if out is None:
 *         out = ndarray(out_shape, dtype=a.dtype)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyNumber_Add(__pyx_v_lshape, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_v_rshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_out_shape = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":1705
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1706
 *     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_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_out_shape);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1705
 * 
 *     out_shape = lshape + indices.shape + rshape
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(out_shape, dtype=a.dtype)
 *     else:
 */
    goto __pyx_L8;
  }

  /* "cupy/core/core.pyx":1708
 *         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_3 = PyObject_RichCompare(__pyx_v_out->dtype, __pyx_v_a->dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1709
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1708
 *         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":1710
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_v_out_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1711
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1710
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output shape mismatch')
 * 
 */
    }
  }
  __pyx_L8:;

  /* "cupy/core/core.pyx":1713
 *             raise ValueError('Output shape mismatch')
 * 
 *     cdim = indices.size             # <<<<<<<<<<<<<<
 *     rdim = internal.prod(rshape)
 *     indices = indices.reshape(
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_cdim = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1714
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_rdim = __pyx_t_7;

  /* "cupy/core/core.pyx":1715
 *     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_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_reshape_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":1716
 *     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(a.reduced_view(), indices, rdim, out)
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_lshape); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Multiply(__pyx_tuple__72, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = PyObject_Length(__pyx_v_rshape); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Multiply(__pyx_tuple__73, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  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);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __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_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1717
 *     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, out)
 *     else:
 */
  __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_v_axis, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_10 = (__pyx_t_1 != 0);
  __pyx_t_2 = __pyx_t_10;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1718
 *         (1,) * len(lshape) + indices.shape + (1,) * len(rshape))
 *     if axis == 0 or axis is None:
 *         return _take_kernel_0axis(a.reduced_view(), indices, rdim, out)             # <<<<<<<<<<<<<<
 *     else:
 *         return _take_kernel(a.reduced_view(), indices, cdim, rdim, adim, out)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
    __pyx_t_4 = __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_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_7 = 1;
      }
    }
    __pyx_t_11 = PyTuple_New(4+__pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __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_3);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_7, __pyx_t_3);
    __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(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_7, ((PyObject *)__pyx_v_out));
    __pyx_t_3 = 0;
    __pyx_t_9 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __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":1717
 *     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, out)
 *     else:
 */
  }

  /* "cupy/core/core.pyx":1720
 *         return _take_kernel_0axis(a.reduced_view(), indices, rdim, out)
 *     else:
 *         return _take_kernel(a.reduced_view(), indices, cdim, rdim, adim, out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->reduced_view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_rdim); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __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_3 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(6+__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __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_7, __pyx_t_4);
    __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(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_7, ((PyObject *)__pyx_v_out));
    __pyx_t_4 = 0;
    __pyx_t_11 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __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":1680
 * 
 * 
 * cpdef ndarray _take(ndarray a, indices, axis=None, ndarray out=None):             # <<<<<<<<<<<<<<
 *     if axis is None:
 *         a = a.ravel()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_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_out_shape);
  __Pyx_XDECREF(__pyx_v_cdim);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_indices);
  __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_61_take(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_61_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_60_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_60_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1723
 * 
 * 
 * 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_63_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1725
 * 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":1726
 *                        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":1725
 * 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":1728
 *         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":1730
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __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":1731
 * 
 *     tr = list(six.moves.range(a.ndim))
 *     del tr[max_axis]             # <<<<<<<<<<<<<<
 *     del tr[min_axis]
 *     if offset >= 0:
 */
  if (__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_max_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1732
 *     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 (__Pyx_DelItemInt(__pyx_v_tr, __pyx_v_min_axis, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1733
 *     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":1734
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __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":1733
 *     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":1736
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_axis2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_axis1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __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":1737
 *     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":1739
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __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":1740
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_8, 0, -2L, NULL, NULL, &__pyx_slice__74, 0, 1, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __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":1741
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1742
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_v_a->dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __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":1741
 *     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":1744
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __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":1746
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __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":1748
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, -2L, NULL, NULL, &__pyx_slice__75, 0, 1, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1749
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, -2L, NULL, NULL, &__pyx_slice__76, 0, 1, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1747
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":1750
 *         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":1723
 * 
 * 
 * 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_63_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_63_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_62_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_62_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1757
 * # -----------------------------------------------------------------------------
 * 
 * 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 a_is_vec, b_is_vec
 */

static PyObject *__pyx_pw_4cupy_4core_4core_65dot(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_a_is_vec;
  int __pyx_v_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;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_opt_args_4cupy_4core_4core_rollaxis __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1762
 *     cdef vector.vector[Py_ssize_t] ret_shape
 *     cdef vector.vector[Py_ssize_t] shape
 *     a_ndim = a._shape.size()             # <<<<<<<<<<<<<<
 *     b_ndim = b._shape.size()
 *     assert a_ndim > 0 and b_ndim > 0
 */
  __pyx_v_a_ndim = __pyx_v_a->_shape.size();

  /* "cupy/core/core.pyx":1763
 *     cdef vector.vector[Py_ssize_t] shape
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()             # <<<<<<<<<<<<<<
 *     assert a_ndim > 0 and b_ndim > 0
 *     a_is_vec = a_ndim == 1
 */
  __pyx_v_b_ndim = __pyx_v_b->_shape.size();

  /* "cupy/core/core.pyx":1764
 *     a_ndim = a._shape.size()
 *     b_ndim = b._shape.size()
 *     assert a_ndim > 0 and b_ndim > 0             # <<<<<<<<<<<<<<
 *     a_is_vec = a_ndim == 1
 *     b_is_vec = b_ndim == 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = ((__pyx_v_a_ndim > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L3_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_b_ndim > 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L3_bool_binop_done:;
    if (unlikely(!__pyx_t_1)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "cupy/core/core.pyx":1765
 *     b_ndim = b._shape.size()
 *     assert a_ndim > 0 and b_ndim > 0
 *     a_is_vec = a_ndim == 1             # <<<<<<<<<<<<<<
 *     b_is_vec = b_ndim == 1
 * 
 */
  __pyx_v_a_is_vec = (__pyx_v_a_ndim == 1);

  /* "cupy/core/core.pyx":1766
 *     assert a_ndim > 0 and b_ndim > 0
 *     a_is_vec = a_ndim == 1
 *     b_is_vec = b_ndim == 1             # <<<<<<<<<<<<<<
 * 
 *     if a_is_vec:
 */
  __pyx_v_b_is_vec = (__pyx_v_b_ndim == 1);

  /* "cupy/core/core.pyx":1768
 *     b_is_vec = b_ndim == 1
 * 
 *     if a_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(1)
 */
  __pyx_t_1 = (__pyx_v_a_is_vec != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1769
 * 
 *     if a_is_vec:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":1770
 *     if 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_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1771
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1772
 *         shape.push_back(1)
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)             # <<<<<<<<<<<<<<
 *         a_ndim = 2
 *     if b_is_vec:
 */
    __pyx_t_3 = ((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_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1773
 *         shape.push_back(a.size)
 *         a = a._reshape(shape)
 *         a_ndim = 2             # <<<<<<<<<<<<<<
 *     if b_is_vec:
 *         shape.clear()
 */
    __pyx_v_a_ndim = 2;

    /* "cupy/core/core.pyx":1768
 *     b_is_vec = b_ndim == 1
 * 
 *     if a_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(1)
 */
  }

  /* "cupy/core/core.pyx":1774
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  __pyx_t_1 = (__pyx_v_b_is_vec != 0);
  if (__pyx_t_1) {

    /* "cupy/core/core.pyx":1775
 *         a_ndim = 2
 *     if b_is_vec:
 *         shape.clear()             # <<<<<<<<<<<<<<
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 */
    __pyx_v_shape.clear();

    /* "cupy/core/core.pyx":1776
 *     if 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_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1777
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1778
 *         shape.push_back(b.size)
 *         shape.push_back(1)
 *         b = b._reshape(shape)             # <<<<<<<<<<<<<<
 *         b_ndim = 2
 * 
 */
    __pyx_t_3 = ((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_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1779
 *         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":1774
 *         a = a._reshape(shape)
 *         a_ndim = 2
 *     if b_is_vec:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(b.size)
 */
  }

  /* "cupy/core/core.pyx":1781
 *         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":1782
 * 
 *     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":1784
 *     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":1785
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":1784
 *     b_axis = b_ndim - 2
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:             # <<<<<<<<<<<<<<
 *         raise ValueError('Axis dimension mismatch')
 * 
 */
  }

  /* "cupy/core/core.pyx":1787
 *         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":1788
 * 
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)             # <<<<<<<<<<<<<<
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)
 */
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.start = 0;
    __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_a, __pyx_v_a_axis, 0, &__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1787
 *         raise ValueError('Axis dimension mismatch')
 * 
 *     if a_axis:             # <<<<<<<<<<<<<<
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 */
  }

  /* "cupy/core/core.pyx":1789
 *     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":1790
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:
 *         b = rollaxis(b, b_axis, 0)             # <<<<<<<<<<<<<<
 * 
 *     k = a._shape[0]
 */
    __pyx_t_4.__pyx_n = 1;
    __pyx_t_4.start = 0;
    __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4core_4core_rollaxis(__pyx_v_b, __pyx_v_b_axis, 0, &__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "cupy/core/core.pyx":1789
 *     if a_axis:
 *         a = rollaxis(a, a_axis, 0)
 *     if b_axis:             # <<<<<<<<<<<<<<
 *         b = rollaxis(b, b_axis, 0)
 * 
 */
  }

  /* "cupy/core/core.pyx":1792
 *         b = rollaxis(b, b_axis, 0)
 * 
 *     k = a._shape[0]             # <<<<<<<<<<<<<<
 *     m = b.size // k
 *     n = a.size // k
 */
  __pyx_v_k = (__pyx_v_a->_shape[0]);

  /* "cupy/core/core.pyx":1793
 * 
 *     k = a._shape[0]
 *     m = b.size // k             # <<<<<<<<<<<<<<
 *     n = a.size // k
 * 
 */
  if (unlikely(__pyx_v_k == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_m = __Pyx_div_Py_ssize_t(__pyx_v_b->size, __pyx_v_k);

  /* "cupy/core/core.pyx":1794
 *     k = a._shape[0]
 *     m = b.size // k
 *     n = a.size // k             # <<<<<<<<<<<<<<
 * 
 *     ret_shape.assign(a._shape.begin() + 1, a._shape.end())
 */
  if (unlikely(__pyx_v_k == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_n = __Pyx_div_Py_ssize_t(__pyx_v_a->size, __pyx_v_k);

  /* "cupy/core/core.pyx":1796
 *     n = a.size // k
 * 
 *     ret_shape.assign(a._shape.begin() + 1, a._shape.end())             # <<<<<<<<<<<<<<
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is None:
 */
  try {
    __pyx_v_ret_shape.assign((__pyx_v_a->_shape.begin() + 1), __pyx_v_a->_shape.end());
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1797
 * 
 *     ret_shape.assign(a._shape.begin() + 1, a._shape.end())
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())             # <<<<<<<<<<<<<<
 *     if out is None:
 *         if a_is_vec:
 */
  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_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cupy/core/core.pyx":1798
 *     ret_shape.assign(a._shape.begin() + 1, a._shape.end())
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is None:             # <<<<<<<<<<<<<<
 *         if a_is_vec:
 *             if b_is_vec:
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1799
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is None:
 *         if a_is_vec:             # <<<<<<<<<<<<<<
 *             if b_is_vec:
 *                 ret_shape.clear()
 */
    __pyx_t_2 = (__pyx_v_a_is_vec != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1800
 *     if out is None:
 *         if a_is_vec:
 *             if b_is_vec:             # <<<<<<<<<<<<<<
 *                 ret_shape.clear()
 *             else:
 */
      __pyx_t_2 = (__pyx_v_b_is_vec != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1801
 *         if a_is_vec:
 *             if b_is_vec:
 *                 ret_shape.clear()             # <<<<<<<<<<<<<<
 *             else:
 *                 ret_shape.erase(ret_shape.begin())
 */
        __pyx_v_ret_shape.clear();

        /* "cupy/core/core.pyx":1800
 *     if out is None:
 *         if a_is_vec:
 *             if b_is_vec:             # <<<<<<<<<<<<<<
 *                 ret_shape.clear()
 *             else:
 */
        goto __pyx_L12;
      }

      /* "cupy/core/core.pyx":1803
 *                 ret_shape.clear()
 *             else:
 *                 ret_shape.erase(ret_shape.begin())             # <<<<<<<<<<<<<<
 *         elif b_is_vec:
 *             ret_shape.erase(ret_shape.begin())
 */
      /*else*/ {
        __pyx_v_ret_shape.erase(__pyx_v_ret_shape.begin());
      }
      __pyx_L12:;

      /* "cupy/core/core.pyx":1799
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is None:
 *         if a_is_vec:             # <<<<<<<<<<<<<<
 *             if b_is_vec:
 *                 ret_shape.clear()
 */
      goto __pyx_L11;
    }

    /* "cupy/core/core.pyx":1804
 *             else:
 *                 ret_shape.erase(ret_shape.begin())
 *         elif b_is_vec:             # <<<<<<<<<<<<<<
 *             ret_shape.erase(ret_shape.begin())
 *     else:
 */
    __pyx_t_2 = (__pyx_v_b_is_vec != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1805
 *                 ret_shape.erase(ret_shape.begin())
 *         elif b_is_vec:
 *             ret_shape.erase(ret_shape.begin())             # <<<<<<<<<<<<<<
 *     else:
 *         if out.size != n * m:
 */
      __pyx_v_ret_shape.erase(__pyx_v_ret_shape.begin());

      /* "cupy/core/core.pyx":1804
 *             else:
 *                 ret_shape.erase(ret_shape.begin())
 *         elif b_is_vec:             # <<<<<<<<<<<<<<
 *             ret_shape.erase(ret_shape.begin())
 *     else:
 */
    }
    __pyx_L11:;

    /* "cupy/core/core.pyx":1798
 *     ret_shape.assign(a._shape.begin() + 1, a._shape.end())
 *     ret_shape.insert(ret_shape.end(), b._shape.begin() + 1, b._shape.end())
 *     if out is None:             # <<<<<<<<<<<<<<
 *         if a_is_vec:
 *             if b_is_vec:
 */
    goto __pyx_L10;
  }

  /* "cupy/core/core.pyx":1807
 *             ret_shape.erase(ret_shape.begin())
 *     else:
 *         if out.size != n * m:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 */
  /*else*/ {
    __pyx_t_2 = ((__pyx_v_out->size != (__pyx_v_n * __pyx_v_m)) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1808
 *     else:
 *         if 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_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1807
 *             ret_shape.erase(ret_shape.begin())
 *     else:
 *         if out.size != n * m:             # <<<<<<<<<<<<<<
 *             raise ValueError('Output array has an invalid size')
 *         if not out._c_contiguous:
 */
    }

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

      /* "cupy/core/core.pyx":1810
 *             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_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1809
 *         if 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_L10:;

  /* "cupy/core/core.pyx":1812
 *             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_3 = ((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_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1757
 * # -----------------------------------------------------------------------------
 * 
 * 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 a_is_vec, b_is_vec
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __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_65dot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_65dot(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_64dot(__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_64dot(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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1815
 * 
 * 
 * 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_67tensordot_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_inca;
  int __pyx_v_incb;
  int __pyx_v_transa;
  int __pyx_v_transb;
  int __pyx_v_lda;
  int __pyx_v_ldb;
  Py_ssize_t __pyx_v_mode;
  Py_ssize_t __pyx_v_handle;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_ret_dtype = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_c = NULL;
  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;
  struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  char const *__pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  Py_ssize_t __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1822
 *     cdef Py_ssize_t mode, handle
 *     cdef str dtype, ret_dtype
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ret_dtype = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/core/core.pyx":1823
 *     cdef str dtype, ret_dtype
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1824
 *     ret_dtype = a.dtype.char
 *     if ret_dtype != b.dtype.char:
 *         ret_dtype = numpy.find_common_type((ret_dtype, b.dtype), ()).char             # <<<<<<<<<<<<<<
 * 
 *     # Cast to float32 or float64
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_ret_dtype, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1823
 *     cdef str dtype, ret_dtype
 *     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":1827
 * 
 *     # Cast to float32 or float64
 *     if ret_dtype == 'f' or ret_dtype == 'd':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
  __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_2 = __pyx_t_9;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_ret_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1828
 *     # Cast to float32 or float64
 *     if 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":1827
 * 
 *     # Cast to float32 or float64
 *     if ret_dtype == 'f' or ret_dtype == 'd':             # <<<<<<<<<<<<<<
 *         dtype = ret_dtype
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/core/core.pyx":1830
 *         dtype = ret_dtype
 *     else:
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char             # <<<<<<<<<<<<<<
 * 
 *     a = a.astype(dtype, copy=False)
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_find_common_type); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_ret_dtype);
    __Pyx_GIVEREF(__pyx_v_ret_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ret_dtype);
    __Pyx_INCREF(__pyx_n_s_f);
    __Pyx_GIVEREF(__pyx_n_s_f);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_f);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_1);
    __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_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_char); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_dtype = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;
  }
  __pyx_L4:;

  /* "cupy/core/core.pyx":1832
 *         dtype = numpy.find_common_type((ret_dtype, 'f'), ()).char
 * 
 *     a = a.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 *     b = b.astype(dtype, copy=False)
 * 
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.copy = Py_False;
  __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->astype(__pyx_v_a, __pyx_v_dtype, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1833
 * 
 *     a = a.astype(dtype, copy=False)
 *     b = b.astype(dtype, copy=False)             # <<<<<<<<<<<<<<
 * 
 *     if not a.size or not b.size:
 */
  __pyx_t_10.__pyx_n = 1;
  __pyx_t_10.copy = Py_False;
  __pyx_t_7 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_b->__pyx_vtab)->astype(__pyx_v_b, __pyx_v_dtype, 0, &__pyx_t_10)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
  __pyx_t_7 = 0;

  /* "cupy/core/core.pyx":1835
 *     b = b.astype(dtype, copy=False)
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 */
  __pyx_t_8 = ((!(__pyx_v_a->size != 0)) != 0);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_2 = __pyx_t_8;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_8 = ((!(__pyx_v_b->size != 0)) != 0);
  __pyx_t_2 = __pyx_t_8;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1836
 * 
 *     if not a.size or not b.size:
 *         if a.size or b.size:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 *         if out is None:
 */
    __pyx_t_8 = (__pyx_v_a->size != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_2 = __pyx_t_8;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_8 = (__pyx_v_b->size != 0);
    __pyx_t_2 = __pyx_t_8;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1837
 *     if not a.size or not b.size:
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cupy/core/core.pyx":1836
 * 
 *     if not a.size or not b.size:
 *         if a.size or b.size:             # <<<<<<<<<<<<<<
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 *         if out is None:
 */
    }

    /* "cupy/core/core.pyx":1838
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 *         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":1839
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)             # <<<<<<<<<<<<<<
 *         out.fill(0)
 *         return out
 */
      __pyx_t_7 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_ret_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __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_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":1838
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 */
    }

    /* "cupy/core/core.pyx":1840
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_out->__pyx_vtab)->fill(__pyx_v_out, __pyx_int_0, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1841
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 *         out.fill(0)
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     if out is None:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __pyx_r = __pyx_v_out;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1835
 *     b = b.astype(dtype, copy=False)
 * 
 *     if not a.size or not b.size:             # <<<<<<<<<<<<<<
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')
 */
  }

  /* "cupy/core/core.pyx":1843
 *         return out
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
  __pyx_t_8 = (((PyObject *)__pyx_v_out) == Py_None);
  __pyx_t_2 = (__pyx_t_8 != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1844
 * 
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 *         if dtype == ret_dtype:
 *             ret = out
 */
    __pyx_t_5 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1845
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1846
 *         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":1845
 *     if out is None:
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:             # <<<<<<<<<<<<<<
 *             ret = out
 *         else:
 */
      goto __pyx_L15;
    }

    /* "cupy/core/core.pyx":1848
 *             ret = out
 *         else:
 *             ret = ndarray(ret_shape, ret_dtype)             # <<<<<<<<<<<<<<
 *     else:
 *         ret = out
 */
    /*else*/ {
      __pyx_t_5 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
      __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_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
      __pyx_t_5 = 0;
    }
    __pyx_L15:;

    /* "cupy/core/core.pyx":1843
 *         return out
 * 
 *     if out is None:             # <<<<<<<<<<<<<<
 *         out = ndarray(ret_shape, dtype)
 *         if dtype == ret_dtype:
 */
    goto __pyx_L14;
  }

  /* "cupy/core/core.pyx":1850
 *             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":1851
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_out->dtype, __pyx_v_dtype, Py_NE)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1852
 *         ret = out
 *         if out.dtype != dtype:
 *             out = ndarray(ret_shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     # It copies the operands if needed
 */
      __pyx_t_5 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_ret_shape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_dtype);
      __Pyx_GIVEREF(__pyx_v_dtype);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_dtype);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF_SET(__pyx_v_out, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/core/core.pyx":1851
 *     else:
 *         ret = out
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             out = ndarray(ret_shape, dtype)
 * 
 */
    }
  }
  __pyx_L14:;

  /* "cupy/core/core.pyx":1855
 * 
 *     # It copies the operands if needed
 *     if a._shape.size() != 2 or a._shape[0] != k or a._shape[1] != n:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_a->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L18_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L18_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_a->_shape[1]) != __pyx_v_n) != 0);
  __pyx_t_8 = __pyx_t_2;
  __pyx_L18_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1856
 *     # 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":1857
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1858
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1859
 *         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_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_filename = __pyx_f[0]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __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":1855
 * 
 *     # 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":1860
 *         shape.push_back(n)
 *         a = a._reshape(shape)
 *     if b._shape.size() != 2 or b._shape[0] != k or b._shape[1] != m:             # <<<<<<<<<<<<<<
 *         shape.clear()
 *         shape.push_back(k)
 */
  __pyx_t_2 = ((__pyx_v_b->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L22_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[0]) != __pyx_v_k) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L22_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_b->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_8 = __pyx_t_2;
  __pyx_L22_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1861
 *         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":1862
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1863
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cupy/core/core.pyx":1864
 *         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_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_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __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":1860
 *         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":1865
 *         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":1866
 *         b = b._reshape(shape)
 *     c = out
 *     if c._shape.size() != 2 or c._shape[0] != n or c._shape[1] != m:             # <<<<<<<<<<<<<<
 *         c = c.view()
 *         c.shape = (n, m)
 */
  __pyx_t_2 = ((__pyx_v_c->_shape.size() != 2) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[0]) != __pyx_v_n) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_8 = __pyx_t_2;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_2 = (((__pyx_v_c->_shape[1]) != __pyx_v_m) != 0);
  __pyx_t_8 = __pyx_t_2;
  __pyx_L26_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1867
 *     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_5 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_c->__pyx_vtab)->view(__pyx_v_c, 0, NULL)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_c, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/core/core.pyx":1868
 *     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_5 = PyInt_FromSsize_t(__pyx_v_n); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_m); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
    __pyx_t_5 = 0;
    __pyx_t_7 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_c), __pyx_n_s_shape, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1866
 *         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":1871
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     if k == 1:             # <<<<<<<<<<<<<<
 *         if n == 1:
 *             # Scalar-vector product
 */
  __pyx_t_8 = ((__pyx_v_k == 1) != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1872
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     if k == 1:
 *         if n == 1:             # <<<<<<<<<<<<<<
 *             # Scalar-vector product
 *             multiply(a, b, c)
 */
    __pyx_t_8 = ((__pyx_v_n == 1) != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1874
 *         if n == 1:
 *             # Scalar-vector product
 *             multiply(a, b, c)             # <<<<<<<<<<<<<<
 *         elif m == 1:
 *             # Scalar-vector product
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_1 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_6, ((PyObject *)__pyx_v_a));
      __Pyx_INCREF(((PyObject *)__pyx_v_b));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_b));
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_6, ((PyObject *)__pyx_v_b));
      __Pyx_INCREF(((PyObject *)__pyx_v_c));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_c));
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_6, ((PyObject *)__pyx_v_c));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1872
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     if k == 1:
 *         if n == 1:             # <<<<<<<<<<<<<<
 *             # Scalar-vector product
 *             multiply(a, b, c)
 */
      goto __pyx_L30;
    }

    /* "cupy/core/core.pyx":1875
 *             # Scalar-vector product
 *             multiply(a, b, c)
 *         elif m == 1:             # <<<<<<<<<<<<<<
 *             # Scalar-vector product
 *             multiply(a.T, b, c)
 */
    __pyx_t_8 = ((__pyx_v_m == 1) != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1877
 *         elif m == 1:
 *             # Scalar-vector product
 *             multiply(a.T, b, c)             # <<<<<<<<<<<<<<
 *         else:
 *             # Outer product A^T * B
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_multiply); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_3 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __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_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_b));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_b));
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, ((PyObject *)__pyx_v_b));
      __Pyx_INCREF(((PyObject *)__pyx_v_c));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_c));
      PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_6, ((PyObject *)__pyx_v_c));
      __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1875
 *             # Scalar-vector product
 *             multiply(a, b, c)
 *         elif m == 1:             # <<<<<<<<<<<<<<
 *             # Scalar-vector product
 *             multiply(a.T, b, c)
 */
      goto __pyx_L30;
    }

    /* "cupy/core/core.pyx":1882
 *             # c is C-contiguous while cuBLAS requires F-contiguous arrays, so
 *             # we compute C^T = B^T * A here.
 *             handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 *             c.fill(0)
 *             a, inca = _to_cublas_vector(a, 1)
 */
    /*else*/ {
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6device_get_cublas_handle(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_handle = __pyx_t_6;

      /* "cupy/core/core.pyx":1883
 *             # we compute C^T = B^T * A here.
 *             handle = device.get_cublas_handle()
 *             c.fill(0)             # <<<<<<<<<<<<<<
 *             a, inca = _to_cublas_vector(a, 1)
 *             b, incb = _to_cublas_vector(b, 1)
 */
      __pyx_t_4 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_c->__pyx_vtab)->fill(__pyx_v_c, __pyx_int_0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1884
 *             handle = device.get_cublas_handle()
 *             c.fill(0)
 *             a, inca = _to_cublas_vector(a, 1)             # <<<<<<<<<<<<<<
 *             b, incb = _to_cublas_vector(b, 1)
 *             if dtype == 'f':
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_a, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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 != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_v_inca = __pyx_t_11;

      /* "cupy/core/core.pyx":1885
 *             c.fill(0)
 *             a, inca = _to_cublas_vector(a, 1)
 *             b, incb = _to_cublas_vector(b, 1)             # <<<<<<<<<<<<<<
 *             if dtype == 'f':
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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 != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __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_3));
      __pyx_t_3 = 0;
      __pyx_v_incb = __pyx_t_11;

      /* "cupy/core/core.pyx":1886
 *             a, inca = _to_cublas_vector(a, 1)
 *             b, incb = _to_cublas_vector(b, 1)
 *             if dtype == 'f':             # <<<<<<<<<<<<<<
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 */
      __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (__pyx_t_8 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1887
 *             b, incb = _to_cublas_vector(b, 1)
 *             if dtype == 'f':
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,             # <<<<<<<<<<<<<<
 *                             inca, c.data.ptr, m)
 *             elif dtype == 'd':
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_sger(__pyx_v_handle, __pyx_v_m, __pyx_v_n, 1.0, __pyx_v_b->data->ptr, __pyx_v_incb, __pyx_v_a->data->ptr, __pyx_v_inca, __pyx_v_c->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":1886
 *             a, inca = _to_cublas_vector(a, 1)
 *             b, incb = _to_cublas_vector(b, 1)
 *             if dtype == 'f':             # <<<<<<<<<<<<<<
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 */
        goto __pyx_L31;
      }

      /* "cupy/core/core.pyx":1889
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 *             elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                 cublas.dger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 */
      __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_2 != 0);
      if (__pyx_t_8) {

        /* "cupy/core/core.pyx":1890
 *                             inca, c.data.ptr, m)
 *             elif dtype == 'd':
 *                 cublas.dger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,             # <<<<<<<<<<<<<<
 *                             inca, c.data.ptr, m)
 *         if dtype != ret_dtype:
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_dger(__pyx_v_handle, __pyx_v_m, __pyx_v_n, 1.0, __pyx_v_b->data->ptr, __pyx_v_incb, __pyx_v_a->data->ptr, __pyx_v_inca, __pyx_v_c->data->ptr, __pyx_v_m, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":1889
 *                 cublas.sger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 *             elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                 cublas.dger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 */
      }
      __pyx_L31:;
    }
    __pyx_L30:;

    /* "cupy/core/core.pyx":1892
 *                 cublas.dger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 *         if dtype != ret_dtype:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_NE)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1893
 *                             inca, c.data.ptr, m)
 *         if dtype != ret_dtype:
 *             elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *         return ret
 * 
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_1 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_out));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
      PyTuple_SET_ITEM(__pyx_t_1, 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_1, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1892
 *                 cublas.dger(handle, m, n, 1, b.data.ptr, incb, a.data.ptr,
 *                             inca, c.data.ptr, m)
 *         if dtype != ret_dtype:             # <<<<<<<<<<<<<<
 *             elementwise_copy(out, ret)
 *         return ret
 */
    }

    /* "cupy/core/core.pyx":1894
 *         if dtype != ret_dtype:
 *             elementwise_copy(out, ret)
 *         return ret             # <<<<<<<<<<<<<<
 * 
 *     handle = device.get_cublas_handle()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1871
 * 
 *     # Be careful that cuBLAS uses the FORTRAN-order matrix representation.
 *     if k == 1:             # <<<<<<<<<<<<<<
 *         if n == 1:
 *             # Scalar-vector product
 */
  }

  /* "cupy/core/core.pyx":1896
 *         return ret
 * 
 *     handle = device.get_cublas_handle()             # <<<<<<<<<<<<<<
 *     if n == 1:
 *         if m == 1:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_6device_get_cublas_handle(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_handle = __pyx_t_6;

  /* "cupy/core/core.pyx":1897
 * 
 *     handle = device.get_cublas_handle()
 *     if n == 1:             # <<<<<<<<<<<<<<
 *         if m == 1:
 *             # Inner product
 */
  __pyx_t_2 = ((__pyx_v_n == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1898
 *     handle = device.get_cublas_handle()
 *     if n == 1:
 *         if m == 1:             # <<<<<<<<<<<<<<
 *             # Inner product
 *             a, inca = _to_cublas_vector(a, 0)
 */
    __pyx_t_2 = ((__pyx_v_m == 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1900
 *         if m == 1:
 *             # Inner product
 *             a, inca = _to_cublas_vector(a, 0)             # <<<<<<<<<<<<<<
 *             b, incb = _to_cublas_vector(b, 0)
 *             mode = cublas.getPointerMode(handle)
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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 != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __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_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_v_inca = __pyx_t_11;

      /* "cupy/core/core.pyx":1901
 *             # Inner product
 *             a, inca = _to_cublas_vector(a, 0)
 *             b, incb = _to_cublas_vector(b, 0)             # <<<<<<<<<<<<<<
 *             mode = cublas.getPointerMode(handle)
 *             cublas.setPointerMode(handle,
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_b, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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 != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __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_1));
      __pyx_t_1 = 0;
      __pyx_v_incb = __pyx_t_11;

      /* "cupy/core/core.pyx":1902
 *             a, inca = _to_cublas_vector(a, 0)
 *             b, incb = _to_cublas_vector(b, 0)
 *             mode = cublas.getPointerMode(handle)             # <<<<<<<<<<<<<<
 *             cublas.setPointerMode(handle,
 *                                   cublas.CUBLAS_POINTER_MODE_DEVICE)
 */
      __pyx_t_11 = __pyx_f_4cupy_4cuda_6cublas_getPointerMode(__pyx_v_handle, 0); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_mode = __pyx_t_11;

      /* "cupy/core/core.pyx":1903
 *             b, incb = _to_cublas_vector(b, 0)
 *             mode = cublas.getPointerMode(handle)
 *             cublas.setPointerMode(handle,             # <<<<<<<<<<<<<<
 *                                   cublas.CUBLAS_POINTER_MODE_DEVICE)
 *             try:
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_setPointerMode(__pyx_v_handle, __pyx_e_4cupy_4cuda_6cublas_CUBLAS_POINTER_MODE_DEVICE, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1905
 *             cublas.setPointerMode(handle,
 *                                   cublas.CUBLAS_POINTER_MODE_DEVICE)
 *             try:             # <<<<<<<<<<<<<<
 *                 if dtype == 'f':
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 */
      /*try:*/ {

        /* "cupy/core/core.pyx":1906
 *                                   cublas.CUBLAS_POINTER_MODE_DEVICE)
 *             try:
 *                 if dtype == 'f':             # <<<<<<<<<<<<<<
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 */
        __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L36_error;}
        __pyx_t_8 = (__pyx_t_2 != 0);
        if (__pyx_t_8) {

          /* "cupy/core/core.pyx":1907
 *             try:
 *                 if dtype == 'f':
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,             # <<<<<<<<<<<<<<
 *                                 c.data.ptr)
 *                 elif dtype == 'd':
 */
          __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_sdot(__pyx_v_handle, __pyx_v_k, __pyx_v_a->data->ptr, __pyx_v_inca, __pyx_v_b->data->ptr, __pyx_v_incb, __pyx_v_c->data->ptr, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L36_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "cupy/core/core.pyx":1906
 *                                   cublas.CUBLAS_POINTER_MODE_DEVICE)
 *             try:
 *                 if dtype == 'f':             # <<<<<<<<<<<<<<
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 */
          goto __pyx_L38;
        }

        /* "cupy/core/core.pyx":1909
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 *                 elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                     cublas.ddot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 */
        __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L36_error;}
        __pyx_t_2 = (__pyx_t_8 != 0);
        if (__pyx_t_2) {

          /* "cupy/core/core.pyx":1910
 *                                 c.data.ptr)
 *                 elif dtype == 'd':
 *                     cublas.ddot(handle, k, a.data.ptr, inca, b.data.ptr, incb,             # <<<<<<<<<<<<<<
 *                                 c.data.ptr)
 *             finally:
 */
          __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_ddot(__pyx_v_handle, __pyx_v_k, __pyx_v_a->data->ptr, __pyx_v_inca, __pyx_v_b->data->ptr, __pyx_v_incb, __pyx_v_c->data->ptr, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L36_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "cupy/core/core.pyx":1909
 *                     cublas.sdot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 *                 elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                     cublas.ddot(handle, k, a.data.ptr, inca, b.data.ptr, incb,
 *                                 c.data.ptr)
 */
        }
        __pyx_L38:;
      }

      /* "cupy/core/core.pyx":1913
 *                                 c.data.ptr)
 *             finally:
 *                 cublas.setPointerMode(handle, mode)             # <<<<<<<<<<<<<<
 *         else:
 *             # Matrix-vector product B^T * A
 */
      /*finally:*/ {
        /*normal exit:*/{
          __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_setPointerMode(__pyx_v_handle, __pyx_v_mode, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L37;
        }
        /*exception exit:*/{
          __pyx_L36_error:;
          __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
          {
            __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_setPointerMode(__pyx_v_handle, __pyx_v_mode, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L40_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          }
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
          __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
          __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
          goto __pyx_L1_error;
          __pyx_L40_error:;
          if (PY_MAJOR_VERSION >= 3) {
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          }
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
          goto __pyx_L1_error;
        }
        __pyx_L37:;
      }

      /* "cupy/core/core.pyx":1898
 *     handle = device.get_cublas_handle()
 *     if n == 1:
 *         if m == 1:             # <<<<<<<<<<<<<<
 *             # Inner product
 *             a, inca = _to_cublas_vector(a, 0)
 */
      goto __pyx_L34;
    }

    /* "cupy/core/core.pyx":1916
 *         else:
 *             # Matrix-vector product B^T * A
 *             a, inca = _to_cublas_vector(a, 0)             # <<<<<<<<<<<<<<
 *             b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *             if transb:
 */
    /*else*/ {
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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 != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __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_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_v_inca = __pyx_t_12;

      /* "cupy/core/core.pyx":1917
 *             # Matrix-vector product B^T * A
 *             a, inca = _to_cublas_vector(a, 0)
 *             b, transb, ldb = _mat_to_cublas_contiguous(b, 1)             # <<<<<<<<<<<<<<
 *             if transb:
 *                 # gemv requires (m, k) as the original matrix dimensions
 */
      __pyx_t_4 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      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_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;
      __pyx_v_transb = __pyx_t_12;
      __pyx_v_ldb = __pyx_t_11;

      /* "cupy/core/core.pyx":1918
 *             a, inca = _to_cublas_vector(a, 0)
 *             b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *             if transb:             # <<<<<<<<<<<<<<
 *                 # gemv requires (m, k) as the original matrix dimensions
 *                 # rather than the transposed dimensions.
 */
      __pyx_t_2 = (__pyx_v_transb != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1921
 *                 # gemv requires (m, k) as the original matrix dimensions
 *                 # rather than the transposed dimensions.
 *                 m, k = k, m             # <<<<<<<<<<<<<<
 *             if dtype == 'f':
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 */
        __pyx_t_6 = __pyx_v_k;
        __pyx_t_20 = __pyx_v_m;
        __pyx_v_m = __pyx_t_6;
        __pyx_v_k = __pyx_t_20;

        /* "cupy/core/core.pyx":1918
 *             a, inca = _to_cublas_vector(a, 0)
 *             b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *             if transb:             # <<<<<<<<<<<<<<
 *                 # gemv requires (m, k) as the original matrix dimensions
 *                 # rather than the transposed dimensions.
 */
      }

      /* "cupy/core/core.pyx":1922
 *                 # rather than the transposed dimensions.
 *                 m, k = k, m
 *             if dtype == 'f':             # <<<<<<<<<<<<<<
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 */
      __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_2 != 0);
      if (__pyx_t_8) {

        /* "cupy/core/core.pyx":1923
 *                 m, k = k, m
 *             if dtype == 'f':
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *             elif dtype == 'd':
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_sgemv(__pyx_v_handle, __pyx_v_transb, __pyx_v_m, __pyx_v_k, 1.0, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_a->data->ptr, __pyx_v_inca, 0.0, __pyx_v_c->data->ptr, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":1922
 *                 # rather than the transposed dimensions.
 *                 m, k = k, m
 *             if dtype == 'f':             # <<<<<<<<<<<<<<
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 */
        goto __pyx_L42;
      }

      /* "cupy/core/core.pyx":1925
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *             elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                 cublas.dgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 */
      __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (__pyx_t_8 != 0);
      if (__pyx_t_2) {

        /* "cupy/core/core.pyx":1926
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *             elif dtype == 'd':
 *                 cublas.dgemv(handle, transb, m, k, 1, b.data.ptr, ldb,             # <<<<<<<<<<<<<<
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *     elif m == 1:
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_dgemv(__pyx_v_handle, __pyx_v_transb, __pyx_v_m, __pyx_v_k, 1.0, __pyx_v_b->data->ptr, __pyx_v_ldb, __pyx_v_a->data->ptr, __pyx_v_inca, 0.0, __pyx_v_c->data->ptr, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/core/core.pyx":1925
 *                 cublas.sgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *             elif dtype == 'd':             # <<<<<<<<<<<<<<
 *                 cublas.dgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 */
      }
      __pyx_L42:;
    }
    __pyx_L34:;

    /* "cupy/core/core.pyx":1897
 * 
 *     handle = device.get_cublas_handle()
 *     if n == 1:             # <<<<<<<<<<<<<<
 *         if m == 1:
 *             # Inner product
 */
    goto __pyx_L33;
  }

  /* "cupy/core/core.pyx":1928
 *                 cublas.dgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *     elif m == 1:             # <<<<<<<<<<<<<<
 *         # Matrix-vector product A^T * B
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)
 */
  __pyx_t_2 = ((__pyx_v_m == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/core/core.pyx":1930
 *     elif m == 1:
 *         # Matrix-vector product A^T * B
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)             # <<<<<<<<<<<<<<
 *         b, incb = _to_cublas_vector(b, 0)
 *         if transa:
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    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_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_a, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_v_transa = __pyx_t_11;
    __pyx_v_lda = __pyx_t_12;

    /* "cupy/core/core.pyx":1931
 *         # Matrix-vector product A^T * B
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)
 *         b, incb = _to_cublas_vector(b, 0)             # <<<<<<<<<<<<<<
 *         if transa:
 *             # gemv requires (n, k) as the original matrix dimensions rather
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__to_cublas_vector(__pyx_v_b, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    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 != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __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_1));
    __pyx_t_1 = 0;
    __pyx_v_incb = __pyx_t_12;

    /* "cupy/core/core.pyx":1932
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)
 *         b, incb = _to_cublas_vector(b, 0)
 *         if transa:             # <<<<<<<<<<<<<<
 *             # gemv requires (n, k) as the original matrix dimensions rather
 *             # than the transposed dimensions.
 */
    __pyx_t_2 = (__pyx_v_transa != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1935
 *             # gemv requires (n, k) as the original matrix dimensions rather
 *             # than the transposed dimensions.
 *             n, k = k, n             # <<<<<<<<<<<<<<
 *         if dtype == 'f':
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 */
      __pyx_t_20 = __pyx_v_k;
      __pyx_t_6 = __pyx_v_n;
      __pyx_v_n = __pyx_t_20;
      __pyx_v_k = __pyx_t_6;

      /* "cupy/core/core.pyx":1932
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)
 *         b, incb = _to_cublas_vector(b, 0)
 *         if transa:             # <<<<<<<<<<<<<<
 *             # gemv requires (n, k) as the original matrix dimensions rather
 *             # than the transposed dimensions.
 */
    }

    /* "cupy/core/core.pyx":1936
 *             # than the transposed dimensions.
 *             n, k = k, n
 *         if dtype == 'f':             # <<<<<<<<<<<<<<
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 */
    __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_f, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1937
 *             n, k = k, n
 *         if dtype == 'f':
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,             # <<<<<<<<<<<<<<
 *                          incb, 0, c.data.ptr, 1)
 *         elif dtype == 'd':
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_sgemv(__pyx_v_handle, __pyx_v_transa, __pyx_v_n, __pyx_v_k, 1.0, __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_b->data->ptr, __pyx_v_incb, 0.0, __pyx_v_c->data->ptr, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1936
 *             # than the transposed dimensions.
 *             n, k = k, n
 *         if dtype == 'f':             # <<<<<<<<<<<<<<
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 */
      goto __pyx_L44;
    }

    /* "cupy/core/core.pyx":1939
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 *         elif dtype == 'd':             # <<<<<<<<<<<<<<
 *             cublas.dgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 */
    __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_n_s_d, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1940
 *                          incb, 0, c.data.ptr, 1)
 *         elif dtype == 'd':
 *             cublas.dgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,             # <<<<<<<<<<<<<<
 *                          incb, 0, c.data.ptr, 1)
 *     else:
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_6cublas_dgemv(__pyx_v_handle, __pyx_v_transa, __pyx_v_n, __pyx_v_k, 1.0, __pyx_v_a->data->ptr, __pyx_v_lda, __pyx_v_b->data->ptr, __pyx_v_incb, 0.0, __pyx_v_c->data->ptr, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1939
 *             cublas.sgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 *         elif dtype == 'd':             # <<<<<<<<<<<<<<
 *             cublas.dgemv(handle, transa, n, k, 1, a.data.ptr, lda, b.data.ptr,
 *                          incb, 0, c.data.ptr, 1)
 */
    }
    __pyx_L44:;

    /* "cupy/core/core.pyx":1928
 *                 cublas.dgemv(handle, transb, m, k, 1, b.data.ptr, ldb,
 *                              a.data.ptr, inca, 0, c.data.ptr, 1)
 *     elif m == 1:             # <<<<<<<<<<<<<<
 *         # Matrix-vector product A^T * B
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 1)
 */
    goto __pyx_L33;
  }

  /* "cupy/core/core.pyx":1946
 *         # 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 dtype == 'f':
 */
  /*else*/ {
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_a, 0, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    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_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __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_3 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_12;
    __pyx_v_lda = __pyx_t_11;

    /* "cupy/core/core.pyx":1947
 *         # 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 dtype == 'f':
 *             cublas.sgemm(handle, transb, transa, m, n, k, 1, b.data.ptr, ldb,
 */
    __pyx_t_4 = __pyx_f_4cupy_4core_4core__mat_to_cublas_contiguous(__pyx_v_b, 1, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    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_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = 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_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_4core_4core_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __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_3));
    __pyx_t_3 = 0;
    __pyx_v_transb = __pyx_t_11;
    __pyx_v_ldb = __pyx_t_12;

    /* "cupy/core/core.pyx":1948
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *         b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *         if 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_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "cupy/core/core.pyx":1949
 *         b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *         if 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_4 = __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_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1948
 *         a, transa, lda = _mat_to_cublas_contiguous(a, 0)
 *         b, transb, ldb = _mat_to_cublas_contiguous(b, 1)
 *         if 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_L45;
    }

    /* "cupy/core/core.pyx":1951
 *             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_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = (__pyx_t_8 != 0);
    if (__pyx_t_2) {

      /* "cupy/core/core.pyx":1952
 *                          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_4 = __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_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/core/core.pyx":1951
 *             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_L45:;
  }
  __pyx_L33:;

  /* "cupy/core/core.pyx":1955
 *                          a.data.ptr, lda, 0, c.data.ptr, m)
 * 
 *     if dtype != ret_dtype:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_dtype, __pyx_v_ret_dtype, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = (__pyx_t_2 != 0);
  if (__pyx_t_8) {

    /* "cupy/core/core.pyx":1956
 * 
 *     if dtype != ret_dtype:
 *         elementwise_copy(out, ret)             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __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_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_out));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_out));
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, ((PyObject *)__pyx_v_out));
    __Pyx_INCREF(((PyObject *)__pyx_v_ret));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_ret));
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, ((PyObject *)__pyx_v_ret));
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/core/core.pyx":1955
 *                          a.data.ptr, lda, 0, c.data.ptr, m)
 * 
 *     if dtype != ret_dtype:             # <<<<<<<<<<<<<<
 *         elementwise_copy(out, ret)
 *     return ret
 */
  }

  /* "cupy/core/core.pyx":1957
 *     if dtype != ret_dtype:
 *         elementwise_copy(out, ret)
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret));
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1815
 * 
 * 
 * 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_67tensordot_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_67tensordot_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tensordot_core") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_m = __Pyx_PyIndex_AsSsize_t(values[4]); if (unlikely((__pyx_v_m == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k = __Pyx_PyIndex_AsSsize_t(values[5]); if (unlikely((__pyx_v_k == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ret_shape = __pyx_convert_vector_from_py_Py_ssize_t(values[6]); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "out", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_66tensordot_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_66tensordot_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1961
 * 
 * @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_69_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_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_mat_to_cublas_contiguous", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "cupy/core/core.pyx":1962
 * @cython.profile(False)
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2             # <<<<<<<<<<<<<<
 *     if a._f_contiguous:
 *         return a, trans, a._strides[1] // a.itemsize
 */
  #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_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "cupy/core/core.pyx":1963
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         return a, trans, a._strides[1] // a.itemsize
 *     if not a._c_contiguous:
 */
  __pyx_t_3 = (__pyx_v_a->_f_contiguous != 0);
  if (__pyx_t_3) {

    /* "cupy/core/core.pyx":1964
 *     assert a.ndim == 2
 *     if a._f_contiguous:
 *         return a, trans, a._strides[1] // a.itemsize             # <<<<<<<<<<<<<<
 *     if not a._c_contiguous:
 *         a = a.copy()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_trans); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_a->_strides[1])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1964; __pyx_clineno = __LINE__; goto __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_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_r = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "cupy/core/core.pyx":1963
 * cpdef inline tuple _mat_to_cublas_contiguous(ndarray a, Py_ssize_t trans):
 *     assert a.ndim == 2
 *     if a._f_contiguous:             # <<<<<<<<<<<<<<
 *         return a, trans, a._strides[1] // a.itemsize
 *     if not a._c_contiguous:
 */
  }

  /* "cupy/core/core.pyx":1965
 *     if a._f_contiguous:
 *         return a, trans, a._strides[1] // a.itemsize
 *     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":1966
 *         return a, trans, a._strides[1] // a.itemsize
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __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":1965
 *     if a._f_contiguous:
 *         return a, trans, a._strides[1] // a.itemsize
 *     if not a._c_contiguous:             # <<<<<<<<<<<<<<
 *         a = a.copy()
 *     return a, 1 - trans, a._strides[0] // a.itemsize
 */
  }

  /* "cupy/core/core.pyx":1967
 *     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_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_a->_strides[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __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 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __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_1);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/core/core.pyx":1961
 * 
 * @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((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4core_4core_69_mat_to_cublas_contiguous(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_69_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_68_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_68_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1971
 * 
 * @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_71_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_to_cublas_vector", 0);

  /* "cupy/core/core.pyx":1972
 * @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":1973
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __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":1972
 * @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":1975
 *         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_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1975; __pyx_clineno = __LINE__; goto __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":1971
 * 
 * @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_71_to_cublas_vector(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_71_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_70_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_70_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":1981
 * # -----------------------------------------------------------------------------
 * 
 * cpdef create_comparison(name, op, doc=''):             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */

static PyObject *__pyx_pw_4cupy_4core_4core_73create_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":1982
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":1983
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":1986
 *         ('??->?', '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_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/core/core.pyx":1982
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __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__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_tuple__81);
  __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":1987
 *          '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_filename = __pyx_f[0]; __pyx_lineno = 1987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_doc, __pyx_v_doc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1982
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __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":1981
 * # -----------------------------------------------------------------------------
 * 
 * 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_73create_comparison(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_73create_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __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_72create_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_72create_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2082
 * 
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_arithmetic", 0);

  /* "cupy/core/core.pyx":2083
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/core/core.pyx":2084
 * 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_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/core/core.pyx":2085
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_kp_s__65);
  __Pyx_GIVEREF(__pyx_kp_s__65);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s__65);
  __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_filename = __pyx_f[0]; __pyx_lineno = 2085; __pyx_clineno = __LINE__; goto __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":2088
 *          '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_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2083
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __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":2089
 *          '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_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_doc, __pyx_v_doc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2083
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __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":2082
 * 
 * 
 * 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":2239
 * # -----------------------------------------------------------------------------
 * 
 * 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_75_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":2240
 * 
 * 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":2241
 * 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":2242
 *                   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_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __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":2241
 * 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":2243
 *     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":2244
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2244; __pyx_clineno = __LINE__; goto __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":2243
 *     if axis is None:
 *         axis = tuple(range(a.ndim))
 *     if not isinstance(axis, tuple):             # <<<<<<<<<<<<<<
 *         axis = (axis,)
 * 
 */
  }

  /* "cupy/core/core.pyx":2246
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/core/core.pyx":2247
 * 
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __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":2246
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __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":2248
 *     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":2246
 *         axis = (axis,)
 * 
 *     if dtype is None and issubclass(a.dtype.type,             # <<<<<<<<<<<<<<
 *                                     (numpy.integer, numpy.bool_)):
 *         dtype = 'd'
 */
  }

  /* "cupy/core/core.pyx":2250
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "cupy/core/core.pyx":2251
 * 
 *     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":2252
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __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":2253
 *     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 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __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":2252
 *     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":2254
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __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":2255
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_arrmean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":2256
 *     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":2257
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2257; __pyx_clineno = __LINE__; goto __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":2256
 *     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":2259
 *         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":2260
 *     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_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cupy/core/core.pyx":2259
 *         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_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __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":2239
 * # -----------------------------------------------------------------------------
 * 
 * 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_75_var(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_75_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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":2240
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4cupy_4core_4core_74_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":2239
 * # -----------------------------------------------------------------------------
 * 
 * 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_74_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 2239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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":2263
 * 
 * 
 * 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_fixed(ret, dtype=dtype, out=out)
 */

static PyObject *__pyx_pw_4cupy_4core_4core_77_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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":2264
 * 
 * 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_fixed(ret, dtype=dtype, out=out)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_var_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ddof, __pyx_v_ddof) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_keepdims, __pyx_v_keepdims) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_ret = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/core/core.pyx":2265
 * 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_fixed(ret, dtype=dtype, out=out)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sqrt_fixed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_v_dtype) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_out, __pyx_v_out) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __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":2263
 * 
 * 
 * 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_fixed(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_77_std(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4cupy_4core_4core_77_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 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_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __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_76_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_76_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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_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;
}

/* "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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __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 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_159__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_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_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[] = {
  {"flags", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_3flags, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_2flags},
  {"strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_5strides, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_4strides},
  {"ndim", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_7ndim, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_6ndim},
  {"itemsize", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_9itemsize, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_8itemsize},
  {"nbytes", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_11nbytes, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_10nbytes},
  {"T", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_13T, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_12T},
  {"cstruct", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_15cstruct, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_14cstruct},
  {"tolist", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_17tolist, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_16tolist},
  {"tofile", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_19tofile, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_18tofile},
  {"dump", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_21dump, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_20dump},
  {"dumps", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_23dumps, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_22dumps},
  {"astype", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_25astype, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_24astype},
  {"copy", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_27copy, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_26copy},
  {"view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_29view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_28view},
  {"fill", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_31fill, METH_O, __pyx_doc_4cupy_4core_4core_7ndarray_30fill},
  {"_reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_33_reshape, METH_O, 0},
  {"reshape", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_35reshape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_34reshape},
  {"_transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_37_transpose, METH_O, 0},
  {"transpose", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_39transpose, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_38transpose},
  {"swapaxes", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_41swapaxes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_40swapaxes},
  {"flatten", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_43flatten, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_42flatten},
  {"ravel", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_45ravel, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_44ravel},
  {"squeeze", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_47squeeze, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_46squeeze},
  {"take", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_49take, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_48take},
  {"repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_51repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_50repeat},
  {"diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_53diagonal, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_52diagonal},
  {"max", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_55max, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_54max},
  {"argmax", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_57argmax, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_56argmax},
  {"min", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_59min, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_58min},
  {"argmin", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_61argmin, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_60argmin},
  {"clip", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_63clip, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_62clip},
  {"trace", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_65trace, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_64trace},
  {"sum", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_67sum, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_66sum},
  {"mean", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_69mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_68mean},
  {"var", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_71var, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_70var},
  {"std", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_73std, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_72std},
  {"prod", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_75prod, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_74prod},
  {"all", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_77all, METH_VARARGS|METH_KEYWORDS, 0},
  {"any", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_79any, METH_VARARGS|METH_KEYWORDS, 0},
  {"__copy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_147__copy__, METH_NOARGS, 0},
  {"__deepcopy__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_149__deepcopy__, METH_O, 0},
  {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_151__reduce__, METH_NOARGS, 0},
  {"__array__", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_153__array__, METH_VARARGS|METH_KEYWORDS, 0},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_175dot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_174dot},
  {"device", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_177device, METH_NOARGS, __pyx_doc_4cupy_4core_4core_7ndarray_176device},
  {"get", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_179get, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_178get},
  {"set", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_181set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_180set},
  {"reduced_view", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_183reduced_view, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_7ndarray_182reduced_view},
  {"_update_c_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_185_update_c_contiguity, METH_NOARGS, 0},
  {"_update_f_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_187_update_f_contiguity, METH_NOARGS, 0},
  {"_update_contiguity", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_189_update_contiguity, METH_NOARGS, 0},
  {"_set_shape_and_strides", (PyCFunction)__pyx_pw_4cupy_4core_4core_7ndarray_191_set_shape_and_strides, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_ndarray[] = {
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7ndarray_shape, __pyx_setprop_4cupy_4core_4core_7ndarray_shape, __pyx_k_Lengths_of_axes_Setter_of_this_p, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7ndarray_size, 0, 0, 0},
  {(char *)"_shape", __pyx_getprop_4cupy_4core_4core_7ndarray__shape, __pyx_setprop_4cupy_4core_4core_7ndarray__shape, 0, 0},
  {(char *)"_strides", __pyx_getprop_4cupy_4core_4core_7ndarray__strides, __pyx_setprop_4cupy_4core_4core_7ndarray__strides, 0, 0},
  {(char *)"_c_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__c_contiguous, 0, 0, 0},
  {(char *)"_f_contiguous", __pyx_getprop_4cupy_4core_4core_7ndarray__f_contiguous, 0, 0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_7ndarray_dtype, 0, 0, 0},
  {(char *)"data", __pyx_getprop_4cupy_4core_4core_7ndarray_data, 0, 0, 0},
  {(char *)"base", __pyx_getprop_4cupy_4core_4core_7ndarray_base, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ndarray = {
  __pyx_pw_4cupy_4core_4core_7ndarray_93__add__, /*nb_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_95__sub__, /*nb_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_97__mul__, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_99__div__, /*nb_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_105__mod__, /*nb_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_107__divmod__, /*nb_divmod*/
  __pyx_pw_4cupy_4core_4core_7ndarray_109__pow__, /*nb_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_85__neg__, /*nb_negative*/
  __pyx_pw_4cupy_4core_4core_7ndarray_87__pos__, /*nb_positive*/
  __pyx_pw_4cupy_4core_4core_7ndarray_89__abs__, /*nb_absolute*/
  __pyx_pw_4cupy_4core_4core_7ndarray_83__nonzero__, /*nb_nonzero*/
  __pyx_pw_4cupy_4core_4core_7ndarray_91__invert__, /*nb_invert*/
  __pyx_pw_4cupy_4core_4core_7ndarray_111__lshift__, /*nb_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_113__rshift__, /*nb_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_115__and__, /*nb_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_119__xor__, /*nb_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_117__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  0, /*nb_coerce*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_161__int__, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  __pyx_pw_4cupy_4core_4core_7ndarray_163__long__, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_165__float__, /*nb_float*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_167__oct__, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_169__hex__, /*nb_hex*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_121__iadd__, /*nb_inplace_add*/
  __pyx_pw_4cupy_4core_4core_7ndarray_123__isub__, /*nb_inplace_subtract*/
  __pyx_pw_4cupy_4core_4core_7ndarray_125__imul__, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3 || CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4cupy_4core_4core_7ndarray_127__idiv__, /*nb_inplace_divide*/
  #endif
  __pyx_pw_4cupy_4core_4core_7ndarray_133__imod__, /*nb_inplace_remainder*/
  __pyx_pw_4cupy_4core_4core_7ndarray_135__ipow__, /*nb_inplace_power*/
  __pyx_pw_4cupy_4core_4core_7ndarray_137__ilshift__, /*nb_inplace_lshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_139__irshift__, /*nb_inplace_rshift*/
  __pyx_pw_4cupy_4core_4core_7ndarray_141__iand__, /*nb_inplace_and*/
  __pyx_pw_4cupy_4core_4core_7ndarray_145__ixor__, /*nb_inplace_xor*/
  __pyx_pw_4cupy_4core_4core_7ndarray_143__ior__, /*nb_inplace_or*/
  __pyx_pw_4cupy_4core_4core_7ndarray_103__floordiv__, /*nb_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_101__truediv__, /*nb_true_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_131__ifloordiv__, /*nb_inplace_floor_divide*/
  __pyx_pw_4cupy_4core_4core_7ndarray_129__itruediv__, /*nb_inplace_true_divide*/
  0, /*nb_index*/
  #if PY_VERSION_HEX >= 0x03050000
  0, /*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_155__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_155__len__, /*mp_length*/
  __pyx_pw_4cupy_4core_4core_7ndarray_157__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_171__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_173__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_81__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_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[] = {
  {"ndim", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_3ndim, METH_NOARGS, 0},
  {"cstruct", (PyCFunction)__pyx_pw_4cupy_4core_4core_7Indexer_5cstruct, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_4core_4core_Indexer[] = {
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_7Indexer_size, __pyx_setprop_4cupy_4core_4core_7Indexer_size, 0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_7Indexer_shape, __pyx_setprop_4cupy_4core_4core_7Indexer_shape, 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, 0, 0},
  {(char *)"dtype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_dtype, 0, 0, 0},
  {(char *)"ctype", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_ctype, 0, 0, 0},
  {(char *)"raw", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_raw, 0, 0, 0},
  {(char *)"is_const", __pyx_getprop_4cupy_4core_4core_13ParameterInfo_is_const, 0, 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, 0, 0},
  {(char *)"out_params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_out_params, 0, 0, 0},
  {(char *)"nin", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nin, 0, 0, 0},
  {(char *)"nout", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nout, 0, 0, 0},
  {(char *)"nargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_nargs, 0, 0, 0},
  {(char *)"params", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_params, 0, 0, 0},
  {(char *)"operation", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_operation, 0, 0, 0},
  {(char *)"name", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_name, 0, 0, 0},
  {(char *)"reduce_dims", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_reduce_dims, 0, 0, 0},
  {(char *)"preamble", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_preamble, 0, 0, 0},
  {(char *)"kwargs", __pyx_getprop_4cupy_4core_4core_17ElementwiseKernel_kwargs, 0, 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            ndims) 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, 0, 0},
  {(char *)"shape", __pyx_getprop_4cupy_4core_4core_9broadcast_shape, 0, 0, 0},
  {(char *)"size", __pyx_getprop_4cupy_4core_4core_9broadcast_size, 0, 0, 0},
  {(char *)"nd", __pyx_getprop_4cupy_4core_4core_9broadcast_nd, 0, 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},
  {"_repeat", (PyCFunction)__pyx_pw_4cupy_4core_4core_57_repeat, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4core_4core_56_repeat},
  {"_create_bit_op", (PyCFunction)__pyx_pw_4cupy_4core_4core_59_create_bit_op, METH_VARARGS|METH_KEYWORDS, 0},
  {"_take", (PyCFunction)__pyx_pw_4cupy_4core_4core_61_take, METH_VARARGS|METH_KEYWORDS, 0},
  {"_diagonal", (PyCFunction)__pyx_pw_4cupy_4core_4core_63_diagonal, METH_VARARGS|METH_KEYWORDS, 0},
  {"dot", (PyCFunction)__pyx_pw_4cupy_4core_4core_65dot, METH_VARARGS|METH_KEYWORDS, 0},
  {"tensordot_core", (PyCFunction)__pyx_pw_4cupy_4core_4core_67tensordot_core, METH_VARARGS|METH_KEYWORDS, 0},
  {"_mat_to_cublas_contiguous", (PyCFunction)__pyx_pw_4cupy_4core_4core_69_mat_to_cublas_contiguous, METH_VARARGS|METH_KEYWORDS, 0},
  {"_to_cublas_vector", (PyCFunction)__pyx_pw_4cupy_4core_4core_71_to_cublas_vector, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_comparison", (PyCFunction)__pyx_pw_4cupy_4core_4core_73create_comparison, METH_VARARGS|METH_KEYWORDS, 0},
  {"_var", (PyCFunction)__pyx_pw_4cupy_4core_4core_75_var, METH_VARARGS|METH_KEYWORDS, 0},
  {"_std", (PyCFunction)__pyx_pw_4cupy_4core_4core_77_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_Advanced_indexing_is_not_support, __pyx_k_Advanced_indexing_is_not_support, sizeof(__pyx_k_Advanced_indexing_is_not_support), 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_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_squeeze_dimension_of_size, __pyx_k_Cannot_squeeze_dimension_of_size, sizeof(__pyx_k_Cannot_squeeze_dimension_of_size), 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_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_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_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_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_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_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_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
  {&__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__108, __pyx_k__108, sizeof(__pyx_k__108), 0, 0, 1, 1},
  {&__pyx_kp_s__127, __pyx_k__127, sizeof(__pyx_k__127), 0, 0, 1, 0},
  {&__pyx_kp_s__142, __pyx_k__142, sizeof(__pyx_k__142), 0, 0, 1, 0},
  {&__pyx_kp_s__143, __pyx_k__143, sizeof(__pyx_k__143), 0, 0, 1, 0},
  {&__pyx_kp_s__144, __pyx_k__144, sizeof(__pyx_k__144), 0, 0, 1, 0},
  {&__pyx_kp_s__148, __pyx_k__148, sizeof(__pyx_k__148), 0, 0, 1, 0},
  {&__pyx_kp_s__149, __pyx_k__149, sizeof(__pyx_k__149), 0, 0, 1, 0},
  {&__pyx_kp_s__152, __pyx_k__152, sizeof(__pyx_k__152), 0, 0, 1, 0},
  {&__pyx_kp_s__153, __pyx_k__153, sizeof(__pyx_k__153), 0, 0, 1, 0},
  {&__pyx_kp_s__154, __pyx_k__154, sizeof(__pyx_k__154), 0, 0, 1, 0},
  {&__pyx_kp_s__155, __pyx_k__155, sizeof(__pyx_k__155), 0, 0, 1, 0},
  {&__pyx_kp_s__156, __pyx_k__156, sizeof(__pyx_k__156), 0, 0, 1, 0},
  {&__pyx_kp_s__157, __pyx_k__157, sizeof(__pyx_k__157), 0, 0, 1, 0},
  {&__pyx_kp_s__169, __pyx_k__169, sizeof(__pyx_k__169), 0, 0, 1, 0},
  {&__pyx_kp_s__173, __pyx_k__173, sizeof(__pyx_k__173), 0, 0, 1, 0},
  {&__pyx_kp_s__184, __pyx_k__184, sizeof(__pyx_k__184), 0, 0, 1, 0},
  {&__pyx_kp_s__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 0, 1, 0},
  {&__pyx_kp_s__20, __pyx_k__20, sizeof(__pyx_k__20), 0, 0, 1, 0},
  {&__pyx_kp_s__206, __pyx_k__206, sizeof(__pyx_k__206), 0, 0, 1, 0},
  {&__pyx_kp_s__30, __pyx_k__30, sizeof(__pyx_k__30), 0, 0, 1, 0},
  {&__pyx_kp_s__39, __pyx_k__39, sizeof(__pyx_k__39), 0, 0, 1, 0},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_kp_s__65, __pyx_k__65, sizeof(__pyx_k__65), 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_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_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_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_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_size, __pyx_k_block_size, sizeof(__pyx_k_block_size), 0, 0, 1, 1},
  {&__pyx_n_s_block_stride, __pyx_k_block_stride, sizeof(__pyx_k_block_stride), 0, 0, 1, 1},
  {&__pyx_n_s_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 0, 1, 1},
  {&__pyx_n_s_bool_2, __pyx_k_bool_2, sizeof(__pyx_k_bool_2), 0, 0, 1, 1},
  {&__pyx_n_s_broad, __pyx_k_broad, sizeof(__pyx_k_broad), 0, 0, 1, 1},
  {&__pyx_n_s_broad_shape, __pyx_k_broad_shape, sizeof(__pyx_k_broad_shape), 0, 0, 1, 1},
  {&__pyx_n_s_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_dot_zero_sized_and_non_ze, __pyx_k_cannot_dot_zero_sized_and_non_ze, sizeof(__pyx_k_cannot_dot_zero_sized_and_non_ze), 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_cstruct, __pyx_k_cstruct, sizeof(__pyx_k_cstruct), 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_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_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_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_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_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_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_e, __pyx_k_e, sizeof(__pyx_k_e), 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_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_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_chainer_cupy_core_c, __pyx_k_home_beam2d_chainer_cupy_core_c, sizeof(__pyx_k_home_beam2d_chainer_cupy_core_c), 0, 0, 1, 0},
  {&__pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_k_home_beam2d_chainer_cupy_core_e, sizeof(__pyx_k_home_beam2d_chainer_cupy_core_e), 0, 0, 1, 0},
  {&__pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_k_home_beam2d_chainer_cupy_core_r, sizeof(__pyx_k_home_beam2d_chainer_cupy_core_r), 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_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_kp_s_incompatible_shape, __pyx_k_incompatible_shape, sizeof(__pyx_k_incompatible_shape), 0, 0, 1, 0},
  {&__pyx_n_s_indexer, __pyx_k_indexer, sizeof(__pyx_k_indexer), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_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_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
  {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_kp_s_int32__block_stride, __pyx_k_int32__block_stride, sizeof(__pyx_k_int32__block_stride), 0, 0, 1, 0},
  {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1},
  {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1},
  {&__pyx_kp_s_int_li_i_rdim_cdim_int_ri_i_rdi, __pyx_k_int_li_i_rdim_cdim_int_ri_i_rdi, sizeof(__pyx_k_int_li_i_rdim_cdim_int_ri_i_rdi), 0, 0, 1, 0},
  {&__pyx_n_s_integer, __pyx_k_integer, sizeof(__pyx_k_integer), 0, 0, 1, 1},
  {&__pyx_n_s_integer_types, __pyx_k_integer_types, sizeof(__pyx_k_integer_types), 0, 0, 1, 1},
  {&__pyx_n_s_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_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_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_n_s_min_max_st, __pyx_k_min_max_st, sizeof(__pyx_k_min_max_st), 0, 0, 1, 1},
  {&__pyx_kp_s_min_max_st_in0, __pyx_k_min_max_st_in0, sizeof(__pyx_k_min_max_st_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_min_max_st_in0__J, __pyx_k_min_max_st_in0__J, sizeof(__pyx_k_min_max_st_in0__J), 0, 0, 1, 0},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 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_argmin_a_b, __pyx_k_my_argmin_a_b, sizeof(__pyx_k_my_argmin_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_min_a_b, __pyx_k_my_min_a_b, sizeof(__pyx_k_my_min_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_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_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_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_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_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_min_in2_max_in1_in0, __pyx_k_out0_min_in2_max_in1_in0, sizeof(__pyx_k_out0_min_in2_max_in1_in0), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_out0_type_in0_out0_type_in1, __pyx_k_out0_out0_type_in0_out0_type_in1, sizeof(__pyx_k_out0_out0_type_in0_out0_type_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_pow_in0_in1, __pyx_k_out0_pow_in0_in1, sizeof(__pyx_k_out0_pow_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_powf_in0_in1, __pyx_k_out0_powf_in0_in1, sizeof(__pyx_k_out0_powf_in0_in1), 0, 0, 1, 0},
  {&__pyx_kp_s_out0_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_a_indices_rdim_i_rdim, __pyx_k_out_a_indices_rdim_i_rdim, sizeof(__pyx_k_out_a_indices_rdim_i_rdim), 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, __pyx_k_raw_T_a_S_indices_int32_rdim, sizeof(__pyx_k_raw_T_a_S_indices_int32_rdim), 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_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_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_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_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_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 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_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_fixed, __pyx_k_sqrt_fixed, sizeof(__pyx_k_sqrt_fixed), 0, 0, 1, 1},
  {&__pyx_n_s_squeeze, __pyx_k_squeeze, sizeof(__pyx_k_squeeze), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 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_kp_s_struct_min_max_st_type_in0_raw, __pyx_k_struct_min_max_st_type_in0_raw, sizeof(__pyx_k_struct_min_max_st_type_in0_raw), 0, 0, 1, 0},
  {&__pyx_n_s_substitute, __pyx_k_substitute, sizeof(__pyx_k_substitute), 0, 0, 1, 1},
  {&__pyx_n_s_subtract, __pyx_k_subtract, sizeof(__pyx_k_subtract), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_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_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_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_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_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_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_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_oct = __Pyx_GetBuiltinName(__pyx_n_s_oct); if (!__pyx_builtin_oct) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1559; __pyx_clineno = __LINE__; goto __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":80
 *         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_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "cupy/core/core.pyx":413
 *             axis = <Py_ssize_t?>axes[i]
 *             if axis < -ndim or axis >= ndim:
 *                 raise IndexError('Axes overrun')             # <<<<<<<<<<<<<<
 *             axes[i] = axis % ndim
 * 
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Axes_overrun); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/core/core.pyx":467
 *         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__6 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "cupy/core/core.pyx":539
 *             if j < vec_axis.size() and i == vec_axis[j]:
 *                 if n != 1:
 *                     raise RuntimeError('Cannot squeeze dimension of size > 1')             # <<<<<<<<<<<<<<
 *                 j += 1
 *             else:
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Cannot_squeeze_dimension_of_size); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/core/core.pyx":933
 *     def __len__(self):
 *         if self._shape.size() == 0:
 *             raise TypeError('len() of unsized object')             # <<<<<<<<<<<<<<
 *         return self._shape[0]
 * 
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_len_of_unsized_object); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/core/core.pyx":949
 *         for s in slices:
 *             if isinstance(s, ndarray):
 *                 raise ValueError('Advanced indexing is not supported')             # <<<<<<<<<<<<<<
 * 
 *         # Expand ellipsis into empty slices
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Advanced_indexing_is_not_support); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/core/core.pyx":961
 *                 ellipsis = i
 *         ndim = self._shape.size()
 *         noneslices = [slice(None)]             # <<<<<<<<<<<<<<
 *         if n_ellipses > 0:
 *             if n_ellipses > 1:
 */
  __pyx_slice__10 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);

  /* "cupy/core/core.pyx":964
 *         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__11 = PyTuple_Pack(1, __pyx_kp_s_Only_one_Ellipsis_is_allowed_in); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/core/core.pyx":1113
 *         """
 *         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__12 = PyTuple_Pack(1, __pyx_kp_s_Only_numpy_ndarray_can_be_set_to); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/core/core.pyx":1118
 *                 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__13 = PyTuple_Pack(1, __pyx_kp_s_Shape_mismatch); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/core/core.pyx":1120
 *             raise ValueError('Shape mismatch')
 *         if not self._c_contiguous:
 *             raise RuntimeError('Cannot set to non-contiguous array')             # <<<<<<<<<<<<<<
 * 
 *         arr = numpy.ascontiguousarray(arr)
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Cannot_set_to_non_contiguous_arr); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cupy/core/core.pyx":1187
 *                                  bint update_c_contiguity=True):
 *         if shape.size() != strides.size():
 *             raise ValueError('len(shape) != len(strides)')             # <<<<<<<<<<<<<<
 *         self._shape = shape
 *         self._strides = strides
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_len_shape_len_strides); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "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__16 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "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__17 = PyTuple_Pack(1, __pyx_kp_s_preamble_extern_C___global___vo); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "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__18 = PyTuple_Pack(1, __pyx_kp_s_dtype_is_None); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "cupy/core/elementwise.pxi":259
 *     if len(s) == 0:
 *         return ()
 *     return tuple([ParameterInfo(i, is_const) for i in s.strip().split(',')])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s__20); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "cupy/core/elementwise.pxi":269
 *         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__22 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_must_be_cupy_nd); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "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'.")
 *     else:
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Specified_size_can_be_used_only); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "cupy/core/elementwise.pxi":333
 *     else:
 *         if not is_not_none:
 *             raise ValueError('Loop size is Undecided')             # <<<<<<<<<<<<<<
 *     brod = broadcast(*value)
 *     value = []
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Loop_size_is_Undecided); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "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')
 *         if a.shape != out_shape:
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cupy/core/elementwise.pxi":354
 *                 '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__26 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/core/elementwise.pxi":373
 *         for p in out_params:
 *             if p.raw:
 *                 raise ValueError('Output array size is Undecided')             # <<<<<<<<<<<<<<
 *         return [ndarray(out_shape, t) for t in out_types]
 * 
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_Output_array_size_is_Undecided); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cupy/core/elementwise.pxi":380
 *         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__28 = PyTuple_Pack(1, __pyx_kp_s_Output_arguments_type_must_be_cu); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cupy/core/elementwise.pxi":383
 *                 '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__29 = PyTuple_Pack(1, __pyx_kp_s_Out_shape_is_mismatched); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cupy/core/elementwise.pxi":466
 *         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__31 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cupy/core/elementwise.pxi":475
 *         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__32 = PyTuple_Pack(1, __pyx_kp_s_Can_not_use_i_as_a_parameter_nam); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cupy/core/elementwise.pxi":499
 *         cdef function.Function kern
 * 
 *         size = kwargs.pop('size', None)             # <<<<<<<<<<<<<<
 *         if kwargs:
 *             raise TypeError('Wrong arguments %s' % kwargs)
 */
  __pyx_tuple__33 = PyTuple_Pack(2, __pyx_n_s_size, Py_None); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "cupy/core/elementwise.pxi":676
 *             for i in range(nout))
 *         self._params = _in_params + _out_params + (
 *             ParameterInfo('CIndexer _ind', False),)             # <<<<<<<<<<<<<<
 *         self._routine_cache = {}
 * 
 */
  __pyx_tuple__34 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__ind, Py_False); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "cupy/core/elementwise.pxi":715
 *         cdef function.Function kern
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavie of casting is 'same_kind' on numpy>=1.10
 */
  __pyx_tuple__35 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "cupy/core/elementwise.pxi":716
 * 
 *         out = kwargs.pop('out', None)
 *         dtype = kwargs.pop('dtype', None)             # <<<<<<<<<<<<<<
 *         # Note default behavie of casting is 'same_kind' on numpy>=1.10
 *         casting = kwargs.pop('casting', 'same_kind')
 */
  __pyx_tuple__36 = PyTuple_Pack(2, __pyx_n_s_dtype, Py_None); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "cupy/core/elementwise.pxi":718
 *         dtype = kwargs.pop('dtype', None)
 *         # Note default behavie 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__37 = PyTuple_Pack(2, __pyx_n_s_casting, __pyx_n_s_same_kind); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "cupy/core/elementwise.pxi":736
 *                 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__38 = PyTuple_Pack(1, __pyx_kp_s_Cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "cupy/core/elementwise.pxi":785
 *             typ, rt = t
 * 
 *         types = typ.split('->')             # <<<<<<<<<<<<<<
 *         if len(types) == 1:
 *             in_types = out_types = tuple(types)
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s__39); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "cupy/core/reduction.pxi":19
 *     if identity is None:
 *         identity = ''
 *     module_code = string.Template('''             # <<<<<<<<<<<<<<
 *     ${type_preamble}
 *     ${preamble}
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_type_preamble_preamble_define_R); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "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__42 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "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__43 = PyTuple_Pack(1, __pyx_kp_s_Illegal_conditions); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "cupy/core/reduction.pxi":196
 *         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__44 = PyTuple_Pack(2, __pyx_kp_s_T_in0, Py_True); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "cupy/core/reduction.pxi":197
 *         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__45 = PyTuple_Pack(2, __pyx_kp_s_T_out0, Py_False); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "cupy/core/reduction.pxi":200
 *         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__46 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "cupy/core/reduction.pxi":202
 *             _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__47 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "cupy/core/reduction.pxi":209
 *     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__48 = PyTuple_Pack(1, __pyx_kp_s_Input_type_must_be_cupy_ndarray); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "cupy/core/reduction.pxi":336
 *         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__49 = PyTuple_Pack(2, __pyx_kp_s_CIndexer__in_ind_CIndexer__out_i, Py_False); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "cupy/core/reduction.pxi":337
 *             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__50 = PyTuple_Pack(2, __pyx_kp_s_int32__block_stride, Py_True); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "cupy/core/reduction.pxi":368
 *         """
 * 
 *         out = kwargs.pop('out', None)             # <<<<<<<<<<<<<<
 *         axis = kwargs.pop('axis', None)
 *         keepdims = kwargs.pop('keepdims', False)
 */
  __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_out, Py_None); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "cupy/core/reduction.pxi":369
 * 
 *         out = kwargs.pop('out', None)
 *         axis = kwargs.pop('axis', None)             # <<<<<<<<<<<<<<
 *         keepdims = kwargs.pop('keepdims', False)
 *         if kwargs:
 */
  __pyx_tuple__52 = PyTuple_Pack(2, __pyx_n_s_axis, Py_None); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "cupy/core/reduction.pxi":370
 *         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__53 = PyTuple_Pack(2, __pyx_n_s_keepdims, Py_False); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "cupy/core/reduction.pxi":381
 *         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__54 = PyTuple_Pack(1, __pyx_kp_s__4); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "cupy/core/reduction.pxi":383
 *                 raise NotImplementedError('')
 *             if len(out_args) != 0:
 *                 raise ValueError("cannot specify 'out' as both "             # <<<<<<<<<<<<<<
 *                                  "a positional and keyword argument")
 *             out_args = [out]
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_cannot_specify_out_as_both_a_pos); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "cupy/core/reduction.pxi":457
 *             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__56 = PyTuple_Pack(1, __pyx_kp_s__39); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "cupy/core/core.pyx":1375
 *         ndim = a._shape.size()
 *         if ndmin > ndim:
 *             a.shape = (1,) * (ndmin - ndim) + a.shape             # <<<<<<<<<<<<<<
 *         return a
 *     else:
 */
  __pyx_tuple__57 = PyTuple_New(1); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__57, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "cupy/core/core.pyx":1416
 *         start += ndim
 *     if not (0 <= axis < ndim and 0 <= start <= ndim):
 *         raise ValueError('Axis out of range')             # <<<<<<<<<<<<<<
 *     if axis < start:
 *         start -= 1
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_Axis_out_of_range); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "cupy/core/core.pyx":1461
 *         cdef vector.vector[vector.vector[Py_ssize_t]] shape_arr
 *         cdef ndarray a, view
 *         rev = slice(None, None, -1)             # <<<<<<<<<<<<<<
 * 
 *         self.nd = 0
 */
  __pyx_slice__59 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__59);
  __Pyx_GIVEREF(__pyx_slice__59);

  /* "cupy/core/core.pyx":1502
 *                     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__60 = PyTuple_Pack(1, __pyx_kp_s_Broadcasting_failed); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "cupy/core/core.pyx":1531
 *                 "'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__61 = PyTuple_Pack(2, __pyx_int_neg_1, __pyx_int_1); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_tuple__61); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "cupy/core/core.pyx":1545
 *                     .format(repeats))
 *         if axis is None:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "'axis' should be specified if 'repeats' is sequence")
 *         if a.shape[axis] != len(repeats):
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_axis_should_be_specified_if_rep); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "cupy/core/core.pyx":1561
 *     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__64 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__64);
  __Pyx_GIVEREF(__pyx_slice__64);

  /* "cupy/core/core.pyx":1579
 * 
 * cpdef _create_bit_op(name, op, no_bool, doc=''):
 *     types = () if no_bool else ('??->?',)             # <<<<<<<<<<<<<<
 *     return create_ufunc(
 *         'cupy_' + name,
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s__65); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "cupy/core/core.pyx":1582
 *     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__67 = 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__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "cupy/core/core.pyx":1688
 *     else:
 *         if axis >= a.ndim:
 *             raise ValueError('Axis overrun')             # <<<<<<<<<<<<<<
 *         lshape = a.shape[:axis]
 *         rshape = a.shape[axis + 1:]
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_Axis_overrun); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "cupy/core/core.pyx":1699
 *             return a[indices].copy()
 *         else:
 *             out[:] = a[indices]             # <<<<<<<<<<<<<<
 *             return out
 *     elif not isinstance(indices, ndarray):
 */
  __pyx_slice__69 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__69);
  __Pyx_GIVEREF(__pyx_slice__69);

  /* "cupy/core/core.pyx":1709
 *     else:
 *         if out.dtype != a.dtype:
 *             raise TypeError('Output dtype mismatch')             # <<<<<<<<<<<<<<
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_Output_dtype_mismatch); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "cupy/core/core.pyx":1711
 *             raise TypeError('Output dtype mismatch')
 *         if out.shape != out_shape:
 *             raise ValueError('Output shape mismatch')             # <<<<<<<<<<<<<<
 * 
 *     cdim = indices.size
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_Output_shape_mismatch); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "cupy/core/core.pyx":1716
 *     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(a.reduced_view(), indices, rdim, out)
 */
  __pyx_tuple__72 = PyTuple_New(1); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__72, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__72);
  __pyx_tuple__73 = PyTuple_New(1); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_tuple__73, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "cupy/core/core.pyx":1740
 * 
 *     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__74 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__74);
  __Pyx_GIVEREF(__pyx_slice__74);

  /* "cupy/core/core.pyx":1748
 *     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__75 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__75);
  __Pyx_GIVEREF(__pyx_slice__75);

  /* "cupy/core/core.pyx":1749
 *     ret._set_shape_and_strides(
 *         a.shape[:-2] + (diag_size,),
 *         a.strides[:-2] + (a.strides[-1] + a.strides[-2],))             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  __pyx_slice__76 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__76);
  __Pyx_GIVEREF(__pyx_slice__76);

  /* "cupy/core/core.pyx":1785
 * 
 *     if a._shape[a_axis] != b._shape[b_axis]:
 *         raise ValueError('Axis dimension mismatch')             # <<<<<<<<<<<<<<
 * 
 *     if a_axis:
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_s_Axis_dimension_mismatch); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "cupy/core/core.pyx":1808
 *     else:
 *         if 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__78 = PyTuple_Pack(1, __pyx_kp_s_Output_array_has_an_invalid_size); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "cupy/core/core.pyx":1810
 *             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__79 = PyTuple_Pack(1, __pyx_kp_s_Output_array_must_be_C_contiguou); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "cupy/core/core.pyx":1837
 *     if not a.size or not b.size:
 *         if a.size or b.size:
 *             raise ValueError('cannot dot zero-sized and non-zero-sized arrays')             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out = ndarray(ret_shape, dtype=ret_dtype)
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_s_cannot_dot_zero_sized_and_non_ze); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "cupy/core/core.pyx":1984
 *     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__81 = PyTuple_Pack(14, __pyx_kp_s__65, __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__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);

  /* "cupy/core/core.pyx":1040
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_tuple__82 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);

  /* "cupy/core/elementwise.pxi":37
 * 
 * cdef dict _typenames_base = {
 *     numpy.dtype('float64'): 'double',             # <<<<<<<<<<<<<<
 *     numpy.dtype('float32'): 'float',
 *     numpy.dtype('float16'): 'float16',
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_n_s_float64); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "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__84 = PyTuple_Pack(1, __pyx_n_s_float32); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);

  /* "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__85 = PyTuple_Pack(1, __pyx_n_s_float16); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);

  /* "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__86 = PyTuple_Pack(1, __pyx_n_s_int64); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "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__87 = PyTuple_Pack(1, __pyx_n_s_int32); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);

  /* "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__88 = PyTuple_Pack(1, __pyx_n_s_int16); if (unlikely(!__pyx_tuple__88)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);

  /* "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__89 = PyTuple_Pack(1, __pyx_n_s_int8); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);

  /* "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__90 = PyTuple_Pack(1, __pyx_n_s_uint64); if (unlikely(!__pyx_tuple__90)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);

  /* "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__91 = PyTuple_Pack(1, __pyx_n_s_uint32); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);

  /* "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__92 = PyTuple_Pack(1, __pyx_n_s_uint16); if (unlikely(!__pyx_tuple__92)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);

  /* "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__93 = PyTuple_Pack(1, __pyx_n_s_uint8); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_tuple__94 = PyTuple_Pack(1, __pyx_n_s_bool_2); if (unlikely(!__pyx_tuple__94)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);

  /* "cupy/core/elementwise.pxi":256
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_tuple__95 = PyTuple_Pack(3, __pyx_n_s_s_2, __pyx_n_s_is_const, __pyx_n_s_i); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_get_param_info, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":263
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_tuple__97 = 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__97)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);
  __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(4, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_decide_params_type, 263, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":388
 * 
 * @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__99 = 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__99)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);
  __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(7, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_get_elementwise_kernel, 388, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":553
 * 
 * @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__101 = 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__101)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);
  __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(7, 0, 13, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_get_ufunc_kernel, 553, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":661
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
  __pyx_tuple__103 = 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__103)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);
  __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(7, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_init, 661, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__105 = PyTuple_Pack(2, ((PyObject*)__pyx_kp_s__4), ((PyObject*)__pyx_kp_s__4)); if (unlikely(!__pyx_tuple__105)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);

  /* "cupy/core/elementwise.pxi":679
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_tuple__106 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__106)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_repr, 679, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":683
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_tuple__109 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_types, __pyx_n_s_in_types, __pyx_n_s_out_types, __pyx_n_s__108, __pyx_n_s_in_str, __pyx_n_s_out_str, __pyx_n_s_t); if (unlikely(!__pyx_tuple__109)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);
  __pyx_codeobj__110 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_types, 683, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__110)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/elementwise.pxi":697
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_tuple__111 = 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__111)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);
  __pyx_codeobj__112 = (PyObject*)__Pyx_PyCode_New(1, 0, 22, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__111, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_e, __pyx_n_s_call, 697, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__112)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __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__113 = 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__113)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);
  __pyx_codeobj__114 = (PyObject*)__Pyx_PyCode_New(13, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__113, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_get_simple_reduction_function, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__114)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":189
 * class simple_reduction_function(object):
 * 
 *     def __init__(self, name, ops, identity, preamble):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self._ops = ops
 */
  __pyx_tuple__115 = 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__115)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);
  __pyx_codeobj__116 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__115, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_init, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__116)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":207
 *         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__117 = 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__117)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);
  __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(6, 0, 23, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_call, 207, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__119 = PyTuple_Pack(4, ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_None), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__119)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);

  /* "cupy/core/reduction.pxi":271
 * 
 * @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__120 = 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__120)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);
  __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(12, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_get_reduction_kernel, 271, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/reduction.pxi":325
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_tuple__122 = 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__122)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);
  __pyx_codeobj__123 = (PyObject*)__Pyx_PyCode_New(12, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_init, 325, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__123)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__124 = 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__124)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);

  /* "cupy/core/reduction.pxi":351
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_tuple__125 = 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__125)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);
  __pyx_codeobj__126 = (PyObject*)__Pyx_PyCode_New(1, 0, 30, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__125, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_r, __pyx_n_s_call, 351, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__126)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1250
 * _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__128 = PyTuple_Pack(14, __pyx_kp_s__127, __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__128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);

  /* "cupy/core/core.pyx":1255
 * 
 * 
 * def elementwise_copy(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy(*args, **kwargs)
 */
  __pyx_tuple__129 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__129);
  __Pyx_GIVEREF(__pyx_tuple__129);
  __pyx_codeobj__130 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__129, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_c, __pyx_n_s_elementwise_copy, 1255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__130)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1262
 * _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__131 = PyTuple_Pack(14, __pyx_kp_s__65, __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__131)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__131);
  __Pyx_GIVEREF(__pyx_tuple__131);

  /* "cupy/core/core.pyx":1267
 * 
 * 
 * def elementwise_copy_where(*args, **kwargs):             # <<<<<<<<<<<<<<
 *     kwargs['casting'] = 'unsafe'
 *     return _elementwise_copy_where(*args, **kwargs)
 */
  __pyx_tuple__132 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__132)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_beam2d_chainer_cupy_core_c, __pyx_n_s_elementwise_copy_where_2, 1267, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1330
 * 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', 'f->f', 'd->d'),
 *     ('min_max_st(in0)', 'my_min(a, b)', 'out0 = a.value', 'min_max_st'),
 */
  __pyx_tuple__134 = PyTuple_Pack(14, __pyx_kp_s__127, __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__134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);

  /* "cupy/core/core.pyx":1332
 *     ('?->?', '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(in0)', 'my_min(a, b)', 'out0 = a.value', 'min_max_st'),             # <<<<<<<<<<<<<<
 *     None, _min_max_preamble)
 * 
 */
  __pyx_tuple__135 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_in0, __pyx_kp_s_my_min_a_b, __pyx_kp_s_out0_a_value, __pyx_n_s_min_max_st); if (unlikely(!__pyx_tuple__135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__135);
  __Pyx_GIVEREF(__pyx_tuple__135);

  /* "cupy/core/core.pyx":1338
 * 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', 'f->f', 'd->d'),
 *     ('min_max_st(in0)', 'my_max(a, b)', 'out0 = a.value', 'min_max_st'),
 */
  __pyx_tuple__136 = PyTuple_Pack(14, __pyx_kp_s__127, __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__136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);

  /* "cupy/core/core.pyx":1340
 *     ('?->?', '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(in0)', 'my_max(a, b)', 'out0 = a.value', 'min_max_st'),             # <<<<<<<<<<<<<<
 *     None, _min_max_preamble)
 * 
 */
  __pyx_tuple__137 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_in0, __pyx_kp_s_my_max_a_b, __pyx_kp_s_out0_a_value, __pyx_n_s_min_max_st); if (unlikely(!__pyx_tuple__137)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__137);
  __Pyx_GIVEREF(__pyx_tuple__137);

  /* "cupy/core/core.pyx":1346
 * 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', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index', 'min_max_st'),
 */
  __pyx_tuple__138 = 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_kp_s_e_l, __pyx_kp_s_f_l, __pyx_kp_s_d_l); if (unlikely(!__pyx_tuple__138)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);

  /* "cupy/core/core.pyx":1348
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 *      'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index', 'min_max_st'),             # <<<<<<<<<<<<<<
 *     None, _min_max_preamble)
 * 
 */
  __pyx_tuple__139 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_in0__J, __pyx_kp_s_my_argmin_a_b, __pyx_kp_s_out0_a_index, __pyx_n_s_min_max_st); if (unlikely(!__pyx_tuple__139)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__139);
  __Pyx_GIVEREF(__pyx_tuple__139);

  /* "cupy/core/core.pyx":1354
 * 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', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index', 'min_max_st'),
 */
  __pyx_tuple__140 = 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_kp_s_e_l, __pyx_kp_s_f_l, __pyx_kp_s_d_l); if (unlikely(!__pyx_tuple__140)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_GIVEREF(__pyx_tuple__140);

  /* "cupy/core/core.pyx":1356
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 *      'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index', 'min_max_st'),             # <<<<<<<<<<<<<<
 *     None, _min_max_preamble)
 * 
 */
  __pyx_tuple__141 = PyTuple_Pack(4, __pyx_kp_s_min_max_st_in0__J, __pyx_kp_s_my_argmax_a_b, __pyx_kp_s_out0_a_index, __pyx_n_s_min_max_st); if (unlikely(!__pyx_tuple__141)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__141);
  __Pyx_GIVEREF(__pyx_tuple__141);

  /* "cupy/core/core.pyx":1623
 * 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__145 = PyTuple_Pack(2, __pyx_kp_s__127, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__145)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__145);
  __Pyx_GIVEREF(__pyx_tuple__145);
  __pyx_tuple__146 = PyTuple_Pack(11, __pyx_tuple__145, __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__146)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__146);
  __Pyx_GIVEREF(__pyx_tuple__146);

  /* "cupy/core/core.pyx":1621
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_tuple__147 = PyTuple_Pack(3, __pyx_n_s_cupy_invert, __pyx_tuple__146, __pyx_kp_s_out0_in0_3); if (unlikely(!__pyx_tuple__147)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__147);
  __Pyx_GIVEREF(__pyx_tuple__147);

  /* "cupy/core/core.pyx":1660
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'T out',
 */
  __pyx_tuple__150 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_cdim_int, __pyx_kp_s_T_out, __pyx_kp_s_int_li_i_rdim_cdim_int_ri_i_rdi, __pyx_n_s_cupy_take); if (unlikely(!__pyx_tuple__150)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__150);
  __Pyx_GIVEREF(__pyx_tuple__150);

  /* "cupy/core/core.pyx":1671
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim',
 *     'T out',
 */
  __pyx_tuple__151 = PyTuple_Pack(4, __pyx_kp_s_raw_T_a_S_indices_int32_rdim, __pyx_kp_s_T_out, __pyx_kp_s_out_a_indices_rdim_i_rdim, __pyx_n_s_cupy_take_0axis); if (unlikely(!__pyx_tuple__151)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__151);
  __Pyx_GIVEREF(__pyx_tuple__151);

  /* "cupy/core/core.pyx":2046
 * 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__158 = PyTuple_Pack(13, __pyx_kp_s__127, __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, __pyx_kp_s_f_2, __pyx_kp_s_d_2); if (unlikely(!__pyx_tuple__158)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__158);
  __Pyx_GIVEREF(__pyx_tuple__158);

  /* "cupy/core/core.pyx":2048
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a & b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'true', '')
 * 
 */
  __pyx_tuple__159 = 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__159)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__159);
  __Pyx_GIVEREF(__pyx_tuple__159);

  /* "cupy/core/core.pyx":2054
 * 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__160 = PyTuple_Pack(13, __pyx_kp_s__127, __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, __pyx_kp_s_f_2, __pyx_kp_s_d_2); if (unlikely(!__pyx_tuple__160)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__160);
  __Pyx_GIVEREF(__pyx_tuple__160);

  /* "cupy/core/core.pyx":2056
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 *      'q->?', 'Q->?', 'e->?', 'f->?', 'd->?'),
 *     ('in0', 'a | b', 'out0 = a', 'bool'),             # <<<<<<<<<<<<<<
 *     'false', '')
 * 
 */
  __pyx_tuple__161 = 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__161)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__161);
  __Pyx_GIVEREF(__pyx_tuple__161);

  /* "cupy/core/core.pyx":2068
 *     ('?->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__162 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__162)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__162);
  __Pyx_GIVEREF(__pyx_tuple__162);
  __pyx_tuple__163 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__162); if (unlikely(!__pyx_tuple__163)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__163);
  __Pyx_GIVEREF(__pyx_tuple__163);

  /* "cupy/core/core.pyx":2066
 * 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__164 = 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__163, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__164)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__164);
  __Pyx_GIVEREF(__pyx_tuple__164);

  /* "cupy/core/core.pyx":2070
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'),
 *     ('in0', 'a + b', 'out0 = a', None), 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__165 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_3, __pyx_kp_s_out0_a, Py_None); if (unlikely(!__pyx_tuple__165)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__165);
  __Pyx_GIVEREF(__pyx_tuple__165);

  /* "cupy/core/core.pyx":2077
 *     ['?->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__166 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__166)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__166);
  __Pyx_GIVEREF(__pyx_tuple__166);
  __pyx_tuple__167 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__166); if (unlikely(!__pyx_tuple__167)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__167);
  __Pyx_GIVEREF(__pyx_tuple__167);

  /* "cupy/core/core.pyx":2079
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'],
 *     ('in0', 'a * b', 'out0 = a', None), 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__168 = PyTuple_Pack(4, __pyx_n_s_in0, __pyx_kp_s_a_b_4, __pyx_kp_s_out0_a, Py_None); if (unlikely(!__pyx_tuple__168)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__168);
  __Pyx_GIVEREF(__pyx_tuple__168);

  /* "cupy/core/core.pyx":2103
 * 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__170 = PyTuple_Pack(2, __pyx_kp_s__127, __pyx_kp_s_out0_in0_2); if (unlikely(!__pyx_tuple__170)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__170);
  __Pyx_GIVEREF(__pyx_tuple__170);
  __pyx_tuple__171 = PyTuple_Pack(14, __pyx_tuple__170, __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__171)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__171);
  __Pyx_GIVEREF(__pyx_tuple__171);

  /* "cupy/core/core.pyx":2101
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_tuple__172 = PyTuple_Pack(3, __pyx_n_s_cupy_negative, __pyx_tuple__171, __pyx_kp_s_out0_in0_4); if (unlikely(!__pyx_tuple__172)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__172);
  __Pyx_GIVEREF(__pyx_tuple__172);

  /* "cupy/core/core.pyx":2127
 *     ('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__174 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__174)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__174);
  __Pyx_GIVEREF(__pyx_tuple__174);

  /* "cupy/core/core.pyx":2128
 *      '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__175 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__175)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__175);
  __Pyx_GIVEREF(__pyx_tuple__175);

  /* "cupy/core/core.pyx":2129
 *      ('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__176 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0_in1); if (unlikely(!__pyx_tuple__176)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__176);
  __Pyx_GIVEREF(__pyx_tuple__176);

  /* "cupy/core/core.pyx":2125
 * 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__177 = 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__174, __pyx_tuple__175, __pyx_tuple__176); if (unlikely(!__pyx_tuple__177)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__177);
  __Pyx_GIVEREF(__pyx_tuple__177);

  /* "cupy/core/core.pyx":2123
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__178 = PyTuple_Pack(3, __pyx_n_s_cupy_divide, __pyx_tuple__177, __pyx_kp_s_out0_in1_0_0_floor_double_in0_do); if (unlikely(!__pyx_tuple__178)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__178);
  __Pyx_GIVEREF(__pyx_tuple__178);

  /* "cupy/core/core.pyx":2142
 *     ('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__179 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__179)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__179);
  __Pyx_GIVEREF(__pyx_tuple__179);

  /* "cupy/core/core.pyx":2143
 *      '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__180 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_powf_in0_in1); if (unlikely(!__pyx_tuple__180)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__180);
  __Pyx_GIVEREF(__pyx_tuple__180);

  /* "cupy/core/core.pyx":2144
 *      ('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__181 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_pow_in0_in1); if (unlikely(!__pyx_tuple__181)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__181);
  __Pyx_GIVEREF(__pyx_tuple__181);

  /* "cupy/core/core.pyx":2140
 * 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__182 = 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__179, __pyx_tuple__180, __pyx_tuple__181); if (unlikely(!__pyx_tuple__182)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__182);
  __Pyx_GIVEREF(__pyx_tuple__182);

  /* "cupy/core/core.pyx":2138
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__183 = PyTuple_Pack(3, __pyx_n_s_cupy_power, __pyx_tuple__182, __pyx_kp_s_out0_rint_pow_double_in0_double); if (unlikely(!__pyx_tuple__183)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__183);
  __Pyx_GIVEREF(__pyx_tuple__183);

  /* "cupy/core/core.pyx":2164
 * 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__185 = 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__185)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__185);
  __Pyx_GIVEREF(__pyx_tuple__185);

  /* "cupy/core/core.pyx":2162
 * 
 * 
 * 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__186 = PyTuple_Pack(3, __pyx_n_s_cupy_true_divide, __pyx_tuple__185, __pyx_kp_s_out0_out0_type_in0_out0_type_in1); if (unlikely(!__pyx_tuple__186)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__186);
  __Pyx_GIVEREF(__pyx_tuple__186);

  /* "cupy/core/core.pyx":2180
 * 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__187 = 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__187)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__187);
  __Pyx_GIVEREF(__pyx_tuple__187);

  /* "cupy/core/core.pyx":2178
 * 
 * 
 * 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__188 = PyTuple_Pack(3, __pyx_n_s_cupy_floor_divide, __pyx_tuple__187, __pyx_kp_s_out0__floor_divide_in0_in1); if (unlikely(!__pyx_tuple__188)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__188);
  __Pyx_GIVEREF(__pyx_tuple__188);

  /* "cupy/core/core.pyx":2194
 *     ('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__189 = PyTuple_Pack(2, __pyx_kp_s_ee_e, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__189)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__189);
  __Pyx_GIVEREF(__pyx_tuple__189);

  /* "cupy/core/core.pyx":2195
 *      '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__190 = PyTuple_Pack(2, __pyx_kp_s_ff_f, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__190)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__190);
  __Pyx_GIVEREF(__pyx_tuple__190);

  /* "cupy/core/core.pyx":2196
 *      ('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__191 = PyTuple_Pack(2, __pyx_kp_s_dd_d, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i); if (unlikely(!__pyx_tuple__191)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__191);
  __Pyx_GIVEREF(__pyx_tuple__191);

  /* "cupy/core/core.pyx":2192
 * 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__192 = 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__189, __pyx_tuple__190, __pyx_tuple__191); if (unlikely(!__pyx_tuple__192)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__192);
  __Pyx_GIVEREF(__pyx_tuple__192);

  /* "cupy/core/core.pyx":2190
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_tuple__193 = PyTuple_Pack(3, __pyx_n_s_cupy_remainder, __pyx_tuple__192, __pyx_kp_s_out0_in0__floor_divide_in0_in1_i_2); if (unlikely(!__pyx_tuple__193)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__193);
  __Pyx_GIVEREF(__pyx_tuple__193);

  /* "cupy/core/core.pyx":2207
 * 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__194 = PyTuple_Pack(2, __pyx_kp_s__127, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__194)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__194);
  __Pyx_GIVEREF(__pyx_tuple__194);

  /* "cupy/core/core.pyx":2208
 *     '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__195 = PyTuple_Pack(2, __pyx_kp_s_B_B, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__195)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__195);
  __Pyx_GIVEREF(__pyx_tuple__195);
  __pyx_tuple__196 = PyTuple_Pack(2, __pyx_kp_s_H_H, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__196)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__196);
  __Pyx_GIVEREF(__pyx_tuple__196);

  /* "cupy/core/core.pyx":2209
 *     (('?->?', '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__197 = PyTuple_Pack(2, __pyx_kp_s_I_I, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__197)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__197);
  __Pyx_GIVEREF(__pyx_tuple__197);
  __pyx_tuple__198 = PyTuple_Pack(2, __pyx_kp_s_L_L, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__198)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__198);
  __Pyx_GIVEREF(__pyx_tuple__198);

  /* "cupy/core/core.pyx":2210
 *      '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__199 = PyTuple_Pack(2, __pyx_kp_s_Q_Q, __pyx_kp_s_out0_in0); if (unlikely(!__pyx_tuple__199)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__199);
  __Pyx_GIVEREF(__pyx_tuple__199);

  /* "cupy/core/core.pyx":2211
 *      '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__200 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__200)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__200);
  __Pyx_GIVEREF(__pyx_tuple__200);

  /* "cupy/core/core.pyx":2212
 *      '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__201 = PyTuple_Pack(2, __pyx_kp_s_f_f, __pyx_kp_s_out0_fabsf_in0); if (unlikely(!__pyx_tuple__201)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__201);
  __Pyx_GIVEREF(__pyx_tuple__201);

  /* "cupy/core/core.pyx":2213
 *      ('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__202 = PyTuple_Pack(2, __pyx_kp_s_d_d, __pyx_kp_s_out0_fabs_in0); if (unlikely(!__pyx_tuple__202)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__202);
  __Pyx_GIVEREF(__pyx_tuple__202);

  /* "cupy/core/core.pyx":2207
 * 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__203 = PyTuple_Pack(14, __pyx_tuple__194, __pyx_kp_s_b_b, __pyx_tuple__195, __pyx_kp_s_h_h, __pyx_tuple__196, __pyx_kp_s_i_i, __pyx_tuple__197, __pyx_kp_s_l_l, __pyx_tuple__198, __pyx_kp_s_q_q, __pyx_tuple__199, __pyx_tuple__200, __pyx_tuple__201, __pyx_tuple__202); if (unlikely(!__pyx_tuple__203)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__203);
  __Pyx_GIVEREF(__pyx_tuple__203);

  /* "cupy/core/core.pyx":2205
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_tuple__204 = PyTuple_Pack(3, __pyx_n_s_cupy_absolute, __pyx_tuple__203, __pyx_kp_s_out0_in0_0_in0_in0); if (unlikely(!__pyx_tuple__204)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__204);
  __Pyx_GIVEREF(__pyx_tuple__204);

  /* "cupy/core/core.pyx":2225
 * sqrt_fixed = create_ufunc(
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d'),             # <<<<<<<<<<<<<<
 *     'out0 = sqrt(in0)')
 * 
 */
  __pyx_tuple__205 = PyTuple_Pack(3, __pyx_kp_s_e_e, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__205)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__205);
  __Pyx_GIVEREF(__pyx_tuple__205);

  /* "cupy/core/core.pyx":2231
 * 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 = min(in2, max(in1, in0))')
 */
  __pyx_tuple__207 = PyTuple_Pack(14, __pyx_kp_s__206, __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__207)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__207);
  __Pyx_GIVEREF(__pyx_tuple__207);

  /* "cupy/core/core.pyx":2268
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_tuple__208 = 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__208)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__208);
  __Pyx_GIVEREF(__pyx_tuple__208);

  /* "cupy/core/core.pyx":2272
 *     '(x - mean) * (x - mean)',
 *     '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__209 = 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__209)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__209);
  __Pyx_GIVEREF(__pyx_tuple__209);

  /* "cupy/core/core.pyx":2282
 *     ('?->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__210 = PyTuple_Pack(4, Py_None, Py_None, Py_None, __pyx_n_s_float); if (unlikely(!__pyx_tuple__210)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__210);
  __Pyx_GIVEREF(__pyx_tuple__210);
  __pyx_tuple__211 = PyTuple_Pack(2, __pyx_kp_s_e_e, __pyx_tuple__210); if (unlikely(!__pyx_tuple__211)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__211);
  __Pyx_GIVEREF(__pyx_tuple__211);

  /* "cupy/core/core.pyx":2280
 * 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__212 = 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__211, __pyx_kp_s_f_f, __pyx_kp_s_d_d); if (unlikely(!__pyx_tuple__212)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__212);
  __Pyx_GIVEREF(__pyx_tuple__212);

  /* "cupy/core/core.pyx":2284
 *      ('e->e', (None, None, None, 'float')),
 *      'f->f', 'd->d'),
 *     ('in0', 'a + b', 'out0 = a / (_in_ind.size() / _out_ind.size())', None))             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__213 = 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__213)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__213);
  __Pyx_GIVEREF(__pyx_tuple__213);
  __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_float_1_ = PyFloat_FromDouble(1.); if (unlikely(!__pyx_float_1_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  Py_ssize_t __pyx_t_14;
  struct __pyx_opt_args_4cupy_4core_4core_create_ufunc __pyx_t_15;
  struct __pyx_opt_args_4cupy_4core_4core_create_reduction_func __pyx_t_16;
  struct __pyx_opt_args_4cupy_4core_4core__create_bit_op __pyx_t_17;
  struct __pyx_opt_args_4cupy_4core_4core_create_comparison __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_cupy__core__core) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "cupy.core.core")) {
      if (unlikely(PyDict_SetItemString(modules, "cupy.core.core", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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__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_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_4cupy_4core_4core_ndarray.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_4cupy_4core_4core_ndarray.tp_dict, __pyx_vtabptr_4cupy_4core_4core_ndarray) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "ndarray", (PyObject *)&__pyx_type_4cupy_4core_4core_ndarray) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[5]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[6]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[7]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[8]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[8]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[9]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[10]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[10]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[10]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[10]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.core.internal"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "getPointerMode", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_getPointerMode, "int (size_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "setPointerMode", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_setPointerMode, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "sdot", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sdot, "PyObject *(size_t, int, size_t, int, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "ddot", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_ddot, "PyObject *(size_t, int, size_t, int, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "sgemv", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sgemv, "PyObject *(size_t, int, int, int, float, size_t, int, size_t, int, float, size_t, int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "dgemv", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dgemv, "PyObject *(size_t, int, int, int, double, size_t, int, size_t, int, double, size_t, int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "sger", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_sger, "PyObject *(size_t, int, int, float, size_t, int, size_t, int, size_t, int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "dger", (void (**)(void))&__pyx_f_4cupy_4cuda_6cublas_dger, "PyObject *(size_t, int, int, double, size_t, int, size_t, int, size_t, int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("cupy.cuda.device"); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_3, "get_device_id", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_device_id, "int (int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_3, "get_cublas_handle", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_cublas_handle, "PyObject *(int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_4, "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_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif

  /* "cupy/core/core.pyx":2
 * from __future__ import division
 * import ctypes             # <<<<<<<<<<<<<<
 * import sys
 * 
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_ctypes, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ctypes, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":3
 * from __future__ import division
 * import ctypes
 * import sys             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":5
 * import sys
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":6
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy.core import flags
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":8
 * import six
 * 
 * from cupy.core import flags             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_flags);
  __Pyx_GIVEREF(__pyx_n_s_flags);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_flags);
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_cupy_core, __pyx_t_5, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_flags, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":9
 * 
 * from cupy.core import flags
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cimport cpython
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __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_5 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_util); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/core.pyx":74
 * 
 * 
 *     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":104
 *     # -------------------------------------------------------------------------
 *     @property
 *     def flags(self):             # <<<<<<<<<<<<<<
 *         """Object containing memory-layout information.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":103
 *     # Memory layout
 *     # -------------------------------------------------------------------------
 *     @property             # <<<<<<<<<<<<<<
 *     def flags(self):
 *         """Object containing memory-layout information.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_flags, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":141
 * 
 *     @property
 *     def strides(self):             # <<<<<<<<<<<<<<
 *         """Strides of axes in bytes.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_strides); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":140
 *             self._update_f_contiguity()
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def strides(self):
 *         """Strides of axes in bytes.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_strides, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":150
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         """Number of dimensions.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":149
 *         return tuple(self._strides)
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def ndim(self):
 *         """Number of dimensions.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_ndim, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":161
 * 
 *     @property
 *     def itemsize(self):             # <<<<<<<<<<<<<<
 *         """Size of each element in bytes.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":160
 *         return self._shape.size()
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def itemsize(self):
 *         """Size of each element in bytes.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_itemsize, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":170
 * 
 *     @property
 *     def nbytes(self):             # <<<<<<<<<<<<<<
 *         """Size of whole elements in bytes.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_nbytes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":169
 *         return self.dtype.itemsize
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def nbytes(self):
 *         """Size of whole elements in bytes.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_nbytes, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":184
 *     # -------------------------------------------------------------------------
 *     @property
 *     def T(self):             # <<<<<<<<<<<<<<
 *         """Shape-reversed view of the array.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":183
 *     # Other attributes
 *     # -------------------------------------------------------------------------
 *     @property             # <<<<<<<<<<<<<<
 *     def T(self):
 *         """Shape-reversed view of the array.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_T, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "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_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":206
 *     # -------------------------------------------------------------------------
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         """C representation of the array.
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_cstruct); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":205
 *     # foreign function interface
 *     # -------------------------------------------------------------------------
 *     @property             # <<<<<<<<<<<<<<
 *     def cstruct(self):
 *         """C representation of the array.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_cstruct, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1040
 *         return int(self.get())
 * 
 *     if sys.version_info < (3,):             # <<<<<<<<<<<<<<
 *         def __long__(self):
 *             # Avoid using long() for flake8
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_version_info); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_6, __pyx_tuple__82, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":1041
 * 
 *     if sys.version_info < (3,):
 *         def __long__(self):             # <<<<<<<<<<<<<<
 *             # Avoid using long() for flake8
 *             return self.get().__long__()
 */
  }

  /* "cupy/core/core.pyx":1079
 *     # -------------------------------------------------------------------------
 *     @property
 *     def device(self):             # <<<<<<<<<<<<<<
 *         """CUDA device on which this array resides."""
 *         return self.data.device
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray, __pyx_n_s_device); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/core.pyx":1078
 *     # Cupy specific attributes and methods
 *     # -------------------------------------------------------------------------
 *     @property             # <<<<<<<<<<<<<<
 *     def device(self):
 *         """CUDA device on which this array resides."""
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict, __pyx_n_s_device, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_ndarray);

  /* "cupy/core/core.pyx":1198
 * 
 * 
 * cdef object newaxis = numpy.newaxis  # == None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __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_5 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_cuda); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cuda, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/carray.pxi":64
 * 
 *     @property
 *     def ndim(self):             # <<<<<<<<<<<<<<
 *         return len(self.shape)
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer, __pyx_n_s_ndim); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/carray.pxi":63
 *         self.size = size
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def ndim(self):
 *         return len(self.shape)
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer->tp_dict, __pyx_n_s_ndim, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_Indexer);

  /* "cupy/core/carray.pxi":68
 * 
 *     @property
 *     def cstruct(self):             # <<<<<<<<<<<<<<
 *         return to_cindexer(self.size, self.shape)
 * 
 */
  __pyx_t_5 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer, __pyx_n_s_cstruct); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/carray.pxi":67
 *         return len(self.shape)
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def cstruct(self):
 *         return to_cindexer(self.size, self.shape)
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __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_property, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4cupy_4core_4core_Indexer->tp_dict, __pyx_n_s_cstruct, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  PyType_Modified(__pyx_ptype_4cupy_4core_4core_Indexer);

  /* "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_5 = __Pyx_Import(__pyx_n_s_string, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":3
 * import string
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * import six
 * 
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":4
 * 
 * import numpy
 * import six             # <<<<<<<<<<<<<<
 * 
 * from cupy import util
 */
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":6
 * import six
 * 
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * from cupy.cuda cimport device
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_util);
  __pyx_t_6 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_5, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_util); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__83, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_double) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_float) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__85, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_float16) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_long_long) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_int) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_short) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_signed_char) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_unsigned_long_long) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_unsigned_int) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_unsigned_short) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__93, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_kp_s_unsigned_char) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/core/elementwise.pxi":48
 *     numpy.dtype('uint16'): 'unsigned short',
 *     numpy.dtype('uint8'): 'unsigned char',
 *     numpy.dtype('bool'): 'bool',             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_t_5, __pyx_n_s_bool_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_filename = __pyx_f[1]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __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_5 = PyObject_GetIter(__pyx_v_4cupy_4core_4core__all_type_chars); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
    for (;;) {
      {
        __pyx_t_8 = __pyx_t_9(__pyx_t_5);
        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_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i, __pyx_t_8);
      __pyx_t_8 = 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_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dtype); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_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_8genexpr1__pyx_v_4cupy_4core_4core_i);
        __Pyx_GIVEREF(__pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_type); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__pyx_v_4cupy_4core_4core__typenames_base == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      }
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_12) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_8genexpr1__pyx_v_4cupy_4core_4core_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_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_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4core_4core__typenames_base, __pyx_t_8); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;};
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_6, (PyObject*)__pyx_t_11, (PyObject*)__pyx_t_10))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_5); __pyx_t_5 = 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_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __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_10 = PyNumber_Add(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __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_10));
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_t_10 = 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_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "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_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (;;) {
    {
      __pyx_t_5 = __pyx_t_9(__pyx_t_6);
      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_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_13 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_13) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __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_5, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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_10)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_filename = __pyx_f[1]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_b, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_u, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_i, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_f, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
    __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, ((PyObject *)(&PyFloat_Type)));
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_type); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)(&PyFloat_Type)), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __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_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject*)&PyBool_Type)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
    __Pyx_INCREF(((PyObject*)&PyBool_Type));
    __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject*)&PyBool_Type));
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_type); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_6, ((PyObject*)&PyBool_Type), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_integer_types); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_12)) || PyTuple_CheckExact(__pyx_t_12)) {
    __pyx_t_6 = __pyx_t_12; __Pyx_INCREF(__pyx_t_6); __pyx_t_14 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_14 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_14); __Pyx_INCREF(__pyx_t_12); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_6, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        #endif
      } else {
        if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_14); __Pyx_INCREF(__pyx_t_12); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_6, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        #endif
      }
    } else {
      __pyx_t_12 = __pyx_t_9(__pyx_t_6);
      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_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_12);
    }
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_i, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = NULL;
    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);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_type); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_i); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (unlikely(PyDict_SetItem(__pyx_v_4cupy_4core_4core__python_type_to_numpy_type, __pyx_t_12, __pyx_t_8) < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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":255
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _get_param_info(s, is_const):
 *     if len(s) == 0:
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_memoize); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":256
 * 
 * @util.memoize()
 * def _get_param_info(s, is_const):             # <<<<<<<<<<<<<<
 *     if len(s) == 0:
 *         return ()
 */
  __pyx_t_11 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_21_get_param_info, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __pyx_t_12 = NULL;
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __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;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_param_info, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":262
 * 
 * 
 * @util.memoize()             # <<<<<<<<<<<<<<
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):
 *     type_dict = {}
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_memoize); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":263
 * 
 * @util.memoize()
 * def _decide_params_type(in_params, out_params, in_args_dtype, out_args_dtype):             # <<<<<<<<<<<<<<
 *     type_dict = {}
 *     if out_args_dtype:
 */
  __pyx_t_11 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_23_decide_params_type, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __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_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __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;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_decide_params_type, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":387
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_elementwise_kernel(args_info, types, params, operation, name,
 *                             preamble, kwargs):
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_memoize); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_for_each_device, Py_True) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_empty_tuple, __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/elementwise.pxi":388
 * 
 * @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_8 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_25_get_elementwise_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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_6 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __pyx_t_12 = NULL;
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_elementwise_kernel, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":552
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_ufunc_kernel(
 *         in_types, out_types, routine, args_info, params, name, preamble):
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_memoize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_for_each_device, Py_True) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":553
 * 
 * @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_11 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_27_get_ufunc_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __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_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __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;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_ufunc_kernel, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/elementwise.pxi":650
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __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_8 = __Pyx_CalculateMetaclass(NULL, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_12 = __Pyx_Py3MetaclassPrepare(__pyx_t_8, __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_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/elementwise.pxi":661
 * 
 *     """
 *     def __init__(self, name, nin, nout, ops, preamble='', doc=''):             # <<<<<<<<<<<<<<
 *         self.name = name
 *         self.nin = nin
 */
  __pyx_t_11 = __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__104)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_11, __pyx_tuple__105);
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_init, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":679
 *         self._routine_cache = {}
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<ufunc '%s'>" % self.name
 * 
 */
  __pyx_t_11 = __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__107)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_repr, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":683
 * 
 *     @property
 *     def types(self):             # <<<<<<<<<<<<<<
 *         """A list of type signatures.
 * 
 */
  __pyx_t_11 = __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__110)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/elementwise.pxi":682
 *         return "<ufunc '%s'>" % self.name
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def types(self):
 *         """A list of type signatures.
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_types, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":697
 *         return types
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Applies the universal function to arguments elementwise.
 * 
 */
  __pyx_t_11 = __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__112)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_call, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/elementwise.pxi":650
 * 
 * 
 * class ufunc(object):             # <<<<<<<<<<<<<<
 * 
 *     """Universal function.
 */
  __pyx_t_11 = __Pyx_Py3ClassCreate(__pyx_t_8, __pyx_n_s_ufunc, __pyx_t_6, __pyx_t_12, NULL, 0, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ufunc, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_collections, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __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_8 = __Pyx_Import(__pyx_n_s_cupy_2, __pyx_t_6, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_8, __pyx_n_s_util); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":10
 * 
 * 
 * six_zip = six.moves.zip             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_moves); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zip); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six_zip, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 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_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_memoize); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_for_each_device, Py_True) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 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_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(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_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __pyx_t_12 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_simple_reduction_function, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":187
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, name, ops, identity, preamble):
 */
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_builtin_object);
  __pyx_t_11 = __Pyx_CalculateMetaclass(NULL, __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_5 = __Pyx_Py3MetaclassPrepare(__pyx_t_11, __pyx_t_8, __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_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/core/reduction.pxi":189
 * class simple_reduction_function(object):
 * 
 *     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__116)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetItem(__pyx_t_5, __pyx_n_s_init, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":207
 *         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__118)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_6, __pyx_tuple__119);
  if (PyObject_SetItem(__pyx_t_5, __pyx_n_s_call, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/reduction.pxi":187
 * 
 * 
 * class simple_reduction_function(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, name, ops, identity, preamble):
 */
  __pyx_t_6 = __Pyx_Py3ClassCreate(__pyx_t_11, __pyx_n_s_simple_reduction_function, __pyx_t_8, __pyx_t_5, NULL, 0, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_simple_reduction_function, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":270
 * 
 * 
 * @util.memoize(for_each_device=True)             # <<<<<<<<<<<<<<
 * def _get_reduction_kernel(
 *         params, args_info, types,
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_util); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_memoize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_for_each_device, Py_True) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":271
 * 
 * @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_11 = PyCFunction_NewEx(&__pyx_mdef_4cupy_4core_4core_43_get_reduction_kernel, NULL, __pyx_n_s_cupy_core_core); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_5 = NULL;
  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);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __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_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_reduction_kernel, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/reduction.pxi":294
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_builtin_object);
  __pyx_t_6 = __Pyx_CalculateMetaclass(NULL, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = __Pyx_Py3MetaclassPrepare(__pyx_t_6, __pyx_t_8, __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_12)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/reduction.pxi":325
 * 
 *     """
 *     def __init__(self, in_params, out_params,             # <<<<<<<<<<<<<<
 *                  map_expr, reduce_expr, post_map_expr,
 *                  identity, name='reduce_kernel', reduce_type=None,
 */
  __pyx_t_11 = __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__123)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_11, __pyx_tuple__124);
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_init, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":351
 *         self.preamble = preamble
 * 
 *     def __call__(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """Compiles and invokes the reduction kernel.
 * 
 */
  __pyx_t_11 = __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__126)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyObject_SetItem(__pyx_t_12, __pyx_n_s_call, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/reduction.pxi":294
 * 
 * 
 * class ReductionKernel(object):             # <<<<<<<<<<<<<<
 * 
 *     """User-defined reduction kernel.
 */
  __pyx_t_11 = __Pyx_Py3ClassCreate(__pyx_t_6, __pyx_n_s_ReductionKernel, __pyx_t_8, __pyx_t_12, NULL, 0, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReductionKernel, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1246
 * # =============================================================================
 * 
 * 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":1252
 *     ('?->?', '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_8 = __pyx_v_4cupy_4core_4core__id;
  __Pyx_INCREF(__pyx_t_8);

  /* "cupy/core/core.pyx":1248
 * 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_15.__pyx_n = 1;
  __pyx_t_15.routine = __pyx_t_8;
  __pyx_t_6 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_copy, __pyx_tuple__128, 0, &__pyx_t_15); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_2, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1255
 * 
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1260
 * 
 * 
 * _elementwise_copy_where = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_copy_where',
 *     ('??->?', 'b?->b', 'B?->B', 'h?->h', 'H?->H', 'i?->i', 'I?->I', 'l?->l',
 */
  __pyx_t_15.__pyx_n = 1;
  __pyx_t_15.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__131, 0, &__pyx_t_15); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy_where, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1267
 * 
 * 
 * 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_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/core/core.pyx":1272
 * 
 * 
 * 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":1282
 *     ('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_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __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":1283
 *      'LL->LL', 'qq->qq', 'QQ->QQ',
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),             # <<<<<<<<<<<<<<
 *      ('dd->dd', _divmod_float)),
 *     '''
 */
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_s_ff_ff);
  __Pyx_GIVEREF(__pyx_kp_s_ff_ff);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_s_ff_ff);
  __Pyx_INCREF(__pyx_v_4cupy_4core_4core__divmod_float);
  __Pyx_GIVEREF(__pyx_v_4cupy_4core_4core__divmod_float);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1284
 *      ('ee->ee', _divmod_float),
 *      ('ff->ff', _divmod_float),
 *      ('dd->dd', _divmod_float)),             # <<<<<<<<<<<<<<
 *     '''
 *     if (in1 == 0) {
 */
  __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_kp_s_dd_dd);
  __Pyx_GIVEREF(__pyx_kp_s_dd_dd);
  PyTuple_SET_ITEM(__pyx_t_12, 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_12, 1, __pyx_v_4cupy_4core_4core__divmod_float);

  /* "cupy/core/core.pyx":1280
 * 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_11 = PyTuple_New(13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_kp_s_bb_bb);
  __Pyx_GIVEREF(__pyx_kp_s_bb_bb);
  PyTuple_SET_ITEM(__pyx_t_11, 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_11, 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_11, 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_11, 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_11, 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_11, 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_11, 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_11, 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_11, 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_11, 9, __pyx_kp_s_QQ_QQ);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_11, 10, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_11, 11, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_11, 12, __pyx_t_12);
  __pyx_t_6 = 0;
  __pyx_t_8 = 0;
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1278
 * 
 * 
 * divmod = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divmod',
 *     ('bb->bb', 'BB->BB', 'hh->hh', 'HH->HH', 'ii->ii', 'II->II', 'll->ll',
 */
  __pyx_t_15.__pyx_n = 1;
  __pyx_t_15.routine = __pyx_kp_s_if_in1_0_out0_0_out1_0_else_out;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_divmod, __pyx_t_11, 0, &__pyx_t_15); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divmod, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1296
 * 
 * 
 * cdef _min_max_preamble = '''             # <<<<<<<<<<<<<<
 * struct min_max_st{
 *     type_in0_raw value;
 */
  __Pyx_INCREF(__pyx_kp_s_struct_min_max_st_type_in0_raw);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__min_max_preamble);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__min_max_preamble, __pyx_kp_s_struct_min_max_st_type_in0_raw);
  __Pyx_GIVEREF(__pyx_kp_s_struct_min_max_st_type_in0_raw);

  /* "cupy/core/core.pyx":1333
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st(in0)', 'my_min(a, b)', 'out0 = a.value', 'min_max_st'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_12 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1328
 * 
 * 
 * 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_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__135;
  __pyx_t_16.identity = Py_None;
  __pyx_t_16.preamble = __pyx_t_12;
  __pyx_t_11 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_min, __pyx_tuple__134, 0, &__pyx_t_16); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__amin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__amin, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":1341
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     ('min_max_st(in0)', 'my_max(a, b)', 'out0 = a.value', 'min_max_st'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_11 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_11);

  /* "cupy/core/core.pyx":1336
 * 
 * 
 * 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_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__137;
  __pyx_t_16.identity = Py_None;
  __pyx_t_16.preamble = __pyx_t_11;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_max, __pyx_tuple__136, 0, &__pyx_t_16); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__amax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__amax, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1349
 *      'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmin(a, b)', 'out0 = a.index', 'min_max_st'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_12 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1344
 * 
 * 
 * cdef _argmin = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmin',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 */
  __pyx_t_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__139;
  __pyx_t_16.identity = Py_None;
  __pyx_t_16.preamble = __pyx_t_12;
  __pyx_t_11 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmin, __pyx_tuple__138, 0, &__pyx_t_16); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmin);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmin, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":1357
 *      'q->l', 'Q->l', 'e->l', 'f->l', 'd->l'),
 *     ('min_max_st(in0, _J)', 'my_argmax(a, b)', 'out0 = a.index', 'min_max_st'),
 *     None, _min_max_preamble)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_11 = __pyx_v_4cupy_4core_4core__min_max_preamble;
  __Pyx_INCREF(__pyx_t_11);

  /* "cupy/core/core.pyx":1352
 * 
 * 
 * cdef _argmax = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_argmax',
 *     ('?->l', 'B->l', 'h->l', 'H->l', 'i->l', 'I->l', 'l->l', 'L->l',
 */
  __pyx_t_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__141;
  __pyx_t_16.identity = Py_None;
  __pyx_t_16.preamble = __pyx_t_11;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_argmax, __pyx_tuple__140, 0, &__pyx_t_16); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__argmax);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__argmax, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1588
 * 
 * 
 * bitwise_and = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_and', '&', False,
 *     '''Computes the bitwise AND of two arrays elementwise.
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.doc = __pyx_kp_s_Computes_the_bitwise_AND_of_two;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_and, __pyx_kp_s__142, Py_False, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_and, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1599
 * 
 * 
 * bitwise_or = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_or', '|', False,
 *     '''Computes the bitwise OR of two arrays elementwise.
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.doc = __pyx_kp_s_Computes_the_bitwise_OR_of_two_a;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_or, __pyx_kp_s__143, Py_False, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_or, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1610
 * 
 * 
 * bitwise_xor = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'bitwise_xor', '^', False,
 *     '''Computes the bitwise XOR of two arrays elementwise.
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.doc = __pyx_kp_s_Computes_the_bitwise_XOR_of_two;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_bitwise_xor, __pyx_kp_s__144, Py_False, 0, &__pyx_t_17); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bitwise_xor, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1621
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":1626
 *      '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_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_doc, __pyx_kp_s_Computes_the_bitwise_NOT_of_an_a) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":1621
 * 
 * 
 * invert = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_invert',
 *     (('?->?', 'out0 = !in0'), 'b->b', 'B->B', 'h->h', 'H->H', 'i->i', 'I->I',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__147, __pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_invert, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1635
 * 
 * 
 * left_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'left_shift', '<<', True,
 *     '''Shifts the bits of each integer element to the left.
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_left_shift, __pyx_kp_s__148, Py_True, 0, &__pyx_t_17); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_left_shift, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1646
 * 
 * 
 * right_shift = _create_bit_op(             # <<<<<<<<<<<<<<
 *     'right_shift', '>>', True,
 *     '''Shifts the bits of each integer element to the right.
 */
  __pyx_t_17.__pyx_n = 1;
  __pyx_t_17.doc = __pyx_kp_s_Shifts_the_bits_of_each_integer_2;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core__create_bit_op(__pyx_n_s_right_shift, __pyx_kp_s__149, Py_True, 0, &__pyx_t_17); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_right_shift, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1660
 * # -----------------------------------------------------------------------------
 * 
 * cdef _take_kernel = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 cdim, int32 rdim, int32 adim',
 *     'T out',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__150, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1671
 * 
 * 
 * cdef _take_kernel_0axis = ElementwiseKernel(             # <<<<<<<<<<<<<<
 *     'raw T a, S indices, int32 rdim',
 *     'T out',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ElementwiseKernel), __pyx_tuple__151, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__take_kernel_0axis);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__take_kernel_0axis, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1990
 * 
 * 
 * greater = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater', '>',
 *     '''Tests elementwise if ``x1 > x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater, __pyx_kp_s__152, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":1999
 * 
 * 
 * greater_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'greater_equal', '>=',
 *     '''Tests elementwise if ``x1 >= x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_2;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_greater_equal, __pyx_kp_s__153, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_greater_equal, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2008
 * 
 * 
 * less = create_comparison(             # <<<<<<<<<<<<<<
 *     'less', '<',
 *     '''Tests elementwise if ``x1 < x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_3;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less, __pyx_kp_s__154, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2017
 * 
 * 
 * less_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'less_equal', '<=',
 *     '''Tests elementwise if ``x1 <= x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_4;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_less_equal, __pyx_kp_s__155, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_less_equal, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2026
 * 
 * 
 * equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'equal', '==',
 *     '''Tests elementwise if ``x1 == x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_5;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_equal, __pyx_kp_s__156, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_equal, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2035
 * 
 * 
 * not_equal = create_comparison(             # <<<<<<<<<<<<<<
 *     'not_equal', '!=',
 *     '''Tests elementwise if ``x1 != x2``.
 */
  __pyx_t_18.__pyx_n = 1;
  __pyx_t_18.doc = __pyx_kp_s_Tests_elementwise_if_x1_x2_seeal_6;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_comparison(__pyx_n_s_not_equal, __pyx_kp_s__157, 0, &__pyx_t_18); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_not_equal, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2044
 * 
 * 
 * cdef _all = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_all',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__159;
  __pyx_t_16.identity = __pyx_n_s_true;
  __pyx_t_16.preamble = __pyx_kp_s__4;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_all, __pyx_tuple__158, 0, &__pyx_t_16); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__all);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__all, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2052
 * 
 * 
 * cdef _any = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_any',
 *     ('?->?', 'B->?', 'h->?', 'H->?', 'i->?', 'I->?', 'l->?', 'L->?',
 */
  __pyx_t_16.__pyx_n = 3;
  __pyx_t_16.routine = __pyx_tuple__161;
  __pyx_t_16.identity = __pyx_n_s_false;
  __pyx_t_16.preamble = __pyx_kp_s__4;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_any, __pyx_tuple__160, 0, &__pyx_t_16); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__any);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__any, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2064
 * # -----------------------------------------------------------------------------
 * 
 * cdef _sum = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_sum',
 *     ('?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_16.__pyx_n = 2;
  __pyx_t_16.routine = __pyx_tuple__165;
  __pyx_t_16.identity = __pyx_int_0;
  __pyx_t_8 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_sum, __pyx_tuple__164, 0, &__pyx_t_16); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__sum);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__sum, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2075
 * 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_8 = PyList_New(13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_kp_s_l);
  __Pyx_GIVEREF(__pyx_kp_s_l);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_kp_s_l);
  __Pyx_INCREF(__pyx_kp_s_B_L);
  __Pyx_GIVEREF(__pyx_kp_s_B_L);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_kp_s_B_L);
  __Pyx_INCREF(__pyx_kp_s_h_l);
  __Pyx_GIVEREF(__pyx_kp_s_h_l);
  PyList_SET_ITEM(__pyx_t_8, 2, __pyx_kp_s_h_l);
  __Pyx_INCREF(__pyx_kp_s_H_L);
  __Pyx_GIVEREF(__pyx_kp_s_H_L);
  PyList_SET_ITEM(__pyx_t_8, 3, __pyx_kp_s_H_L);
  __Pyx_INCREF(__pyx_kp_s_i_l);
  __Pyx_GIVEREF(__pyx_kp_s_i_l);
  PyList_SET_ITEM(__pyx_t_8, 4, __pyx_kp_s_i_l);
  __Pyx_INCREF(__pyx_kp_s_I_L);
  __Pyx_GIVEREF(__pyx_kp_s_I_L);
  PyList_SET_ITEM(__pyx_t_8, 5, __pyx_kp_s_I_L);
  __Pyx_INCREF(__pyx_kp_s_l_l);
  __Pyx_GIVEREF(__pyx_kp_s_l_l);
  PyList_SET_ITEM(__pyx_t_8, 6, __pyx_kp_s_l_l);
  __Pyx_INCREF(__pyx_kp_s_L_L);
  __Pyx_GIVEREF(__pyx_kp_s_L_L);
  PyList_SET_ITEM(__pyx_t_8, 7, __pyx_kp_s_L_L);
  __Pyx_INCREF(__pyx_kp_s_q_q);
  __Pyx_GIVEREF(__pyx_kp_s_q_q);
  PyList_SET_ITEM(__pyx_t_8, 8, __pyx_kp_s_q_q);
  __Pyx_INCREF(__pyx_kp_s_Q_Q);
  __Pyx_GIVEREF(__pyx_kp_s_Q_Q);
  PyList_SET_ITEM(__pyx_t_8, 9, __pyx_kp_s_Q_Q);
  __Pyx_INCREF(__pyx_tuple__167);
  __Pyx_GIVEREF(__pyx_tuple__167);
  PyList_SET_ITEM(__pyx_t_8, 10, __pyx_tuple__167);
  __Pyx_INCREF(__pyx_kp_s_f_f);
  __Pyx_GIVEREF(__pyx_kp_s_f_f);
  PyList_SET_ITEM(__pyx_t_8, 11, __pyx_kp_s_f_f);
  __Pyx_INCREF(__pyx_kp_s_d_d);
  __Pyx_GIVEREF(__pyx_kp_s_d_d);
  PyList_SET_ITEM(__pyx_t_8, 12, __pyx_kp_s_d_d);

  /* "cupy/core/core.pyx":2073
 * 
 * 
 * cdef _prod = create_reduction_func(             # <<<<<<<<<<<<<<
 *     'cupy_prod',
 *     ['?->l', 'B->L', 'h->l', 'H->L', 'i->l', 'I->L', 'l->l', 'L->L',
 */
  __pyx_t_16.__pyx_n = 2;
  __pyx_t_16.routine = __pyx_tuple__168;
  __pyx_t_16.identity = __pyx_int_1;
  __pyx_t_11 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_prod, __pyx_t_8, 0, &__pyx_t_16); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__prod);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__prod, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2092
 * 
 * 
 * add = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'add', '+', '|',
 *     '''Adds two arrays elementwise.
 */
  __pyx_t_11 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_add, __pyx_kp_s__169, __pyx_kp_s__143, __pyx_kp_s_Adds_two_arrays_elementwise_seea); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2101
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/core.pyx":2107
 *      'q->q', 'Q->Q', 'e->e', 'f->f', 'd->d'),
 *     'out0 = -in0',
 *     doc='''Takes numerical negative elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.negative`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Takes_numerical_negative_element) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2101
 * 
 * 
 * negative = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_negative',
 *     (('?->?', 'out0 = !in0'),
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__172, __pyx_t_8); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_negative, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2114
 * 
 * 
 * multiply = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'multiply', '*', '&',
 *     '''Multiplies two arrays elementwise.
 */
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_multiply, __pyx_kp_s__173, __pyx_kp_s__142, __pyx_kp_s_Multiplies_two_arrays_elementwis); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiply, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2123
 * 
 * 
 * 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_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":2131
 *      ('dd->d', 'out0 = in0 / in1')),
 *     'out0 = in1 == 0 ? 0 : floor((double)in0 / (double)in1)',
 *     doc='''Divides arguments elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.divide`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Divides_arguments_elementwise_se) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2123
 * 
 * 
 * divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__178, __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2138
 * 
 * 
 * power = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_power',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/core/core.pyx":2146
 *      ('dd->d', 'out0 = pow(in0, in1)')),
 *     'out0 = rint(pow((double)in0, (double)in1))',
 *     doc='''Computes ``x1 ** x2`` elementwise.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.power`
 */
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Computes_x1_x2_elementwise_seeal) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2138
 * 
 * 
 * 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_PyObject_Call(__pyx_t_11, __pyx_tuple__183, __pyx_t_8); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_power, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2153
 * 
 * 
 * subtract = create_arithmetic(             # <<<<<<<<<<<<<<
 *     'subtract', '-', '^',
 *     '''Subtracts arguments elementwise.
 */
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_arithmetic(__pyx_n_s_subtract, __pyx_kp_s__184, __pyx_kp_s__144, __pyx_kp_s_Subtracts_arguments_elementwise); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_subtract, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2162
 * 
 * 
 * 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_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":2167
 *      '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_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_doc, __pyx_kp_s_Elementwise_true_division_i_e_di) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2162
 * 
 * 
 * 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_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__186, __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_true_divide, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2174
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_PY3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_7) {

    /* "cupy/core/core.pyx":2175
 * 
 * if six.PY3:
 *     divide = true_divide             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_true_divide); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_divide, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cupy/core/core.pyx":2174
 * 
 * 
 * if six.PY3:             # <<<<<<<<<<<<<<
 *     divide = true_divide
 * 
 */
  }

  /* "cupy/core/core.pyx":2178
 * 
 * 
 * floor_divide = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_floor_divide',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2183
 *      '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_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_doc, __pyx_kp_s_Elementwise_floor_division_i_e_i) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2178
 * 
 * 
 * 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_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__188, __pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_floor_divide, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2190
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('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_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);

  /* "cupy/core/core.pyx":2198
 *      ('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_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_doc, __pyx_kp_s_Computes_the_remainder_of_Python) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2190
 * 
 * 
 * remainder = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_remainder',
 *     ('bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__193, __pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_remainder, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/core/core.pyx":2205
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_create_ufunc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/core/core.pyx":2215
 *      ('d->d', 'out0 = fabs(in0)')),
 *     'out0 = in0 > 0 ? in0 : -in0',
 *     doc='''Elementwise absolute value function.             # <<<<<<<<<<<<<<
 * 
 *     .. seealso:: :data:`numpy.absolute`
 */
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_doc, __pyx_kp_s_Elementwise_absolute_value_funct) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cupy/core/core.pyx":2205
 * 
 * 
 * absolute = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_absolute',
 *     (('?->?', 'out0 = in0'),
 */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__204, __pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_absolute, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2223
 * 
 * # Fixed version of sqrt
 * sqrt_fixed = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_sqrt',
 *     ('e->e', 'f->f', 'd->d'),
 */
  __pyx_t_15.__pyx_n = 1;
  __pyx_t_15.routine = __pyx_kp_s_out0_sqrt_in0;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_sqrt, __pyx_tuple__205, 0, &__pyx_t_15); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sqrt_fixed, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2229
 * 
 * 
 * cdef _clip = create_ufunc(             # <<<<<<<<<<<<<<
 *     'cupy_clip',
 *     ('???->?', 'bbb->b', 'BBB->B', 'hhh->h', 'HHH->H', 'iii->i', 'III->I',
 */
  __pyx_t_15.__pyx_n = 1;
  __pyx_t_15.routine = __pyx_kp_s_out0_min_in2_max_in1_in0;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_ufunc(__pyx_n_s_cupy_clip, __pyx_tuple__207, 0, &__pyx_t_15); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__clip);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__clip, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2268
 * 
 * 
 * cdef _var_core = ReductionKernel(             # <<<<<<<<<<<<<<
 *     'S x, T mean, T alpha', 'T out',
 *     '(x - mean) * (x - mean)',
 */
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__208, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  __pyx_t_11 = 0;

  /* "cupy/core/core.pyx":2272
 *     '(x - mean) * (x - mean)',
 *     '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_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReductionKernel); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__209, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__var_core_out);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__var_core_out, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":2278
 * 
 * # 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_16.__pyx_n = 1;
  __pyx_t_16.routine = __pyx_tuple__213;
  __pyx_t_12 = __pyx_f_4cupy_4core_4core_create_reduction_func(__pyx_n_s_cupy_mean, __pyx_tuple__212, 0, &__pyx_t_16); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_XGOTREF(__pyx_v_4cupy_4core_4core__mean);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4core_4core__mean, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;

  /* "cupy/core/core.pyx":1
 * from __future__ import division             # <<<<<<<<<<<<<<
 * import ctypes
 * import sys
 */
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

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

  /*--- 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_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  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 --- */
#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

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

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

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

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
}

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

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

#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

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    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_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

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

#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

#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

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

#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

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

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))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            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));
}

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

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))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        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;
}

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

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

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");
}

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);  if (0) goto bad;
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

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

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    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;
}

#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

#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

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
}

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
}

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
}

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

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

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

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

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

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))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        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;
}

#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
#endif

#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

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

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

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

#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

#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

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))
                    PyErr_Clear();
                else
                    return -1;
            }
        }
        return m->sq_ass_item(o, i, (PyObject *)NULL);
    }
#endif
    return __Pyx_DelItem_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    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;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

#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

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

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

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

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

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

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

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

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

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]);
        PyMem_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 = PyMem_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);
}

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

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

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

#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;\
    }

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) 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_Int(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_Int(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;
}

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

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) 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_Int(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_Int(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;
}

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

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) 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_Int(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_Int(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;
}

#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_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;
    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;
    }
    if (value) {
#if CYTHON_COMPILING_IN_PYPY
#else
        if (self->exc_traceback) {
            PyThreadState *tstate = PyThreadState_GET();
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    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 = PyIter_Next(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;
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __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;
}

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

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

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

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

#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

#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",
            module_name, class_name);
        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",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#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

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