/* Generated by Cython 0.29.21 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "_FORCE_INLINES",
                "1"
            ],
            [
                "CUPY_NO_CUDA",
                "1"
            ]
        ],
        "depends": [],
        "extra_compile_args": [
            "-fopenmp"
        ],
        "extra_link_args": [
            "-Wl,--disable-new-dtags,-rpath,/usr/local/cuda/lib64"
        ],
        "include_dirs": [
            "/usr/local/cuda/include"
        ],
        "language": "c++",
        "library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "name": "cupy.cudnn",
        "sources": [
            "cupy/cudnn.pyx"
        ]
    },
    "module_name": "cupy.cudnn"
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_21"
#define CYTHON_HEX_VERSION 0x001D15F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef __cplusplus
  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #else
    #define CYTHON_INLINE inline
  #endif
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
    x.~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
    T *operator->() { return ptr; }
    T *operator&() { return ptr; }
    operator T&() { return *ptr; }
    template<typename U> bool operator ==(U other) { return *ptr == other; }
    template<typename U> bool operator !=(U other) { return *ptr != other; }
  private:
    T *ptr;
};

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #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)
#endif
  #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
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__cupy__cudnn
#define __PYX_HAVE_API__cupy__cudnn
/* Early includes */
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <vector>
#include <stdint.h>
#include <utility>

    #if __cplusplus > 199711L
    #include <type_traits>

    namespace cython_std {
    template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); }
    template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); }
    }

    #endif
    
#include <map>
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#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)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "cupy/cudnn.pyx",
  "stringsource",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/function.pxd",
  "cupy/core/core.pxd",
  "cupy/core/_routines_manipulation.pxd",
  "cupy/cuda/cudnn.pxd",
};

/* "internal.pxd":43
 * cpdef size_t clp2(size_t x)
 * 
 * ctypedef unsigned short _float16             # <<<<<<<<<<<<<<
 * 
 * cpdef uint16_t to_float16(float f)
 */
typedef unsigned short __pyx_t_4cupy_4core_8internal__float16;

/*--- Type declarations ---*/
struct __pyx_obj_4cupy_4cuda_6device_Handle;
struct __pyx_obj_4cupy_4cuda_6device_Device;
struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer;
struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool;
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory;
struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator;
struct __pyx_obj_4cupy_4cuda_8function_CPointer;
struct __pyx_obj_4cupy_4cuda_8function_Function;
struct __pyx_obj_4cupy_4cuda_8function_Module;
struct __pyx_obj_4cupy_4cuda_8function_LinkState;
struct __pyx_obj_4cupy_4core_4core_ndarray;
struct __pyx_obj_4cupy_4core_4core_Indexer;
struct __pyx_obj_4cupy_4core_22_routines_manipulation_broadcast;
struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf;
struct __pyx_obj_4cupy_5cudnn_Descriptor;
struct __pyx_obj_4cupy_5cudnn__DescriptorArray;
struct __pyx_obj_4cupy_5cudnn_DropoutStates;
struct __pyx_obj_4cupy_5cudnn__Algorithm;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_set_allocator;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_free_all_blocks;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_set_limit;

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

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

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

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

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

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

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

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

/* "cupy/cuda/function.pxd":14
 *         public intptr_t ptr
 * 
 *     cpdef linear_launch(self, size_t size, args, size_t shared_mem=*,             # <<<<<<<<<<<<<<
 *                         size_t block_max_size=*, stream=*)
 * 
 */
struct __pyx_opt_args_4cupy_4cuda_8function_8Function_linear_launch {
  int __pyx_n;
  size_t shared_mem;
  size_t block_max_size;
  PyObject *stream;
};
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_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_round;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set;
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view;
struct __pyx_opt_args_4cupy_4core_4core_ascontiguousarray;
struct __pyx_opt_args_4cupy_4core_4core_asfortranarray;
struct __pyx_opt_args_4cupy_4core_4core_compile_with_cache;
struct __pyx_opt_args_4cupy_4core_4core_array;

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

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

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

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

/* "cupy/core/core.pxd":31
 *     cpdef ndarray astype(self, dtype, order=*, casting=*, subok=*, copy=*)
 *     cpdef ndarray copy(self, order=*)
 *     cpdef ndarray view(self, dtype=*)             # <<<<<<<<<<<<<<
 *     cpdef fill(self, value)
 *     cpdef ndarray swapaxes(self, Py_ssize_t axis1, Py_ssize_t axis2)
 */
struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view {
  int __pyx_n;
  PyObject *dtype;
};

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* "cupy/core/core.pxd":109
 * 
 * # TODO(niboshi): Move to _routines_creation.pyx
 * cpdef ndarray array(obj, dtype=*, bint copy=*, order=*, bint subok=*,             # <<<<<<<<<<<<<<
 *                     Py_ssize_t ndmin=*)
 * cpdef ndarray _convert_object_with_cuda_array_interface(a)
 */
struct __pyx_opt_args_4cupy_4core_4core_array {
  int __pyx_n;
  PyObject *dtype;
  int copy;
  PyObject *order;
  int subok;
  Py_ssize_t ndmin;
};
struct __pyx_opt_args_4cupy_4core_22_routines_manipulation_rollaxis;

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

/* "cudnn.pxd":6
 * ###############################################################################
 * 
 * cpdef enum:             # <<<<<<<<<<<<<<
 *     CUDNN_DATA_FLOAT = 0
 *     CUDNN_DATA_DOUBLE = 1
 */
enum  {
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_FLOAT = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_DOUBLE = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_HALF = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DEFAULT_MATH = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PROPAGATE_NAN = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NON_DETERMINISTIC = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DETERMINISTIC = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NHWC = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_ADD = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_MUL = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_MIN = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_MAX = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_SQRT = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_OP_TENSOR_NOT = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_ADD = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MUL = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MIN = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MAX = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_AMAX = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_AVG = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_NORM1 = 6,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_NORM2 = 7,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MUL_NO_ZEROS = 8,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_NO_INDICES = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_FLATTENED_INDICES = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_32BIT_INDICES = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_64BIT_INDICES = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_16BIT_INDICES = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_8BIT_INDICES = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_IMAGE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_SAME_HW = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_FEATURE_MAP = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_SAME_CHW = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_SAME_C = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ADD_FULL_TENSOR = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CROSS_CORRELATION = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_NO_WORKSPACE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_PREFER_FASTEST = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_GEMM = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_DIRECT = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_FFT = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD = 6,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED = 7,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_NO_WORKSPACE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_PREFER_FASTEST = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0 = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3 = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_NO_WORKSPACE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_PREFER_FASTEST = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_0 = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_FAST = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_ACCURATE = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_LOG = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_MODE_INSTANCE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_MODE_CHANNEL = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_POOLING_MAX = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_POOLING_MAX_DETERMINISTIC = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_SIGMOID = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_RELU = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_TANH = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_CLIPPED_RELU = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_ELU = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ACTIVATION_IDENTITY = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_LRN_CROSS_CHANNEL_DIM1 = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DIVNORM_PRECOMPUTED_MEANS = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_PER_ACTIVATION = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_SPATIAL = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_SPATIAL_PERSISTENT = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CTC_LOSS_ALGO_DETERMINISTIC = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CTC_LOSS_ALGO_NON_DETERMINISTIC = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_OPS_BN = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_OPS_BN_ACTIVATION = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_OPS_BN_ADD_ACTIVATION = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_RELU = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_TANH = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_LSTM = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_GRU = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_UNIDIRECTIONAL = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BIDIRECTIONAL = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_ALGO_STANDARD = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_ALGO_PERSIST_STATIC = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_ALGO_PERSIST_DYNAMIC = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_PACKED = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_DATA_LAYOUT_BATCH_MAJOR_UNPACKED = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_DISABLED = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_ENABLED = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SKIP_INPUT = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SAMPLER_BILINEAR = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_RUNTIME_PREREQUISITE_MISSING = 11,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_RUNTIME_IN_PROGRESS = 12,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_RUNTIME_FP_OVERFLOW = 13,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ERRQUERY_RAWCODE = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ERRQUERY_NONBLOCKING = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ERRQUERY_BLOCKING = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_SCALE_BIAS_ACTIVATION_CONV_BNSTATS = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_SCALE_BIAS_ACTIVATION_WGRAD = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_BN_FINALIZE_STATISTICS_TRAINING = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_BN_FINALIZE_STATISTICS_INFERENCE = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_CONV_SCALE_BIAS_ADD_ACTIVATION = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_SCALE_BIAS_ADD_ACTIVATION_GEN_BITMASK = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_FUSED_DACTIVATION_FORK_DBATCHNORM = 6,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_XDESC = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_XDATA_PLACEHOLDER = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_MODE = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQSCALEBIAS_DESC = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_DESC = 6,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_CONV_DESC = 7,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_WDESC = 8,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_WDATA_PLACEHOLDER = 9,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DWDESC = 10,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DWDATA_PLACEHOLDER = 11,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YDESC = 12,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YDATA_PLACEHOLDER = 13,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DYDESC = 14,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DYDATA_PLACEHOLDER = 15,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSTATS_DESC = 16,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSUM_PLACEHOLDER = 17,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSQSUM_PLACEHOLDER = 18,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SCALEBIAS_MEANVAR_DESC = 19,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SCALE_PLACEHOLDER = 20,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_BIAS_PLACEHOLDER = 21,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER = 22,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER = 23,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER = 24,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER = 25,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ZDESC = 26,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ZDATA_PLACEHOLDER = 27,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQSCALEBIAS_DESC = 28,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER = 29,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER = 30,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_BITMASK_DESC = 31,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER = 32,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DXDESC = 33,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DXDATA_PLACEHOLDER = 34,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DZDESC = 35,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DZDATA_PLACEHOLDER = 36,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DSCALE_PLACEHOLDER = 37,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DBIAS_PLACEHOLDER = 38,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_NULL = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_ELEM_ALIGNED = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_16B_ALIGNED = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_XDATA = 0,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_EQSCALE = 1,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_EQBIAS = 2,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_WDATA = 3,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_DWDATA = 4,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_YDATA = 5,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_DYDATA = 6,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_YSUM = 7,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_YSQSUM = 8,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_WORKSPACE = 9,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_SCALE = 10,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_BIAS = 11,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_SAVED_MEAN = 12,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_SAVED_INVSTD = 13,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_RUNNING_MEAN = 14,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_RUNNING_VAR = 15,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_ZDATA = 16,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_Z_EQSCALE = 17,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_Z_EQBIAS = 18,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_ACTIVATION_BITMASK = 19,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_DXDATA = 20,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_DZDATA = 21,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_DSCALE = 22,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PTR_BN_DBIAS = 23,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES = 0x64,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT = 0x65,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR = 0x66,
  __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EPSILON = 0x67
};
struct __pyx_opt_args_4cupy_4core_8internal__normalize_order;

/* "internal.pxd":49
 * cpdef float from_float16(uint16_t v)
 * 
 * cdef int _normalize_order(order, cpp_bool allow_k=*) except? 0             # <<<<<<<<<<<<<<
 * 
 * cpdef bint _contig_axes(tuple axes)
 */
struct __pyx_opt_args_4cupy_4core_8internal__normalize_order {
  int __pyx_n;
  bool allow_k;
};
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor;
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor;
struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor;
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn;
struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training;

/* "cupy/cudnn.pyx":121
 * 
 * cpdef _create_tensor_nd_descriptor(
 *         size_t desc, core.ndarray arr, int data_type=-1):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[int] c_shape, c_strides
 *     cdef Py_ssize_t itemsize, s
 */
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor {
  int __pyx_n;
  int data_type;
};

/* "cupy/cudnn.pyx":145
 * 
 * 
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,             # <<<<<<<<<<<<<<
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 */
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor {
  int __pyx_n;
  int format;
};

/* "cupy/cudnn.pyx":176
 * 
 * cpdef _create_filter_descriptor(
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[int] c_shape
 *     cdef Py_ssize_t s, ndim = arr._shape.size()
 */
struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor {
  int __pyx_n;
  int format;
};

/* "cupy/cudnn.pyx":2027
 * 
 * cdef _create_tensor_descriptor_for_bn(
 *         size_t desc, core.ndarray arr, bint is_for_conv2d,             # <<<<<<<<<<<<<<
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 *     assert arr._c_contiguous
 */
struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn {
  int __pyx_n;
  int format;
};

/* "cupy/cudnn.pyx":2109
 * 
 * cdef _batch_normalization_forward_training(
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,             # <<<<<<<<<<<<<<
 *         core.ndarray running_mean, core.ndarray running_var,
 *         mean, inv_std, double eps, double decay,
 */
struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training {
  int __pyx_n;
  int d_layout;
};

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


/* "device.pxd":12
 *         object _destroy_func
 * 
 * cdef class Device:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int id
 */
struct __pyx_obj_4cupy_4cuda_6device_Device {
  PyObject_HEAD
  struct __pyx_vtabstruct_4cupy_4cuda_6device_Device *__pyx_vtab;
  int id;
  PyObject *_device_stack;
};


/* "memory.pxd":11
 * 
 * @cython.no_gc
 * cdef class BaseMemory:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory {
  PyObject_HEAD
  intptr_t ptr;
  size_t size;
  int device_id;
};


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


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


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


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


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


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


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


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


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


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


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


/* "cudnn.pxd":250
 * ###############################################################################
 * 
 * cdef class CuDNNAlgoPerf:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int algo
 */
struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf {
  PyObject_HEAD
  int algo;
  int status;
  float time;
  size_t memory;
  int determinism;
  int mathType;
};


/* "cupy/cudnn.pyx":82
 * 
 * 
 * cdef class Descriptor:             # <<<<<<<<<<<<<<
 * 
 *     cdef public size_t value
 */
struct __pyx_obj_4cupy_5cudnn_Descriptor {
  PyObject_HEAD
  size_t value;
  PyObject *destroy;
};


/* "cupy/cudnn.pyx":863
 * 
 * 
 * cdef class _DescriptorArray:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_4cupy_5cudnn__DescriptorArray {
  PyObject_HEAD
  std::vector<size_t>  _value;
  PyObject *_destroy;
};


/* "cupy/cudnn.pyx":1234
 * 
 * 
 * cdef class DropoutStates:             # <<<<<<<<<<<<<<
 * 
 *     cdef public:
 */
struct __pyx_obj_4cupy_5cudnn_DropoutStates {
  PyObject_HEAD
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *_states;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *_desc;
};


/* "cupy/cudnn.pyx":1311
 * 
 * 
 * cdef class _Algorithm:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int algo
 */
struct __pyx_obj_4cupy_5cudnn__Algorithm {
  PyObject_HEAD
  int algo;
  int mathType;
  size_t memory;
};



/* "device.pxd":12
 *         object _destroy_func
 * 
 * cdef class Device:             # <<<<<<<<<<<<<<
 *     cdef:
 *         public int id
 */

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


/* "memory.pxd":20
 * 
 * @cython.final
 * cdef class MemoryPointer:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

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


/* "memory.pxd":49
 * 
 * 
 * cdef class MemoryPool:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

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


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

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


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

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


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

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


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

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


/* "cupy/core/core.pxd":7
 * from cupy.cuda.function cimport Module
 * 
 * cdef class ndarray:             # <<<<<<<<<<<<<<
 *     cdef:
 *         object __weakref__
 */

struct __pyx_vtabstruct_4cupy_4core_4core_ndarray {
  PyObject *(*_init_fast)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, PyObject *, int);
  PyObject *(*item)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*tolist)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*tobytes)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tobytes *__pyx_optional_args);
  PyObject *(*tofile)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_tofile *__pyx_optional_args);
  PyObject *(*dump)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*dumps)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*astype)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_astype *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*copy)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_copy *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_view *__pyx_optional_args);
  PyObject *(*fill)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*swapaxes)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, Py_ssize_t, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*flatten)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*ravel)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_ravel *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*squeeze)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_squeeze *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*take)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_take *__pyx_optional_args);
  PyObject *(*put)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_put *__pyx_optional_args);
  PyObject *(*repeat)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_repeat *__pyx_optional_args);
  PyObject *(*choose)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_choose *__pyx_optional_args);
  PyObject *(*sort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sort *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argsort)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argsort *__pyx_optional_args);
  PyObject *(*partition)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_partition *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argpartition)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argpartition *__pyx_optional_args);
  PyObject *(*nonzero)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*diagonal)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_diagonal *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*max)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_max *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argmax)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmax *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*min)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_min *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*argmin)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_argmin *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*clip)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_clip *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*round)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_round *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*trace)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_trace *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*sum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_sum *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*cumsum)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumsum *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*mean)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_mean *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*var)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_var *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*std)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_std *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*prod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_prod *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*cumprod)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_cumprod *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*all)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_all *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*any)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_any *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*conj)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*get)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_get *__pyx_optional_args);
  PyObject *(*set)(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_set *__pyx_optional_args);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*reduced_view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_4core_4core_7ndarray_reduced_view *__pyx_optional_args);
  PyObject *(*_update_c_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_update_f_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_update_contiguity)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
  PyObject *(*_set_shape_and_strides)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  const &, int, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4core_4core_ndarray *(*_view)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, std::vector<Py_ssize_t>  const &, int, int);
  PyObject *(*_set_contiguous_strides)(struct __pyx_obj_4cupy_4core_4core_ndarray *, Py_ssize_t, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4cupy_4cuda_8function_CPointer *(*get_pointer)(struct __pyx_obj_4cupy_4core_4core_ndarray *);
  PyObject *(*toDlpack)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *__pyx_vtabptr_4cupy_4core_4core_ndarray;


/* "cupy/core/core.pxd":90
 * 
 * 
 * cdef class Indexer:             # <<<<<<<<<<<<<<
 *     cdef:
 *         readonly Py_ssize_t size
 */

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

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

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

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

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

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

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

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

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

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

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

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

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

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

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

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

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

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

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

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

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

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

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

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

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

/* UnaryNegOverflows.proto */
#define UNARY_NEG_WOULD_OVERFLOW(x)\
        (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

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

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

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

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

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

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

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

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

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

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

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

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

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

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

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

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

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

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

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

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

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

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

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

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

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

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

/* RaiseKeywordRequired.proto */
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2))
#endif

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

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

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

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

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

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

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

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

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

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

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

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

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

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

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

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

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

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

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

/* CIntFromPy.proto */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);

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

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

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


/* Module declarations from 'libcpp' */

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

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

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

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

/* Module declarations from 'cython' */

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

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

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

/* Module declarations from 'cupy.cuda.memory' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_BaseMemory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_MemoryPool = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory = 0;
static PyTypeObject *__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator = 0;
static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(*__pyx_f_4cupy_4cuda_6memory_alloc)(PyObject *, int __pyx_skip_dispatch); /*proto*/

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

/* Module declarations from 'cupy.core.core' */
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_ndarray = 0;
static PyTypeObject *__pyx_ptype_4cupy_4core_4core_Indexer = 0;
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_4core__internal_ascontiguousarray)(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.core._routines_manipulation' */
static PyTypeObject *__pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast = 0;
static struct __pyx_obj_4cupy_4core_4core_ndarray *(*__pyx_f_4cupy_4core_22_routines_manipulation__reshape)(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.cudnn' */
static PyTypeObject *__pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf = 0;
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getVersion)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_queryRuntimeError)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_create)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroy)(size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor)(size_t, int, int, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getTensor4dDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setTensorNdDescriptor)(size_t, int, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_addTensor_v3)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createOpTensorDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setOpTensorDescriptor)(size_t, int, int, int, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createReduceTensorDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setReduceTensorDescriptor)(size_t, int, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setFilter4dDescriptor_v4)(size_t, int, int, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setFilterNdDescriptor_v4)(size_t, int, int, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getFilterNdDescriptor)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType)(size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setConvolutionGroupCount)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setConvolution2dDescriptor_v5)(size_t, int, int, int, int, int, int, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setConvolutionNdDescriptor_v3)(size_t, int, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx_v7)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v6)(size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v7)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardWorkspaceSize)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_convolutionForward)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx_v7)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v6)(size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v7)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterWorkspaceSize)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardFilter_v3)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx_v7)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v6)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v7)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataWorkspaceSize)(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardData_v3)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createPoolingDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setPooling2dDescriptor_v4)(size_t, int, int, int, int, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setPoolingNdDescriptor_v4)(size_t, int, int, int, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_poolingForward)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_poolingBackward)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_deriveBNTensorDescriptor)(size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTraining)(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, double, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardInference)(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackward)(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTrainingEx)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, double, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationForwardTrainingExWorkspaceSize)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackwardEx)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationBackwardExWorkspaceSize)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationTrainingExReserveSpaceSize)(size_t, int, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor)(size_t, int, int, double, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_softmaxForward)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_softmaxBackward)(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_activationForward_v4)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_activationBackward_v4)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createDropoutDescriptor)(int __pyx_skip_dispatch); /*proto*/
static Py_ssize_t (*__pyx_f_4cupy_4cuda_5cudnn_dropoutGetStatesSize)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setDropoutDescriptor)(size_t, size_t, float, size_t, size_t, unsigned PY_LONG_LONG, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getDropoutReserveSpaceSize)(size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_dropoutForward)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_dropoutBackward)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createCTCLossDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setCTCLossDescriptor)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_getCTCLossWorkspaceSize)(size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_CTCLoss)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createRNNDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v5)(size_t, int, int, size_t, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v6)(size_t, size_t, int, int, size_t, int, int, int, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode)(size_t, int, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createRNNDataDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setRNNDataDescriptor)(size_t, int, size_t, int, int, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getRNNWorkspaceSize)(size_t, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getRNNTrainingReserveSize)(size_t, size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerMatrixParams)(size_t, size_t, int, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerBiasParams)(size_t, size_t, int, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNForwardInference)(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNForwardTraining)(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardData)(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeights)(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNForwardInferenceEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNForwardTrainingEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardDataEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeightsEx)(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static size_t (*__pyx_f_4cupy_4cuda_5cudnn_createSpatialTransformerDescriptor)(int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setSpatialTransformerDescriptor)(size_t, size_t, int, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsConstParamPack)(int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setFusedOpsConstParamPackAttribute)(size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getFusedOpsConstParamPackAttribute)(size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsVariantParamPack)(int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute)(size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute)(size_t, int, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsPlan)(int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_makeFusedOpsPlan)(size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_5cudnn_fusedOpsExecute)(size_t, size_t, size_t, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.core.internal' */
static Py_ssize_t (*__pyx_f_4cupy_4core_8internal_prod_sequence)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cudnn' */
static PyTypeObject *__pyx_ptype_4cupy_5cudnn_Descriptor = 0;
static PyTypeObject *__pyx_ptype_4cupy_5cudnn__DescriptorArray = 0;
static PyTypeObject *__pyx_ptype_4cupy_5cudnn_DropoutStates = 0;
static PyTypeObject *__pyx_ptype_4cupy_5cudnn__Algorithm = 0;
static int __pyx_v_4cupy_5cudnn__cudnn_version;
static PyObject *__pyx_v_4cupy_5cudnn__thread_local = 0;
static std::vector<size_t>  __pyx_v_4cupy_5cudnn__handles;
static size_t __pyx_v_4cupy_5cudnn__max_workspace_size;
static PyObject *__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache = 0;
static PyObject *__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache = 0;
static PyObject *__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache = 0;
static PyObject *__pyx_v_4cupy_5cudnn__algorithm_fwd_cache = 0;
static PyObject *__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache = 0;
static PyObject *__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache = 0;
static size_t __pyx_f_4cupy_5cudnn_get_handle(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__get_nd_tensor_cache(int __pyx_skip_dispatch); /*proto*/
static size_t __pyx_f_4cupy_5cudnn_get_max_workspace_size(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_max_workspace_size(PyObject *, int __pyx_skip_dispatch); /*proto*/
static int __pyx_f_4cupy_5cudnn_get_data_type(PyObject *, int __pyx_skip_dispatch); /*proto*/
static int __pyx_f_4cupy_5cudnn__get_byte_size(int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_filter_descriptor(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_convolution_descriptor(size_t, PyObject *, PyObject *, PyObject *, int, PyObject *, int, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_5cudnn__ascontiguousarray_normalized_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_pooling_descriptor(size_t, PyObject *, PyObject *, PyObject *, int); /*proto*/
static struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_f_4cupy_5cudnn__create_rnn_data_descriptor(void); /*proto*/
static struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *); /*proto*/
static int __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_softmax(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(PyObject *, PyObject *); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(PyObject *); /*proto*/
static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_f_4cupy_5cudnn__make_rnn_workspace(struct __pyx_obj_4cupy_5cudnn_Descriptor *, int, struct __pyx_obj_4cupy_5cudnn__DescriptorArray *); /*proto*/
static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_f_4cupy_5cudnn__make_rnn_reserve_space(struct __pyx_obj_4cupy_5cudnn_Descriptor *, int, struct __pyx_obj_4cupy_5cudnn__DescriptorArray *); /*proto*/
static Py_ssize_t __pyx_f_4cupy_5cudnn__get_n_layers(int, struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_5cudnn__make_rnn_result_array(int, Py_ssize_t, struct __pyx_obj_4cupy_4core_4core_ndarray *); /*proto*/
static int __pyx_f_4cupy_5cudnn_is_tensor_core_available(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, size_t, size_t, size_t, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch); /*proto*/
static int __pyx_f_4cupy_5cudnn__should_use_tensor_core(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_bn(size_t, struct __pyx_obj_4cupy_4core_4core_ndarray *, int, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__get_dtype_of_tensor_descriptor(size_t); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__batch_normalization_forward_training(struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, struct __pyx_obj_4cupy_4core_4core_ndarray *, PyObject *, PyObject *, double, double, int, int, int, struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_fused_ops_const_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *, int, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_get_fused_ops_const_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_fused_ops_variant_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *, int, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_get_fused_ops_variant_param_pack_attribute(size_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle_Descriptor__set_state(struct __pyx_obj_4cupy_5cudnn_Descriptor *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle__DescriptorArray__set_state(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle_DropoutStates__set_state(struct __pyx_obj_4cupy_5cudnn_DropoutStates *, PyObject *); /*proto*/
static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &); /*proto*/
static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *); /*proto*/
static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &); /*proto*/
static std::vector<int>  __pyx_convert_vector_from_py_int(PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "cupy.cudnn"
extern int __pyx_module_is_main_cupy__cudnn;
int __pyx_module_is_main_cupy__cudnn = 0;

/* Implementation of 'cupy.cudnn' */
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_reversed;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_DeprecationWarning;
static PyObject *__pyx_builtin_RuntimeError;
static const char __pyx_k_W[] = "W";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_f[] = "f";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_w[] = "w";
static const char __pyx_k_x[] = "x";
static const char __pyx_k_y[] = "y";
static const char __pyx_k_cx[] = "cx";
static const char __pyx_k_cy[] = "cy";
static const char __pyx_k_dW[] = "dW";
static const char __pyx_k_dw[] = "dw";
static const char __pyx_k_dy[] = "dy";
static const char __pyx_k_gW[] = "gW";
static const char __pyx_k_gx[] = "gx";
static const char __pyx_k_gy[] = "gy";
static const char __pyx_k_hx[] = "hx";
static const char __pyx_k_hy[] = "hy";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_xs[] = "xs";
static const char __pyx_k_ys[] = "ys";
static const char __pyx_k_W_2[] = "W: {}";
static const char __pyx_k__77[] = "_";
static const char __pyx_k_arr[] = "arr";
static const char __pyx_k_b_2[] = "b: {}";
static const char __pyx_k_dcx[] = "dcx";
static const char __pyx_k_dcy[] = "dcy";
static const char __pyx_k_dhx[] = "dhx";
static const char __pyx_k_dhy[] = "dhy";
static const char __pyx_k_dim[] = "dim";
static const char __pyx_k_dxs[] = "dxs";
static const char __pyx_k_dys[] = "dys";
static const char __pyx_k_eps[] = "eps";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_key[] = "key";
static const char __pyx_k_mat[] = "mat";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_one[] = "one";
static const char __pyx_k_ops[] = "ops";
static const char __pyx_k_pad[] = "pad";
static const char __pyx_k_ptr[] = "ptr";
static const char __pyx_k_var[] = "var";
static const char __pyx_k_x_2[] = "x: {}";
static const char __pyx_k_y_2[] = "y: {}";
static const char __pyx_k_None[] = "None";
static const char __pyx_k_algo[] = "algo";
static const char __pyx_k_attr[] = "attr";
static const char __pyx_k_auto[] = "auto";
static const char __pyx_k_axis[] = "axis";
static const char __pyx_k_beta[] = "beta";
static const char __pyx_k_bias[] = "bias";
static const char __pyx_k_char[] = "char";
static const char __pyx_k_coef[] = "coef";
static const char __pyx_k_cupy[] = "cupy";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_desc[] = "desc";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_loss[] = "loss";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mean[] = "mean";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "name";
static const char __pyx_k_ndim[] = "ndim";
static const char __pyx_k_perf[] = "perf";
static const char __pyx_k_plan[] = "plan";
static const char __pyx_k_seed[] = "seed";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_util[] = "util";
static const char __pyx_k_warn[] = "warn";
static const char __pyx_k_zero[] = "zero";
static const char __pyx_k_alpha[] = "alpha";
static const char __pyx_k_cache[] = "cache";
static const char __pyx_k_cudnn[] = "cudnn";
static const char __pyx_k_debug[] = "debug";
static const char __pyx_k_decay[] = "decay";
static const char __pyx_k_dim_A[] = "dim_A";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_gamma[] = "gamma";
static const char __pyx_k_gbeta[] = "gbeta";
static const char __pyx_k_infos[] = "infos";
static const char __pyx_k_ksize[] = "ksize";
static const char __pyx_k_layer[] = "layer";
static const char __pyx_k_local[] = "local";
static const char __pyx_k_never[] = "never";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_param[] = "param";
static const char __pyx_k_probs[] = "probs";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_always[] = "always";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_atexit[] = "atexit";
static const char __pyx_k_b_desc[] = "b_desc";
static const char __pyx_k_bn_ops[] = "bn_ops";
static const char __pyx_k_ctypes[] = "ctypes";
static const char __pyx_k_dev_id[] = "dev_id";
static const char __pyx_k_device[] = "device";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_ggamma[] = "ggamma";
static const char __pyx_k_groups[] = "groups";
static const char __pyx_k_handle[] = "handle";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_labels[] = "labels";
static const char __pyx_k_length[] = "length";
static const char __pyx_k_memory[] = "memory";
static const char __pyx_k_name_2[] = "__name__";
static const char __pyx_k_offset[] = "offset";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_states[] = "states";
static const char __pyx_k_stride[] = "stride";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_w_desc[] = "w_desc";
static const char __pyx_k_x_desc[] = "x_desc";
static const char __pyx_k_y_desc[] = "y_desc";
static const char __pyx_k_b_shape[] = "b_shape";
static const char __pyx_k_cx_desc[] = "cx_desc";
static const char __pyx_k_cy_desc[] = "cy_desc";
static const char __pyx_k_dropout[] = "dropout";
static const char __pyx_k_dw_desc[] = "dw_desc";
static const char __pyx_k_dy_desc[] = "dy_desc";
static const char __pyx_k_float16[] = "float16";
static const char __pyx_k_float32[] = "float32";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_gy_desc[] = "gy_desc";
static const char __pyx_k_hx_desc[] = "hx_desc";
static const char __pyx_k_hy_desc[] = "hy_desc";
static const char __pyx_k_indices[] = "indices";
static const char __pyx_k_inv_std[] = "inv_std";
static const char __pyx_k_lengths[] = "lengths";
static const char __pyx_k_n_units[] = "n_units";
static const char __pyx_k_nb_dims[] = "nb_dims";
static const char __pyx_k_op_type[] = "op_type";
static const char __pyx_k_rstatus[] = "rstatus";
static const char __pyx_k_shape_2[] = "_shape";
static const char __pyx_k_strides[] = "_strides";
static const char __pyx_k_act_desc[] = "act_desc";
static const char __pyx_k_biasData[] = "biasData";
static const char __pyx_k_biasDesc[] = "biasDesc";
static const char __pyx_k_ctc_desc[] = "ctc_desc";
static const char __pyx_k_ctc_loss[] = "ctc_loss";
static const char __pyx_k_d_layout[] = "d_layout";
static const char __pyx_k_dcx_desc[] = "dcx_desc";
static const char __pyx_k_dcy_desc[] = "dcy_desc";
static const char __pyx_k_dhx_desc[] = "dhx_desc";
static const char __pyx_k_dhy_desc[] = "dhy_desc";
static const char __pyx_k_dilation[] = "dilation";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_handle_2[] = "_handle";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_mat_desc[] = "mat_desc";
static const char __pyx_k_mathType[] = "mathType";
static const char __pyx_k_n_layers[] = "n_layers";
static const char __pyx_k_py_cudnn[] = "py_cudnn";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_register[] = "register";
static const char __pyx_k_reversed[] = "reversed";
static const char __pyx_k_rnn_desc[] = "rnn_desc";
static const char __pyx_k_rnn_mode[] = "rnn_mode";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_var_pack[] = "var_pack";
static const char __pyx_k_w_layout[] = "w_layout";
static const char __pyx_k_warnings[] = "warnings";
static const char __pyx_k_xs_descs[] = "xs_descs";
static const char __pyx_k_ys_descs[] = "ys_descs";
static const char __pyx_k_Algorithm[] = "_Algorithm";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_add_infos[] = "add_infos";
static const char __pyx_k_algorithm[] = "algorithm";
static const char __pyx_k_auto_tune[] = "auto_tune";
static const char __pyx_k_bias_desc[] = "bias_desc";
static const char __pyx_k_byte_size[] = "byte_size";
static const char __pyx_k_conv_desc[] = "conv_desc";
static const char __pyx_k_cupy_cuda[] = "cupy.cuda";
static const char __pyx_k_data_type[] = "data_type";
static const char __pyx_k_destroyer[] = "destroyer";
static const char __pyx_k_direction[] = "direction";
static const char __pyx_k_dxs_descs[] = "dxs_descs";
static const char __pyx_k_dys_descs[] = "dys_descs";
static const char __pyx_k_float_one[] = "float_one";
static const char __pyx_k_gradients[] = "gradients";
static const char __pyx_k_math_type[] = "math_type";
static const char __pyx_k_need_cast[] = "need_cast";
static const char __pyx_k_pool_desc[] = "pool_desc";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_save_mean[] = "save_mean";
static const char __pyx_k_strides_2[] = "strides";
static const char __pyx_k_threading[] = "threading";
static const char __pyx_k_work_size[] = "work_size";
static const char __pyx_k_workspace[] = "workspace";
static const char __pyx_k_CuDNNError[] = "CuDNNError";
static const char __pyx_k_Descriptor[] = "Descriptor";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_add_tensor[] = "add_tensor";
static const char __pyx_k_batch_size[] = "batch_size";
static const char __pyx_k_const_pack[] = "const_pack";
static const char __pyx_k_conv_param[] = "conv_param";
static const char __pyx_k_cudnn_mode[] = "cudnn_mode";
static const char __pyx_k_cupy_cudnn[] = "cupy.cudnn";
static const char __pyx_k_descriptor[] = "descriptor";
static const char __pyx_k_double_one[] = "double_one";
static const char __pyx_k_float_zero[] = "float_zero";
static const char __pyx_k_input_mode[] = "input_mode";
static const char __pyx_k_labels_ptr[] = "labels_ptr";
static const char __pyx_k_num_layers[] = "num_layers";
static const char __pyx_k_probs_desc[] = "probs_desc";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_query_mode[] = "query_mode";
static const char __pyx_k_state_size[] = "state_size";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_double_zero[] = "double_zero";
static const char __pyx_k_dtype_param[] = "dtype_param";
static const char __pyx_k_filter_desc[] = "filter_desc";
static const char __pyx_k_hidden_size[] = "hidden_size";
static const char __pyx_k_param_label[] = "param_label";
static const char __pyx_k_reduce_type[] = "reduce_type";
static const char __pyx_k_running_var[] = "running_var";
static const char __pyx_k_srcDestData[] = "srcDestData";
static const char __pyx_k_srcDestDesc[] = "srcDestDesc";
static const char __pyx_k_tensor_core[] = "tensor_core";
static const char __pyx_k_x_data_desc[] = "x_data_desc";
static const char __pyx_k_y_data_desc[] = "y_data_desc";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_c_contiguous[] = "c_contiguous";
static const char __pyx_k_dropout_desc[] = "dropout_desc";
static const char __pyx_k_dx_data_desc[] = "dx_data_desc";
static const char __pyx_k_dy_data_desc[] = "dy_data_desc";
static const char __pyx_k_input_length[] = "input_length";
static const char __pyx_k_label_length[] = "label_length";
static const char __pyx_k_lin_layer_id[] = "lin_layer_id";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_relu_nan_opt[] = "relu_nan_opt";
static const char __pyx_k_running_mean[] = "running_mean";
static const char __pyx_k_sampler_type[] = "sampler_type";
static const char __pyx_k_save_inv_std[] = "save_inv_std";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_DropoutStates[] = "DropoutStates";
static const char __pyx_k_arr_or_scaler[] = "arr_or_scaler";
static const char __pyx_k_derivedBnDesc[] = "derivedBnDesc";
static const char __pyx_k_deterministic[] = "deterministic";
static const char __pyx_k_dropout_ratio[] = "dropout_ratio";
static const char __pyx_k_is_for_conv2d[] = "is_for_conv2d";
static const char __pyx_k_nan_prop_mode[] = "nan_prop_mode";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_reserve_space[] = "reserve_space";
static const char __pyx_k_reset_handles[] = "reset_handles";
static const char __pyx_k_cupy_cudnn_pyx[] = "cupy/cudnn.pyx";
static const char __pyx_k_desc_or_scalar[] = "desc_or_scalar";
static const char __pyx_k_direction_mode[] = "direction_mode";
static const char __pyx_k_get_array_info[] = "_get_array_info";
static const char __pyx_k_gradients_desc[] = "gradients_desc";
static const char __pyx_k_workspace_size[] = "workspace_size";
static const char __pyx_k_DescriptorArray[] = "_DescriptorArray";
static const char __pyx_k_list_attr_param[] = "list_attr_param";
static const char __pyx_k_pooling_forward[] = "pooling_forward";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_softmax_forward[] = "softmax_forward";
static const char __pyx_k_use_tensor_core[] = "use_tensor_core";
static const char __pyx_k_elementwise_copy[] = "elementwise_copy";
static const char __pyx_k_input_length_ptr[] = "input_length_ptr";
static const char __pyx_k_label_length_ptr[] = "label_length_ptr";
static const char __pyx_k_pooling_backward[] = "pooling_backward";
static const char __pyx_k_softmax_backward[] = "softmax_backward";
static const char __pyx_k_tensor_core_mode[] = "tensor_core_mode";
static const char __pyx_k_cupy_core__ufuncs[] = "cupy.core._ufuncs";
static const char __pyx_k_fused_ops_execute[] = "fused_ops_execute";
static const char __pyx_k_rnn_backward_data[] = "rnn_backward_data";
static const char __pyx_k_DeprecationWarning[] = "DeprecationWarning";
static const char __pyx_k_PerformanceWarning[] = "PerformanceWarning";
static const char __pyx_k_activation_forward[] = "activation_forward";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_max_workspace_size[] = "max_workspace_size";
static const char __pyx_k_activation_backward[] = "activation_backward";
static const char __pyx_k_convolution_forward[] = "convolution_forward";
static const char __pyx_k_destroyFusedOpsPlan[] = "destroyFusedOpsPlan";
static const char __pyx_k_make_fused_ops_plan[] = "make_fused_ops_plan";
static const char __pyx_k_state_size_in_bytes[] = "state_size_in_bytes";
static const char __pyx_k_destroyRNNDescriptor[] = "destroyRNNDescriptor";
static const char __pyx_k_rnn_backward_data_ex[] = "rnn_backward_data_ex";
static const char __pyx_k_rnn_backward_weights[] = "rnn_backward_weights";
static const char __pyx_k_rnn_forward_training[] = "rnn_forward_training";
static const char __pyx_k_create_dropout_states[] = "create_dropout_states";
static const char __pyx_k_create_fused_ops_plan[] = "create_fused_ops_plan";
static const char __pyx_k_create_rnn_descriptor[] = "create_rnn_descriptor";
static const char __pyx_k_cudnn_nd_tensor_cache[] = "cudnn_nd_tensor_cache";
static const char __pyx_k_d_layout_r_w_layout_r[] = "d_layout={!r}, w_layout={!r}";
static const char __pyx_k_rnn_forward_inference[] = "rnn_forward_inference";
static const char __pyx_k_set_dropout_descriptor[] = "set_dropout_descriptor";
static const char __pyx_k_Invalid_cuDNN_data_type[] = "Invalid cuDNN data type: {}";
static const char __pyx_k_Unknown_cudnn_data_type[] = "Unknown cudnn data type {} ";
static const char __pyx_k_destroyFilterDescriptor[] = "destroyFilterDescriptor";
static const char __pyx_k_destroyTensorDescriptor[] = "destroyTensorDescriptor";
static const char __pyx_k_pyx_unpickle_Descriptor[] = "__pyx_unpickle_Descriptor";
static const char __pyx_k_rnn_backward_weights_ex[] = "rnn_backward_weights_ex";
static const char __pyx_k_rnn_forward_training_ex[] = "rnn_forward_training_ex";
static const char __pyx_k_shape_r_dtype_strides_r[] = "shape={!r}, dtype={}, strides={!r}";
static const char __pyx_k_create_filter_descriptor[] = "create_filter_descriptor";
static const char __pyx_k_create_tensor_descriptor[] = "create_tensor_descriptor";
static const char __pyx_k_destroyCTCLossDescriptor[] = "destroyCTCLossDescriptor";
static const char __pyx_k_destroyDropoutDescriptor[] = "destroyDropoutDescriptor";
static const char __pyx_k_destroyPoolingDescriptor[] = "destroyPoolingDescriptor";
static const char __pyx_k_destroyRNNDataDescriptor[] = "destroyRNNDataDescriptor";
static const char __pyx_k_rnn_forward_inference_ex[] = "rnn_forward_inference_ex";
static const char __pyx_k_auto_tune_r_tensor_core_r[] = "auto_tune={!r}, tensor_core={!r}";
static const char __pyx_k_convolution_backward_data[] = "convolution_backward_data";
static const char __pyx_k_create_dropout_descriptor[] = "create_dropout_descriptor";
static const char __pyx_k_create_pooling_descriptor[] = "create_pooling_descriptor";
static const char __pyx_k_destroyOpTensorDescriptor[] = "destroyOpTensorDescriptor";
static const char __pyx_k_unknown_cudnnTensorFormat[] = "unknown cudnnTensorFormat: {}";
static const char __pyx_k_create_ctc_loss_descriptor[] = "_create_ctc_loss_descriptor";
static const char __pyx_k_pyx_unpickle_DropoutStates[] = "__pyx_unpickle_DropoutStates";
static const char __pyx_k_convolution_backward_filter[] = "convolution_backward_filter";
static const char __pyx_k_create_op_tensor_descriptor[] = "create_op_tensor_descriptor";
static const char __pyx_k_create_tensor_nd_descriptor[] = "create_tensor_nd_descriptor";
static const char __pyx_k_destroyActivationDescriptor[] = "destroyActivationDescriptor";
static const char __pyx_k_No_available_algorithm_found[] = "No available algorithm found.";
static const char __pyx_k_batch_normalization_backward[] = "batch_normalization_backward";
static const char __pyx_k_create_activation_descriptor[] = "create_activation_descriptor";
static const char __pyx_k_destroyConvolutionDescriptor[] = "destroyConvolutionDescriptor";
static const char __pyx_k_func_cudnnConvolutionForward[] = "func: cudnnConvolutionForward";
static const char __pyx_k_create_convolution_descriptor[] = "create_convolution_descriptor";
static const char __pyx_k_destroyFusedOpsConstParamPack[] = "destroyFusedOpsConstParamPack";
static const char __pyx_k_destroyReduceTensorDescriptor[] = "destroyReduceTensorDescriptor";
static const char __pyx_k_get_rnn_lin_layer_bias_params[] = "get_rnn_lin_layer_bias_params";
static const char __pyx_k_pyx_unpickle__DescriptorArray[] = "__pyx_unpickle__DescriptorArray";
static const char __pyx_k_A_numerical_overflow_might_have[] = "A numerical overflow might have happend in cuDNNbatch normalization (status:{})";
static const char __pyx_k_Dtype_is_not_supported_in_cuDNN[] = "Dtype {} is not supported in cuDNN";
static const char __pyx_k_No_conv_bwd_data_algo_available[] = "No conv bwd data algo available with workspace size less equal {}";
static const char __pyx_k_No_conv_fwd_algo_available_with[] = "No conv fwd algo available with workspace size less equal {}";
static const char __pyx_k_Tensor_Core_mode_is_set_but_the[] = "Tensor Core mode is set but the selected convolution forward algorithm is not a Tensor Core enabled algorithm. This might be due to lack of workspace memory. x.shape:{}, W.shape:{}, y.shape:{}, pad:{}, stride:{}";
static const char __pyx_k_The_best_algo_of_conv_fwd_might[] = "The best algo of conv fwd might not be selected due to lack of workspace size ({})";
static const char __pyx_k_create_reduce_tensor_descriptor[] = "create_reduce_tensor_descriptor";
static const char __pyx_k_destroyFusedOpsVariantParamPack[] = "destroyFusedOpsVariantParamPack";
static const char __pyx_k_dilation_must_be_one_when_cuDNN[] = "dilation must be one when cuDNN < 6.0";
static const char __pyx_k_get_rnn_lin_layer_matrix_params[] = "get_rnn_lin_layer_matrix_params";
static const char __pyx_k_groups_must_be_one_when_cuDNN_7[] = "groups must be one when cuDNN < 7.0";
static const char __pyx_k_ksize_stride_and_pad_must_be_of[] = "ksize, stride, and pad must be of same length";
static const char __pyx_k_tensor_code_mode_must_be_either[] = "tensor_code_mode must be either of \"always\", \"auto\", or \"never\".";
static const char __pyx_k_Both_mean_and_inv_std_must_be_No[] = "Both mean and inv_std must be None if one is.";
static const char __pyx_k_Could_be_faster_by_calling_batch[] = "Could be faster by calling batch_normalization_forward_training_ex() instead of batch_normalization_forward_training().";
static const char __pyx_k_Incompatible_checksums_s_vs_0x2a[] = "Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xfd[] = "Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xfe[] = "Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))";
static const char __pyx_k_No_conv_bwd_filter_algo_availabl[] = "No conv bwd filter algo available with workspace size less equal {}";
static const char __pyx_k_The_best_algo_of_conv_bwd_data_m[] = "The best algo of conv bwd data might not not selected due to lack of workspace size ({})";
static const char __pyx_k_The_best_algo_of_conv_bwd_filter[] = "The best algo of conv bwd filter might not not selected due to lack of workspace size ({})";
static const char __pyx_k_batch_normalization_forward_infe[] = "batch_normalization_forward_inference";
static const char __pyx_k_batch_normalization_forward_trai[] = "batch_normalization_forward_training";
static const char __pyx_k_create_dropout_states_is_depreca[] = "create_dropout_states is deprecated.Please use DropoutStates class instead.";
static const char __pyx_k_create_fused_ops_const_param_pac[] = "create_fused_ops_const_param_pack";
static const char __pyx_k_create_fused_ops_variant_param_p[] = "create_fused_ops_variant_param_pack";
static const char __pyx_k_create_spatial_transformer_descr[] = "create_spatial_transformer_descriptor";
static const char __pyx_k_create_uninitialized_tensor_desc[] = "create_uninitialized_tensor_descriptor";
static const char __pyx_k_cupy_cudnn_supports_c_contiguous[] = "cupy.cudnn supports c-contiguous arrays only";
static const char __pyx_k_destroySpatialTransformerDescrip[] = "destroySpatialTransformerDescriptor";
static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
static const char __pyx_k_pad_and_stride_must_be_of_same_l[] = "pad and stride must be of same length";
static const char __pyx_k_pad_r_stride_r_dilation_r_groups[] = "pad={!r}, stride={!r}, dilation={!r}, groups={!r}";
static const char __pyx_k_pooling_forward_supports_c_conti[] = "pooling_forward supports c-contiguous y only";
static const char __pyx_k_reserve_space_can_only_be_passed[] = "reserve_space can only be passed in cuDNN >= 7401";
static const char __pyx_k_Tensor_Core_mode_is_set_but_the_2[] = "Tensor Core mode is set but the selected convolution backward filter algorithm is not a Tensor Core enabled algorithm. This might be due to lack of workspace memory. x.shape:{}, dy.shape:{}, dW.shape:{}, pad:{}, stride:{}";
static const char __pyx_k_Tensor_Core_mode_is_set_but_the_3[] = "Tensor Core mode is set but the selected convolution backward data algorithm is not a Tensor Core enabled algorithm. This might be due to lack of workspace memory. W.shape:{}, x.shape:{}, y.shape:{}, pad:{}, stride:{}";
static const char __pyx_k_batch_normalization_forward_trai_2[] = "batch_normalization_forward_training_ex";
static PyObject *__pyx_kp_u_A_numerical_overflow_might_have;
static PyObject *__pyx_n_s_Algorithm;
static PyObject *__pyx_kp_u_Both_mean_and_inv_std_must_be_No;
static PyObject *__pyx_kp_u_Could_be_faster_by_calling_batch;
static PyObject *__pyx_n_s_CuDNNError;
static PyObject *__pyx_n_s_DeprecationWarning;
static PyObject *__pyx_n_s_Descriptor;
static PyObject *__pyx_n_s_DescriptorArray;
static PyObject *__pyx_n_s_DropoutStates;
static PyObject *__pyx_kp_u_Dtype_is_not_supported_in_cuDNN;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x2a;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xfd;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xfe;
static PyObject *__pyx_kp_u_Invalid_cuDNN_data_type;
static PyObject *__pyx_kp_u_No_available_algorithm_found;
static PyObject *__pyx_kp_u_No_conv_bwd_data_algo_available;
static PyObject *__pyx_kp_u_No_conv_bwd_filter_algo_availabl;
static PyObject *__pyx_kp_u_No_conv_fwd_algo_available_with;
static PyObject *__pyx_n_u_None;
static PyObject *__pyx_n_s_PerformanceWarning;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_u_Tensor_Core_mode_is_set_but_the;
static PyObject *__pyx_kp_u_Tensor_Core_mode_is_set_but_the_2;
static PyObject *__pyx_kp_u_Tensor_Core_mode_is_set_but_the_3;
static PyObject *__pyx_kp_u_The_best_algo_of_conv_bwd_data_m;
static PyObject *__pyx_kp_u_The_best_algo_of_conv_bwd_filter;
static PyObject *__pyx_kp_u_The_best_algo_of_conv_fwd_might;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_u_Unknown_cudnn_data_type;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_W;
static PyObject *__pyx_kp_u_W_2;
static PyObject *__pyx_n_s__77;
static PyObject *__pyx_n_s_act_desc;
static PyObject *__pyx_n_s_activation_backward;
static PyObject *__pyx_n_s_activation_forward;
static PyObject *__pyx_n_s_add_infos;
static PyObject *__pyx_n_s_add_tensor;
static PyObject *__pyx_n_s_algo;
static PyObject *__pyx_n_s_algorithm;
static PyObject *__pyx_n_s_alpha;
static PyObject *__pyx_n_u_always;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_arr;
static PyObject *__pyx_n_s_arr_or_scaler;
static PyObject *__pyx_n_s_atexit;
static PyObject *__pyx_n_s_attr;
static PyObject *__pyx_n_u_auto;
static PyObject *__pyx_n_s_auto_tune;
static PyObject *__pyx_kp_u_auto_tune_r_tensor_core_r;
static PyObject *__pyx_n_s_axis;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_u_b;
static PyObject *__pyx_kp_u_b_2;
static PyObject *__pyx_n_s_b_desc;
static PyObject *__pyx_n_s_b_shape;
static PyObject *__pyx_n_s_batch_normalization_backward;
static PyObject *__pyx_n_s_batch_normalization_forward_infe;
static PyObject *__pyx_n_s_batch_normalization_forward_trai;
static PyObject *__pyx_n_s_batch_normalization_forward_trai_2;
static PyObject *__pyx_n_s_batch_size;
static PyObject *__pyx_n_s_beta;
static PyObject *__pyx_n_s_bias;
static PyObject *__pyx_n_s_biasData;
static PyObject *__pyx_n_s_biasDesc;
static PyObject *__pyx_n_s_bias_desc;
static PyObject *__pyx_n_s_bn_ops;
static PyObject *__pyx_n_s_byte_size;
static PyObject *__pyx_n_s_c_contiguous;
static PyObject *__pyx_n_s_cache;
static PyObject *__pyx_n_s_char;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_coef;
static PyObject *__pyx_n_s_const_pack;
static PyObject *__pyx_n_s_conv_desc;
static PyObject *__pyx_n_s_conv_param;
static PyObject *__pyx_n_s_convolution_backward_data;
static PyObject *__pyx_n_s_convolution_backward_filter;
static PyObject *__pyx_n_s_convolution_forward;
static PyObject *__pyx_n_s_create_activation_descriptor;
static PyObject *__pyx_n_s_create_convolution_descriptor;
static PyObject *__pyx_n_s_create_ctc_loss_descriptor;
static PyObject *__pyx_n_s_create_dropout_descriptor;
static PyObject *__pyx_n_s_create_dropout_states;
static PyObject *__pyx_kp_u_create_dropout_states_is_depreca;
static PyObject *__pyx_n_s_create_filter_descriptor;
static PyObject *__pyx_n_s_create_fused_ops_const_param_pac;
static PyObject *__pyx_n_s_create_fused_ops_plan;
static PyObject *__pyx_n_s_create_fused_ops_variant_param_p;
static PyObject *__pyx_n_s_create_op_tensor_descriptor;
static PyObject *__pyx_n_s_create_pooling_descriptor;
static PyObject *__pyx_n_s_create_reduce_tensor_descriptor;
static PyObject *__pyx_n_s_create_rnn_descriptor;
static PyObject *__pyx_n_s_create_spatial_transformer_descr;
static PyObject *__pyx_n_s_create_tensor_descriptor;
static PyObject *__pyx_n_s_create_tensor_nd_descriptor;
static PyObject *__pyx_n_s_create_uninitialized_tensor_desc;
static PyObject *__pyx_n_s_ctc_desc;
static PyObject *__pyx_n_s_ctc_loss;
static PyObject *__pyx_n_s_ctypes;
static PyObject *__pyx_n_s_cudnn;
static PyObject *__pyx_n_s_cudnn_mode;
static PyObject *__pyx_n_s_cudnn_nd_tensor_cache;
static PyObject *__pyx_n_u_cudnn_nd_tensor_cache;
static PyObject *__pyx_n_s_cupy;
static PyObject *__pyx_n_s_cupy_core__ufuncs;
static PyObject *__pyx_n_s_cupy_cuda;
static PyObject *__pyx_n_s_cupy_cudnn;
static PyObject *__pyx_kp_s_cupy_cudnn_pyx;
static PyObject *__pyx_kp_u_cupy_cudnn_supports_c_contiguous;
static PyObject *__pyx_n_s_cx;
static PyObject *__pyx_n_s_cx_desc;
static PyObject *__pyx_n_s_cy;
static PyObject *__pyx_n_s_cy_desc;
static PyObject *__pyx_n_u_d;
static PyObject *__pyx_n_s_dW;
static PyObject *__pyx_n_s_d_layout;
static PyObject *__pyx_kp_u_d_layout_r_w_layout_r;
static PyObject *__pyx_n_s_data;
static PyObject *__pyx_n_s_data_type;
static PyObject *__pyx_n_s_dcx;
static PyObject *__pyx_n_s_dcx_desc;
static PyObject *__pyx_n_s_dcy;
static PyObject *__pyx_n_s_dcy_desc;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_decay;
static PyObject *__pyx_n_s_derivedBnDesc;
static PyObject *__pyx_n_s_desc;
static PyObject *__pyx_n_s_desc_or_scalar;
static PyObject *__pyx_n_s_descriptor;
static PyObject *__pyx_n_s_destroyActivationDescriptor;
static PyObject *__pyx_n_s_destroyCTCLossDescriptor;
static PyObject *__pyx_n_s_destroyConvolutionDescriptor;
static PyObject *__pyx_n_s_destroyDropoutDescriptor;
static PyObject *__pyx_n_s_destroyFilterDescriptor;
static PyObject *__pyx_n_s_destroyFusedOpsConstParamPack;
static PyObject *__pyx_n_s_destroyFusedOpsPlan;
static PyObject *__pyx_n_s_destroyFusedOpsVariantParamPack;
static PyObject *__pyx_n_s_destroyOpTensorDescriptor;
static PyObject *__pyx_n_s_destroyPoolingDescriptor;
static PyObject *__pyx_n_s_destroyRNNDataDescriptor;
static PyObject *__pyx_n_s_destroyRNNDescriptor;
static PyObject *__pyx_n_s_destroyReduceTensorDescriptor;
static PyObject *__pyx_n_s_destroySpatialTransformerDescrip;
static PyObject *__pyx_n_s_destroyTensorDescriptor;
static PyObject *__pyx_n_s_destroyer;
static PyObject *__pyx_n_s_deterministic;
static PyObject *__pyx_n_s_dev_id;
static PyObject *__pyx_n_s_device;
static PyObject *__pyx_n_s_dhx;
static PyObject *__pyx_n_s_dhx_desc;
static PyObject *__pyx_n_s_dhy;
static PyObject *__pyx_n_s_dhy_desc;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dilation;
static PyObject *__pyx_kp_u_dilation_must_be_one_when_cuDNN;
static PyObject *__pyx_n_s_dim;
static PyObject *__pyx_n_s_dim_A;
static PyObject *__pyx_n_s_direction;
static PyObject *__pyx_n_s_direction_mode;
static PyObject *__pyx_n_s_double_one;
static PyObject *__pyx_n_s_double_zero;
static PyObject *__pyx_n_s_dropout;
static PyObject *__pyx_n_s_dropout_desc;
static PyObject *__pyx_n_s_dropout_ratio;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dtype_param;
static PyObject *__pyx_n_s_dw;
static PyObject *__pyx_n_s_dw_desc;
static PyObject *__pyx_n_s_dx_data_desc;
static PyObject *__pyx_n_s_dxs;
static PyObject *__pyx_n_s_dxs_descs;
static PyObject *__pyx_n_s_dy;
static PyObject *__pyx_n_s_dy_data_desc;
static PyObject *__pyx_n_s_dy_desc;
static PyObject *__pyx_n_s_dys;
static PyObject *__pyx_n_s_dys_descs;
static PyObject *__pyx_n_s_e;
static PyObject *__pyx_n_u_e;
static PyObject *__pyx_n_s_elementwise_copy;
static PyObject *__pyx_n_s_eps;
static PyObject *__pyx_n_u_f;
static PyObject *__pyx_n_s_filter_desc;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_float16;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_float_one;
static PyObject *__pyx_n_s_float_zero;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_kp_u_func_cudnnConvolutionForward;
static PyObject *__pyx_n_s_fused_ops_execute;
static PyObject *__pyx_n_s_gW;
static PyObject *__pyx_n_s_gamma;
static PyObject *__pyx_n_s_gbeta;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_array_info;
static PyObject *__pyx_n_s_get_rnn_lin_layer_bias_params;
static PyObject *__pyx_n_s_get_rnn_lin_layer_matrix_params;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_ggamma;
static PyObject *__pyx_n_s_gradients;
static PyObject *__pyx_n_s_gradients_desc;
static PyObject *__pyx_n_s_groups;
static PyObject *__pyx_kp_u_groups_must_be_one_when_cuDNN_7;
static PyObject *__pyx_n_s_gx;
static PyObject *__pyx_n_s_gy;
static PyObject *__pyx_n_s_gy_desc;
static PyObject *__pyx_n_s_handle;
static PyObject *__pyx_n_s_handle_2;
static PyObject *__pyx_n_s_hidden_size;
static PyObject *__pyx_n_s_hx;
static PyObject *__pyx_n_s_hx_desc;
static PyObject *__pyx_n_s_hy;
static PyObject *__pyx_n_s_hy_desc;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_indices;
static PyObject *__pyx_n_s_infos;
static PyObject *__pyx_n_s_input_length;
static PyObject *__pyx_n_s_input_length_ptr;
static PyObject *__pyx_n_s_input_mode;
static PyObject *__pyx_n_s_inv_std;
static PyObject *__pyx_n_s_is_for_conv2d;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_ksize;
static PyObject *__pyx_kp_u_ksize_stride_and_pad_must_be_of;
static PyObject *__pyx_n_s_label_length;
static PyObject *__pyx_n_s_label_length_ptr;
static PyObject *__pyx_n_s_labels;
static PyObject *__pyx_n_s_labels_ptr;
static PyObject *__pyx_n_s_layer;
static PyObject *__pyx_n_s_length;
static PyObject *__pyx_n_s_lengths;
static PyObject *__pyx_n_s_lin_layer_id;
static PyObject *__pyx_n_s_list_attr_param;
static PyObject *__pyx_n_s_local;
static PyObject *__pyx_n_s_loss;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_make_fused_ops_plan;
static PyObject *__pyx_n_s_mat;
static PyObject *__pyx_n_s_mat_desc;
static PyObject *__pyx_n_s_mathType;
static PyObject *__pyx_n_s_math_type;
static PyObject *__pyx_n_s_max_workspace_size;
static PyObject *__pyx_n_s_mean;
static PyObject *__pyx_n_s_memory;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_n_layers;
static PyObject *__pyx_n_s_n_units;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_nan_prop_mode;
static PyObject *__pyx_n_s_nb_dims;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_need_cast;
static PyObject *__pyx_n_u_never;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
static PyObject *__pyx_n_s_num_layers;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_offset;
static PyObject *__pyx_n_s_one;
static PyObject *__pyx_n_s_op_type;
static PyObject *__pyx_n_s_ops;
static PyObject *__pyx_n_s_pad;
static PyObject *__pyx_kp_u_pad_and_stride_must_be_of_same_l;
static PyObject *__pyx_kp_u_pad_r_stride_r_dilation_r_groups;
static PyObject *__pyx_n_s_param;
static PyObject *__pyx_n_s_param_label;
static PyObject *__pyx_n_s_perf;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_plan;
static PyObject *__pyx_n_s_pool_desc;
static PyObject *__pyx_n_s_pooling_backward;
static PyObject *__pyx_n_s_pooling_forward;
static PyObject *__pyx_kp_u_pooling_forward_supports_c_conti;
static PyObject *__pyx_n_s_probs;
static PyObject *__pyx_n_s_probs_desc;
static PyObject *__pyx_n_s_ptr;
static PyObject *__pyx_n_s_py_cudnn;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_Descriptor;
static PyObject *__pyx_n_s_pyx_unpickle_DropoutStates;
static PyObject *__pyx_n_s_pyx_unpickle__DescriptorArray;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_query_mode;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_reduce_type;
static PyObject *__pyx_n_s_register;
static PyObject *__pyx_n_s_relu_nan_opt;
static PyObject *__pyx_n_s_reserve_space;
static PyObject *__pyx_kp_u_reserve_space_can_only_be_passed;
static PyObject *__pyx_n_s_reset_handles;
static PyObject *__pyx_n_s_reversed;
static PyObject *__pyx_n_s_rnn_backward_data;
static PyObject *__pyx_n_s_rnn_backward_data_ex;
static PyObject *__pyx_n_s_rnn_backward_weights;
static PyObject *__pyx_n_s_rnn_backward_weights_ex;
static PyObject *__pyx_n_s_rnn_desc;
static PyObject *__pyx_n_s_rnn_forward_inference;
static PyObject *__pyx_n_s_rnn_forward_inference_ex;
static PyObject *__pyx_n_s_rnn_forward_training;
static PyObject *__pyx_n_s_rnn_forward_training_ex;
static PyObject *__pyx_n_s_rnn_mode;
static PyObject *__pyx_n_s_rstatus;
static PyObject *__pyx_n_s_running_mean;
static PyObject *__pyx_n_s_running_var;
static PyObject *__pyx_n_s_sampler_type;
static PyObject *__pyx_n_s_save_inv_std;
static PyObject *__pyx_n_s_save_mean;
static PyObject *__pyx_n_s_seed;
static PyObject *__pyx_n_s_set_dropout_descriptor;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_shape_2;
static PyObject *__pyx_kp_u_shape_r_dtype_strides_r;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_softmax_backward;
static PyObject *__pyx_n_s_softmax_forward;
static PyObject *__pyx_n_s_srcDestData;
static PyObject *__pyx_n_s_srcDestDesc;
static PyObject *__pyx_n_s_state_size;
static PyObject *__pyx_n_s_state_size_in_bytes;
static PyObject *__pyx_n_s_states;
static PyObject *__pyx_n_s_stride;
static PyObject *__pyx_n_s_strides;
static PyObject *__pyx_n_s_strides_2;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_kp_u_tensor_code_mode_must_be_either;
static PyObject *__pyx_n_s_tensor_core;
static PyObject *__pyx_n_s_tensor_core_mode;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_threading;
static PyObject *__pyx_kp_u_unknown_cudnnTensorFormat;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_use_tensor_core;
static PyObject *__pyx_n_s_util;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_var;
static PyObject *__pyx_n_s_var_pack;
static PyObject *__pyx_n_s_w;
static PyObject *__pyx_n_s_w_desc;
static PyObject *__pyx_n_s_w_layout;
static PyObject *__pyx_n_s_warn;
static PyObject *__pyx_n_s_warnings;
static PyObject *__pyx_n_s_work_size;
static PyObject *__pyx_n_s_workspace;
static PyObject *__pyx_n_s_workspace_size;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_kp_u_x_2;
static PyObject *__pyx_n_s_x_data_desc;
static PyObject *__pyx_n_s_x_desc;
static PyObject *__pyx_n_s_xs;
static PyObject *__pyx_n_s_xs_descs;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_kp_u_y_2;
static PyObject *__pyx_n_s_y_data_desc;
static PyObject *__pyx_n_s_y_desc;
static PyObject *__pyx_n_s_ys;
static PyObject *__pyx_n_s_ys_descs;
static PyObject *__pyx_n_s_zero;
static PyObject *__pyx_pf_4cupy_5cudnn_get_handle(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_2reset_handles(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_4_get_nd_tensor_cache(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_6get_max_workspace_size(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_8set_max_workspace_size(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size); /* proto */
static int __pyx_pf_4cupy_5cudnn_10Descriptor___init__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v_descriptor, PyObject *__pyx_v_destroyer); /* proto */
static void __pyx_pf_4cupy_5cudnn_10Descriptor_2__dealloc__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_5value___get__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_5cudnn_10Descriptor_5value_2__set__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_4__reduce_cython__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_6__setstate_cython__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10get_data_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_12_get_byte_size(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_data_type); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_14_create_tensor_nd_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_data_type); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_16_create_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_format); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_18_create_tensor_descriptor_as4darray(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_20_create_filter_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_format); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_22_create_convolution_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, PyObject *__pyx_v_dtype, int __pyx_v_mode, int __pyx_v_use_tensor_core); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_24_ascontiguousarray_normalized_strides(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_26create_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_28create_uninitialized_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_30create_tensor_nd_descriptor(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_32create_filter_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_format); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_34create_convolution_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dtype, PyObject *__pyx_v_mode, PyObject *__pyx_v_dilation, PyObject *__pyx_v_use_tensor_core, PyObject *__pyx_v_groups); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_36create_pooling_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_38rnn_forward_inference_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_40rnn_forward_training_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_42rnn_backward_data_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_44rnn_backward_weights_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_46create_activation_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mode, PyObject *__pyx_v_nan_prop_mode, PyObject *__pyx_v_coef); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_48activation_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_mode, double __pyx_v_coef); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_50activation_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, int __pyx_v_mode, float __pyx_v_coef); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_52softmax_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_axis, int __pyx_v_algorithm); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_54softmax_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, int __pyx_v_axis, int __pyx_v_algorithm); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_56create_dropout_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_dropout, PyObject *__pyx_v_states, PyObject *__pyx_v_state_size_in_bytes, PyObject *__pyx_v_seed); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_58set_dropout_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_desc, PyObject *__pyx_v_handle, PyObject *__pyx_v_dropout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_60_create_ctc_loss_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data_type); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_62ctc_loss(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_probs, PyObject *__pyx_v_labels, PyObject *__pyx_v_label_length, PyObject *__pyx_v_input_length, int __pyx_v_algo); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_64create_rnn_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_hidden_size, PyObject *__pyx_v_num_layers, PyObject *__pyx_v_dropout_desc, PyObject *__pyx_v_input_mode, PyObject *__pyx_v_direction, PyObject *__pyx_v_mode, PyObject *__pyx_v_data_type, PyObject *__pyx_v_algo); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_66get_rnn_lin_layer_matrix_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_rnn_desc, PyObject *__pyx_v_layer, PyObject *__pyx_v_x_desc, PyObject *__pyx_v_w_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, PyObject *__pyx_v_lin_layer_id); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_68get_rnn_lin_layer_bias_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_rnn_desc, PyObject *__pyx_v_layer, PyObject *__pyx_v_x_desc, PyObject *__pyx_v_w_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, PyObject *__pyx_v_lin_layer_id); /* proto */
static int __pyx_pf_4cupy_5cudnn_16_DescriptorArray___init__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v_destroyer); /* proto */
static void __pyx_pf_4cupy_5cudnn_16_DescriptorArray_2__dealloc__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_4append(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v_desc); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_4data___get__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_6__reduce_cython__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_8__setstate_cython__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_70rnn_forward_inference(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_72rnn_forward_training(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_74rnn_backward_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_76rnn_backward_weights(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, PyObject *__pyx_v_lengths); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_78create_dropout_states(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_80create_spatial_transformer_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sampler_type, PyObject *__pyx_v_dtype, PyObject *__pyx_v_nb_dims, PyObject *__pyx_v_dim_A); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_82add_tensor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_alpha, PyObject *__pyx_v_biasDesc, PyObject *__pyx_v_biasData, PyObject *__pyx_v_beta, PyObject *__pyx_v_srcDestDesc, PyObject *__pyx_v_srcDestData); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_84create_op_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op_type, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_86create_reduce_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_88is_tensor_core_available(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype); /* proto */
static int __pyx_pf_4cupy_5cudnn_13DropoutStates___init__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_seed); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_2set_dropout_ratio(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_dropout_ratio); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_4forward(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, PyObject *__pyx_v_dropout_ratio); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_6backward(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, PyObject *__pyx_v_dropout_ratio, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reserve_space); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_7_states___get__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states_2__set__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states_4__del__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc___get__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self); /* proto */
static int __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc_2__set__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc_4__del__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_8__reduce_cython__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_10__setstate_cython__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4cupy_5cudnn_10_Algorithm___cinit__(struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_self, int __pyx_v_algo, size_t __pyx_v_memory, int __pyx_v_mathType); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10_Algorithm_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_10_Algorithm_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_90_warn_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_92_find_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_94_get_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_96_warn_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_98_find_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_dy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_100_get_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_gy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_102_warn_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_104_find_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_106_get_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_108_should_use_tensor_core(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tensor_core_mode, PyObject *__pyx_v_dtype); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_110_get_array_info(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_112convolution_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_114convolution_backward_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gW, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_deterministic, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_116convolution_backward_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_deterministic, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_118pooling_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_120pooling_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_122batch_normalization_forward_training(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var, PyObject *__pyx_v_mean, PyObject *__pyx_v_inv_std, double __pyx_v_eps, double __pyx_v_decay, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_124batch_normalization_forward_training_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var, PyObject *__pyx_v_mean, PyObject *__pyx_v_inv_std, double __pyx_v_eps, double __pyx_v_decay, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_126batch_normalization_forward_inference(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_var, double __pyx_v_eps, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_d_layout); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_128batch_normalization_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_inv_std, double __pyx_v_eps, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_130create_activation_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mode, PyObject *__pyx_v_relu_nan_opt, PyObject *__pyx_v_coef); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_132create_fused_ops_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_134create_fused_ops_const_param_pack(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops, PyObject *__pyx_v_list_attr_param); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_136make_fused_ops_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_plan, PyObject *__pyx_v_const_pack); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_138create_fused_ops_variant_param_pack(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops, PyObject *__pyx_v_list_attr_param); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_140fused_ops_execute(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_plan, PyObject *__pyx_v_var_pack); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_142set_fused_ops_const_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label, PyObject *__pyx_v_desc_or_scalar); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_144get_fused_ops_const_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_146set_fused_ops_variant_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_var_pack, int __pyx_v_param_label, PyObject *__pyx_v_arr_or_scaler); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_148get_fused_ops_variant_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_var_pack, int __pyx_v_param_label); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_150__pyx_unpickle_Descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_152__pyx_unpickle__DescriptorArray(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4cupy_5cudnn_154__pyx_unpickle_DropoutStates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_4cupy_5cudnn_Descriptor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_5cudnn__DescriptorArray(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_5cudnn_DropoutStates(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4cupy_5cudnn__Algorithm(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static PyObject *__pyx_float_0_;
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_70;
static PyObject *__pyx_int_44931744;
static PyObject *__pyx_int_266093133;
static PyObject *__pyx_int_267320206;
static PyObject *__pyx_int_neg_1;
static int __pyx_k_;
static int __pyx_k__3;
static PyObject *__pyx_k__7;
static PyObject *__pyx_k__9;
static PyObject *__pyx_k__10;
static PyObject *__pyx_k__13;
static int __pyx_k__20;
static int __pyx_k__21;
static int __pyx_k__22;
static int __pyx_k__23;
static int __pyx_k__24;
static int __pyx_k__25;
static int __pyx_k__27;
static int __pyx_k__28;
static int __pyx_k__29;
static int __pyx_k__30;
static int __pyx_k__32;
static int __pyx_k__33;
static PyObject *__pyx_k__35;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_slice__14;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__82;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__88;
static PyObject *__pyx_tuple__90;
static PyObject *__pyx_tuple__92;
static PyObject *__pyx_tuple__94;
static PyObject *__pyx_tuple__96;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__102;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__108;
static PyObject *__pyx_tuple__110;
static PyObject *__pyx_tuple__112;
static PyObject *__pyx_tuple__114;
static PyObject *__pyx_tuple__116;
static PyObject *__pyx_tuple__118;
static PyObject *__pyx_tuple__120;
static PyObject *__pyx_tuple__122;
static PyObject *__pyx_tuple__124;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__39;
static PyObject *__pyx_codeobj__40;
static PyObject *__pyx_codeobj__42;
static PyObject *__pyx_codeobj__44;
static PyObject *__pyx_codeobj__46;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__52;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__60;
static PyObject *__pyx_codeobj__62;
static PyObject *__pyx_codeobj__64;
static PyObject *__pyx_codeobj__66;
static PyObject *__pyx_codeobj__68;
static PyObject *__pyx_codeobj__70;
static PyObject *__pyx_codeobj__72;
static PyObject *__pyx_codeobj__74;
static PyObject *__pyx_codeobj__76;
static PyObject *__pyx_codeobj__79;
static PyObject *__pyx_codeobj__81;
static PyObject *__pyx_codeobj__83;
static PyObject *__pyx_codeobj__85;
static PyObject *__pyx_codeobj__87;
static PyObject *__pyx_codeobj__89;
static PyObject *__pyx_codeobj__91;
static PyObject *__pyx_codeobj__93;
static PyObject *__pyx_codeobj__95;
static PyObject *__pyx_codeobj__97;
static PyObject *__pyx_codeobj__99;
static PyObject *__pyx_codeobj__101;
static PyObject *__pyx_codeobj__103;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__107;
static PyObject *__pyx_codeobj__109;
static PyObject *__pyx_codeobj__111;
static PyObject *__pyx_codeobj__113;
static PyObject *__pyx_codeobj__115;
static PyObject *__pyx_codeobj__117;
static PyObject *__pyx_codeobj__119;
static PyObject *__pyx_codeobj__121;
static PyObject *__pyx_codeobj__123;
static PyObject *__pyx_codeobj__125;
static PyObject *__pyx_codeobj__127;
static PyObject *__pyx_codeobj__129;
static PyObject *__pyx_codeobj__131;
static PyObject *__pyx_codeobj__133;
static PyObject *__pyx_codeobj__135;
static PyObject *__pyx_codeobj__137;
/* Late includes */

/* "cupy/cudnn.pyx":27
 * 
 * 
 * cpdef size_t get_handle() except? 0:             # <<<<<<<<<<<<<<
 *     cdef int dev
 *     dev = device.get_device_id()
 */

static PyObject *__pyx_pw_4cupy_5cudnn_1get_handle(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static size_t __pyx_f_4cupy_5cudnn_get_handle(CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_dev;
  size_t __pyx_v_ret;
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  size_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_handle", 0);

  /* "cupy/cudnn.pyx":29
 * cpdef size_t get_handle() except? 0:
 *     cdef int dev
 *     dev = device.get_device_id()             # <<<<<<<<<<<<<<
 *     if <int>_handles.size() <= dev:
 *         _handles.resize(dev + 1, 0)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_6device_get_device_id(0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 29, __pyx_L1_error)
  __pyx_v_dev = __pyx_t_1;

  /* "cupy/cudnn.pyx":30
 *     cdef int dev
 *     dev = device.get_device_id()
 *     if <int>_handles.size() <= dev:             # <<<<<<<<<<<<<<
 *         _handles.resize(dev + 1, 0)
 *     ret = _handles[dev]
 */
  __pyx_t_2 = ((((int)__pyx_v_4cupy_5cudnn__handles.size()) <= __pyx_v_dev) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":31
 *     dev = device.get_device_id()
 *     if <int>_handles.size() <= dev:
 *         _handles.resize(dev + 1, 0)             # <<<<<<<<<<<<<<
 *     ret = _handles[dev]
 *     if ret != 0:
 */
    try {
      __pyx_v_4cupy_5cudnn__handles.resize((__pyx_v_dev + 1), 0);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 31, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":30
 *     cdef int dev
 *     dev = device.get_device_id()
 *     if <int>_handles.size() <= dev:             # <<<<<<<<<<<<<<
 *         _handles.resize(dev + 1, 0)
 *     ret = _handles[dev]
 */
  }

  /* "cupy/cudnn.pyx":32
 *     if <int>_handles.size() <= dev:
 *         _handles.resize(dev + 1, 0)
 *     ret = _handles[dev]             # <<<<<<<<<<<<<<
 *     if ret != 0:
 *         return ret
 */
  __pyx_v_ret = (__pyx_v_4cupy_5cudnn__handles[__pyx_v_dev]);

  /* "cupy/cudnn.pyx":33
 *         _handles.resize(dev + 1, 0)
 *     ret = _handles[dev]
 *     if ret != 0:             # <<<<<<<<<<<<<<
 *         return ret
 *     ret = cudnn.create()
 */
  __pyx_t_2 = ((__pyx_v_ret != 0) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":34
 *     ret = _handles[dev]
 *     if ret != 0:
 *         return ret             # <<<<<<<<<<<<<<
 *     ret = cudnn.create()
 *     _handles[dev] = ret
 */
    __pyx_r = __pyx_v_ret;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":33
 *         _handles.resize(dev + 1, 0)
 *     ret = _handles[dev]
 *     if ret != 0:             # <<<<<<<<<<<<<<
 *         return ret
 *     ret = cudnn.create()
 */
  }

  /* "cupy/cudnn.pyx":35
 *     if ret != 0:
 *         return ret
 *     ret = cudnn.create()             # <<<<<<<<<<<<<<
 *     _handles[dev] = ret
 *     return ret
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_create(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L1_error)
  __pyx_v_ret = __pyx_t_3;

  /* "cupy/cudnn.pyx":36
 *         return ret
 *     ret = cudnn.create()
 *     _handles[dev] = ret             # <<<<<<<<<<<<<<
 *     return ret
 * 
 */
  (__pyx_v_4cupy_5cudnn__handles[__pyx_v_dev]) = __pyx_v_ret;

  /* "cupy/cudnn.pyx":37
 *     ret = cudnn.create()
 *     _handles[dev] = ret
 *     return ret             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_ret;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":27
 * 
 * 
 * cpdef size_t get_handle() except? 0:             # <<<<<<<<<<<<<<
 *     cdef int dev
 *     dev = device.get_device_id()
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_1get_handle(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_get_handle[] = "get_handle() -> size_t";
static PyObject *__pyx_pw_4cupy_5cudnn_1get_handle(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_handle (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_get_handle(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_5cudnn_get_handle(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_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_handle", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __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.cudnn.get_handle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":41
 * 
 * @atexit.register
 * def reset_handles():             # <<<<<<<<<<<<<<
 *     for handle in _handles:
 *         if handle:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_3reset_handles(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_2reset_handles[] = "reset_handles()";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_3reset_handles = {"reset_handles", (PyCFunction)__pyx_pw_4cupy_5cudnn_3reset_handles, METH_NOARGS, __pyx_doc_4cupy_5cudnn_2reset_handles};
static PyObject *__pyx_pw_4cupy_5cudnn_3reset_handles(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_handles (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_2reset_handles(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_5cudnn_2reset_handles(CYTHON_UNUSED PyObject *__pyx_self) {
  size_t __pyx_v_handle;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<size_t> ::iterator __pyx_t_1;
  size_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("reset_handles", 0);

  /* "cupy/cudnn.pyx":42
 * @atexit.register
 * def reset_handles():
 *     for handle in _handles:             # <<<<<<<<<<<<<<
 *         if handle:
 *             cudnn.destroy(handle)
 */
  __pyx_t_1 = __pyx_v_4cupy_5cudnn__handles.begin();
  for (;;) {
    if (!(__pyx_t_1 != __pyx_v_4cupy_5cudnn__handles.end())) break;
    __pyx_t_2 = *__pyx_t_1;
    ++__pyx_t_1;
    __pyx_v_handle = __pyx_t_2;

    /* "cupy/cudnn.pyx":43
 * def reset_handles():
 *     for handle in _handles:
 *         if handle:             # <<<<<<<<<<<<<<
 *             cudnn.destroy(handle)
 *     _handles.clear()
 */
    __pyx_t_3 = (__pyx_v_handle != 0);
    if (__pyx_t_3) {

      /* "cupy/cudnn.pyx":44
 *     for handle in _handles:
 *         if handle:
 *             cudnn.destroy(handle)             # <<<<<<<<<<<<<<
 *     _handles.clear()
 * 
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroy(__pyx_v_handle, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":43
 * def reset_handles():
 *     for handle in _handles:
 *         if handle:             # <<<<<<<<<<<<<<
 *             cudnn.destroy(handle)
 *     _handles.clear()
 */
    }

    /* "cupy/cudnn.pyx":42
 * @atexit.register
 * def reset_handles():
 *     for handle in _handles:             # <<<<<<<<<<<<<<
 *         if handle:
 *             cudnn.destroy(handle)
 */
  }

  /* "cupy/cudnn.pyx":45
 *         if handle:
 *             cudnn.destroy(handle)
 *     _handles.clear()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_4cupy_5cudnn__handles.clear();

  /* "cupy/cudnn.pyx":41
 * 
 * @atexit.register
 * def reset_handles():             # <<<<<<<<<<<<<<
 *     for handle in _handles:
 *         if handle:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.reset_handles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":48
 * 
 * 
 * cpdef dict _get_nd_tensor_cache():             # <<<<<<<<<<<<<<
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):
 *         _thread_local.cudnn_nd_tensor_cache = {}
 */

static PyObject *__pyx_pw_4cupy_5cudnn_5_get_nd_tensor_cache(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__get_nd_tensor_cache(CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_nd_tensor_cache", 0);

  /* "cupy/cudnn.pyx":49
 * 
 * cpdef dict _get_nd_tensor_cache():
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):             # <<<<<<<<<<<<<<
 *         _thread_local.cudnn_nd_tensor_cache = {}
 *     return _thread_local.cudnn_nd_tensor_cache
 */
  __pyx_t_1 = __pyx_v_4cupy_5cudnn__thread_local;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_u_cudnn_nd_tensor_cache); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":50
 * cpdef dict _get_nd_tensor_cache():
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):
 *         _thread_local.cudnn_nd_tensor_cache = {}             # <<<<<<<<<<<<<<
 *     return _thread_local.cudnn_nd_tensor_cache
 * 
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_5cudnn__thread_local, __pyx_n_s_cudnn_nd_tensor_cache, __pyx_t_1) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":49
 * 
 * cpdef dict _get_nd_tensor_cache():
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):             # <<<<<<<<<<<<<<
 *         _thread_local.cudnn_nd_tensor_cache = {}
 *     return _thread_local.cudnn_nd_tensor_cache
 */
  }

  /* "cupy/cudnn.pyx":51
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):
 *         _thread_local.cudnn_nd_tensor_cache = {}
 *     return _thread_local.cudnn_nd_tensor_cache             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_4cupy_5cudnn__thread_local, __pyx_n_s_cudnn_nd_tensor_cache); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 51, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":48
 * 
 * 
 * cpdef dict _get_nd_tensor_cache():             # <<<<<<<<<<<<<<
 *     if not hasattr(_thread_local, 'cudnn_nd_tensor_cache'):
 *         _thread_local.cudnn_nd_tensor_cache = {}
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn._get_nd_tensor_cache", __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_5cudnn_5_get_nd_tensor_cache(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_4_get_nd_tensor_cache[] = "_get_nd_tensor_cache() -> dict";
static PyObject *__pyx_pw_4cupy_5cudnn_5_get_nd_tensor_cache(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_nd_tensor_cache (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_4_get_nd_tensor_cache(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_5cudnn_4_get_nd_tensor_cache(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_nd_tensor_cache", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__get_nd_tensor_cache(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":57
 * 
 * 
 * cpdef size_t get_max_workspace_size():             # <<<<<<<<<<<<<<
 *     """Gets the workspace size for cuDNN.
 * 
 */

static PyObject *__pyx_pw_4cupy_5cudnn_7get_max_workspace_size(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static size_t __pyx_f_4cupy_5cudnn_get_max_workspace_size(CYTHON_UNUSED int __pyx_skip_dispatch) {
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_max_workspace_size", 0);

  /* "cupy/cudnn.pyx":66
 * 
 *     """
 *     return _max_workspace_size             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_4cupy_5cudnn__max_workspace_size;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":57
 * 
 * 
 * cpdef size_t get_max_workspace_size():             # <<<<<<<<<<<<<<
 *     """Gets the workspace size for cuDNN.
 * 
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_7get_max_workspace_size(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_6get_max_workspace_size[] = "get_max_workspace_size() -> size_t\nGets the workspace size for cuDNN.\n\n    Check \"cuDNN Library User Guide\" for detail.\n\n    Returns:\n        int: The workspace size for cuDNN.\n\n    ";
static PyObject *__pyx_pw_4cupy_5cudnn_7get_max_workspace_size(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_max_workspace_size (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_6get_max_workspace_size(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_5cudnn_6get_max_workspace_size(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_max_workspace_size", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_f_4cupy_5cudnn_get_max_workspace_size(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":69
 * 
 * 
 * cpdef set_max_workspace_size(size):             # <<<<<<<<<<<<<<
 *     """Sets the workspace size for cuDNN.
 * 
 */

static PyObject *__pyx_pw_4cupy_5cudnn_9set_max_workspace_size(PyObject *__pyx_self, PyObject *__pyx_v_size); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_max_workspace_size(PyObject *__pyx_v_size, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_max_workspace_size", 0);

  /* "cupy/cudnn.pyx":79
 *     """
 *     global _max_workspace_size
 *     _max_workspace_size = size             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_size); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error)
  __pyx_v_4cupy_5cudnn__max_workspace_size = __pyx_t_1;

  /* "cupy/cudnn.pyx":69
 * 
 * 
 * cpdef set_max_workspace_size(size):             # <<<<<<<<<<<<<<
 *     """Sets the workspace size for cuDNN.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cudnn.set_max_workspace_size", __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_5cudnn_9set_max_workspace_size(PyObject *__pyx_self, PyObject *__pyx_v_size); /*proto*/
static char __pyx_doc_4cupy_5cudnn_8set_max_workspace_size[] = "set_max_workspace_size(size)\nSets the workspace size for cuDNN.\n\n    Check \"cuDNN Library User Guide\" for detail.\n\n    Args:\n        size: The workspace size for cuDNN.\n\n    ";
static PyObject *__pyx_pw_4cupy_5cudnn_9set_max_workspace_size(PyObject *__pyx_self, PyObject *__pyx_v_size) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_max_workspace_size (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_8set_max_workspace_size(__pyx_self, ((PyObject *)__pyx_v_size));

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

static PyObject *__pyx_pf_4cupy_5cudnn_8set_max_workspace_size(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size) {
  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("set_max_workspace_size", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_set_max_workspace_size(__pyx_v_size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":87
 *     cdef object destroy
 * 
 *     def __init__(self, descriptor, destroyer):             # <<<<<<<<<<<<<<
 *         self.value = descriptor
 *         self.destroy = destroyer
 */

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_10Descriptor_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_5cudnn_10Descriptor_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_descriptor = 0;
  PyObject *__pyx_v_destroyer = 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_descriptor,&__pyx_n_s_destroyer,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_descriptor)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_destroyer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 87, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 87, __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_descriptor = values[0];
    __pyx_v_destroyer = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 87, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.Descriptor.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_10Descriptor___init__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self), __pyx_v_descriptor, __pyx_v_destroyer);

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

static int __pyx_pf_4cupy_5cudnn_10Descriptor___init__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v_descriptor, PyObject *__pyx_v_destroyer) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cudnn.pyx":88
 * 
 *     def __init__(self, descriptor, destroyer):
 *         self.value = descriptor             # <<<<<<<<<<<<<<
 *         self.destroy = destroyer
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_descriptor); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L1_error)
  __pyx_v_self->value = __pyx_t_1;

  /* "cupy/cudnn.pyx":89
 *     def __init__(self, descriptor, destroyer):
 *         self.value = descriptor
 *         self.destroy = destroyer             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_INCREF(__pyx_v_destroyer);
  __Pyx_GIVEREF(__pyx_v_destroyer);
  __Pyx_GOTREF(__pyx_v_self->destroy);
  __Pyx_DECREF(__pyx_v_self->destroy);
  __pyx_v_self->destroy = __pyx_v_destroyer;

  /* "cupy/cudnn.pyx":87
 *     cdef object destroy
 * 
 *     def __init__(self, descriptor, destroyer):             # <<<<<<<<<<<<<<
 *         self.value = descriptor
 *         self.destroy = destroyer
 */

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

/* "cupy/cudnn.pyx":91
 *         self.destroy = destroyer
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.value:
 *             self.destroy(self.value)
 */

/* Python wrapper */
static void __pyx_pw_4cupy_5cudnn_10Descriptor_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4cupy_5cudnn_10Descriptor_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4cupy_5cudnn_10Descriptor_2__dealloc__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self));

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

static void __pyx_pf_4cupy_5cudnn_10Descriptor_2__dealloc__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "cupy/cudnn.pyx":92
 * 
 *     def __dealloc__(self):
 *         if self.value:             # <<<<<<<<<<<<<<
 *             self.destroy(self.value)
 *             self.value = 0
 */
  __pyx_t_1 = (__pyx_v_self->value != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":93
 *     def __dealloc__(self):
 *         if self.value:
 *             self.destroy(self.value)             # <<<<<<<<<<<<<<
 *             self.value = 0
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_self->value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->destroy);
    __pyx_t_4 = __pyx_v_self->destroy; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":94
 *         if self.value:
 *             self.destroy(self.value)
 *             self.value = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_self->value = 0;

    /* "cupy/cudnn.pyx":92
 * 
 *     def __dealloc__(self):
 *         if self.value:             # <<<<<<<<<<<<<<
 *             self.destroy(self.value)
 *             self.value = 0
 */
  }

  /* "cupy/cudnn.pyx":91
 *         self.destroy = destroyer
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self.value:
 *             self.destroy(self.value)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("cupy.cudnn.Descriptor.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cupy/cudnn.pyx":84
 * cdef class Descriptor:
 * 
 *     cdef public size_t value             # <<<<<<<<<<<<<<
 *     cdef object destroy
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_5value_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10Descriptor_5value___get__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_5value___get__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__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_FromSize_t(__pyx_v_self->value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn.Descriptor.value.__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_5cudnn_10Descriptor_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_5cudnn_10Descriptor_5value_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_5cudnn_10Descriptor_5value_2__set__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_5cudnn_10Descriptor_5value_2__set__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  size_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_PyInt_As_size_t(__pyx_v_value); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
  __pyx_v_self->value = __pyx_t_1;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_10Descriptor_4__reduce_cython__[] = "Descriptor.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10Descriptor_4__reduce_cython__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_4__reduce_cython__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.destroy, self.value)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->destroy);
  __Pyx_GIVEREF(__pyx_v_self->destroy);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->destroy);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.destroy, self.value)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self.destroy, self.value)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.destroy is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.destroy, self.value)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.destroy is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->destroy != Py_None);
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.destroy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self.destroy is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_Descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_267320206);
    __Pyx_GIVEREF(__pyx_int_267320206);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_267320206);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.destroy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, None), state
 *     else:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Descriptor__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_267320206);
    __Pyx_GIVEREF(__pyx_int_267320206);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_267320206);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.Descriptor.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Descriptor__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_5cudnn_10Descriptor_6__setstate_cython__[] = "Descriptor.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_5cudnn_10Descriptor_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10Descriptor_6__setstate_cython__(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10Descriptor_6__setstate_cython__(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Descriptor__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_5cudnn___pyx_unpickle_Descriptor__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Descriptor, (type(self), 0xfeefb8e, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Descriptor__set_state(self, __pyx_state)
 */

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

/* "cupy/cudnn.pyx":97
 * 
 * 
 * cpdef int get_data_type(dtype) except? -1:             # <<<<<<<<<<<<<<
 *     cdef char t = ord(dtype.char)
 *     if t == b'f':
 */

static PyObject *__pyx_pw_4cupy_5cudnn_11get_data_type(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static int __pyx_f_4cupy_5cudnn_get_data_type(PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  char __pyx_v_t;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  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("get_data_type", 0);

  /* "cupy/cudnn.pyx":98
 * 
 * cpdef int get_data_type(dtype) except? -1:
 *     cdef char t = ord(dtype.char)             # <<<<<<<<<<<<<<
 *     if t == b'f':
 *         return cudnn.CUDNN_DATA_FLOAT
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Ord(__pyx_t_1); if (unlikely(__pyx_t_2 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 98, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_t = __pyx_t_2;

  /* "cupy/cudnn.pyx":99
 * cpdef int get_data_type(dtype) except? -1:
 *     cdef char t = ord(dtype.char)
 *     if t == b'f':             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_DATA_FLOAT
 *     elif t == b'd':
 */
  switch (__pyx_v_t) {
    case 'f':

    /* "cupy/cudnn.pyx":100
 *     cdef char t = ord(dtype.char)
 *     if t == b'f':
 *         return cudnn.CUDNN_DATA_FLOAT             # <<<<<<<<<<<<<<
 *     elif t == b'd':
 *         return cudnn.CUDNN_DATA_DOUBLE
 */
    __pyx_r = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_FLOAT;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":99
 * cpdef int get_data_type(dtype) except? -1:
 *     cdef char t = ord(dtype.char)
 *     if t == b'f':             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_DATA_FLOAT
 *     elif t == b'd':
 */
    break;
    case 'd':

    /* "cupy/cudnn.pyx":102
 *         return cudnn.CUDNN_DATA_FLOAT
 *     elif t == b'd':
 *         return cudnn.CUDNN_DATA_DOUBLE             # <<<<<<<<<<<<<<
 *     elif t == b'e':
 *         return cudnn.CUDNN_DATA_HALF
 */
    __pyx_r = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_DOUBLE;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":101
 *     if t == b'f':
 *         return cudnn.CUDNN_DATA_FLOAT
 *     elif t == b'd':             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_DATA_DOUBLE
 *     elif t == b'e':
 */
    break;
    case 'e':

    /* "cupy/cudnn.pyx":104
 *         return cudnn.CUDNN_DATA_DOUBLE
 *     elif t == b'e':
 *         return cudnn.CUDNN_DATA_HALF             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('Dtype {} is not supported in cuDNN'.format(dtype))
 */
    __pyx_r = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_HALF;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":103
 *     elif t == b'd':
 *         return cudnn.CUDNN_DATA_DOUBLE
 *     elif t == b'e':             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_DATA_HALF
 *     else:
 */
    break;
    default:

    /* "cupy/cudnn.pyx":106
 *         return cudnn.CUDNN_DATA_HALF
 *     else:
 *         raise TypeError('Dtype {} is not supported in cuDNN'.format(dtype))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Dtype_is_not_supported_in_cuDNN, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_dtype) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_dtype);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 106, __pyx_L1_error)
    break;
  }

  /* "cupy/cudnn.pyx":97
 * 
 * 
 * cpdef int get_data_type(dtype) except? -1:             # <<<<<<<<<<<<<<
 *     cdef char t = ord(dtype.char)
 *     if t == b'f':
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.get_data_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_11get_data_type(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_5cudnn_10get_data_type[] = "get_data_type(dtype) -> int";
static PyObject *__pyx_pw_4cupy_5cudnn_11get_data_type(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_data_type (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10get_data_type(__pyx_self, ((PyObject *)__pyx_v_dtype));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10get_data_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __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("get_data_type", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_v_dtype, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 97, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __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.cudnn.get_data_type", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":109
 * 
 * 
 * cpdef int _get_byte_size(int data_type) except -1:             # <<<<<<<<<<<<<<
 *     if data_type == cudnn.CUDNN_DATA_HALF:
 *         return 2
 */

static PyObject *__pyx_pw_4cupy_5cudnn_13_get_byte_size(PyObject *__pyx_self, PyObject *__pyx_arg_data_type); /*proto*/
static int __pyx_f_4cupy_5cudnn__get_byte_size(int __pyx_v_data_type, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_byte_size", 0);

  /* "cupy/cudnn.pyx":110
 * 
 * cpdef int _get_byte_size(int data_type) except -1:
 *     if data_type == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         return 2
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:
 */
  switch (__pyx_v_data_type) {
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_HALF:

    /* "cupy/cudnn.pyx":111
 * cpdef int _get_byte_size(int data_type) except -1:
 *     if data_type == cudnn.CUDNN_DATA_HALF:
 *         return 2             # <<<<<<<<<<<<<<
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:
 *         return 4
 */
    __pyx_r = 2;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":110
 * 
 * cpdef int _get_byte_size(int data_type) except -1:
 *     if data_type == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         return 2
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_FLOAT:

    /* "cupy/cudnn.pyx":113
 *         return 2
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:
 *         return 4             # <<<<<<<<<<<<<<
 *     elif data_type == cudnn.CUDNN_DATA_DOUBLE:
 *         return 8
 */
    __pyx_r = 4;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":112
 *     if data_type == cudnn.CUDNN_DATA_HALF:
 *         return 2
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:             # <<<<<<<<<<<<<<
 *         return 4
 *     elif data_type == cudnn.CUDNN_DATA_DOUBLE:
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_DOUBLE:

    /* "cupy/cudnn.pyx":115
 *         return 4
 *     elif data_type == cudnn.CUDNN_DATA_DOUBLE:
 *         return 8             # <<<<<<<<<<<<<<
 *     else:
 *         raise TypeError('Invalid cuDNN data type: {}'.format(data_type))
 */
    __pyx_r = 8;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":114
 *     elif data_type == cudnn.CUDNN_DATA_FLOAT:
 *         return 4
 *     elif data_type == cudnn.CUDNN_DATA_DOUBLE:             # <<<<<<<<<<<<<<
 *         return 8
 *     else:
 */
    break;
    default:

    /* "cupy/cudnn.pyx":117
 *         return 8
 *     else:
 *         raise TypeError('Invalid cuDNN data type: {}'.format(data_type))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Invalid_cuDNN_data_type, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_data_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 117, __pyx_L1_error)
    break;
  }

  /* "cupy/cudnn.pyx":109
 * 
 * 
 * cpdef int _get_byte_size(int data_type) except -1:             # <<<<<<<<<<<<<<
 *     if data_type == cudnn.CUDNN_DATA_HALF:
 *         return 2
 */

  /* function 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.cudnn._get_byte_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13_get_byte_size(PyObject *__pyx_self, PyObject *__pyx_arg_data_type); /*proto*/
static char __pyx_doc_4cupy_5cudnn_12_get_byte_size[] = "_get_byte_size(int data_type) -> int";
static PyObject *__pyx_pw_4cupy_5cudnn_13_get_byte_size(PyObject *__pyx_self, PyObject *__pyx_arg_data_type) {
  int __pyx_v_data_type;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_byte_size (wrapper)", 0);
  assert(__pyx_arg_data_type); {
    __pyx_v_data_type = __Pyx_PyInt_As_int(__pyx_arg_data_type); if (unlikely((__pyx_v_data_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._get_byte_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_12_get_byte_size(__pyx_self, ((int)__pyx_v_data_type));

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

static PyObject *__pyx_pf_4cupy_5cudnn_12_get_byte_size(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_data_type) {
  PyObject *__pyx_r = NULL;
  __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("_get_byte_size", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__get_byte_size(__pyx_v_data_type, 0); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 109, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __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.cudnn._get_byte_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":120
 * 
 * 
 * cpdef _create_tensor_nd_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int data_type=-1):
 *     cdef vector.vector[int] c_shape, c_strides
 */

static PyObject *__pyx_pw_4cupy_5cudnn_15_create_tensor_nd_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor *__pyx_optional_args) {
  int __pyx_v_data_type = ((int)-1);
  std::vector<int>  __pyx_v_c_shape;
  std::vector<int>  __pyx_v_c_strides;
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_s;
  int __pyx_v_next_stride;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  std::vector<Py_ssize_t> ::iterator __pyx_t_5;
  std::vector<Py_ssize_t>  *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_nd_descriptor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_data_type = __pyx_optional_args->data_type;
    }
  }

  /* "cupy/cudnn.pyx":125
 *     cdef Py_ssize_t itemsize, s
 *     cdef int next_stride, i
 *     if data_type == -1:  # `-1` is used instead of `None`             # <<<<<<<<<<<<<<
 *         data_type = get_data_type(arr.dtype)
 *     itemsize = arr.itemsize
 */
  __pyx_t_1 = ((__pyx_v_data_type == -1L) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":126
 *     cdef int next_stride, i
 *     if data_type == -1:  # `-1` is used instead of `None`
 *         data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     itemsize = arr.itemsize
 *     for s in arr._strides:
 */
    __pyx_t_2 = __pyx_v_arr->dtype;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_2, 0); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 126, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_data_type = __pyx_t_3;

    /* "cupy/cudnn.pyx":125
 *     cdef Py_ssize_t itemsize, s
 *     cdef int next_stride, i
 *     if data_type == -1:  # `-1` is used instead of `None`             # <<<<<<<<<<<<<<
 *         data_type = get_data_type(arr.dtype)
 *     itemsize = arr.itemsize
 */
  }

  /* "cupy/cudnn.pyx":127
 *     if data_type == -1:  # `-1` is used instead of `None`
 *         data_type = get_data_type(arr.dtype)
 *     itemsize = arr.itemsize             # <<<<<<<<<<<<<<
 *     for s in arr._strides:
 *         c_strides.push_back(s // itemsize)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_itemsize = __pyx_t_4;

  /* "cupy/cudnn.pyx":128
 *         data_type = get_data_type(arr.dtype)
 *     itemsize = arr.itemsize
 *     for s in arr._strides:             # <<<<<<<<<<<<<<
 *         c_strides.push_back(s // itemsize)
 *     for s in arr._shape:
 */
  __pyx_t_6 = &__pyx_v_arr->_strides;
  __pyx_t_5 = __pyx_t_6->begin();
  for (;;) {
    if (!(__pyx_t_5 != __pyx_t_6->end())) break;
    __pyx_t_4 = *__pyx_t_5;
    ++__pyx_t_5;
    __pyx_v_s = __pyx_t_4;

    /* "cupy/cudnn.pyx":129
 *     itemsize = arr.itemsize
 *     for s in arr._strides:
 *         c_strides.push_back(s // itemsize)             # <<<<<<<<<<<<<<
 *     for s in arr._shape:
 *         c_shape.push_back(s)
 */
    if (unlikely(__pyx_v_itemsize == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 129, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_s))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 129, __pyx_L1_error)
    }
    try {
      __pyx_v_c_strides.push_back(__Pyx_div_Py_ssize_t(__pyx_v_s, __pyx_v_itemsize));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 129, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":128
 *         data_type = get_data_type(arr.dtype)
 *     itemsize = arr.itemsize
 *     for s in arr._strides:             # <<<<<<<<<<<<<<
 *         c_strides.push_back(s // itemsize)
 *     for s in arr._shape:
 */
  }

  /* "cupy/cudnn.pyx":130
 *     for s in arr._strides:
 *         c_strides.push_back(s // itemsize)
 *     for s in arr._shape:             # <<<<<<<<<<<<<<
 *         c_shape.push_back(s)
 *     # Use "c-contiguous stride" with the next axis, if ambiguous
 */
  __pyx_t_6 = &__pyx_v_arr->_shape;
  __pyx_t_5 = __pyx_t_6->begin();
  for (;;) {
    if (!(__pyx_t_5 != __pyx_t_6->end())) break;
    __pyx_t_4 = *__pyx_t_5;
    ++__pyx_t_5;
    __pyx_v_s = __pyx_t_4;

    /* "cupy/cudnn.pyx":131
 *         c_strides.push_back(s // itemsize)
 *     for s in arr._shape:
 *         c_shape.push_back(s)             # <<<<<<<<<<<<<<
 *     # Use "c-contiguous stride" with the next axis, if ambiguous
 *     next_stride = 1
 */
    try {
      __pyx_v_c_shape.push_back(__pyx_v_s);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 131, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":130
 *     for s in arr._strides:
 *         c_strides.push_back(s // itemsize)
 *     for s in arr._shape:             # <<<<<<<<<<<<<<
 *         c_shape.push_back(s)
 *     # Use "c-contiguous stride" with the next axis, if ambiguous
 */
  }

  /* "cupy/cudnn.pyx":133
 *         c_shape.push_back(s)
 *     # Use "c-contiguous stride" with the next axis, if ambiguous
 *     next_stride = 1             # <<<<<<<<<<<<<<
 *     for i in reversed(range(c_shape.size())):
 *         if c_shape[i] <= 1:
 */
  __pyx_v_next_stride = 1;

  /* "cupy/cudnn.pyx":134
 *     # Use "c-contiguous stride" with the next axis, if ambiguous
 *     next_stride = 1
 *     for i in reversed(range(c_shape.size())):             # <<<<<<<<<<<<<<
 *         if c_shape[i] <= 1:
 *             c_strides[i] = next_stride
 */
  for (__pyx_t_3 = __pyx_v_c_shape.size()-1; __pyx_t_3 >= 0; __pyx_t_3-=1) {
    __pyx_v_i = __pyx_t_3;

    /* "cupy/cudnn.pyx":135
 *     next_stride = 1
 *     for i in reversed(range(c_shape.size())):
 *         if c_shape[i] <= 1:             # <<<<<<<<<<<<<<
 *             c_strides[i] = next_stride
 *         else:
 */
    __pyx_t_1 = (((__pyx_v_c_shape[__pyx_v_i]) <= 1) != 0);
    if (__pyx_t_1) {

      /* "cupy/cudnn.pyx":136
 *     for i in reversed(range(c_shape.size())):
 *         if c_shape[i] <= 1:
 *             c_strides[i] = next_stride             # <<<<<<<<<<<<<<
 *         else:
 *             next_stride = c_shape[i] * c_strides[i]
 */
      (__pyx_v_c_strides[__pyx_v_i]) = __pyx_v_next_stride;

      /* "cupy/cudnn.pyx":135
 *     next_stride = 1
 *     for i in reversed(range(c_shape.size())):
 *         if c_shape[i] <= 1:             # <<<<<<<<<<<<<<
 *             c_strides[i] = next_stride
 *         else:
 */
      goto __pyx_L10;
    }

    /* "cupy/cudnn.pyx":138
 *             c_strides[i] = next_stride
 *         else:
 *             next_stride = c_shape[i] * c_strides[i]             # <<<<<<<<<<<<<<
 * 
 *     cudnn.setTensorNdDescriptor(
 */
    /*else*/ {
      __pyx_v_next_stride = ((__pyx_v_c_shape[__pyx_v_i]) * (__pyx_v_c_strides[__pyx_v_i]));
    }
    __pyx_L10:;
  }

  /* "cupy/cudnn.pyx":140
 *             next_stride = c_shape[i] * c_strides[i]
 * 
 *     cudnn.setTensorNdDescriptor(             # <<<<<<<<<<<<<<
 *         desc, data_type, arr._shape.size(), <size_t>&c_shape[0],
 *         <size_t>&c_strides[0])
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setTensorNdDescriptor(__pyx_v_desc, __pyx_v_data_type, __pyx_v_arr->_shape.size(), ((size_t)(&(__pyx_v_c_shape[0]))), ((size_t)(&(__pyx_v_c_strides[0]))), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":120
 * 
 * 
 * cpdef _create_tensor_nd_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int data_type=-1):
 *     cdef vector.vector[int] c_shape, c_strides
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_nd_descriptor", __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_5cudnn_15_create_tensor_nd_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_14_create_tensor_nd_descriptor[] = "_create_tensor_nd_descriptor(size_t desc, ndarray arr, int data_type=-1)";
static PyObject *__pyx_pw_4cupy_5cudnn_15_create_tensor_nd_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_desc;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_v_data_type;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_tensor_nd_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_arr,&__pyx_n_s_data_type,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_tensor_nd_descriptor", 0, 2, 3, 1); __PYX_ERR(0, 120, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data_type);
          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_tensor_nd_descriptor") < 0)) __PYX_ERR(0, 120, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_desc = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L3_error)
    __pyx_v_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    if (values[2]) {
      __pyx_v_data_type = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_data_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L3_error)
    } else {
      __pyx_v_data_type = ((int)-1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_tensor_nd_descriptor", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 120, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_nd_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 121, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_14_create_tensor_nd_descriptor(__pyx_self, __pyx_v_desc, __pyx_v_arr, __pyx_v_data_type);

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

static PyObject *__pyx_pf_4cupy_5cudnn_14_create_tensor_nd_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_data_type) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_nd_descriptor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.data_type = __pyx_v_data_type;
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_desc, __pyx_v_arr, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":145
 * 
 * 
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,             # <<<<<<<<<<<<<<
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 */

static PyObject *__pyx_pw_4cupy_5cudnn_17_create_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor *__pyx_optional_args) {
  int __pyx_v_format = __pyx_k_;
  int __pyx_v_data_type;
  Py_ssize_t __pyx_v_n;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_v_h;
  Py_ssize_t __pyx_v_w;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_descriptor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_format = __pyx_optional_args->format;
    }
  }

  /* "cupy/cudnn.pyx":147
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     if arr._shape.size() == 4:
 */
  __pyx_t_1 = ((!(__pyx_v_arr->_c_contiguous != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/cudnn.pyx":148
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')             # <<<<<<<<<<<<<<
 *     if arr._shape.size() == 4:
 *         data_type = get_data_type(arr.dtype)
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 148, __pyx_L1_error)

    /* "cupy/cudnn.pyx":147
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     if arr._shape.size() == 4:
 */
  }

  /* "cupy/cudnn.pyx":149
 *     if not arr._c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     if arr._shape.size() == 4:             # <<<<<<<<<<<<<<
 *         data_type = get_data_type(arr.dtype)
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 */
  __pyx_t_1 = ((__pyx_v_arr->_shape.size() == 4) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":150
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     if arr._shape.size() == 4:
 *         data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             n, c, h, w = arr._shape
 */
    __pyx_t_2 = __pyx_v_arr->dtype;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_2, 0); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_data_type = __pyx_t_3;

    /* "cupy/cudnn.pyx":151
 *     if arr._shape.size() == 4:
 *         data_type = get_data_type(arr.dtype)
 *         if format == cudnn.CUDNN_TENSOR_NCHW:             # <<<<<<<<<<<<<<
 *             n, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 */
    switch (__pyx_v_format) {
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW:

      /* "cupy/cudnn.pyx":152
 *         data_type = get_data_type(arr.dtype)
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             n, c, h, w = arr._shape             # <<<<<<<<<<<<<<
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 *             n, h, w, c = arr._shape
 */
      __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_arr->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 152, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 152, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7};
        __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 152, __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;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) __PYX_ERR(0, 152, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L6_unpacking_done;
        __pyx_L5_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 152, __pyx_L1_error)
        __pyx_L6_unpacking_done:;
      }
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_n = __pyx_t_10;
      __pyx_v_c = __pyx_t_11;
      __pyx_v_h = __pyx_t_12;
      __pyx_v_w = __pyx_t_13;

      /* "cupy/cudnn.pyx":151
 *     if arr._shape.size() == 4:
 *         data_type = get_data_type(arr.dtype)
 *         if format == cudnn.CUDNN_TENSOR_NCHW:             # <<<<<<<<<<<<<<
 *             n, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 */
      break;
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NHWC:

      /* "cupy/cudnn.pyx":154
 *             n, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 *             n, h, w, c = arr._shape             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))
 */
      __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_arr->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 154, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_5,&__pyx_t_4};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 154, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_5,&__pyx_t_4};
        __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __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;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) __PYX_ERR(0, 154, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 154, __pyx_L1_error)
        __pyx_L8_unpacking_done:;
      }
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_n = __pyx_t_13;
      __pyx_v_h = __pyx_t_12;
      __pyx_v_w = __pyx_t_11;
      __pyx_v_c = __pyx_t_10;

      /* "cupy/cudnn.pyx":153
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             n, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:             # <<<<<<<<<<<<<<
 *             n, h, w, c = arr._shape
 *         else:
 */
      break;
      default:

      /* "cupy/cudnn.pyx":156
 *             n, h, w, c = arr._shape
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))             # <<<<<<<<<<<<<<
 *         cudnn.setTensor4dDescriptor(desc, format, data_type, n, c, h, w)
 *     else:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unknown_cudnnTensorFormat, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 156, __pyx_L1_error)
      break;
    }

    /* "cupy/cudnn.pyx":157
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))
 *         cudnn.setTensor4dDescriptor(desc, format, data_type, n, c, h, w)             # <<<<<<<<<<<<<<
 *     else:
 *         _create_tensor_nd_descriptor(desc, arr)
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor(__pyx_v_desc, __pyx_v_format, __pyx_v_data_type, __pyx_v_n, __pyx_v_c, __pyx_v_h, __pyx_v_w, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":149
 *     if not arr._c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     if arr._shape.size() == 4:             # <<<<<<<<<<<<<<
 *         data_type = get_data_type(arr.dtype)
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":159
 *         cudnn.setTensor4dDescriptor(desc, format, data_type, n, c, h, w)
 *     else:
 *         _create_tensor_nd_descriptor(desc, arr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_desc, __pyx_v_arr, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":145
 * 
 * 
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,             # <<<<<<<<<<<<<<
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_descriptor", __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_5cudnn_17_create_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_16_create_tensor_descriptor[] = "_create_tensor_descriptor(size_t desc, ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW)";
static PyObject *__pyx_pw_4cupy_5cudnn_17_create_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_desc;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_v_format;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_tensor_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_arr,&__pyx_n_s_format,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_tensor_descriptor", 0, 2, 3, 1); __PYX_ERR(0, 145, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_tensor_descriptor") < 0)) __PYX_ERR(0, 145, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_desc = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L3_error)
    __pyx_v_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    if (values[2]) {
      __pyx_v_format = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L3_error)
    } else {
      __pyx_v_format = __pyx_k_;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_tensor_descriptor", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 145, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 145, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_create_tensor_descriptor(__pyx_self, __pyx_v_desc, __pyx_v_arr, __pyx_v_format);

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

static PyObject *__pyx_pf_4cupy_5cudnn_16_create_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_format) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_descriptor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.format = __pyx_v_format;
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_desc, __pyx_v_arr, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":162
 * 
 * 
 * cpdef _create_tensor_descriptor_as4darray(size_t desc,             # <<<<<<<<<<<<<<
 *                                           core.ndarray arr):
 *     cdef Py_ssize_t dim1, dim2
 */

static PyObject *__pyx_pw_4cupy_5cudnn_19_create_tensor_descriptor_as4darray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_dim1;
  Py_ssize_t __pyx_v_dim2;
  int __pyx_v_data_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_descriptor_as4darray", 0);

  /* "cupy/cudnn.pyx":165
 *                                           core.ndarray arr):
 *     cdef Py_ssize_t dim1, dim2
 *     assert arr._c_contiguous             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(arr.dtype)
 *     dim1 = 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(__pyx_v_arr->_c_contiguous != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 165, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":166
 *     cdef Py_ssize_t dim1, dim2
 *     assert arr._c_contiguous
 *     data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     dim1 = 1
 *     if arr._shape.size() > 0:
 */
  __pyx_t_1 = __pyx_v_arr->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_2;

  /* "cupy/cudnn.pyx":167
 *     assert arr._c_contiguous
 *     data_type = get_data_type(arr.dtype)
 *     dim1 = 1             # <<<<<<<<<<<<<<
 *     if arr._shape.size() > 0:
 *         dim1 = arr._shape[0]
 */
  __pyx_v_dim1 = 1;

  /* "cupy/cudnn.pyx":168
 *     data_type = get_data_type(arr.dtype)
 *     dim1 = 1
 *     if arr._shape.size() > 0:             # <<<<<<<<<<<<<<
 *         dim1 = arr._shape[0]
 *     dim2 = arr.size // dim1
 */
  __pyx_t_3 = ((__pyx_v_arr->_shape.size() > 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":169
 *     dim1 = 1
 *     if arr._shape.size() > 0:
 *         dim1 = arr._shape[0]             # <<<<<<<<<<<<<<
 *     dim2 = arr.size // dim1
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 */
    __pyx_v_dim1 = (__pyx_v_arr->_shape[0]);

    /* "cupy/cudnn.pyx":168
 *     data_type = get_data_type(arr.dtype)
 *     dim1 = 1
 *     if arr._shape.size() > 0:             # <<<<<<<<<<<<<<
 *         dim1 = arr._shape[0]
 *     dim2 = arr.size // dim1
 */
  }

  /* "cupy/cudnn.pyx":170
 *     if arr._shape.size() > 0:
 *         dim1 = arr._shape[0]
 *     dim2 = arr.size // dim1             # <<<<<<<<<<<<<<
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 *                                 dim1, dim2, 1, 1)
 */
  if (unlikely(__pyx_v_dim1 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 170, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_dim1 == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_arr->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 170, __pyx_L1_error)
  }
  __pyx_v_dim2 = __Pyx_div_Py_ssize_t(__pyx_v_arr->size, __pyx_v_dim1);

  /* "cupy/cudnn.pyx":171
 *         dim1 = arr._shape[0]
 *     dim2 = arr.size // dim1
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,             # <<<<<<<<<<<<<<
 *                                 dim1, dim2, 1, 1)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor(__pyx_v_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW, __pyx_v_data_type, __pyx_v_dim1, __pyx_v_dim2, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":162
 * 
 * 
 * cpdef _create_tensor_descriptor_as4darray(size_t desc,             # <<<<<<<<<<<<<<
 *                                           core.ndarray arr):
 *     cdef Py_ssize_t dim1, dim2
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_descriptor_as4darray", __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_5cudnn_19_create_tensor_descriptor_as4darray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_18_create_tensor_descriptor_as4darray[] = "_create_tensor_descriptor_as4darray(size_t desc, ndarray arr)";
static PyObject *__pyx_pw_4cupy_5cudnn_19_create_tensor_descriptor_as4darray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_desc;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_tensor_descriptor_as4darray (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_arr,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_tensor_descriptor_as4darray", 1, 2, 2, 1); __PYX_ERR(0, 162, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_tensor_descriptor_as4darray") < 0)) __PYX_ERR(0, 162, __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_desc = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error)
    __pyx_v_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_tensor_descriptor_as4darray", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 162, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_descriptor_as4darray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 163, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_18_create_tensor_descriptor_as4darray(__pyx_self, __pyx_v_desc, __pyx_v_arr);

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

static PyObject *__pyx_pf_4cupy_5cudnn_18_create_tensor_descriptor_as4darray(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  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("_create_tensor_descriptor_as4darray", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(__pyx_v_desc, __pyx_v_arr, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":175
 * 
 * 
 * cpdef _create_filter_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef vector.vector[int] c_shape
 */

static PyObject *__pyx_pw_4cupy_5cudnn_21_create_filter_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_filter_descriptor(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor *__pyx_optional_args) {
  int __pyx_v_format = __pyx_k__3;
  std::vector<int>  __pyx_v_c_shape;
  Py_ssize_t __pyx_v_s;
  Py_ssize_t __pyx_v_ndim;
  int __pyx_v_data_type;
  Py_ssize_t __pyx_v_k;
  Py_ssize_t __pyx_v_c;
  Py_ssize_t __pyx_v_h;
  Py_ssize_t __pyx_v_w;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  std::vector<Py_ssize_t> ::iterator __pyx_t_14;
  std::vector<Py_ssize_t>  *__pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_filter_descriptor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_format = __pyx_optional_args->format;
    }
  }

  /* "cupy/cudnn.pyx":178
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef vector.vector[int] c_shape
 *     cdef Py_ssize_t s, ndim = arr._shape.size()             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(arr.dtype)
 *     if ndim == 4:
 */
  __pyx_v_ndim = __pyx_v_arr->_shape.size();

  /* "cupy/cudnn.pyx":179
 *     cdef vector.vector[int] c_shape
 *     cdef Py_ssize_t s, ndim = arr._shape.size()
 *     data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     if ndim == 4:
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 */
  __pyx_t_1 = __pyx_v_arr->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_2;

  /* "cupy/cudnn.pyx":180
 *     cdef Py_ssize_t s, ndim = arr._shape.size()
 *     data_type = get_data_type(arr.dtype)
 *     if ndim == 4:             # <<<<<<<<<<<<<<
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             k, c, h, w = arr._shape
 */
  __pyx_t_3 = ((__pyx_v_ndim == 4) != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":181
 *     data_type = get_data_type(arr.dtype)
 *     if ndim == 4:
 *         if format == cudnn.CUDNN_TENSOR_NCHW:             # <<<<<<<<<<<<<<
 *             k, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 */
    switch (__pyx_v_format) {
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW:

      /* "cupy/cudnn.pyx":182
 *     if ndim == 4:
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             k, c, h, w = arr._shape             # <<<<<<<<<<<<<<
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 *             k, h, w, c = arr._shape
 */
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_arr->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 182, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 182, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7};
        __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 182, __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;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L4_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) __PYX_ERR(0, 182, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L5_unpacking_done;
        __pyx_L4_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 182, __pyx_L1_error)
        __pyx_L5_unpacking_done:;
      }
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_k = __pyx_t_10;
      __pyx_v_c = __pyx_t_11;
      __pyx_v_h = __pyx_t_12;
      __pyx_v_w = __pyx_t_13;

      /* "cupy/cudnn.pyx":181
 *     data_type = get_data_type(arr.dtype)
 *     if ndim == 4:
 *         if format == cudnn.CUDNN_TENSOR_NCHW:             # <<<<<<<<<<<<<<
 *             k, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 */
      break;
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NHWC:

      /* "cupy/cudnn.pyx":184
 *             k, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:
 *             k, h, w, c = arr._shape             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))
 */
      __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_arr->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 184, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_5,&__pyx_t_4};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 184, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_6,&__pyx_t_5,&__pyx_t_4};
        __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 184, __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;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) __PYX_ERR(0, 184, __pyx_L1_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 184, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_k = __pyx_t_13;
      __pyx_v_h = __pyx_t_12;
      __pyx_v_w = __pyx_t_11;
      __pyx_v_c = __pyx_t_10;

      /* "cupy/cudnn.pyx":183
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             k, c, h, w = arr._shape
 *         elif format == cudnn.CUDNN_TENSOR_NHWC:             # <<<<<<<<<<<<<<
 *             k, h, w, c = arr._shape
 *         else:
 */
      break;
      default:

      /* "cupy/cudnn.pyx":186
 *             k, h, w, c = arr._shape
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))             # <<<<<<<<<<<<<<
 *         cudnn.setFilter4dDescriptor_v4(
 *             desc, data_type, format, k, c, h, w)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_unknown_cudnnTensorFormat, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 186, __pyx_L1_error)
      break;
    }

    /* "cupy/cudnn.pyx":187
 *         else:
 *             raise ValueError('unknown cudnnTensorFormat: {}'.format(format))
 *         cudnn.setFilter4dDescriptor_v4(             # <<<<<<<<<<<<<<
 *             desc, data_type, format, k, c, h, w)
 *     else:
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setFilter4dDescriptor_v4(__pyx_v_desc, __pyx_v_data_type, __pyx_v_format, __pyx_v_k, __pyx_v_c, __pyx_v_h, __pyx_v_w, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":180
 *     cdef Py_ssize_t s, ndim = arr._shape.size()
 *     data_type = get_data_type(arr.dtype)
 *     if ndim == 4:             # <<<<<<<<<<<<<<
 *         if format == cudnn.CUDNN_TENSOR_NCHW:
 *             k, c, h, w = arr._shape
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":190
 *             desc, data_type, format, k, c, h, w)
 *     else:
 *         for s in arr._shape:             # <<<<<<<<<<<<<<
 *             c_shape.push_back(s)
 *         cudnn.setFilterNdDescriptor_v4(
 */
  /*else*/ {
    __pyx_t_15 = &__pyx_v_arr->_shape;
    __pyx_t_14 = __pyx_t_15->begin();
    for (;;) {
      if (!(__pyx_t_14 != __pyx_t_15->end())) break;
      __pyx_t_10 = *__pyx_t_14;
      ++__pyx_t_14;
      __pyx_v_s = __pyx_t_10;

      /* "cupy/cudnn.pyx":191
 *     else:
 *         for s in arr._shape:
 *             c_shape.push_back(s)             # <<<<<<<<<<<<<<
 *         cudnn.setFilterNdDescriptor_v4(
 *             desc, data_type, format, ndim, <size_t>&c_shape[0])
 */
      try {
        __pyx_v_c_shape.push_back(__pyx_v_s);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 191, __pyx_L1_error)
      }

      /* "cupy/cudnn.pyx":190
 *             desc, data_type, format, k, c, h, w)
 *     else:
 *         for s in arr._shape:             # <<<<<<<<<<<<<<
 *             c_shape.push_back(s)
 *         cudnn.setFilterNdDescriptor_v4(
 */
    }

    /* "cupy/cudnn.pyx":192
 *         for s in arr._shape:
 *             c_shape.push_back(s)
 *         cudnn.setFilterNdDescriptor_v4(             # <<<<<<<<<<<<<<
 *             desc, data_type, format, ndim, <size_t>&c_shape[0])
 * 
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setFilterNdDescriptor_v4(__pyx_v_desc, __pyx_v_data_type, __pyx_v_format, __pyx_v_ndim, ((size_t)(&(__pyx_v_c_shape[0]))), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":175
 * 
 * 
 * cpdef _create_filter_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef vector.vector[int] c_shape
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn._create_filter_descriptor", __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_5cudnn_21_create_filter_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_20_create_filter_descriptor[] = "_create_filter_descriptor(size_t desc, ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW)";
static PyObject *__pyx_pw_4cupy_5cudnn_21_create_filter_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_desc;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr = 0;
  int __pyx_v_format;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_filter_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_arr,&__pyx_n_s_format,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_filter_descriptor", 0, 2, 3, 1); __PYX_ERR(0, 175, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_filter_descriptor") < 0)) __PYX_ERR(0, 175, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_desc = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L3_error)
    __pyx_v_arr = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    if (values[2]) {
      __pyx_v_format = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_format == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L3_error)
    } else {
      __pyx_v_format = __pyx_k__3;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_filter_descriptor", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 175, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._create_filter_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 176, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_20_create_filter_descriptor(__pyx_self, __pyx_v_desc, __pyx_v_arr, __pyx_v_format);

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

static PyObject *__pyx_pf_4cupy_5cudnn_20_create_filter_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_format) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_filter_descriptor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.format = __pyx_v_format;
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_filter_descriptor(__pyx_v_desc, __pyx_v_arr, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":196
 * 
 * 
 * cpdef _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, tuple pad, tuple stride, tuple dilation, int groups,
 *         object dtype, int mode, bint use_tensor_core):
 */

static PyObject *__pyx_pw_4cupy_5cudnn_23_create_convolution_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__create_convolution_descriptor(size_t __pyx_v_desc, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, PyObject *__pyx_v_dtype, int __pyx_v_mode, int __pyx_v_use_tensor_core, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_d0;
  int __pyx_v_d1;
  int __pyx_v_p0;
  int __pyx_v_p1;
  int __pyx_v_s0;
  int __pyx_v_s1;
  std::vector<int>  __pyx_v_c_pad;
  std::vector<int>  __pyx_v_c_stride;
  std::vector<int>  __pyx_v_c_dilation;
  Py_ssize_t __pyx_v_ndim;
  int __pyx_v_compute_type;
  int __pyx_v_i;
  int __pyx_v_math_type;
  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<int>  __pyx_t_5;
  int __pyx_t_6;
  std::vector<int> ::iterator __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_convolution_descriptor", 0);

  /* "cupy/cudnn.pyx":201
 *     cdef int d0, d1, p0, p1, s0, s1
 *     cdef vector.vector[int] c_pad, c_stride, c_dilation
 *     ndim = len(pad)             # <<<<<<<<<<<<<<
 *     if ndim != len(stride):
 *         raise ValueError('pad and stride must be of same length')
 */
  if (unlikely(__pyx_v_pad == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 201, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_pad); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 201, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_1;

  /* "cupy/cudnn.pyx":202
 *     cdef vector.vector[int] c_pad, c_stride, c_dilation
 *     ndim = len(pad)
 *     if ndim != len(stride):             # <<<<<<<<<<<<<<
 *         raise ValueError('pad and stride must be of same length')
 * 
 */
  if (unlikely(__pyx_v_stride == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 202, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_stride); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 202, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_v_ndim != __pyx_t_1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/cudnn.pyx":203
 *     ndim = len(pad)
 *     if ndim != len(stride):
 *         raise ValueError('pad and stride must be of same length')             # <<<<<<<<<<<<<<
 * 
 *     compute_type = get_data_type(dtype)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 203, __pyx_L1_error)

    /* "cupy/cudnn.pyx":202
 *     cdef vector.vector[int] c_pad, c_stride, c_dilation
 *     ndim = len(pad)
 *     if ndim != len(stride):             # <<<<<<<<<<<<<<
 *         raise ValueError('pad and stride must be of same length')
 * 
 */
  }

  /* "cupy/cudnn.pyx":205
 *         raise ValueError('pad and stride must be of same length')
 * 
 *     compute_type = get_data_type(dtype)             # <<<<<<<<<<<<<<
 *     # TODO(takagi) Temporarily use computing precision of FP32 for
 *     #     storing precision of FP16.
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_v_dtype, 0); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L1_error)
  __pyx_v_compute_type = __pyx_t_4;

  /* "cupy/cudnn.pyx":208
 *     # TODO(takagi) Temporarily use computing precision of FP32 for
 *     #     storing precision of FP16.
 *     if compute_type == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         compute_type = cudnn.CUDNN_DATA_FLOAT
 * 
 */
  __pyx_t_2 = ((__pyx_v_compute_type == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_HALF) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":209
 *     #     storing precision of FP16.
 *     if compute_type == cudnn.CUDNN_DATA_HALF:
 *         compute_type = cudnn.CUDNN_DATA_FLOAT             # <<<<<<<<<<<<<<
 * 
 *     if ndim != 2:
 */
    __pyx_v_compute_type = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_FLOAT;

    /* "cupy/cudnn.pyx":208
 *     # TODO(takagi) Temporarily use computing precision of FP32 for
 *     #     storing precision of FP16.
 *     if compute_type == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         compute_type = cudnn.CUDNN_DATA_FLOAT
 * 
 */
  }

  /* "cupy/cudnn.pyx":211
 *         compute_type = cudnn.CUDNN_DATA_FLOAT
 * 
 *     if ndim != 2:             # <<<<<<<<<<<<<<
 *         c_pad = pad
 *         c_stride = stride
 */
  __pyx_t_2 = ((__pyx_v_ndim != 2) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":212
 * 
 *     if ndim != 2:
 *         c_pad = pad             # <<<<<<<<<<<<<<
 *         c_stride = stride
 *         if dilation is None:
 */
    __pyx_t_5 = __pyx_convert_vector_from_py_int(__pyx_v_pad); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 212, __pyx_L1_error)
    __pyx_v_c_pad = __pyx_t_5;

    /* "cupy/cudnn.pyx":213
 *     if ndim != 2:
 *         c_pad = pad
 *         c_stride = stride             # <<<<<<<<<<<<<<
 *         if dilation is None:
 *             c_dilation.assign(ndim, 1)
 */
    __pyx_t_5 = __pyx_convert_vector_from_py_int(__pyx_v_stride); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 213, __pyx_L1_error)
    __pyx_v_c_stride = __pyx_t_5;

    /* "cupy/cudnn.pyx":214
 *         c_pad = pad
 *         c_stride = stride
 *         if dilation is None:             # <<<<<<<<<<<<<<
 *             c_dilation.assign(ndim, 1)
 *         else:
 */
    __pyx_t_2 = (__pyx_v_dilation == ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_2 != 0);
    if (__pyx_t_6) {

      /* "cupy/cudnn.pyx":215
 *         c_stride = stride
 *         if dilation is None:
 *             c_dilation.assign(ndim, 1)             # <<<<<<<<<<<<<<
 *         else:
 *             c_dilation = dilation
 */
      __pyx_v_c_dilation.assign(__pyx_v_ndim, 1);

      /* "cupy/cudnn.pyx":214
 *         c_pad = pad
 *         c_stride = stride
 *         if dilation is None:             # <<<<<<<<<<<<<<
 *             c_dilation.assign(ndim, 1)
 *         else:
 */
      goto __pyx_L6;
    }

    /* "cupy/cudnn.pyx":217
 *             c_dilation.assign(ndim, 1)
 *         else:
 *             c_dilation = dilation             # <<<<<<<<<<<<<<
 *             if _cudnn_version < 6000:
 *                 for i in c_dilation:
 */
    /*else*/ {
      __pyx_t_5 = __pyx_convert_vector_from_py_int(__pyx_v_dilation); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L1_error)
      __pyx_v_c_dilation = __pyx_t_5;

      /* "cupy/cudnn.pyx":218
 *         else:
 *             c_dilation = dilation
 *             if _cudnn_version < 6000:             # <<<<<<<<<<<<<<
 *                 for i in c_dilation:
 *                     if i != 1:
 */
      __pyx_t_6 = ((__pyx_v_4cupy_5cudnn__cudnn_version < 0x1770) != 0);
      if (__pyx_t_6) {

        /* "cupy/cudnn.pyx":219
 *             c_dilation = dilation
 *             if _cudnn_version < 6000:
 *                 for i in c_dilation:             # <<<<<<<<<<<<<<
 *                     if i != 1:
 *                         raise ValueError(
 */
        __pyx_t_7 = __pyx_v_c_dilation.begin();
        for (;;) {
          if (!(__pyx_t_7 != __pyx_v_c_dilation.end())) break;
          __pyx_t_4 = *__pyx_t_7;
          ++__pyx_t_7;
          __pyx_v_i = __pyx_t_4;

          /* "cupy/cudnn.pyx":220
 *             if _cudnn_version < 6000:
 *                 for i in c_dilation:
 *                     if i != 1:             # <<<<<<<<<<<<<<
 *                         raise ValueError(
 *                             'dilation must be one when cuDNN < 6.0')
 */
          __pyx_t_6 = ((__pyx_v_i != 1) != 0);
          if (unlikely(__pyx_t_6)) {

            /* "cupy/cudnn.pyx":221
 *                 for i in c_dilation:
 *                     if i != 1:
 *                         raise ValueError(             # <<<<<<<<<<<<<<
 *                             'dilation must be one when cuDNN < 6.0')
 *         cudnn.setConvolutionNdDescriptor_v3(
 */
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_Raise(__pyx_t_3, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __PYX_ERR(0, 221, __pyx_L1_error)

            /* "cupy/cudnn.pyx":220
 *             if _cudnn_version < 6000:
 *                 for i in c_dilation:
 *                     if i != 1:             # <<<<<<<<<<<<<<
 *                         raise ValueError(
 *                             'dilation must be one when cuDNN < 6.0')
 */
          }

          /* "cupy/cudnn.pyx":219
 *             c_dilation = dilation
 *             if _cudnn_version < 6000:
 *                 for i in c_dilation:             # <<<<<<<<<<<<<<
 *                     if i != 1:
 *                         raise ValueError(
 */
        }

        /* "cupy/cudnn.pyx":218
 *         else:
 *             c_dilation = dilation
 *             if _cudnn_version < 6000:             # <<<<<<<<<<<<<<
 *                 for i in c_dilation:
 *                     if i != 1:
 */
      }
    }
    __pyx_L6:;

    /* "cupy/cudnn.pyx":223
 *                         raise ValueError(
 *                             'dilation must be one when cuDNN < 6.0')
 *         cudnn.setConvolutionNdDescriptor_v3(             # <<<<<<<<<<<<<<
 *             desc, ndim, <size_t>&c_pad[0], <size_t>&c_stride[0],
 *             <size_t>&c_dilation[0], mode, compute_type)
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionNdDescriptor_v3(__pyx_v_desc, __pyx_v_ndim, ((size_t)(&(__pyx_v_c_pad[0]))), ((size_t)(&(__pyx_v_c_stride[0]))), ((size_t)(&(__pyx_v_c_dilation[0]))), __pyx_v_mode, __pyx_v_compute_type, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cudnn.pyx":211
 *         compute_type = cudnn.CUDNN_DATA_FLOAT
 * 
 *     if ndim != 2:             # <<<<<<<<<<<<<<
 *         c_pad = pad
 *         c_stride = stride
 */
    goto __pyx_L5;
  }

  /* "cupy/cudnn.pyx":227
 *             <size_t>&c_dilation[0], mode, compute_type)
 *     else:
 *         if dilation is None:             # <<<<<<<<<<<<<<
 *             d0 = d1 = 1
 *         else:
 */
  /*else*/ {
    __pyx_t_6 = (__pyx_v_dilation == ((PyObject*)Py_None));
    __pyx_t_2 = (__pyx_t_6 != 0);
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":228
 *     else:
 *         if dilation is None:
 *             d0 = d1 = 1             # <<<<<<<<<<<<<<
 *         else:
 *             d0, d1 = dilation
 */
      __pyx_v_d0 = 1;
      __pyx_v_d1 = 1;

      /* "cupy/cudnn.pyx":227
 *             <size_t>&c_dilation[0], mode, compute_type)
 *     else:
 *         if dilation is None:             # <<<<<<<<<<<<<<
 *             d0 = d1 = 1
 *         else:
 */
      goto __pyx_L11;
    }

    /* "cupy/cudnn.pyx":230
 *             d0 = d1 = 1
 *         else:
 *             d0, d1 = dilation             # <<<<<<<<<<<<<<
 *             if _cudnn_version < 6000 and (d0 != 1 or d1 != 1):
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')
 */
    /*else*/ {
      if (likely(__pyx_v_dilation != Py_None)) {
        PyObject* sequence = __pyx_v_dilation;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 230, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 230, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 230, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_d0 = __pyx_t_4;
      __pyx_v_d1 = __pyx_t_9;

      /* "cupy/cudnn.pyx":231
 *         else:
 *             d0, d1 = dilation
 *             if _cudnn_version < 6000 and (d0 != 1 or d1 != 1):             # <<<<<<<<<<<<<<
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')
 *         p0, p1 = pad
 */
      __pyx_t_6 = ((__pyx_v_4cupy_5cudnn__cudnn_version < 0x1770) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_2 = __pyx_t_6;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_6 = ((__pyx_v_d0 != 1) != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_2 = __pyx_t_6;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_6 = ((__pyx_v_d1 != 1) != 0);
      __pyx_t_2 = __pyx_t_6;
      __pyx_L13_bool_binop_done:;
      if (unlikely(__pyx_t_2)) {

        /* "cupy/cudnn.pyx":232
 *             d0, d1 = dilation
 *             if _cudnn_version < 6000 and (d0 != 1 or d1 != 1):
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')             # <<<<<<<<<<<<<<
 *         p0, p1 = pad
 *         s0, s1 = stride
 */
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 232, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 232, __pyx_L1_error)

        /* "cupy/cudnn.pyx":231
 *         else:
 *             d0, d1 = dilation
 *             if _cudnn_version < 6000 and (d0 != 1 or d1 != 1):             # <<<<<<<<<<<<<<
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')
 *         p0, p1 = pad
 */
      }
    }
    __pyx_L11:;

    /* "cupy/cudnn.pyx":233
 *             if _cudnn_version < 6000 and (d0 != 1 or d1 != 1):
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')
 *         p0, p1 = pad             # <<<<<<<<<<<<<<
 *         s0, s1 = stride
 *         cudnn.setConvolution2dDescriptor_v5(
 */
    if (likely(__pyx_v_pad != Py_None)) {
      PyObject* sequence = __pyx_v_pad;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 233, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_3);
      #else
      __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 233, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 233, __pyx_L1_error)
    }
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_p0 = __pyx_t_9;
    __pyx_v_p1 = __pyx_t_4;

    /* "cupy/cudnn.pyx":234
 *                 raise ValueError('dilation must be one when cuDNN < 6.0')
 *         p0, p1 = pad
 *         s0, s1 = stride             # <<<<<<<<<<<<<<
 *         cudnn.setConvolution2dDescriptor_v5(
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 */
    if (likely(__pyx_v_stride != Py_None)) {
      PyObject* sequence = __pyx_v_stride;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 234, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 234, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_s0 = __pyx_t_4;
    __pyx_v_s1 = __pyx_t_9;

    /* "cupy/cudnn.pyx":235
 *         p0, p1 = pad
 *         s0, s1 = stride
 *         cudnn.setConvolution2dDescriptor_v5(             # <<<<<<<<<<<<<<
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 *     if _cudnn_version >= 7000:
 */
    __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_setConvolution2dDescriptor_v5(__pyx_v_desc, __pyx_v_p0, __pyx_v_p1, __pyx_v_s0, __pyx_v_s1, __pyx_v_d0, __pyx_v_d1, __pyx_v_mode, __pyx_v_compute_type, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_L5:;

  /* "cupy/cudnn.pyx":237
 *         cudnn.setConvolution2dDescriptor_v5(
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if use_tensor_core:
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 */
  __pyx_t_2 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":238
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 *     if _cudnn_version >= 7000:
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 *             cudnn.setConvolutionMathType(desc, math_type)
 */
    __pyx_t_2 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":239
 *     if _cudnn_version >= 7000:
 *         if use_tensor_core:
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(desc, math_type)
 *         if groups > 1:
 */
      __pyx_v_math_type = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH;

      /* "cupy/cudnn.pyx":240
 *         if use_tensor_core:
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 *             cudnn.setConvolutionMathType(desc, math_type)             # <<<<<<<<<<<<<<
 *         if groups > 1:
 *             cudnn.setConvolutionGroupCount(desc, groups)
 */
      __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType(__pyx_v_desc, __pyx_v_math_type, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 240, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/cudnn.pyx":238
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 *     if _cudnn_version >= 7000:
 *         if use_tensor_core:             # <<<<<<<<<<<<<<
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 *             cudnn.setConvolutionMathType(desc, math_type)
 */
    }

    /* "cupy/cudnn.pyx":241
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 *             cudnn.setConvolutionMathType(desc, math_type)
 *         if groups > 1:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:
 */
    __pyx_t_2 = ((__pyx_v_groups > 1) != 0);
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":242
 *             cudnn.setConvolutionMathType(desc, math_type)
 *         if groups > 1:
 *             cudnn.setConvolutionGroupCount(desc, groups)             # <<<<<<<<<<<<<<
 *     elif groups > 1:
 *         raise ValueError('groups must be one when cuDNN < 7.0')
 */
      __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionGroupCount(__pyx_v_desc, __pyx_v_groups, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cupy/cudnn.pyx":241
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 *             cudnn.setConvolutionMathType(desc, math_type)
 *         if groups > 1:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:
 */
    }

    /* "cupy/cudnn.pyx":237
 *         cudnn.setConvolution2dDescriptor_v5(
 *             desc, p0, p1, s0, s1, d0, d1, mode, compute_type)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if use_tensor_core:
 *             math_type = cudnn.CUDNN_TENSOR_OP_MATH
 */
    goto __pyx_L16;
  }

  /* "cupy/cudnn.pyx":243
 *         if groups > 1:
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:             # <<<<<<<<<<<<<<
 *         raise ValueError('groups must be one when cuDNN < 7.0')
 * 
 */
  __pyx_t_2 = ((__pyx_v_groups > 1) != 0);
  if (unlikely(__pyx_t_2)) {

    /* "cupy/cudnn.pyx":244
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:
 *         raise ValueError('groups must be one when cuDNN < 7.0')             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 244, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_Raise(__pyx_t_8, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __PYX_ERR(0, 244, __pyx_L1_error)

    /* "cupy/cudnn.pyx":243
 *         if groups > 1:
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:             # <<<<<<<<<<<<<<
 *         raise ValueError('groups must be one when cuDNN < 7.0')
 * 
 */
  }
  __pyx_L16:;

  /* "cupy/cudnn.pyx":196
 * 
 * 
 * cpdef _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, tuple pad, tuple stride, tuple dilation, int groups,
 *         object dtype, int mode, bint use_tensor_core):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn._create_convolution_descriptor", __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_5cudnn_23_create_convolution_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_22_create_convolution_descriptor[] = "_create_convolution_descriptor(size_t desc, tuple pad, tuple stride, tuple dilation, int groups, dtype, int mode, bool use_tensor_core)";
static PyObject *__pyx_pw_4cupy_5cudnn_23_create_convolution_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_desc;
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_dilation = 0;
  int __pyx_v_groups;
  PyObject *__pyx_v_dtype = 0;
  int __pyx_v_mode;
  int __pyx_v_use_tensor_core;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_convolution_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_pad,&__pyx_n_s_stride,&__pyx_n_s_dilation,&__pyx_n_s_groups,&__pyx_n_s_dtype,&__pyx_n_s_mode,&__pyx_n_s_use_tensor_core,0};
    PyObject* values[8] = {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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 1); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 2); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dilation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 3); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_groups)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 4); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 5); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 6); __PYX_ERR(0, 196, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, 7); __PYX_ERR(0, 196, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_convolution_descriptor") < 0)) __PYX_ERR(0, 196, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
    }
    __pyx_v_desc = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L3_error)
    __pyx_v_pad = ((PyObject*)values[1]);
    __pyx_v_stride = ((PyObject*)values[2]);
    __pyx_v_dilation = ((PyObject*)values[3]);
    __pyx_v_groups = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_groups == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L3_error)
    __pyx_v_dtype = values[5];
    __pyx_v_mode = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_convolution_descriptor", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 196, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._create_convolution_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 197, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 197, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dilation), (&PyTuple_Type), 1, "dilation", 1))) __PYX_ERR(0, 197, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_22_create_convolution_descriptor(__pyx_self, __pyx_v_desc, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_v_dtype, __pyx_v_mode, __pyx_v_use_tensor_core);

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

static PyObject *__pyx_pf_4cupy_5cudnn_22_create_convolution_descriptor(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_desc, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, PyObject *__pyx_v_dtype, int __pyx_v_mode, int __pyx_v_use_tensor_core) {
  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("_create_convolution_descriptor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_convolution_descriptor(__pyx_v_desc, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_v_dtype, __pyx_v_mode, __pyx_v_use_tensor_core, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":247
 * 
 * 
 * cpdef core.ndarray _ascontiguousarray_normalized_strides(core.ndarray a):             # <<<<<<<<<<<<<<
 *     cdef core.ndarray newarray
 * 
 */

static PyObject *__pyx_pw_4cupy_5cudnn_25_ascontiguousarray_normalized_strides(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_5cudnn__ascontiguousarray_normalized_strides(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_newarray = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__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_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_ascontiguousarray_normalized_strides", 0);

  /* "cupy/cudnn.pyx":250
 *     cdef core.ndarray newarray
 * 
 *     if a._c_contiguous:             # <<<<<<<<<<<<<<
 *         newarray = a.view()
 *         newarray._set_contiguous_strides(newarray.itemsize, True)
 */
  __pyx_t_1 = (__pyx_v_a->_c_contiguous != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":251
 * 
 *     if a._c_contiguous:
 *         newarray = a.view()             # <<<<<<<<<<<<<<
 *         newarray._set_contiguous_strides(newarray.itemsize, True)
 *     else:
 */
    __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_a->__pyx_vtab)->view(__pyx_v_a, 0, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":252
 *     if a._c_contiguous:
 *         newarray = a.view()
 *         newarray._set_contiguous_strides(newarray.itemsize, True)             # <<<<<<<<<<<<<<
 *     else:
 *         newarray = core.ndarray(a.shape, a.dtype)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_newarray), __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_newarray->__pyx_vtab)->_set_contiguous_strides(__pyx_v_newarray, __pyx_t_3, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":250
 *     cdef core.ndarray newarray
 * 
 *     if a._c_contiguous:             # <<<<<<<<<<<<<<
 *         newarray = a.view()
 *         newarray._set_contiguous_strides(newarray.itemsize, True)
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":254
 *         newarray._set_contiguous_strides(newarray.itemsize, True)
 *     else:
 *         newarray = core.ndarray(a.shape, a.dtype)             # <<<<<<<<<<<<<<
 *         elementwise_copy(a, newarray)
 *     return newarray
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __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_v_a->dtype);
    __Pyx_GIVEREF(__pyx_v_a->dtype);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_a->dtype);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 254, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_newarray = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":255
 *     else:
 *         newarray = core.ndarray(a.shape, a.dtype)
 *         elementwise_copy(a, newarray)             # <<<<<<<<<<<<<<
 *     return newarray
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_a), ((PyObject *)__pyx_v_newarray)};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_a));
      __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_newarray));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_newarray));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":256
 *         newarray = core.ndarray(a.shape, a.dtype)
 *         elementwise_copy(a, newarray)
 *     return newarray             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_newarray));
  __pyx_r = __pyx_v_newarray;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":247
 * 
 * 
 * cpdef core.ndarray _ascontiguousarray_normalized_strides(core.ndarray a):             # <<<<<<<<<<<<<<
 *     cdef core.ndarray newarray
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.cudnn._ascontiguousarray_normalized_strides", __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_5cudnn_25_ascontiguousarray_normalized_strides(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_4cupy_5cudnn_24_ascontiguousarray_normalized_strides[] = "_ascontiguousarray_normalized_strides(ndarray a) -> ndarray";
static PyObject *__pyx_pw_4cupy_5cudnn_25_ascontiguousarray_normalized_strides(PyObject *__pyx_self, PyObject *__pyx_v_a) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_ascontiguousarray_normalized_strides (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "a", 0))) __PYX_ERR(0, 247, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_24_ascontiguousarray_normalized_strides(__pyx_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_a));

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

static PyObject *__pyx_pf_4cupy_5cudnn_24_ascontiguousarray_normalized_strides(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_ascontiguousarray_normalized_strides", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__ascontiguousarray_normalized_strides(__pyx_v_a, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":259
 * 
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_27create_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_26create_tensor_descriptor[] = "create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_27create_tensor_descriptor = {"create_tensor_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_27create_tensor_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_26create_tensor_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_27create_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arr = 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("create_tensor_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_format,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__7;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_tensor_descriptor") < 0)) __PYX_ERR(0, 259, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_arr = values[0];
    __pyx_v_format = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_tensor_descriptor", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 259, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_26create_tensor_descriptor(__pyx_self, __pyx_v_arr, __pyx_v_format);

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

static PyObject *__pyx_pf_4cupy_5cudnn_26create_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_format) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_tensor_descriptor", 0);

  /* "cupy/cudnn.pyx":260
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_descriptor(desc.value, arr, format)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 260, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":261
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)             # <<<<<<<<<<<<<<
 *     _create_tensor_descriptor(desc.value, arr, format)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyTensorDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":260
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_descriptor(desc.value, arr, format)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 260, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":262
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_descriptor(desc.value, arr, format)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  if (!(likely(((__pyx_v_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_arr, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 262, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_format); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L1_error)
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.format = __pyx_t_5;
  __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_desc->value, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arr), 0, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":263
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_descriptor(desc.value, arr, format)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":259
 * 
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":266
 * 
 * 
 * def create_uninitialized_tensor_descriptor():             # <<<<<<<<<<<<<<
 *     """Create uninitialized tensor descriptor.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_29create_uninitialized_tensor_descriptor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_28create_uninitialized_tensor_descriptor[] = "create_uninitialized_tensor_descriptor()\nCreate uninitialized tensor descriptor.\n\n    Create a cudnnCreateTensorDescriptor_t that is not yet initialized.\n    This is used by the batch normalization functions.\n    ";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_29create_uninitialized_tensor_descriptor = {"create_uninitialized_tensor_descriptor", (PyCFunction)__pyx_pw_4cupy_5cudnn_29create_uninitialized_tensor_descriptor, METH_NOARGS, __pyx_doc_4cupy_5cudnn_28create_uninitialized_tensor_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_29create_uninitialized_tensor_descriptor(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_uninitialized_tensor_descriptor (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_28create_uninitialized_tensor_descriptor(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_5cudnn_28create_uninitialized_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __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("create_uninitialized_tensor_descriptor", 0);

  /* "cupy/cudnn.pyx":272
 *     This is used by the batch normalization functions.
 *     """
 *     return Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 272, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":273
 *     """
 *     return Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyTensorDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":272
 *     This is used by the batch normalization functions.
 *     """
 *     return Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":266
 * 
 * 
 * def create_uninitialized_tensor_descriptor():             # <<<<<<<<<<<<<<
 *     """Create uninitialized tensor descriptor.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_uninitialized_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":276
 * 
 * 
 * def create_tensor_nd_descriptor(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     cdef dict cache
 *     if arr.size == 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_31create_tensor_nd_descriptor(PyObject *__pyx_self, PyObject *__pyx_v_arr); /*proto*/
static char __pyx_doc_4cupy_5cudnn_30create_tensor_nd_descriptor[] = "create_tensor_nd_descriptor(ndarray arr)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_31create_tensor_nd_descriptor = {"create_tensor_nd_descriptor", (PyCFunction)__pyx_pw_4cupy_5cudnn_31create_tensor_nd_descriptor, METH_O, __pyx_doc_4cupy_5cudnn_30create_tensor_nd_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_31create_tensor_nd_descriptor(PyObject *__pyx_self, PyObject *__pyx_v_arr) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_tensor_nd_descriptor (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 276, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_30create_tensor_nd_descriptor(__pyx_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arr));

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

static PyObject *__pyx_pf_4cupy_5cudnn_30create_tensor_nd_descriptor(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  PyObject *__pyx_v_cache = 0;
  int __pyx_v_data_type;
  PyObject *__pyx_v_key = NULL;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_tensor_nd_descriptor", 0);

  /* "cupy/cudnn.pyx":278
 * def create_tensor_nd_descriptor(core.ndarray arr):
 *     cdef dict cache
 *     if arr.size == 0:             # <<<<<<<<<<<<<<
 *         return Descriptor(0, None)
 *     if not arr.flags.c_contiguous:
 */
  __pyx_t_1 = ((__pyx_v_arr->size == 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":279
 *     cdef dict cache
 *     if arr.size == 0:
 *         return Descriptor(0, None)             # <<<<<<<<<<<<<<
 *     if not arr.flags.c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":278
 * def create_tensor_nd_descriptor(core.ndarray arr):
 *     cdef dict cache
 *     if arr.size == 0:             # <<<<<<<<<<<<<<
 *         return Descriptor(0, None)
 *     if not arr.flags.c_contiguous:
 */
  }

  /* "cupy/cudnn.pyx":280
 *     if arr.size == 0:
 *         return Descriptor(0, None)
 *     if not arr.flags.c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     data_type = get_data_type(arr.dtype)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((!__pyx_t_1) != 0);
  if (unlikely(__pyx_t_4)) {

    /* "cupy/cudnn.pyx":281
 *         return Descriptor(0, None)
 *     if not arr.flags.c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(arr.dtype)
 *     key = (data_type, tuple(arr._shape))
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(0, 281, __pyx_L1_error)

    /* "cupy/cudnn.pyx":280
 *     if arr.size == 0:
 *         return Descriptor(0, None)
 *     if not arr.flags.c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     data_type = get_data_type(arr.dtype)
 */
  }

  /* "cupy/cudnn.pyx":282
 *     if not arr.flags.c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     key = (data_type, tuple(arr._shape))
 *     cache = _get_nd_tensor_cache()
 */
  __pyx_t_3 = __pyx_v_arr->dtype;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_3, 0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data_type = __pyx_t_5;

  /* "cupy/cudnn.pyx":283
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 *     data_type = get_data_type(arr.dtype)
 *     key = (data_type, tuple(arr._shape))             # <<<<<<<<<<<<<<
 *     cache = _get_nd_tensor_cache()
 *     if key in cache:
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_data_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_arr->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":284
 *     data_type = get_data_type(arr.dtype)
 *     key = (data_type, tuple(arr._shape))
 *     cache = _get_nd_tensor_cache()             # <<<<<<<<<<<<<<
 *     if key in cache:
 *         return cache[key]
 */
  __pyx_t_2 = __pyx_f_4cupy_5cudnn__get_nd_tensor_cache(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_cache = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":285
 *     key = (data_type, tuple(arr._shape))
 *     cache = _get_nd_tensor_cache()
 *     if key in cache:             # <<<<<<<<<<<<<<
 *         return cache[key]
 * 
 */
  if (unlikely(__pyx_v_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 285, __pyx_L1_error)
  }
  __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_v_key, __pyx_v_cache, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 285, __pyx_L1_error)
  __pyx_t_1 = (__pyx_t_4 != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":286
 *     cache = _get_nd_tensor_cache()
 *     if key in cache:
 *         return cache[key]             # <<<<<<<<<<<<<<
 * 
 *     # numpy's stride is defined in bytes, but cudnn's stride is defined in
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_cache == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 286, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_cache, __pyx_v_key); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":285
 *     key = (data_type, tuple(arr._shape))
 *     cache = _get_nd_tensor_cache()
 *     if key in cache:             # <<<<<<<<<<<<<<
 *         return cache[key]
 * 
 */
  }

  /* "cupy/cudnn.pyx":290
 *     # numpy's stride is defined in bytes, but cudnn's stride is defined in
 *     # size of element
 *     desc = Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":291
 *     # size of element
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)             # <<<<<<<<<<<<<<
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)
 *     cache[key] = desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_destroyTensorDescriptor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":290
 *     # numpy's stride is defined in bytes, but cudnn's stride is defined in
 *     # size of element
 *     desc = Descriptor(cudnn.createTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)
 */
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":292
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)             # <<<<<<<<<<<<<<
 *     cache[key] = desc
 *     return desc
 */
  __pyx_t_8.__pyx_n = 1;
  __pyx_t_8.data_type = __pyx_v_data_type;
  __pyx_t_3 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_desc->value, __pyx_v_arr, 0, &__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":293
 *                       py_cudnn.destroyTensorDescriptor)
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)
 *     cache[key] = desc             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  if (unlikely(__pyx_v_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 293, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_cache, __pyx_v_key, ((PyObject *)__pyx_v_desc)) < 0)) __PYX_ERR(0, 293, __pyx_L1_error)

  /* "cupy/cudnn.pyx":294
 *     _create_tensor_nd_descriptor(desc.value, arr, data_type)
 *     cache[key] = desc
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":276
 * 
 * 
 * def create_tensor_nd_descriptor(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     cdef dict cache
 *     if arr.size == 0:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.cudnn.create_tensor_nd_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cache);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":297
 * 
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_33create_filter_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_32create_filter_descriptor[] = "create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_33create_filter_descriptor = {"create_filter_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_33create_filter_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_32create_filter_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_33create_filter_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_arr = 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("create_filter_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_format,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k__9;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_filter_descriptor") < 0)) __PYX_ERR(0, 297, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_arr = values[0];
    __pyx_v_format = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_filter_descriptor", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 297, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_filter_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_32create_filter_descriptor(__pyx_self, __pyx_v_arr, __pyx_v_format);

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

static PyObject *__pyx_pf_4cupy_5cudnn_32create_filter_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_format) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_filter_descriptor", 0);

  /* "cupy/cudnn.pyx":298
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createFilterDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyFilterDescriptor)
 *     _create_filter_descriptor(desc.value, arr, format)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":299
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)             # <<<<<<<<<<<<<<
 *     _create_filter_descriptor(desc.value, arr, format)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyFilterDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":298
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):
 *     desc = Descriptor(cudnn.createFilterDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyFilterDescriptor)
 *     _create_filter_descriptor(desc.value, arr, format)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":300
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)
 *     _create_filter_descriptor(desc.value, arr, format)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  if (!(likely(((__pyx_v_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_arr, __pyx_ptype_4cupy_4core_4core_ndarray))))) __PYX_ERR(0, 300, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_format); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
  __pyx_t_6.__pyx_n = 1;
  __pyx_t_6.format = __pyx_t_5;
  __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_filter_descriptor(__pyx_v_desc->value, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arr), 0, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":301
 *                       py_cudnn.destroyFilterDescriptor)
 *     _create_filter_descriptor(desc.value, arr, format)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":297
 * 
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_filter_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":304
 * 
 * 
 * def create_convolution_descriptor(pad, stride, dtype,             # <<<<<<<<<<<<<<
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_35create_convolution_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_34create_convolution_descriptor[] = "create_convolution_descriptor(pad, stride, dtype, mode=cudnn.CUDNN_CROSS_CORRELATION, dilation=None, use_tensor_core=False, groups=1)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_35create_convolution_descriptor = {"create_convolution_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_35create_convolution_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_34create_convolution_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_35create_convolution_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_dilation = 0;
  PyObject *__pyx_v_use_tensor_core = 0;
  PyObject *__pyx_v_groups = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_convolution_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pad,&__pyx_n_s_stride,&__pyx_n_s_dtype,&__pyx_n_s_mode,&__pyx_n_s_dilation,&__pyx_n_s_use_tensor_core,&__pyx_n_s_groups,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[3] = __pyx_k__10;

    /* "cupy/cudnn.pyx":306
 * def create_convolution_descriptor(pad, stride, dtype,
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,             # <<<<<<<<<<<<<<
 *                                   use_tensor_core=False,
 *                                   groups=1):
 */
    values[4] = ((PyObject *)Py_None);

    /* "cupy/cudnn.pyx":307
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 *                                   use_tensor_core=False,             # <<<<<<<<<<<<<<
 *                                   groups=1):
 *     desc = Descriptor(cudnn.createConvolutionDescriptor(),
 */
    values[5] = ((PyObject *)Py_False);
    values[6] = ((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  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_convolution_descriptor", 0, 3, 7, 1); __PYX_ERR(0, 304, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_convolution_descriptor", 0, 3, 7, 2); __PYX_ERR(0, 304, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dilation);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_groups);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_convolution_descriptor") < 0)) __PYX_ERR(0, 304, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pad = values[0];
    __pyx_v_stride = values[1];
    __pyx_v_dtype = values[2];
    __pyx_v_mode = values[3];
    __pyx_v_dilation = values[4];
    __pyx_v_use_tensor_core = values[5];
    __pyx_v_groups = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_convolution_descriptor", 0, 3, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 304, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_convolution_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_34create_convolution_descriptor(__pyx_self, __pyx_v_pad, __pyx_v_stride, __pyx_v_dtype, __pyx_v_mode, __pyx_v_dilation, __pyx_v_use_tensor_core, __pyx_v_groups);

  /* "cupy/cudnn.pyx":304
 * 
 * 
 * def create_convolution_descriptor(pad, stride, dtype,             # <<<<<<<<<<<<<<
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 */

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

static PyObject *__pyx_pf_4cupy_5cudnn_34create_convolution_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dtype, PyObject *__pyx_v_mode, PyObject *__pyx_v_dilation, PyObject *__pyx_v_use_tensor_core, PyObject *__pyx_v_groups) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_convolution_descriptor", 0);

  /* "cupy/cudnn.pyx":309
 *                                   use_tensor_core=False,
 *                                   groups=1):
 *     desc = Descriptor(cudnn.createConvolutionDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyConvolutionDescriptor)
 *     _create_convolution_descriptor(
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 309, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":310
 *                                   groups=1):
 *     desc = Descriptor(cudnn.createConvolutionDescriptor(),
 *                       py_cudnn.destroyConvolutionDescriptor)             # <<<<<<<<<<<<<<
 *     _create_convolution_descriptor(
 *         desc.value, pad, stride, dilation, groups,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyConvolutionDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":309
 *                                   use_tensor_core=False,
 *                                   groups=1):
 *     desc = Descriptor(cudnn.createConvolutionDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyConvolutionDescriptor)
 *     _create_convolution_descriptor(
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":312
 *                       py_cudnn.destroyConvolutionDescriptor)
 *     _create_convolution_descriptor(
 *         desc.value, pad, stride, dilation, groups,             # <<<<<<<<<<<<<<
 *         dtype, mode, use_tensor_core)
 *     return desc
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_pad))||((__pyx_v_pad) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_pad)->tp_name), 0))) __PYX_ERR(0, 312, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_stride))||((__pyx_v_stride) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_stride)->tp_name), 0))) __PYX_ERR(0, 312, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_dilation))||((__pyx_v_dilation) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_dilation)->tp_name), 0))) __PYX_ERR(0, 312, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_groups); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 312, __pyx_L1_error)

  /* "cupy/cudnn.pyx":313
 *     _create_convolution_descriptor(
 *         desc.value, pad, stride, dilation, groups,
 *         dtype, mode, use_tensor_core)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_mode); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 313, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_use_tensor_core); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 313, __pyx_L1_error)

  /* "cupy/cudnn.pyx":311
 *     desc = Descriptor(cudnn.createConvolutionDescriptor(),
 *                       py_cudnn.destroyConvolutionDescriptor)
 *     _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *         desc.value, pad, stride, dilation, groups,
 *         dtype, mode, use_tensor_core)
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_convolution_descriptor(__pyx_v_desc->value, ((PyObject*)__pyx_v_pad), ((PyObject*)__pyx_v_stride), ((PyObject*)__pyx_v_dilation), __pyx_t_5, __pyx_v_dtype, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":314
 *         desc.value, pad, stride, dilation, groups,
 *         dtype, mode, use_tensor_core)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":304
 * 
 * 
 * def create_convolution_descriptor(pad, stride, dtype,             # <<<<<<<<<<<<<<
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_convolution_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":317
 * 
 * 
 * cdef _create_pooling_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef vector.vector[int] c_ksize, c_pad, c_stride
 */

static PyObject *__pyx_f_4cupy_5cudnn__create_pooling_descriptor(size_t __pyx_v_desc, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode) {
  std::vector<int>  __pyx_v_c_ksize;
  std::vector<int>  __pyx_v_c_pad;
  std::vector<int>  __pyx_v_c_stride;
  int __pyx_v_ndim;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  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_t_10;
  std::vector<int>  __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_pooling_descriptor", 0);

  /* "cupy/cudnn.pyx":320
 *         size_t desc, tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef vector.vector[int] c_ksize, c_pad, c_stride
 *     cdef int ndim = len(ksize)             # <<<<<<<<<<<<<<
 *     if ndim != len(stride) or ndim != len(pad):
 *         raise ValueError('ksize, stride, and pad must be of same length')
 */
  if (unlikely(__pyx_v_ksize == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 320, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_ksize); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 320, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_1;

  /* "cupy/cudnn.pyx":321
 *     cdef vector.vector[int] c_ksize, c_pad, c_stride
 *     cdef int ndim = len(ksize)
 *     if ndim != len(stride) or ndim != len(pad):             # <<<<<<<<<<<<<<
 *         raise ValueError('ksize, stride, and pad must be of same length')
 *     if ndim == 2:
 */
  if (unlikely(__pyx_v_stride == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 321, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_stride); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 321, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_v_ndim != __pyx_t_1) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_pad == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 321, __pyx_L1_error)
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_pad); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 321, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_v_ndim != __pyx_t_1) != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_2)) {

    /* "cupy/cudnn.pyx":322
 *     cdef int ndim = len(ksize)
 *     if ndim != len(stride) or ndim != len(pad):
 *         raise ValueError('ksize, stride, and pad must be of same length')             # <<<<<<<<<<<<<<
 *     if ndim == 2:
 *         cudnn.setPooling2dDescriptor_v4(
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 322, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 322, __pyx_L1_error)

    /* "cupy/cudnn.pyx":321
 *     cdef vector.vector[int] c_ksize, c_pad, c_stride
 *     cdef int ndim = len(ksize)
 *     if ndim != len(stride) or ndim != len(pad):             # <<<<<<<<<<<<<<
 *         raise ValueError('ksize, stride, and pad must be of same length')
 *     if ndim == 2:
 */
  }

  /* "cupy/cudnn.pyx":323
 *     if ndim != len(stride) or ndim != len(pad):
 *         raise ValueError('ksize, stride, and pad must be of same length')
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         cudnn.setPooling2dDescriptor_v4(
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0],
 */
  __pyx_t_2 = ((__pyx_v_ndim == 2) != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":325
 *     if ndim == 2:
 *         cudnn.setPooling2dDescriptor_v4(
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0],             # <<<<<<<<<<<<<<
 *             ksize[1], pad[0], pad[1], stride[0], stride[1])
 *     else:
 */
    if (unlikely(__pyx_v_ksize == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 325, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_ksize, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 325, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":326
 *         cudnn.setPooling2dDescriptor_v4(
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0],
 *             ksize[1], pad[0], pad[1], stride[0], stride[1])             # <<<<<<<<<<<<<<
 *     else:
 *         c_ksize = ksize
 */
    if (unlikely(__pyx_v_ksize == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 326, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_ksize, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_v_pad == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 326, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_pad, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_v_pad == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 326, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_pad, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_v_stride == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 326, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_stride, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__pyx_v_stride == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 326, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_v_stride, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":324
 *         raise ValueError('ksize, stride, and pad must be of same length')
 *     if ndim == 2:
 *         cudnn.setPooling2dDescriptor_v4(             # <<<<<<<<<<<<<<
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0],
 *             ksize[1], pad[0], pad[1], stride[0], stride[1])
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setPooling2dDescriptor_v4(__pyx_v_desc, __pyx_v_mode, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":323
 *     if ndim != len(stride) or ndim != len(pad):
 *         raise ValueError('ksize, stride, and pad must be of same length')
 *     if ndim == 2:             # <<<<<<<<<<<<<<
 *         cudnn.setPooling2dDescriptor_v4(
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0],
 */
    goto __pyx_L6;
  }

  /* "cupy/cudnn.pyx":328
 *             ksize[1], pad[0], pad[1], stride[0], stride[1])
 *     else:
 *         c_ksize = ksize             # <<<<<<<<<<<<<<
 *         c_pad = pad
 *         c_stride = stride
 */
  /*else*/ {
    __pyx_t_11 = __pyx_convert_vector_from_py_int(__pyx_v_ksize); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 328, __pyx_L1_error)
    __pyx_v_c_ksize = __pyx_t_11;

    /* "cupy/cudnn.pyx":329
 *     else:
 *         c_ksize = ksize
 *         c_pad = pad             # <<<<<<<<<<<<<<
 *         c_stride = stride
 *         cudnn.setPoolingNdDescriptor_v4(
 */
    __pyx_t_11 = __pyx_convert_vector_from_py_int(__pyx_v_pad); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 329, __pyx_L1_error)
    __pyx_v_c_pad = __pyx_t_11;

    /* "cupy/cudnn.pyx":330
 *         c_ksize = ksize
 *         c_pad = pad
 *         c_stride = stride             # <<<<<<<<<<<<<<
 *         cudnn.setPoolingNdDescriptor_v4(
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ndim,
 */
    __pyx_t_11 = __pyx_convert_vector_from_py_int(__pyx_v_stride); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 330, __pyx_L1_error)
    __pyx_v_c_stride = __pyx_t_11;

    /* "cupy/cudnn.pyx":331
 *         c_pad = pad
 *         c_stride = stride
 *         cudnn.setPoolingNdDescriptor_v4(             # <<<<<<<<<<<<<<
 *             desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ndim,
 *             <size_t>&c_ksize[0], <size_t>&c_pad[0], <size_t>&c_stride[0])
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setPoolingNdDescriptor_v4(__pyx_v_desc, __pyx_v_mode, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, __pyx_v_ndim, ((size_t)(&(__pyx_v_c_ksize[0]))), ((size_t)(&(__pyx_v_c_pad[0]))), ((size_t)(&(__pyx_v_c_stride[0]))), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L6:;

  /* "cupy/cudnn.pyx":335
 *             <size_t>&c_ksize[0], <size_t>&c_pad[0], <size_t>&c_stride[0])
 * 
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_desc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":317
 * 
 * 
 * cdef _create_pooling_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef vector.vector[int] c_ksize, c_pad, c_stride
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn._create_pooling_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":338
 * 
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_37create_pooling_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_36create_pooling_descriptor[] = "create_pooling_descriptor(ksize, stride, pad, int mode)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_37create_pooling_descriptor = {"create_pooling_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_37create_pooling_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_36create_pooling_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_37create_pooling_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ksize = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_pad = 0;
  int __pyx_v_mode;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_pooling_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ksize,&__pyx_n_s_stride,&__pyx_n_s_pad,&__pyx_n_s_mode,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ksize)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_pooling_descriptor", 1, 4, 4, 1); __PYX_ERR(0, 338, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_pooling_descriptor", 1, 4, 4, 2); __PYX_ERR(0, 338, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_pooling_descriptor", 1, 4, 4, 3); __PYX_ERR(0, 338, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_pooling_descriptor") < 0)) __PYX_ERR(0, 338, __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_ksize = values[0];
    __pyx_v_stride = values[1];
    __pyx_v_pad = values[2];
    __pyx_v_mode = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 338, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_pooling_descriptor", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 338, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_pooling_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_36create_pooling_descriptor(__pyx_self, __pyx_v_ksize, __pyx_v_stride, __pyx_v_pad, __pyx_v_mode);

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

static PyObject *__pyx_pf_4cupy_5cudnn_36create_pooling_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __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("create_pooling_descriptor", 0);

  /* "cupy/cudnn.pyx":339
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyPoolingDescriptor)
 *     _create_pooling_descriptor(desc.value, ksize, stride, pad, mode)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createPoolingDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":340
 * def create_pooling_descriptor(ksize, stride, pad, int mode):
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)             # <<<<<<<<<<<<<<
 *     _create_pooling_descriptor(desc.value, ksize, stride, pad, mode)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyPoolingDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":339
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyPoolingDescriptor)
 *     _create_pooling_descriptor(desc.value, ksize, stride, pad, mode)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":341
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)
 *     _create_pooling_descriptor(desc.value, ksize, stride, pad, mode)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v_ksize))||((__pyx_v_ksize) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_ksize)->tp_name), 0))) __PYX_ERR(0, 341, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_stride))||((__pyx_v_stride) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_stride)->tp_name), 0))) __PYX_ERR(0, 341, __pyx_L1_error)
  if (!(likely(PyTuple_CheckExact(__pyx_v_pad))||((__pyx_v_pad) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_pad)->tp_name), 0))) __PYX_ERR(0, 341, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_pooling_descriptor(__pyx_v_desc->value, ((PyObject*)__pyx_v_ksize), ((PyObject*)__pyx_v_stride), ((PyObject*)__pyx_v_pad), __pyx_v_mode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":342
 *                       py_cudnn.destroyPoolingDescriptor)
 *     _create_pooling_descriptor(desc.value, ksize, stride, pad, mode)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":338
 * 
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_pooling_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":345
 * 
 * 
 * cdef Descriptor _create_rnn_data_descriptor():             # <<<<<<<<<<<<<<
 *     return Descriptor(cudnn.createRNNDataDescriptor(),
 *                       py_cudnn.destroyRNNDataDescriptor)
 */

static struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_f_4cupy_5cudnn__create_rnn_data_descriptor(void) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __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("_create_rnn_data_descriptor", 0);

  /* "cupy/cudnn.pyx":346
 * 
 * cdef Descriptor _create_rnn_data_descriptor():
 *     return Descriptor(cudnn.createRNNDataDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyRNNDataDescriptor)
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createRNNDataDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 346, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":347
 * cdef Descriptor _create_rnn_data_descriptor():
 *     return Descriptor(cudnn.createRNNDataDescriptor(),
 *                       py_cudnn.destroyRNNDataDescriptor)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyRNNDataDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":346
 * 
 * cdef Descriptor _create_rnn_data_descriptor():
 *     return Descriptor(cudnn.createRNNDataDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyRNNDataDescriptor)
 * 
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":345
 * 
 * 
 * cdef Descriptor _create_rnn_data_descriptor():             # <<<<<<<<<<<<<<
 *     return Descriptor(cudnn.createRNNDataDescriptor(),
 *                       py_cudnn.destroyRNNDataDescriptor)
 */

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

/* "cupy/cudnn.pyx":350
 * 
 * 
 * cdef Descriptor _make_unpacked_rnn_data_descriptor(core.ndarray xs, lengths):             # <<<<<<<<<<<<<<
 *     cdef Descriptor descriptor = _create_rnn_data_descriptor()
 *     cdef int data_type = get_data_type(xs.dtype)
 */

static struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_descriptor = 0;
  int __pyx_v_data_type;
  PyObject *__pyx_v_max_length = 0;
  PyObject *__pyx_v_batch = 0;
  PyObject *__pyx_v_n_dim = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__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;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  size_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_unpacked_rnn_data_descriptor", 0);

  /* "cupy/cudnn.pyx":351
 * 
 * cdef Descriptor _make_unpacked_rnn_data_descriptor(core.ndarray xs, lengths):
 *     cdef Descriptor descriptor = _create_rnn_data_descriptor()             # <<<<<<<<<<<<<<
 *     cdef int data_type = get_data_type(xs.dtype)
 *     cdef max_length, batch, n_dim
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__create_rnn_data_descriptor()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_descriptor = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":352
 * cdef Descriptor _make_unpacked_rnn_data_descriptor(core.ndarray xs, lengths):
 *     cdef Descriptor descriptor = _create_rnn_data_descriptor()
 *     cdef int data_type = get_data_type(xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef max_length, batch, n_dim
 *     max_length, batch, n_dim = xs.shape
 */
  __pyx_t_1 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_2;

  /* "cupy/cudnn.pyx":354
 *     cdef int data_type = get_data_type(xs.dtype)
 *     cdef max_length, batch, n_dim
 *     max_length, batch, n_dim = xs.shape             # <<<<<<<<<<<<<<
 *     cudnn.setRNNDataDescriptor(
 *         descriptor.value, data_type,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 354, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 2; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 354, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 354, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_max_length = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_batch = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_n_dim = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":358
 *         descriptor.value, data_type,
 *         cudnn.CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED,
 *         max_length, batch, n_dim,             # <<<<<<<<<<<<<<
 *         lengths.ctypes.data, 0)
 *     return descriptor
 */
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_max_length); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_batch); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_n_dim); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error)

  /* "cupy/cudnn.pyx":359
 *         cudnn.CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED,
 *         max_length, batch, n_dim,
 *         lengths.ctypes.data, 0)             # <<<<<<<<<<<<<<
 *     return descriptor
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_lengths, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":355
 *     cdef max_length, batch, n_dim
 *     max_length, batch, n_dim = xs.shape
 *     cudnn.setRNNDataDescriptor(             # <<<<<<<<<<<<<<
 *         descriptor.value, data_type,
 *         cudnn.CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED,
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_setRNNDataDescriptor(__pyx_v_descriptor->value, __pyx_v_data_type, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_DATA_LAYOUT_SEQ_MAJOR_UNPACKED, __pyx_t_2, __pyx_t_8, __pyx_t_9, __pyx_t_10, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":360
 *         max_length, batch, n_dim,
 *         lengths.ctypes.data, 0)
 *     return descriptor             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_descriptor));
  __pyx_r = __pyx_v_descriptor;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":350
 * 
 * 
 * cdef Descriptor _make_unpacked_rnn_data_descriptor(core.ndarray xs, lengths):             # <<<<<<<<<<<<<<
 *     cdef Descriptor descriptor = _create_rnn_data_descriptor()
 *     cdef int data_type = get_data_type(xs.dtype)
 */

  /* 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.cudnn._make_unpacked_rnn_data_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descriptor);
  __Pyx_XDECREF(__pyx_v_max_length);
  __Pyx_XDECREF(__pyx_v_batch);
  __Pyx_XDECREF(__pyx_v_n_dim);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":363
 * 
 * 
 * def rnn_forward_inference_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_39rnn_forward_inference_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_38rnn_forward_inference_ex[] = "rnn_forward_inference_ex(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_39rnn_forward_inference_ex = {"rnn_forward_inference_ex", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_39rnn_forward_inference_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_38rnn_forward_inference_ex};
static PyObject *__pyx_pw_4cupy_5cudnn_39rnn_forward_inference_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_forward_inference_ex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_lengths,0};
    PyObject* values[8] = {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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 1); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 2); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 3); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 4); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 5); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 6); __PYX_ERR(0, 363, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, 7); __PYX_ERR(0, 363, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_forward_inference_ex") < 0)) __PYX_ERR(0, 363, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 364, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 364, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_lengths = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_forward_inference_ex", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 363, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_inference_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 364, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 365, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 365, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 365, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 366, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_38rnn_forward_inference_ex(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_38rnn_forward_inference_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cy = 0;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_x_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_y_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_forward_inference_ex", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);

  /* "cupy/cudnn.pyx":367
 *         core.ndarray hx, core.ndarray cx, core.ndarray w,
 *         core.ndarray xs, lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":368
 *         core.ndarray xs, lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":369
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":368
 *         core.ndarray xs, lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":370
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":371
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = xs._shape[0]
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":373
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 *     cdef int length = xs._shape[0]             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]
 */
  __pyx_v_length = (__pyx_v_xs->_shape[0]);

  /* "cupy/cudnn.pyx":374
 * 
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx._shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":375
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 */
  __pyx_v_n_units = (__pyx_v_hx->_shape[2]);

  /* "cupy/cudnn.pyx":377
 *     cdef int n_units = hx._shape[2]
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_result_array(__pyx_v_direction_mode, __pyx_v_n_units, __pyx_v_xs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":378
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_hx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_hy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":379
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":380
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 380, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":379
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":381
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_cx->dtype);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_cy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":383
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 */
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_5 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 383, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_5;

  /* "cupy/cudnn.pyx":385
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":386
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/cudnn.pyx":387
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":388
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 *     cudnn.setRNNPaddingMode(
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_12 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_11, 0); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_13 = NULL;
  __pyx_t_12 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_12 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(7+__pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_12, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_12, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_12, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_12, __pyx_t_11);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":385
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 385, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":389
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(             # <<<<<<<<<<<<<<
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode(__pyx_v_rnn_desc->value, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_ENABLED, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":392
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_xs, __pyx_v_lengths)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_x_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":394
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 394, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":395
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 395, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":396
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 396, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":397
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_ys, __pyx_v_lengths)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_y_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":399
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_hy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 399, __pyx_L1_error)
  __pyx_v_hy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":400
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_cy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 400, __pyx_L1_error)
  __pyx_v_cy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":402
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(             # <<<<<<<<<<<<<<
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(((PyObject *)__pyx_v_xs))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":404
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":407
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNForwardInferenceEx(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value,
 *         x_data_desc.value, xs.data.ptr,
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_RNNForwardInferenceEx(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_x_data_desc->value, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_v_y_data_desc->value, __pyx_v_ys->data->ptr, __pyx_v_hy_desc->value, __pyx_v_hy->data->ptr, __pyx_v_cy_desc->value, __pyx_v_cy->data->ptr, 0, 0, 0, 0, 0, 0, 0, 0, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":419
 *         workspace.ptr, workspace.mem.size)
 * 
 *     return hy, cy, ys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_hy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_hy));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_hy));
  __Pyx_INCREF(((PyObject *)__pyx_v_cy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cy));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_cy));
  __Pyx_INCREF(((PyObject *)__pyx_v_ys));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ys));
  PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_ys));
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":363
 * 
 * 
 * def rnn_forward_inference_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_inference_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy);
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_x_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_y_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":422
 * 
 * 
 * def rnn_forward_training_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_41rnn_forward_training_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_40rnn_forward_training_ex[] = "rnn_forward_training_ex(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_41rnn_forward_training_ex = {"rnn_forward_training_ex", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_41rnn_forward_training_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_40rnn_forward_training_ex};
static PyObject *__pyx_pw_4cupy_5cudnn_41rnn_forward_training_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_forward_training_ex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_lengths,0};
    PyObject* values[8] = {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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 1); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 2); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 3); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 4); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 5); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 6); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, 7); __PYX_ERR(0, 422, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_forward_training_ex") < 0)) __PYX_ERR(0, 422, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 423, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 423, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_lengths = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_forward_training_ex", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 422, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_training_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 423, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 424, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 424, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 424, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 424, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_40rnn_forward_training_ex(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_40rnn_forward_training_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cy = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_x_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_y_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_forward_training_ex", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);

  /* "cupy/cudnn.pyx":426
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":427
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":428
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":427
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":429
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":430
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = xs._shape[0]
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":432
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 *     cdef int length = xs._shape[0]             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]
 */
  __pyx_v_length = (__pyx_v_xs->_shape[0]);

  /* "cupy/cudnn.pyx":433
 * 
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx._shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":434
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_v_n_units = (__pyx_v_hx->_shape[2]);

  /* "cupy/cudnn.pyx":436
 *     cdef int n_units = hx._shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":438
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":439
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/cudnn.pyx":440
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":441
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 *     cudnn.setRNNPaddingMode(
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_12 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_11, 0); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_13 = NULL;
  __pyx_t_12 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_12 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(7+__pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_12, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_12, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_12, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_12, __pyx_t_11);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":438
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":442
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(             # <<<<<<<<<<<<<<
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode(__pyx_v_rnn_desc->value, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_ENABLED, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":445
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_result_array(__pyx_v_direction_mode, __pyx_v_n_units, __pyx_v_xs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":446
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_hx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_hy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":447
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":448
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 448, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "cupy/cudnn.pyx":447
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":449
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_cx->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_cy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":451
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_xs, __pyx_v_lengths)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_x_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":453
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 453, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":454
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 454, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":455
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 455, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":456
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_ys, __pyx_v_lengths)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_y_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":458
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_hy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 458, __pyx_L1_error)
  __pyx_v_hy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":459
 *         ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_cy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 459, __pyx_L1_error)
  __pyx_v_cy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":461
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(             # <<<<<<<<<<<<<<
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(((PyObject *)__pyx_v_xs))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":463
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 *     cdef memory.MemoryPointer reserve_space = _make_rnn_reserve_space(
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":465
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 *         rnn_desc, length, xs_descs)
 *     cdef memory.MemoryPointer reserve_space = _make_rnn_reserve_space(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_reserve_space(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":468
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNForwardTrainingEx(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value,
 *         x_data_desc.value, xs.data.ptr,
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_RNNForwardTrainingEx(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_x_data_desc->value, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_v_y_data_desc->value, __pyx_v_ys->data->ptr, __pyx_v_hy_desc->value, __pyx_v_hy->data->ptr, __pyx_v_cy_desc->value, __pyx_v_cy->data->ptr, 0, 0, 0, 0, 0, 0, 0, 0, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":481
 *         reserve_space.ptr, reserve_space.mem.size)
 * 
 *     return reserve_space, hy, cy, ys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_reserve_space));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_reserve_space));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_reserve_space));
  __Pyx_INCREF(((PyObject *)__pyx_v_hy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_hy));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_hy));
  __Pyx_INCREF(((PyObject *)__pyx_v_cy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cy));
  PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_cy));
  __Pyx_INCREF(((PyObject *)__pyx_v_ys));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ys));
  PyTuple_SET_ITEM(__pyx_t_5, 3, ((PyObject *)__pyx_v_ys));
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":422
 * 
 * 
 * def rnn_forward_training_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_training_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy);
  __Pyx_XDECREF((PyObject *)__pyx_v_x_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_y_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_reserve_space);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":484
 * 
 * 
 * def rnn_backward_data_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_43rnn_backward_data_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_42rnn_backward_data_ex[] = "rnn_backward_data_ex(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, ndarray ys, MemoryPointer reserve_space, ndarray dhy, ndarray dcy, ndarray dys, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_43rnn_backward_data_ex = {"rnn_backward_data_ex", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_43rnn_backward_data_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_42rnn_backward_data_ex};
static PyObject *__pyx_pw_4cupy_5cudnn_43rnn_backward_data_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_backward_data_ex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_ys,&__pyx_n_s_reserve_space,&__pyx_n_s_dhy,&__pyx_n_s_dcy,&__pyx_n_s_dys,&__pyx_n_s_lengths,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 1); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 2); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 3); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 4); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 5); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 6); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 7); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reserve_space)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 8); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dhy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 9); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dcy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 10); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 11); __PYX_ERR(0, 484, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, 12); __PYX_ERR(0, 484, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_backward_data_ex") < 0)) __PYX_ERR(0, 484, __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_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 485, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 485, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[7]);
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)values[8]);
    __pyx_v_dhy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[9]);
    __pyx_v_dcy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[10]);
    __pyx_v_dys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[11]);
    __pyx_v_lengths = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_backward_data_ex", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 484, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_data_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 485, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 486, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 486, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 486, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 486, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ys", 0))) __PYX_ERR(0, 487, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer, 1, "reserve_space", 0))) __PYX_ERR(0, 487, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dhy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dhy", 0))) __PYX_ERR(0, 488, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dcy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dcy", 0))) __PYX_ERR(0, 488, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dys", 0))) __PYX_ERR(0, 488, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_42rnn_backward_data_ex(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_ys, __pyx_v_reserve_space, __pyx_v_dhy, __pyx_v_dcy, __pyx_v_dys, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_42rnn_backward_data_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dxs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcx = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_y_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dy_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dhy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dcy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dx_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dhx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dcx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_backward_data_ex", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);
  __Pyx_INCREF((PyObject *)__pyx_v_ys);
  __Pyx_INCREF((PyObject *)__pyx_v_dhy);
  __Pyx_INCREF((PyObject *)__pyx_v_dcy);
  __Pyx_INCREF((PyObject *)__pyx_v_dys);

  /* "cupy/cudnn.pyx":490
 *         core.ndarray dhy, core.ndarray dcy, core.ndarray dys,
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":491
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":492
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":491
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":493
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = core._internal_ascontiguousarray(ys)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":494
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 *     ys = core._internal_ascontiguousarray(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":495
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = core._internal_ascontiguousarray(ys)             # <<<<<<<<<<<<<<
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_ys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 495, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_ys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":496
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = core._internal_ascontiguousarray(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)             # <<<<<<<<<<<<<<
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dhy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dhy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":497
 *     ys = core._internal_ascontiguousarray(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:             # <<<<<<<<<<<<<<
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = core._internal_ascontiguousarray(dys)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_dcy) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":498
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)             # <<<<<<<<<<<<<<
 *     dys = core._internal_ascontiguousarray(dys)
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dcy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 498, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_dcy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":497
 *     ys = core._internal_ascontiguousarray(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:             # <<<<<<<<<<<<<<
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = core._internal_ascontiguousarray(dys)
 */
  }

  /* "cupy/cudnn.pyx":499
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = core._internal_ascontiguousarray(dys)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = xs._shape[0]
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 499, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":501
 *     dys = core._internal_ascontiguousarray(dys)
 * 
 *     cdef int length = xs._shape[0]             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]
 */
  __pyx_v_length = (__pyx_v_xs->_shape[0]);

  /* "cupy/cudnn.pyx":502
 * 
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx._shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":503
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_v_n_units = (__pyx_v_hx->_shape[2]);

  /* "cupy/cudnn.pyx":505
 *     cdef int n_units = hx._shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 505, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":506
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":507
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/cudnn.pyx":508
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 508, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":509
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 *     cudnn.setRNNPaddingMode(
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_12 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_11, 0); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_13 = NULL;
  __pyx_t_12 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_12 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[8] = {__pyx_t_13, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_12, 7+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(7+__pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_12, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_12, __pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_12, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_12, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_14, 4+__pyx_t_12, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_14, 5+__pyx_t_12, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 6+__pyx_t_12, __pyx_t_11);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":506
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 506, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":510
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(             # <<<<<<<<<<<<<<
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode(__pyx_v_rnn_desc->value, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_ENABLED, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":513
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_xs->dtype);
  __Pyx_GIVEREF(__pyx_v_xs->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_xs->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dxs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":514
 * 
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_hx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dhx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":515
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":516
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 516, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_dcy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/cudnn.pyx":515
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":517
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_cx->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dcx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":519
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         ys, lengths)
 *     cdef Descriptor dy_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_ys, __pyx_v_lengths)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_y_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":521
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 *     cdef Descriptor dy_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_dys, __pyx_v_lengths)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_dy_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":523
 *     cdef Descriptor dy_data_desc = _make_unpacked_rnn_data_descriptor(
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_dhy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_dhy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 523, __pyx_L1_error)
  __pyx_v_dhy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":524
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_dcy)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_dcy));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 524, __pyx_L1_error)
  __pyx_v_dcy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":525
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 525, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":526
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor dx_data_desc = _make_unpacked_rnn_data_descriptor(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 526, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":527
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dx_data_desc = _make_unpacked_rnn_data_descriptor(
 *         dxs, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 527, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":528
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor dx_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_dxs, __pyx_v_lengths)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_dx_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":530
 *     cdef Descriptor dx_data_desc = _make_unpacked_rnn_data_descriptor(
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_dhx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_dhx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 530, __pyx_L1_error)
  __pyx_v_dhx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":531
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_14, ((PyObject *)__pyx_v_dcx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_dcx));
  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 531, __pyx_L1_error)
  __pyx_v_dcx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":533
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(             # <<<<<<<<<<<<<<
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(((PyObject *)__pyx_v_xs))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":535
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":538
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNBackwardDataEx(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value,
 *         y_data_desc.value, ys.data.ptr,
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_RNNBackwardDataEx(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_y_data_desc->value, __pyx_v_ys->data->ptr, __pyx_v_dy_data_desc->value, __pyx_v_dys->data->ptr, 0, 0, __pyx_v_dhy_desc->value, __pyx_v_dhy->data->ptr, __pyx_v_dcy_desc->value, __pyx_v_dcy->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_v_dx_data_desc->value, __pyx_v_dxs->data->ptr, __pyx_v_dhx_desc->value, __pyx_v_dhx->data->ptr, __pyx_v_dcx_desc->value, __pyx_v_dcx->data->ptr, 0, 0, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":555
 *         reserve_space.ptr, reserve_space.mem.size)
 * 
 *     return dhx, dcx, dxs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 555, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_dhx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dhx));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_dhx));
  __Pyx_INCREF(((PyObject *)__pyx_v_dcx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dcx));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_dcx));
  __Pyx_INCREF(((PyObject *)__pyx_v_dxs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dxs));
  PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_dxs));
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":484
 * 
 * 
 * def rnn_backward_data_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_data_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dxs);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhx);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcx);
  __Pyx_XDECREF((PyObject *)__pyx_v_y_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dy_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dx_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhy);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcy);
  __Pyx_XDECREF((PyObject *)__pyx_v_dys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":558
 * 
 * 
 * def rnn_backward_weights_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_45rnn_backward_weights_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_44rnn_backward_weights_ex[] = "rnn_backward_weights_ex(DropoutStates states, int direction_mode, int rnn_mode, ndarray xs, ndarray hx, ndarray ys, ndarray w, MemoryPointer reserve_space, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_45rnn_backward_weights_ex = {"rnn_backward_weights_ex", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_45rnn_backward_weights_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_44rnn_backward_weights_ex};
static PyObject *__pyx_pw_4cupy_5cudnn_45rnn_backward_weights_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_backward_weights_ex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_xs,&__pyx_n_s_hx,&__pyx_n_s_ys,&__pyx_n_s_w,&__pyx_n_s_reserve_space,&__pyx_n_s_lengths,0};
    PyObject* values[9] = {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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 1); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 2); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 3); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 4); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 5); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 6); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reserve_space)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 7); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, 8); __PYX_ERR(0, 558, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_backward_weights_ex") < 0)) __PYX_ERR(0, 558, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 559, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 559, __pyx_L3_error)
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)values[7]);
    __pyx_v_lengths = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_backward_weights_ex", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 558, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_weights_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 559, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 560, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 560, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ys", 0))) __PYX_ERR(0, 560, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 561, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer, 1, "reserve_space", 0))) __PYX_ERR(0, 562, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_44rnn_backward_weights_ex(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_xs, __pyx_v_hx, __pyx_v_ys, __pyx_v_w, __pyx_v_reserve_space, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_44rnn_backward_weights_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_x_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_y_data_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dw = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dw_desc = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __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;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_backward_weights_ex", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_ys);
  __Pyx_INCREF((PyObject *)__pyx_v_w);

  /* "cupy/cudnn.pyx":563
 *         core.ndarray w,
 *         memory.MemoryPointer reserve_space, lengths):
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":564
 *         memory.MemoryPointer reserve_space, lengths):
 *     xs = core._internal_ascontiguousarray(xs)
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     ys = core._internal_ascontiguousarray(ys)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":565
 *     xs = core._internal_ascontiguousarray(xs)
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_ys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_ys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":566
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = xs._shape[0]
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":568
 *     w = core._internal_ascontiguousarray(w)
 * 
 *     cdef int length = xs._shape[0]             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]
 */
  __pyx_v_length = (__pyx_v_xs->_shape[0]);

  /* "cupy/cudnn.pyx":569
 * 
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx._shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":570
 *     cdef int length = xs._shape[0]
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx._shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_v_n_units = (__pyx_v_hx->_shape[2]);

  /* "cupy/cudnn.pyx":572
 *     cdef int n_units = hx._shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 */
  __pyx_t_2 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_2 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 572, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_2;

  /* "cupy/cudnn.pyx":573
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "cupy/cudnn.pyx":574
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":575
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/cudnn.pyx":576
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 *     cudnn.setRNNPaddingMode(
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_9);
  __pyx_t_10 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_9, 0); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 576, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_11 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_v_states->_desc), __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[8] = {__pyx_t_11, __pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_v_states->_desc), __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 7+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(7+__pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_10, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_10, __pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_10, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_10, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_10, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 5+__pyx_t_10, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 6+__pyx_t_10, __pyx_t_9);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 573, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":573
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 573, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":577
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 *     cudnn.setRNNPaddingMode(             # <<<<<<<<<<<<<<
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode(__pyx_v_rnn_desc->value, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_PADDED_IO_ENABLED, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":580
 *         rnn_desc.value, cudnn.CUDNN_RNN_PADDED_IO_ENABLED)
 * 
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_xs, __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_x_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":582
 *     cdef Descriptor x_data_desc = _make_unpacked_rnn_data_descriptor(
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(
 *         ys, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_12, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 582, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":583
 *         xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor y_data_desc = _make_unpacked_rnn_data_descriptor(             # <<<<<<<<<<<<<<
 *         ys, lengths)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_unpacked_rnn_data_descriptor(__pyx_v_ys, __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_y_data_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":586
 *         ys, lengths)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(             # <<<<<<<<<<<<<<
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(((PyObject *)__pyx_v_xs))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 586, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":588
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array_for_padded(
 *         xs)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":591
 *         rnn_desc, length, xs_descs)
 * 
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)             # <<<<<<<<<<<<<<
 *     dw.fill(0)
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_w), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_w->dtype);
  __Pyx_GIVEREF(__pyx_v_w->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_w->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dw = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":592
 * 
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)
 *     dw.fill(0)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_dw->__pyx_vtab)->fill(__pyx_v_dw, __pyx_int_0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":593
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)
 *     dw.fill(0)
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)             # <<<<<<<<<<<<<<
 * 
 *     cudnn.RNNBackwardWeightsEx(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_12, ((PyObject *)__pyx_v_dw)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_dw));
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 593, __pyx_L1_error)
  __pyx_v_dw_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":595
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 * 
 *     cudnn.RNNBackwardWeightsEx(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value,
 *         x_data_desc.value, xs.data.ptr,
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeightsEx(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_x_data_desc->value, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_y_data_desc->value, __pyx_v_ys->data->ptr, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_dw_desc->value, __pyx_v_dw->data->ptr, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":603
 *         dw_desc.value, dw.data.ptr,
 *         reserve_space.ptr, reserve_space.mem.size)
 *     return dw             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_dw));
  __pyx_r = ((PyObject *)__pyx_v_dw);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":558
 * 
 * 
 * def rnn_backward_weights_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_weights_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_x_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_y_data_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_dw);
  __Pyx_XDECREF((PyObject *)__pyx_v_dw_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":606
 * 
 * 
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_47create_activation_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_46create_activation_descriptor[] = "create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN, coef=0.0)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_47create_activation_descriptor = {"create_activation_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_47create_activation_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_46create_activation_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_47create_activation_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_nan_prop_mode = 0;
  PyObject *__pyx_v_coef = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_activation_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mode,&__pyx_n_s_nan_prop_mode,&__pyx_n_s_coef,0};
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k__13;
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nan_prop_mode);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coef);
          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_activation_descriptor") < 0)) __PYX_ERR(0, 606, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mode = values[0];
    __pyx_v_nan_prop_mode = values[1];
    __pyx_v_coef = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_activation_descriptor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 606, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_activation_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_46create_activation_descriptor(__pyx_self, __pyx_v_mode, __pyx_v_nan_prop_mode, __pyx_v_coef);

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

static PyObject *__pyx_pf_4cupy_5cudnn_46create_activation_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mode, PyObject *__pyx_v_nan_prop_mode, PyObject *__pyx_v_coef) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  double __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_activation_descriptor", 0);

  /* "cupy/cudnn.pyx":608
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, nan_prop_mode, coef)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 608, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":609
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 *                       py_cudnn.destroyActivationDescriptor)             # <<<<<<<<<<<<<<
 *     cudnn.setActivationDescriptor(desc.value, mode, nan_prop_mode, coef)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyActivationDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":608
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, nan_prop_mode, coef)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":610
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, nan_prop_mode, coef)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_mode); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 610, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_nan_prop_mode); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 610, __pyx_L1_error)
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_coef); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 610, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor(__pyx_v_desc->value, __pyx_t_5, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":611
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, nan_prop_mode, coef)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":606
 * 
 * 
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_activation_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":614
 * 
 * 
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_49activation_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_48activation_forward[] = "activation_forward(ndarray x, int mode, double coef=0.0)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_49activation_forward = {"activation_forward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_49activation_forward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_48activation_forward};
static PyObject *__pyx_pw_4cupy_5cudnn_49activation_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  int __pyx_v_mode;
  double __pyx_v_coef;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("activation_forward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_mode,&__pyx_n_s_coef,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("activation_forward", 0, 2, 3, 1); __PYX_ERR(0, 614, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coef);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "activation_forward") < 0)) __PYX_ERR(0, 614, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 614, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_coef = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_coef == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 614, __pyx_L3_error)
    } else {
      __pyx_v_coef = ((double)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("activation_forward", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 614, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.activation_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 614, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_48activation_forward(__pyx_self, __pyx_v_x, __pyx_v_mode, __pyx_v_coef);

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

static PyObject *__pyx_pf_4cupy_5cudnn_48activation_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_mode, double __pyx_v_coef) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_desc;
  size_t __pyx_v_act_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("activation_forward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);

  /* "cupy/cudnn.pyx":615
 * 
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":616
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":619
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":620
 *     cdef core.ndarray y
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":621
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":619
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":623
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":624
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     x = core._internal_ascontiguousarray(x)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":626
 *         one = <size_t>&float_one
 * 
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     y = core.ndarray(x._shape, x.dtype)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":627
 * 
 *     x = core._internal_ascontiguousarray(x)
 *     y = core.ndarray(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_x->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":629
 *     y = core.ndarray(x._shape, x.dtype)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 629, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":630
 * 
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 630, __pyx_L1_error)
  __pyx_v_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":631
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, x)
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 631, __pyx_L1_error)
  __pyx_v_act_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":632
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor_as4darray(desc, x)
 *         cudnn.setActivationDescriptor(
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":633
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, x)             # <<<<<<<<<<<<<<
 *         cudnn.setActivationDescriptor(
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(__pyx_v_desc, __pyx_v_x, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":634
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, x)
 *         cudnn.setActivationDescriptor(             # <<<<<<<<<<<<<<
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 *         cudnn.activationForward_v4(
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor(__pyx_v_act_desc, __pyx_v_mode, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, __pyx_v_coef, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":636
 *         cudnn.setActivationDescriptor(
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 *         cudnn.activationForward_v4(             # <<<<<<<<<<<<<<
 *             handle, act_desc, one, desc, x.data.ptr,
 *             zero, desc, y.data.ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_activationForward_v4(__pyx_v_handle, __pyx_v_act_desc, __pyx_v_one, __pyx_v_desc, __pyx_v_x->data->ptr, __pyx_v_zero, __pyx_v_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":640
 *             zero, desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(desc)
 *     return y
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor(__pyx_v_act_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":641
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":640
 *             zero, desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(desc)
 *     return y
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor(__pyx_v_act_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 640, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":641
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 641, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":642
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)
 *     return y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_y));
  __pyx_r = ((PyObject *)__pyx_v_y);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":614
 * 
 * 
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cudnn.activation_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":645
 * 
 * 
 * def activation_backward(core.ndarray x, core.ndarray y, core.ndarray gy,             # <<<<<<<<<<<<<<
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_51activation_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_50activation_backward[] = "activation_backward(ndarray x, ndarray y, ndarray gy, int mode, float coef=0.0)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_51activation_backward = {"activation_backward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_51activation_backward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_50activation_backward};
static PyObject *__pyx_pw_4cupy_5cudnn_51activation_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy = 0;
  int __pyx_v_mode;
  float __pyx_v_coef;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("activation_backward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_gy,&__pyx_n_s_mode,&__pyx_n_s_coef,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("activation_backward", 0, 4, 5, 1); __PYX_ERR(0, 645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("activation_backward", 0, 4, 5, 2); __PYX_ERR(0, 645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("activation_backward", 0, 4, 5, 3); __PYX_ERR(0, 645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coef);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "activation_backward") < 0)) __PYX_ERR(0, 645, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_gy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_mode = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 646, __pyx_L3_error)
    if (values[4]) {
      __pyx_v_coef = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_coef == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 646, __pyx_L3_error)
    } else {
      __pyx_v_coef = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("activation_backward", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 645, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.activation_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 645, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 645, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gy", 0))) __PYX_ERR(0, 645, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_50activation_backward(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_gy, __pyx_v_mode, __pyx_v_coef);

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

static PyObject *__pyx_pf_4cupy_5cudnn_50activation_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, int __pyx_v_mode, float __pyx_v_coef) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gx = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_desc;
  size_t __pyx_v_act_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("activation_backward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_y);
  __Pyx_INCREF((PyObject *)__pyx_v_gy);

  /* "cupy/cudnn.pyx":647
 * def activation_backward(core.ndarray x, core.ndarray y, core.ndarray gy,
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":648
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":651
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 651, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":652
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":653
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":651
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":655
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":656
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     gx = core.ndarray(x._shape, x.dtype)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":658
 *         one = <size_t>&float_one
 * 
 *     gx = core.ndarray(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)
 */
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_x->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_gx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":659
 * 
 *     gx = core.ndarray(x._shape, x.dtype)
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":660
 *     gx = core.ndarray(x._shape, x.dtype)
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)             # <<<<<<<<<<<<<<
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_y, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_y, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":661
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gy, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_gy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":663
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 663, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":664
 * 
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 664, __pyx_L1_error)
  __pyx_v_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":665
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, y)
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 665, __pyx_L1_error)
  __pyx_v_act_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":666
 *     desc = cudnn.createTensorDescriptor()
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor_as4darray(desc, y)
 *         cudnn.setActivationDescriptor(
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":667
 *     act_desc = cudnn.createActivationDescriptor()
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, y)             # <<<<<<<<<<<<<<
 *         cudnn.setActivationDescriptor(
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(__pyx_v_desc, __pyx_v_y, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 667, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":668
 *     try:
 *         _create_tensor_descriptor_as4darray(desc, y)
 *         cudnn.setActivationDescriptor(             # <<<<<<<<<<<<<<
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 *         cudnn.activationBackward_v4(
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor(__pyx_v_act_desc, __pyx_v_mode, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, __pyx_v_coef, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 668, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":670
 *         cudnn.setActivationDescriptor(
 *             act_desc, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, coef)
 *         cudnn.activationBackward_v4(             # <<<<<<<<<<<<<<
 *             handle, act_desc, one, desc, y.data.ptr,
 *             desc, gy.data.ptr, desc, x.data.ptr,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_activationBackward_v4(__pyx_v_handle, __pyx_v_act_desc, __pyx_v_one, __pyx_v_desc, __pyx_v_y->data->ptr, __pyx_v_desc, __pyx_v_gy->data->ptr, __pyx_v_desc, __pyx_v_x->data->ptr, __pyx_v_zero, __pyx_v_desc, __pyx_v_gx->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":675
 *             zero, desc, gx.data.ptr)
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(desc)
 *     return gx
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor(__pyx_v_act_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":676
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return gx
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":675
 *             zero, desc, gx.data.ptr)
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(desc)
 *     return gx
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor(__pyx_v_act_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":676
 *     finally:
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return gx
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":677
 *         cudnn.destroyActivationDescriptor(act_desc)
 *         cudnn.destroyTensorDescriptor(desc)
 *     return gx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_gx));
  __pyx_r = ((PyObject *)__pyx_v_gx);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":645
 * 
 * 
 * def activation_backward(core.ndarray x, core.ndarray y, core.ndarray gy,             # <<<<<<<<<<<<<<
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cudnn.activation_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_gx);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_gy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":680
 * 
 * 
 * cdef int _create_tensor_descriptor_for_softmax(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int axis) except?-1:
 *     cdef Py_ssize_t left, center, right
 */

static int __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_softmax(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_axis) {
  Py_ssize_t __pyx_v_left;
  Py_ssize_t __pyx_v_center;
  Py_ssize_t __pyx_v_right;
  int __pyx_v_data_type;
  long __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_descriptor_for_softmax", 0);

  /* "cupy/cudnn.pyx":683
 *         size_t desc, core.ndarray arr, int axis) except?-1:
 *     cdef Py_ssize_t left, center, right
 *     assert arr._c_contiguous             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(arr.dtype)
 *     if axis < 0:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(__pyx_v_arr->_c_contiguous != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 683, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":684
 *     cdef Py_ssize_t left, center, right
 *     assert arr._c_contiguous
 *     data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     if axis < 0:
 *         axis += arr._shape.size()
 */
  __pyx_t_1 = __pyx_v_arr->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_2 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_2;

  /* "cupy/cudnn.pyx":685
 *     assert arr._c_contiguous
 *     data_type = get_data_type(arr.dtype)
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += arr._shape.size()
 *     left = 1
 */
  __pyx_t_3 = ((__pyx_v_axis < 0) != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":686
 *     data_type = get_data_type(arr.dtype)
 *     if axis < 0:
 *         axis += arr._shape.size()             # <<<<<<<<<<<<<<
 *     left = 1
 *     for i in range(0, axis):
 */
    __pyx_v_axis = (__pyx_v_axis + __pyx_v_arr->_shape.size());

    /* "cupy/cudnn.pyx":685
 *     assert arr._c_contiguous
 *     data_type = get_data_type(arr.dtype)
 *     if axis < 0:             # <<<<<<<<<<<<<<
 *         axis += arr._shape.size()
 *     left = 1
 */
  }

  /* "cupy/cudnn.pyx":687
 *     if axis < 0:
 *         axis += arr._shape.size()
 *     left = 1             # <<<<<<<<<<<<<<
 *     for i in range(0, axis):
 *         left *= arr._shape[i]
 */
  __pyx_v_left = 1;

  /* "cupy/cudnn.pyx":688
 *         axis += arr._shape.size()
 *     left = 1
 *     for i in range(0, axis):             # <<<<<<<<<<<<<<
 *         left *= arr._shape[i]
 *     center = arr._shape[axis]
 */
  __pyx_t_2 = __pyx_v_axis;
  __pyx_t_4 = __pyx_t_2;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/cudnn.pyx":689
 *     left = 1
 *     for i in range(0, axis):
 *         left *= arr._shape[i]             # <<<<<<<<<<<<<<
 *     center = arr._shape[axis]
 *     right = 1
 */
    __pyx_v_left = (__pyx_v_left * (__pyx_v_arr->_shape[__pyx_v_i]));
  }

  /* "cupy/cudnn.pyx":690
 *     for i in range(0, axis):
 *         left *= arr._shape[i]
 *     center = arr._shape[axis]             # <<<<<<<<<<<<<<
 *     right = 1
 *     for i in range(axis + 1, <int>arr._shape.size()):
 */
  __pyx_v_center = (__pyx_v_arr->_shape[__pyx_v_axis]);

  /* "cupy/cudnn.pyx":691
 *         left *= arr._shape[i]
 *     center = arr._shape[axis]
 *     right = 1             # <<<<<<<<<<<<<<
 *     for i in range(axis + 1, <int>arr._shape.size()):
 *         right *= arr._shape[i]
 */
  __pyx_v_right = 1;

  /* "cupy/cudnn.pyx":692
 *     center = arr._shape[axis]
 *     right = 1
 *     for i in range(axis + 1, <int>arr._shape.size()):             # <<<<<<<<<<<<<<
 *         right *= arr._shape[i]
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 */
  __pyx_t_2 = ((int)__pyx_v_arr->_shape.size());
  __pyx_t_4 = __pyx_t_2;
  for (__pyx_t_5 = (__pyx_v_axis + 1); __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/cudnn.pyx":693
 *     right = 1
 *     for i in range(axis + 1, <int>arr._shape.size()):
 *         right *= arr._shape[i]             # <<<<<<<<<<<<<<
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 *                                 left, center, right, 1)
 */
    __pyx_v_right = (__pyx_v_right * (__pyx_v_arr->_shape[__pyx_v_i]));
  }

  /* "cupy/cudnn.pyx":694
 *     for i in range(axis + 1, <int>arr._shape.size()):
 *         right *= arr._shape[i]
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,             # <<<<<<<<<<<<<<
 *                                 left, center, right, 1)
 *     if center == 1 and right == 1:
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor(__pyx_v_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW, __pyx_v_data_type, __pyx_v_left, __pyx_v_center, __pyx_v_right, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":696
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 *                                 left, center, right, 1)
 *     if center == 1 and right == 1:             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_SOFTMAX_MODE_INSTANCE
 *     else:
 */
  __pyx_t_6 = ((__pyx_v_center == 1) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_3 = __pyx_t_6;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_6 = ((__pyx_v_right == 1) != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":697
 *                                 left, center, right, 1)
 *     if center == 1 and right == 1:
 *         return cudnn.CUDNN_SOFTMAX_MODE_INSTANCE             # <<<<<<<<<<<<<<
 *     else:
 *         return cudnn.CUDNN_SOFTMAX_MODE_CHANNEL
 */
    __pyx_r = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_MODE_INSTANCE;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":696
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 *                                 left, center, right, 1)
 *     if center == 1 and right == 1:             # <<<<<<<<<<<<<<
 *         return cudnn.CUDNN_SOFTMAX_MODE_INSTANCE
 *     else:
 */
  }

  /* "cupy/cudnn.pyx":699
 *         return cudnn.CUDNN_SOFTMAX_MODE_INSTANCE
 *     else:
 *         return cudnn.CUDNN_SOFTMAX_MODE_CHANNEL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SOFTMAX_MODE_CHANNEL;
    goto __pyx_L0;
  }

  /* "cupy/cudnn.pyx":680
 * 
 * 
 * cdef int _create_tensor_descriptor_for_softmax(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int axis) except?-1:
 *     cdef Py_ssize_t left, center, right
 */

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

/* "cupy/cudnn.pyx":702
 * 
 * 
 * def softmax_forward(core.ndarray x, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_53softmax_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_52softmax_forward[] = "softmax_forward(ndarray x, int axis, int algorithm)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_53softmax_forward = {"softmax_forward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_53softmax_forward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_52softmax_forward};
static PyObject *__pyx_pw_4cupy_5cudnn_53softmax_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  int __pyx_v_axis;
  int __pyx_v_algorithm;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("softmax_forward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_axis,&__pyx_n_s_algorithm,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("softmax_forward", 1, 3, 3, 1); __PYX_ERR(0, 702, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algorithm)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("softmax_forward", 1, 3, 3, 2); __PYX_ERR(0, 702, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "softmax_forward") < 0)) __PYX_ERR(0, 702, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_axis = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L3_error)
    __pyx_v_algorithm = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_algorithm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("softmax_forward", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 702, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.softmax_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 702, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_52softmax_forward(__pyx_self, __pyx_v_x, __pyx_v_axis, __pyx_v_algorithm);

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

static PyObject *__pyx_pf_4cupy_5cudnn_52softmax_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, int __pyx_v_axis, int __pyx_v_algorithm) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_desc;
  int __pyx_v_cudnn_mode;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("softmax_forward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);

  /* "cupy/cudnn.pyx":703
 * 
 * def softmax_forward(core.ndarray x, int axis, int algorithm):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":704
 * def softmax_forward(core.ndarray x, int axis, int algorithm):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":707
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 707, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":708
 *     cdef core.ndarray y
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":709
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":707
 *     cdef size_t zero, one
 *     cdef core.ndarray y
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":711
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":712
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     x = core._internal_ascontiguousarray(x)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":714
 *         one = <size_t>&float_one
 * 
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     y = core.ndarray(x._shape, x.dtype)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":715
 * 
 *     x = core._internal_ascontiguousarray(x)
 *     y = core.ndarray(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_x->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":717
 *     y = core.ndarray(x._shape, x.dtype)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     desc = cudnn.createTensorDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 717, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":718
 * 
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, x, axis)
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 718, __pyx_L1_error)
  __pyx_v_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":719
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, x, axis)
 *         cudnn.softmaxForward(
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":720
 *     desc = cudnn.createTensorDescriptor()
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, x, axis)             # <<<<<<<<<<<<<<
 *         cudnn.softmaxForward(
 *             handle, algorithm, cudnn_mode,
 */
    __pyx_t_5 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_softmax(__pyx_v_desc, __pyx_v_x, __pyx_v_axis); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 720, __pyx_L5_error)
    __pyx_v_cudnn_mode = __pyx_t_5;

    /* "cupy/cudnn.pyx":721
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, x, axis)
 *         cudnn.softmaxForward(             # <<<<<<<<<<<<<<
 *             handle, algorithm, cudnn_mode,
 *             one, desc, x.data.ptr, zero, desc, y.data.ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_softmaxForward(__pyx_v_handle, __pyx_v_algorithm, __pyx_v_cudnn_mode, __pyx_v_one, __pyx_v_desc, __pyx_v_x->data->ptr, __pyx_v_zero, __pyx_v_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":725
 *             one, desc, x.data.ptr, zero, desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 725, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 725, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":726
 *     finally:
 *         cudnn.destroyTensorDescriptor(desc)
 *     return y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_y));
  __pyx_r = ((PyObject *)__pyx_v_y);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":702
 * 
 * 
 * def softmax_forward(core.ndarray x, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cudnn.softmax_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":729
 * 
 * 
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_55softmax_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_54softmax_backward[] = "softmax_backward(ndarray y, ndarray gy, int axis, int algorithm)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_55softmax_backward = {"softmax_backward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_55softmax_backward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_54softmax_backward};
static PyObject *__pyx_pw_4cupy_5cudnn_55softmax_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy = 0;
  int __pyx_v_axis;
  int __pyx_v_algorithm;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("softmax_backward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_y,&__pyx_n_s_gy,&__pyx_n_s_axis,&__pyx_n_s_algorithm,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("softmax_backward", 1, 4, 4, 1); __PYX_ERR(0, 729, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("softmax_backward", 1, 4, 4, 2); __PYX_ERR(0, 729, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algorithm)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("softmax_backward", 1, 4, 4, 3); __PYX_ERR(0, 729, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "softmax_backward") < 0)) __PYX_ERR(0, 729, __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_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_axis = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L3_error)
    __pyx_v_algorithm = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_algorithm == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("softmax_backward", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 729, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.softmax_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 729, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gy", 0))) __PYX_ERR(0, 729, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_54softmax_backward(__pyx_self, __pyx_v_y, __pyx_v_gy, __pyx_v_axis, __pyx_v_algorithm);

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

static PyObject *__pyx_pf_4cupy_5cudnn_54softmax_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, int __pyx_v_axis, int __pyx_v_algorithm) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gx = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_desc;
  int __pyx_v_cudnn_mode;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("softmax_backward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_y);
  __Pyx_INCREF((PyObject *)__pyx_v_gy);

  /* "cupy/cudnn.pyx":730
 * 
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":731
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":734
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if y.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_y->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 734, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":735
 *     cdef core.ndarray gx
 *     if y.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":736
 *     if y.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":734
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if y.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":738
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":739
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     gx = core.ndarray(y._shape, y.dtype)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":741
 *         one = <size_t>&float_one
 * 
 *     gx = core.ndarray(y._shape, y.dtype)             # <<<<<<<<<<<<<<
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)
 */
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_y->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_y->dtype);
  __Pyx_GIVEREF(__pyx_v_y->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_y->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_gx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":742
 * 
 *     gx = core.ndarray(y._shape, y.dtype)
 *     y = core._internal_ascontiguousarray(y)             # <<<<<<<<<<<<<<
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_y, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_y, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":743
 *     gx = core.ndarray(y._shape, y.dtype)
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gy, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_gy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":745
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     desc = cudnn.createTensorDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":746
 * 
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, y, axis)
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 746, __pyx_L1_error)
  __pyx_v_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":747
 *     handle = get_handle()
 *     desc = cudnn.createTensorDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, y, axis)
 *         cudnn.softmaxBackward(
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":748
 *     desc = cudnn.createTensorDescriptor()
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, y, axis)             # <<<<<<<<<<<<<<
 *         cudnn.softmaxBackward(
 *             handle, algorithm, cudnn_mode,
 */
    __pyx_t_5 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_softmax(__pyx_v_desc, __pyx_v_y, __pyx_v_axis); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 748, __pyx_L5_error)
    __pyx_v_cudnn_mode = __pyx_t_5;

    /* "cupy/cudnn.pyx":749
 *     try:
 *         cudnn_mode = _create_tensor_descriptor_for_softmax(desc, y, axis)
 *         cudnn.softmaxBackward(             # <<<<<<<<<<<<<<
 *             handle, algorithm, cudnn_mode,
 *             one, desc, y.data.ptr, desc, gy.data.ptr, zero, desc, gx.data.ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_softmaxBackward(__pyx_v_handle, __pyx_v_algorithm, __pyx_v_cudnn_mode, __pyx_v_one, __pyx_v_desc, __pyx_v_y->data->ptr, __pyx_v_desc, __pyx_v_gy->data->ptr, __pyx_v_zero, __pyx_v_desc, __pyx_v_gx->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":753
 *             one, desc, y.data.ptr, desc, gy.data.ptr, zero, desc, gx.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(desc)             # <<<<<<<<<<<<<<
 *     return gx
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 753, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":754
 *     finally:
 *         cudnn.destroyTensorDescriptor(desc)
 *     return gx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_gx));
  __pyx_r = ((PyObject *)__pyx_v_gx);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":729
 * 
 * 
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cudnn.softmax_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_gx);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_gy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":757
 * 
 * 
 * def create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_57create_dropout_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_56create_dropout_descriptor[] = "create_dropout_descriptor(handle, dropout, states, state_size_in_bytes, seed)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_57create_dropout_descriptor = {"create_dropout_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_57create_dropout_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_56create_dropout_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_57create_dropout_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_dropout = 0;
  PyObject *__pyx_v_states = 0;
  PyObject *__pyx_v_state_size_in_bytes = 0;
  PyObject *__pyx_v_seed = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_dropout_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_dropout,&__pyx_n_s_states,&__pyx_n_s_state_size_in_bytes,&__pyx_n_s_seed,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dropout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_dropout_descriptor", 1, 5, 5, 1); __PYX_ERR(0, 757, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_dropout_descriptor", 1, 5, 5, 2); __PYX_ERR(0, 757, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_state_size_in_bytes)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_dropout_descriptor", 1, 5, 5, 3); __PYX_ERR(0, 757, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_dropout_descriptor", 1, 5, 5, 4); __PYX_ERR(0, 757, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_dropout_descriptor") < 0)) __PYX_ERR(0, 757, __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_handle = values[0];
    __pyx_v_dropout = values[1];
    __pyx_v_states = values[2];
    __pyx_v_state_size_in_bytes = values[3];
    __pyx_v_seed = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_dropout_descriptor", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 757, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_dropout_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_56create_dropout_descriptor(__pyx_self, __pyx_v_handle, __pyx_v_dropout, __pyx_v_states, __pyx_v_state_size_in_bytes, __pyx_v_seed);

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

static PyObject *__pyx_pf_4cupy_5cudnn_56create_dropout_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_dropout, PyObject *__pyx_v_states, PyObject *__pyx_v_state_size_in_bytes, PyObject *__pyx_v_seed) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  float __pyx_t_5;
  size_t __pyx_t_6;
  size_t __pyx_t_7;
  unsigned PY_LONG_LONG __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_dropout_descriptor", 0);

  /* "cupy/cudnn.pyx":759
 * def create_dropout_descriptor(
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyDropoutDescriptor)
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createDropoutDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 759, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":760
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 *                       py_cudnn.destroyDropoutDescriptor)             # <<<<<<<<<<<<<<
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,
 *                                states, state_size_in_bytes, seed)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyDropoutDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 760, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":759
 * def create_dropout_descriptor(
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyDropoutDescriptor)
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":761
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 *                       py_cudnn.destroyDropoutDescriptor)
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,             # <<<<<<<<<<<<<<
 *                                states, state_size_in_bytes, seed)
 *     return desc
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 761, __pyx_L1_error)
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_v_dropout); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 761, __pyx_L1_error)

  /* "cupy/cudnn.pyx":762
 *                       py_cudnn.destroyDropoutDescriptor)
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,
 *                                states, state_size_in_bytes, seed)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_v_states); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 762, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_state_size_in_bytes); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 762, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_v_seed); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 762, __pyx_L1_error)

  /* "cupy/cudnn.pyx":761
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 *                       py_cudnn.destroyDropoutDescriptor)
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,             # <<<<<<<<<<<<<<
 *                                states, state_size_in_bytes, seed)
 *     return desc
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setDropoutDescriptor(__pyx_v_desc->value, __pyx_t_1, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":763
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout,
 *                                states, state_size_in_bytes, seed)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":757
 * 
 * 
 * def create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_dropout_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":766
 * 
 * 
 * def set_dropout_descriptor(desc, handle, dropout):             # <<<<<<<<<<<<<<
 *     # When the fourth argument is NULL, random state is not updated.
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout, 0, 0, 0)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_59set_dropout_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_58set_dropout_descriptor[] = "set_dropout_descriptor(desc, handle, dropout)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_59set_dropout_descriptor = {"set_dropout_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_59set_dropout_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_58set_dropout_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_59set_dropout_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_desc = 0;
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_dropout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_dropout_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_desc,&__pyx_n_s_handle,&__pyx_n_s_dropout,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_dropout_descriptor", 1, 3, 3, 1); __PYX_ERR(0, 766, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dropout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_dropout_descriptor", 1, 3, 3, 2); __PYX_ERR(0, 766, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_dropout_descriptor") < 0)) __PYX_ERR(0, 766, __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_desc = values[0];
    __pyx_v_handle = values[1];
    __pyx_v_dropout = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_dropout_descriptor", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 766, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.set_dropout_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_58set_dropout_descriptor(__pyx_self, __pyx_v_desc, __pyx_v_handle, __pyx_v_dropout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_58set_dropout_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_desc, PyObject *__pyx_v_handle, PyObject *__pyx_v_dropout) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  float __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_dropout_descriptor", 0);

  /* "cupy/cudnn.pyx":768
 * def set_dropout_descriptor(desc, handle, dropout):
 *     # When the fourth argument is NULL, random state is not updated.
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout, 0, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 768, __pyx_L1_error)
  __pyx_t_4 = __pyx_PyFloat_AsFloat(__pyx_v_dropout); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 768, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setDropoutDescriptor(__pyx_t_2, __pyx_t_3, __pyx_t_4, 0, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":766
 * 
 * 
 * def set_dropout_descriptor(desc, handle, dropout):             # <<<<<<<<<<<<<<
 *     # When the fourth argument is NULL, random state is not updated.
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout, 0, 0, 0)
 */

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

/* "cupy/cudnn.pyx":771
 * 
 * 
 * def _create_ctc_loss_descriptor(data_type):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_61_create_ctc_loss_descriptor(PyObject *__pyx_self, PyObject *__pyx_v_data_type); /*proto*/
static char __pyx_doc_4cupy_5cudnn_60_create_ctc_loss_descriptor[] = "_create_ctc_loss_descriptor(data_type)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_61_create_ctc_loss_descriptor = {"_create_ctc_loss_descriptor", (PyCFunction)__pyx_pw_4cupy_5cudnn_61_create_ctc_loss_descriptor, METH_O, __pyx_doc_4cupy_5cudnn_60_create_ctc_loss_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_61_create_ctc_loss_descriptor(PyObject *__pyx_self, PyObject *__pyx_v_data_type) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_ctc_loss_descriptor (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_60_create_ctc_loss_descriptor(__pyx_self, ((PyObject *)__pyx_v_data_type));

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

static PyObject *__pyx_pf_4cupy_5cudnn_60_create_ctc_loss_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data_type) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_ctc_loss_descriptor", 0);

  /* "cupy/cudnn.pyx":772
 * 
 * def _create_ctc_loss_descriptor(data_type):
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(desc.value, data_type)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createCTCLossDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 772, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":773
 * def _create_ctc_loss_descriptor(data_type):
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)             # <<<<<<<<<<<<<<
 *     cudnn.setCTCLossDescriptor(desc.value, data_type)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyCTCLossDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":772
 * 
 * def _create_ctc_loss_descriptor(data_type):
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(desc.value, data_type)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":774
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(desc.value, data_type)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_data_type); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 774, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setCTCLossDescriptor(__pyx_v_desc->value, __pyx_t_5, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":775
 *                       py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(desc.value, data_type)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":771
 * 
 * 
 * def _create_ctc_loss_descriptor(data_type):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn._create_ctc_loss_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":778
 * 
 * 
 * def ctc_loss(core.ndarray probs, labels,             # <<<<<<<<<<<<<<
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_63ctc_loss(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_62ctc_loss[] = "ctc_loss(ndarray probs, labels, label_length, input_length, int algo)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_63ctc_loss = {"ctc_loss", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_63ctc_loss, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_62ctc_loss};
static PyObject *__pyx_pw_4cupy_5cudnn_63ctc_loss(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_probs = 0;
  PyObject *__pyx_v_labels = 0;
  PyObject *__pyx_v_label_length = 0;
  PyObject *__pyx_v_input_length = 0;
  int __pyx_v_algo;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ctc_loss (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_probs,&__pyx_n_s_labels,&__pyx_n_s_label_length,&__pyx_n_s_input_length,&__pyx_n_s_algo,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_probs)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_labels)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("ctc_loss", 1, 5, 5, 1); __PYX_ERR(0, 778, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_label_length)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("ctc_loss", 1, 5, 5, 2); __PYX_ERR(0, 778, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_length)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("ctc_loss", 1, 5, 5, 3); __PYX_ERR(0, 778, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algo)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("ctc_loss", 1, 5, 5, 4); __PYX_ERR(0, 778, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ctc_loss") < 0)) __PYX_ERR(0, 778, __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_probs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_labels = values[1];
    __pyx_v_label_length = values[2];
    __pyx_v_input_length = values[3];
    __pyx_v_algo = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_algo == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 779, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ctc_loss", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 778, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.ctc_loss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_probs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "probs", 0))) __PYX_ERR(0, 778, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_62ctc_loss(__pyx_self, __pyx_v_probs, __pyx_v_labels, __pyx_v_label_length, __pyx_v_input_length, __pyx_v_algo);

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

static PyObject *__pyx_pf_4cupy_5cudnn_62ctc_loss(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_probs, PyObject *__pyx_v_labels, PyObject *__pyx_v_label_length, PyObject *__pyx_v_input_length, int __pyx_v_algo) {
  PyObject *__pyx_v_batch_size = NULL;
  PyObject *__pyx_v_labels_ptr = NULL;
  PyObject *__pyx_v_label_length_ptr = NULL;
  PyObject *__pyx_v_input_length_ptr = NULL;
  size_t __pyx_v_handle;
  int __pyx_v_data_type;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_ctc_desc = NULL;
  PyObject *__pyx_v_gradients = NULL;
  PyObject *__pyx_v_loss = NULL;
  PyObject *__pyx_v_probs_desc = NULL;
  PyObject *__pyx_v_gradients_desc = NULL;
  size_t __pyx_v_work_size;
  PyObject *__pyx_v_workspace = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  size_t __pyx_t_7;
  size_t __pyx_t_8;
  size_t __pyx_t_9;
  size_t __pyx_t_10;
  size_t __pyx_t_11;
  size_t __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ctc_loss", 0);

  /* "cupy/cudnn.pyx":780
 * def ctc_loss(core.ndarray probs, labels,
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]             # <<<<<<<<<<<<<<
 *     labels_ptr = labels.ctypes.data
 *     label_length_ptr = label_length.ctypes.data
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_batch_size = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":781
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]
 *     labels_ptr = labels.ctypes.data             # <<<<<<<<<<<<<<
 *     label_length_ptr = label_length.ctypes.data
 *     input_length_ptr = input_length.ctypes.data
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_labels, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_labels_ptr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":782
 *     batch_size = probs.shape[1]
 *     labels_ptr = labels.ctypes.data
 *     label_length_ptr = label_length.ctypes.data             # <<<<<<<<<<<<<<
 *     input_length_ptr = input_length.ctypes.data
 *     handle = get_handle()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_label_length, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_label_length_ptr = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":783
 *     labels_ptr = labels.ctypes.data
 *     label_length_ptr = label_length.ctypes.data
 *     input_length_ptr = input_length.ctypes.data             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     data_type = get_data_type(probs.dtype)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_length, __pyx_n_s_ctypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_input_length_ptr = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":784
 *     label_length_ptr = label_length.ctypes.data
 *     input_length_ptr = input_length.ctypes.data
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(probs.dtype)
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),
 */
  __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 784, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_3;

  /* "cupy/cudnn.pyx":785
 *     input_length_ptr = input_length.ctypes.data
 *     handle = get_handle()
 *     data_type = get_data_type(probs.dtype)             # <<<<<<<<<<<<<<
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                           py_cudnn.destroyCTCLossDescriptor)
 */
  __pyx_t_1 = __pyx_v_probs->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_4;

  /* "cupy/cudnn.pyx":786
 *     handle = get_handle()
 *     data_type = get_data_type(probs.dtype)
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),             # <<<<<<<<<<<<<<
 *                           py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(ctc_desc.value, data_type)
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createCTCLossDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 786, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":787
 *     data_type = get_data_type(probs.dtype)
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                           py_cudnn.destroyCTCLossDescriptor)             # <<<<<<<<<<<<<<
 *     cudnn.setCTCLossDescriptor(ctc_desc.value, data_type)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_destroyCTCLossDescriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":786
 *     handle = get_handle()
 *     data_type = get_data_type(probs.dtype)
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),             # <<<<<<<<<<<<<<
 *                           py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(ctc_desc.value, data_type)
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __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_5);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ctc_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":788
 *     ctc_desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                           py_cudnn.destroyCTCLossDescriptor)
 *     cudnn.setCTCLossDescriptor(ctc_desc.value, data_type)             # <<<<<<<<<<<<<<
 * 
 *     gradients = core.ndarray(probs._shape, probs.dtype)
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_setCTCLossDescriptor(__pyx_v_ctc_desc->value, __pyx_v_data_type, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":790
 *     cudnn.setCTCLossDescriptor(ctc_desc.value, data_type)
 * 
 *     gradients = core.ndarray(probs._shape, probs.dtype)             # <<<<<<<<<<<<<<
 *     loss = core.ndarray((batch_size, ), 'f')
 *     probs_desc = create_tensor_descriptor(probs)
 */
  __pyx_t_5 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_probs->_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_probs->dtype);
  __Pyx_GIVEREF(__pyx_v_probs->dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_probs->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_gradients = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":791
 * 
 *     gradients = core.ndarray(probs._shape, probs.dtype)
 *     loss = core.ndarray((batch_size, ), 'f')             # <<<<<<<<<<<<<<
 *     probs_desc = create_tensor_descriptor(probs)
 *     gradients_desc = create_tensor_descriptor(gradients)
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_batch_size);
  __Pyx_GIVEREF(__pyx_v_batch_size);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_batch_size);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_n_u_f);
  __Pyx_GIVEREF(__pyx_n_u_f);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_f);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_loss = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":792
 *     gradients = core.ndarray(probs._shape, probs.dtype)
 *     loss = core.ndarray((batch_size, ), 'f')
 *     probs_desc = create_tensor_descriptor(probs)             # <<<<<<<<<<<<<<
 *     gradients_desc = create_tensor_descriptor(gradients)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_create_tensor_descriptor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, ((PyObject *)__pyx_v_probs)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_probs));
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_probs_desc = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":793
 *     loss = core.ndarray((batch_size, ), 'f')
 *     probs_desc = create_tensor_descriptor(probs)
 *     gradients_desc = create_tensor_descriptor(gradients)             # <<<<<<<<<<<<<<
 * 
 *     work_size = cudnn.getCTCLossWorkspaceSize(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_create_tensor_descriptor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_gradients) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_gradients);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_gradients_desc = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":796
 * 
 *     work_size = cudnn.getCTCLossWorkspaceSize(
 *         handle, probs_desc.value, gradients_desc.value,             # <<<<<<<<<<<<<<
 *         labels_ptr, label_length_ptr,
 *         input_length_ptr, algo, ctc_desc.value)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_probs_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 796, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gradients_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 796, __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_ERR(0, 796, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":797
 *     work_size = cudnn.getCTCLossWorkspaceSize(
 *         handle, probs_desc.value, gradients_desc.value,
 *         labels_ptr, label_length_ptr,             # <<<<<<<<<<<<<<
 *         input_length_ptr, algo, ctc_desc.value)
 *     workspace = core.ndarray((work_size,), 'b')
 */
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_labels_ptr); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 797, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_label_length_ptr); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 797, __pyx_L1_error)

  /* "cupy/cudnn.pyx":798
 *         handle, probs_desc.value, gradients_desc.value,
 *         labels_ptr, label_length_ptr,
 *         input_length_ptr, algo, ctc_desc.value)             # <<<<<<<<<<<<<<
 *     workspace = core.ndarray((work_size,), 'b')
 * 
 */
  __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_input_length_ptr); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 798, __pyx_L1_error)

  /* "cupy/cudnn.pyx":795
 *     gradients_desc = create_tensor_descriptor(gradients)
 * 
 *     work_size = cudnn.getCTCLossWorkspaceSize(             # <<<<<<<<<<<<<<
 *         handle, probs_desc.value, gradients_desc.value,
 *         labels_ptr, label_length_ptr,
 */
  __pyx_t_10 = __pyx_f_4cupy_4cuda_5cudnn_getCTCLossWorkspaceSize(__pyx_v_handle, __pyx_t_3, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_v_algo, __pyx_v_ctc_desc->value, 0); if (unlikely(__pyx_t_10 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 795, __pyx_L1_error)
  __pyx_v_work_size = __pyx_t_10;

  /* "cupy/cudnn.pyx":799
 *         labels_ptr, label_length_ptr,
 *         input_length_ptr, algo, ctc_desc.value)
 *     workspace = core.ndarray((work_size,), 'b')             # <<<<<<<<<<<<<<
 * 
 *     cudnn.CTCLoss(handle, probs_desc.value, probs.data.ptr,
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_work_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 799, __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 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __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(__pyx_n_u_b);
  __Pyx_GIVEREF(__pyx_n_u_b);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_b);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_workspace = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":801
 *     workspace = core.ndarray((work_size,), 'b')
 * 
 *     cudnn.CTCLoss(handle, probs_desc.value, probs.data.ptr,             # <<<<<<<<<<<<<<
 *                   labels_ptr, label_length_ptr,
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_probs_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_10 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":802
 * 
 *     cudnn.CTCLoss(handle, probs_desc.value, probs.data.ptr,
 *                   labels_ptr, label_length_ptr,             # <<<<<<<<<<<<<<
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,
 *                   gradients.data.ptr, algo, ctc_desc.value,
 */
  __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_v_labels_ptr); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 802, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_v_label_length_ptr); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 802, __pyx_L1_error)

  /* "cupy/cudnn.pyx":803
 *     cudnn.CTCLoss(handle, probs_desc.value, probs.data.ptr,
 *                   labels_ptr, label_length_ptr,
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,             # <<<<<<<<<<<<<<
 *                   gradients.data.ptr, algo, ctc_desc.value,
 *                   workspace.data.ptr, work_size)
 */
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_input_length_ptr); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 803, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_loss, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gradients_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":804
 *                   labels_ptr, label_length_ptr,
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,
 *                   gradients.data.ptr, algo, ctc_desc.value,             # <<<<<<<<<<<<<<
 *                   workspace.data.ptr, work_size)
 *     return loss, gradients
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gradients, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":805
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,
 *                   gradients.data.ptr, algo, ctc_desc.value,
 *                   workspace.data.ptr, work_size)             # <<<<<<<<<<<<<<
 *     return loss, gradients
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_workspace, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_12 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 805, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":801
 *     workspace = core.ndarray((work_size,), 'b')
 * 
 *     cudnn.CTCLoss(handle, probs_desc.value, probs.data.ptr,             # <<<<<<<<<<<<<<
 *                   labels_ptr, label_length_ptr,
 *                   input_length_ptr, loss.data.ptr, gradients_desc.value,
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_CTCLoss(__pyx_v_handle, __pyx_t_10, __pyx_v_probs->data->ptr, __pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_t_3, __pyx_t_11, __pyx_v_algo, __pyx_v_ctc_desc->value, __pyx_t_12, __pyx_v_work_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":806
 *                   gradients.data.ptr, algo, ctc_desc.value,
 *                   workspace.data.ptr, work_size)
 *     return loss, gradients             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_loss);
  __Pyx_GIVEREF(__pyx_v_loss);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_loss);
  __Pyx_INCREF(__pyx_v_gradients);
  __Pyx_GIVEREF(__pyx_v_gradients);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_gradients);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":778
 * 
 * 
 * def ctc_loss(core.ndarray probs, labels,             # <<<<<<<<<<<<<<
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.ctc_loss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_batch_size);
  __Pyx_XDECREF(__pyx_v_labels_ptr);
  __Pyx_XDECREF(__pyx_v_label_length_ptr);
  __Pyx_XDECREF(__pyx_v_input_length_ptr);
  __Pyx_XDECREF((PyObject *)__pyx_v_ctc_desc);
  __Pyx_XDECREF(__pyx_v_gradients);
  __Pyx_XDECREF(__pyx_v_loss);
  __Pyx_XDECREF(__pyx_v_probs_desc);
  __Pyx_XDECREF(__pyx_v_gradients_desc);
  __Pyx_XDECREF(__pyx_v_workspace);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":809
 * 
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,             # <<<<<<<<<<<<<<
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_65create_rnn_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_64create_rnn_descriptor[] = "create_rnn_descriptor(hidden_size, num_layers, dropout_desc, input_mode, direction, mode, data_type, algo=None)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_65create_rnn_descriptor = {"create_rnn_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_65create_rnn_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_64create_rnn_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_65create_rnn_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_hidden_size = 0;
  PyObject *__pyx_v_num_layers = 0;
  PyObject *__pyx_v_dropout_desc = 0;
  PyObject *__pyx_v_input_mode = 0;
  PyObject *__pyx_v_direction = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_data_type = 0;
  PyObject *__pyx_v_algo = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_rnn_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_hidden_size,&__pyx_n_s_num_layers,&__pyx_n_s_dropout_desc,&__pyx_n_s_input_mode,&__pyx_n_s_direction,&__pyx_n_s_mode,&__pyx_n_s_data_type,&__pyx_n_s_algo,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};

    /* "cupy/cudnn.pyx":810
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,
 *                           input_mode, direction, mode, data_type, algo=None):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 *                       py_cudnn.destroyRNNDescriptor)
 */
    values[7] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden_size)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_layers)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 1); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dropout_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 2); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 3); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 4); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 5); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, 6); __PYX_ERR(0, 809, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algo);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_rnn_descriptor") < 0)) __PYX_ERR(0, 809, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        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_hidden_size = values[0];
    __pyx_v_num_layers = values[1];
    __pyx_v_dropout_desc = values[2];
    __pyx_v_input_mode = values[3];
    __pyx_v_direction = values[4];
    __pyx_v_mode = values[5];
    __pyx_v_data_type = values[6];
    __pyx_v_algo = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_rnn_descriptor", 0, 7, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 809, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_rnn_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_64create_rnn_descriptor(__pyx_self, __pyx_v_hidden_size, __pyx_v_num_layers, __pyx_v_dropout_desc, __pyx_v_input_mode, __pyx_v_direction, __pyx_v_mode, __pyx_v_data_type, __pyx_v_algo);

  /* "cupy/cudnn.pyx":809
 * 
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,             # <<<<<<<<<<<<<<
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 */

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

static PyObject *__pyx_pf_4cupy_5cudnn_64create_rnn_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_hidden_size, PyObject *__pyx_v_num_layers, PyObject *__pyx_v_dropout_desc, PyObject *__pyx_v_input_mode, PyObject *__pyx_v_direction, PyObject *__pyx_v_mode, PyObject *__pyx_v_data_type, PyObject *__pyx_v_algo) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  size_t __pyx_v__handle;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_rnn_descriptor", 0);
  __Pyx_INCREF(__pyx_v_algo);

  /* "cupy/cudnn.pyx":811
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyRNNDescriptor)
 *     if _cudnn_version >= 6000:
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createRNNDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 811, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":812
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 *                       py_cudnn.destroyRNNDescriptor)             # <<<<<<<<<<<<<<
 *     if _cudnn_version >= 6000:
 *         _handle = get_handle()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyRNNDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":811
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyRNNDescriptor)
 *     if _cudnn_version >= 6000:
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":813
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 *                       py_cudnn.destroyRNNDescriptor)
 *     if _cudnn_version >= 6000:             # <<<<<<<<<<<<<<
 *         _handle = get_handle()
 *         if algo is None:
 */
  __pyx_t_5 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1770) != 0);
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":814
 *                       py_cudnn.destroyRNNDescriptor)
 *     if _cudnn_version >= 6000:
 *         _handle = get_handle()             # <<<<<<<<<<<<<<
 *         if algo is None:
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD
 */
    __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 814, __pyx_L1_error)
    __pyx_v__handle = __pyx_t_1;

    /* "cupy/cudnn.pyx":815
 *     if _cudnn_version >= 6000:
 *         _handle = get_handle()
 *         if algo is None:             # <<<<<<<<<<<<<<
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD
 *         cudnn.setRNNDescriptor_v6(
 */
    __pyx_t_5 = (__pyx_v_algo == Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "cupy/cudnn.pyx":816
 *         _handle = get_handle()
 *         if algo is None:
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD             # <<<<<<<<<<<<<<
 *         cudnn.setRNNDescriptor_v6(
 *             _handle, desc.value, hidden_size, num_layers, dropout_desc.value,
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_RNN_ALGO_STANDARD); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":815
 *     if _cudnn_version >= 6000:
 *         _handle = get_handle()
 *         if algo is None:             # <<<<<<<<<<<<<<
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD
 *         cudnn.setRNNDescriptor_v6(
 */
    }

    /* "cupy/cudnn.pyx":818
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD
 *         cudnn.setRNNDescriptor_v6(
 *             _handle, desc.value, hidden_size, num_layers, dropout_desc.value,             # <<<<<<<<<<<<<<
 *             input_mode, direction, mode, algo, data_type)
 *     else:
 */
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_hidden_size); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 818, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_num_layers); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 818, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dropout_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 818, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":819
 *         cudnn.setRNNDescriptor_v6(
 *             _handle, desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, algo, data_type)             # <<<<<<<<<<<<<<
 *     else:
 *         cudnn.setRNNDescriptor_v5(
 */
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_input_mode); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L1_error)
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_mode); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_algo); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L1_error)
    __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_data_type); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L1_error)

    /* "cupy/cudnn.pyx":817
 *         if algo is None:
 *             algo = cudnn.CUDNN_RNN_ALGO_STANDARD
 *         cudnn.setRNNDescriptor_v6(             # <<<<<<<<<<<<<<
 *             _handle, desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, algo, data_type)
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v6(__pyx_v__handle, __pyx_v_desc->value, __pyx_t_7, __pyx_t_8, __pyx_t_1, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":813
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 *                       py_cudnn.destroyRNNDescriptor)
 *     if _cudnn_version >= 6000:             # <<<<<<<<<<<<<<
 *         _handle = get_handle()
 *         if algo is None:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":821
 *             input_mode, direction, mode, algo, data_type)
 *     else:
 *         cudnn.setRNNDescriptor_v5(             # <<<<<<<<<<<<<<
 *             desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, data_type)
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":822
 *     else:
 *         cudnn.setRNNDescriptor_v5(
 *             desc.value, hidden_size, num_layers, dropout_desc.value,             # <<<<<<<<<<<<<<
 *             input_mode, direction, mode, data_type)
 *     return desc
 */
    __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_hidden_size); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_num_layers); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L1_error)
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dropout_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":823
 *         cudnn.setRNNDescriptor_v5(
 *             desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, data_type)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
    __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_input_mode); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_mode); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_data_type); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L1_error)

    /* "cupy/cudnn.pyx":821
 *             input_mode, direction, mode, algo, data_type)
 *     else:
 *         cudnn.setRNNDescriptor_v5(             # <<<<<<<<<<<<<<
 *             desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, data_type)
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v5(__pyx_v_desc->value, __pyx_t_13, __pyx_t_12, __pyx_t_1, __pyx_t_11, __pyx_t_10, __pyx_t_9, __pyx_t_8, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 821, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":824
 *             desc.value, hidden_size, num_layers, dropout_desc.value,
 *             input_mode, direction, mode, data_type)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":809
 * 
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,             # <<<<<<<<<<<<<<
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_rnn_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XDECREF(__pyx_v_algo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":827
 * 
 * 
 * def get_rnn_lin_layer_matrix_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_67get_rnn_lin_layer_matrix_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_66get_rnn_lin_layer_matrix_params[] = "get_rnn_lin_layer_matrix_params(handle, rnn_desc, layer, x_desc, w_desc, ndarray w, lin_layer_id)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_67get_rnn_lin_layer_matrix_params = {"get_rnn_lin_layer_matrix_params", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_67get_rnn_lin_layer_matrix_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_66get_rnn_lin_layer_matrix_params};
static PyObject *__pyx_pw_4cupy_5cudnn_67get_rnn_lin_layer_matrix_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_rnn_desc = 0;
  PyObject *__pyx_v_layer = 0;
  PyObject *__pyx_v_x_desc = 0;
  PyObject *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  PyObject *__pyx_v_lin_layer_id = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_rnn_lin_layer_matrix_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_rnn_desc,&__pyx_n_s_layer,&__pyx_n_s_x_desc,&__pyx_n_s_w_desc,&__pyx_n_s_w,&__pyx_n_s_lin_layer_id,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 1); __PYX_ERR(0, 827, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_layer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 2); __PYX_ERR(0, 827, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 3); __PYX_ERR(0, 827, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 4); __PYX_ERR(0, 827, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 5); __PYX_ERR(0, 827, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lin_layer_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, 6); __PYX_ERR(0, 827, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_rnn_lin_layer_matrix_params") < 0)) __PYX_ERR(0, 827, __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_handle = values[0];
    __pyx_v_rnn_desc = values[1];
    __pyx_v_layer = values[2];
    __pyx_v_x_desc = values[3];
    __pyx_v_w_desc = values[4];
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_lin_layer_id = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_matrix_params", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 827, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.get_rnn_lin_layer_matrix_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 828, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_66get_rnn_lin_layer_matrix_params(__pyx_self, __pyx_v_handle, __pyx_v_rnn_desc, __pyx_v_layer, __pyx_v_x_desc, __pyx_v_w_desc, __pyx_v_w, __pyx_v_lin_layer_id);

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

static PyObject *__pyx_pf_4cupy_5cudnn_66get_rnn_lin_layer_matrix_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_rnn_desc, PyObject *__pyx_v_layer, PyObject *__pyx_v_x_desc, PyObject *__pyx_v_w_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, PyObject *__pyx_v_lin_layer_id) {
  size_t __pyx_v_ptr;
  size_t __pyx_v_mat_desc;
  PyObject *__pyx_v_data_type = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_dim = NULL;
  PyObject *__pyx_v_byte_size = NULL;
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_size = NULL;
  PyObject *__pyx_v_mat = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  size_t __pyx_t_5;
  size_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  char const *__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("get_rnn_lin_layer_matrix_params", 0);

  /* "cupy/cudnn.pyx":829
 * def get_rnn_lin_layer_matrix_params(
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0             # <<<<<<<<<<<<<<
 *     mat_desc = cudnn.createFilterDescriptor()
 *     try:
 */
  __pyx_v_ptr = 0;

  /* "cupy/cudnn.pyx":830
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 *     mat_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         cudnn.getRNNLinLayerMatrixParams(
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L1_error)
  __pyx_v_mat_desc = __pyx_t_1;

  /* "cupy/cudnn.pyx":831
 *     cdef size_t ptr = 0
 *     mat_desc = cudnn.createFilterDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         cudnn.getRNNLinLayerMatrixParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":833
 *     try:
 *         cudnn.getRNNLinLayerMatrixParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,             # <<<<<<<<<<<<<<
 *             w.data.ptr, lin_layer_id, mat_desc, <size_t>&ptr)
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(mat_desc, 3)
 */
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L4_error)
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rnn_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_layer); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L4_error)
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_w_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":834
 *         cudnn.getRNNLinLayerMatrixParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, mat_desc, <size_t>&ptr)             # <<<<<<<<<<<<<<
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(mat_desc, 3)
 *     finally:
 */
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_lin_layer_id); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 834, __pyx_L4_error)

    /* "cupy/cudnn.pyx":832
 *     mat_desc = cudnn.createFilterDescriptor()
 *     try:
 *         cudnn.getRNNLinLayerMatrixParams(             # <<<<<<<<<<<<<<
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, mat_desc, <size_t>&ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerMatrixParams(__pyx_t_1, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_v_w->data->ptr, __pyx_t_7, __pyx_v_mat_desc, ((size_t)(&__pyx_v_ptr)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 832, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":835
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, mat_desc, <size_t>&ptr)
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(mat_desc, 3)             # <<<<<<<<<<<<<<
 *     finally:
 *         cudnn.destroyFilterDescriptor(mat_desc)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getFilterNdDescriptor(__pyx_v_mat_desc, 3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 835, __pyx_L4_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_11);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 835, __pyx_L4_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
      __pyx_t_12 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 835, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_13(__pyx_t_12); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 4) < 0) __PYX_ERR(0, 835, __pyx_L4_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 835, __pyx_L4_error)
      __pyx_L7_unpacking_done:;
    }
    __pyx_v_data_type = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_v__ = __pyx_t_9;
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v__, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_v_dim = __pyx_t_11;
    __pyx_t_11 = 0;
  }

  /* "cupy/cudnn.pyx":837
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(mat_desc, 3)
 *     finally:
 *         cudnn.destroyFilterDescriptor(mat_desc)             # <<<<<<<<<<<<<<
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_mat_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      __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_XGOTREF(__pyx_t_20);
      __pyx_t_7 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_mat_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "cupy/cudnn.pyx":838
 *     finally:
 *         cudnn.destroyFilterDescriptor(mat_desc)
 *     byte_size = _get_byte_size(data_type)             # <<<<<<<<<<<<<<
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)
 */
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_data_type); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_5cudnn__get_byte_size(__pyx_t_4, 0); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 838, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_byte_size = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":839
 *         cudnn.destroyFilterDescriptor(mat_desc)
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size             # <<<<<<<<<<<<<<
 *     size = internal.prod_sequence(dim)
 *     mat = w[offset:offset + size]
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((__pyx_v_ptr - __pyx_v_w->data->ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_11 = PyNumber_FloorDivide(__pyx_t_2, __pyx_v_byte_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 839, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_offset = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/cudnn.pyx":840
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)             # <<<<<<<<<<<<<<
 *     mat = w[offset:offset + size]
 *     return mat
 */
  __pyx_t_11 = PyInt_FromSsize_t(__pyx_f_4cupy_4core_8internal_prod_sequence(__pyx_v_dim, 0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 840, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_v_size = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/cudnn.pyx":841
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)
 *     mat = w[offset:offset + size]             # <<<<<<<<<<<<<<
 *     return mat
 * 
 */
  __pyx_t_11 = PyNumber_Add(__pyx_v_offset, __pyx_v_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_w), 0, 0, &__pyx_v_offset, &__pyx_t_11, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_mat = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":842
 *     size = internal.prod_sequence(dim)
 *     mat = w[offset:offset + size]
 *     return mat             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_mat);
  __pyx_r = __pyx_v_mat;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":827
 * 
 * 
 * def get_rnn_lin_layer_matrix_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.get_rnn_lin_layer_matrix_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data_type);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_dim);
  __Pyx_XDECREF(__pyx_v_byte_size);
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_mat);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":845
 * 
 * 
 * def get_rnn_lin_layer_bias_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_69get_rnn_lin_layer_bias_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_68get_rnn_lin_layer_bias_params[] = "get_rnn_lin_layer_bias_params(handle, rnn_desc, layer, x_desc, w_desc, ndarray w, lin_layer_id)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_69get_rnn_lin_layer_bias_params = {"get_rnn_lin_layer_bias_params", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_69get_rnn_lin_layer_bias_params, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_68get_rnn_lin_layer_bias_params};
static PyObject *__pyx_pw_4cupy_5cudnn_69get_rnn_lin_layer_bias_params(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_rnn_desc = 0;
  PyObject *__pyx_v_layer = 0;
  PyObject *__pyx_v_x_desc = 0;
  PyObject *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  PyObject *__pyx_v_lin_layer_id = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_rnn_lin_layer_bias_params (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_rnn_desc,&__pyx_n_s_layer,&__pyx_n_s_x_desc,&__pyx_n_s_w_desc,&__pyx_n_s_w,&__pyx_n_s_lin_layer_id,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 1); __PYX_ERR(0, 845, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_layer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 2); __PYX_ERR(0, 845, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 3); __PYX_ERR(0, 845, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 4); __PYX_ERR(0, 845, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 5); __PYX_ERR(0, 845, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lin_layer_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, 6); __PYX_ERR(0, 845, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_rnn_lin_layer_bias_params") < 0)) __PYX_ERR(0, 845, __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_handle = values[0];
    __pyx_v_rnn_desc = values[1];
    __pyx_v_layer = values[2];
    __pyx_v_x_desc = values[3];
    __pyx_v_w_desc = values[4];
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_lin_layer_id = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_rnn_lin_layer_bias_params", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 845, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.get_rnn_lin_layer_bias_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 846, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_68get_rnn_lin_layer_bias_params(__pyx_self, __pyx_v_handle, __pyx_v_rnn_desc, __pyx_v_layer, __pyx_v_x_desc, __pyx_v_w_desc, __pyx_v_w, __pyx_v_lin_layer_id);

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

static PyObject *__pyx_pf_4cupy_5cudnn_68get_rnn_lin_layer_bias_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_rnn_desc, PyObject *__pyx_v_layer, PyObject *__pyx_v_x_desc, PyObject *__pyx_v_w_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, PyObject *__pyx_v_lin_layer_id) {
  size_t __pyx_v_ptr;
  size_t __pyx_v_bias_desc;
  PyObject *__pyx_v_data_type = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_v_dim = NULL;
  PyObject *__pyx_v_byte_size = NULL;
  PyObject *__pyx_v_offset = NULL;
  PyObject *__pyx_v_size = NULL;
  PyObject *__pyx_v_bias = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  size_t __pyx_t_5;
  size_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  char const *__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("get_rnn_lin_layer_bias_params", 0);

  /* "cupy/cudnn.pyx":847
 * def get_rnn_lin_layer_bias_params(
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0             # <<<<<<<<<<<<<<
 *     bias_desc = cudnn.createFilterDescriptor()
 *     try:
 */
  __pyx_v_ptr = 0;

  /* "cupy/cudnn.pyx":848
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 *     bias_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         cudnn.getRNNLinLayerBiasParams(
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 848, __pyx_L1_error)
  __pyx_v_bias_desc = __pyx_t_1;

  /* "cupy/cudnn.pyx":849
 *     cdef size_t ptr = 0
 *     bias_desc = cudnn.createFilterDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         cudnn.getRNNLinLayerBiasParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":851
 *     try:
 *         cudnn.getRNNLinLayerBiasParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,             # <<<<<<<<<<<<<<
 *             w.data.ptr, lin_layer_id, bias_desc, <size_t>&ptr)
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(bias_desc, 3)
 */
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L4_error)
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_rnn_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_layer); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L4_error)
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_w_desc, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 851, __pyx_L4_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":852
 *         cudnn.getRNNLinLayerBiasParams(
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, bias_desc, <size_t>&ptr)             # <<<<<<<<<<<<<<
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(bias_desc, 3)
 *     finally:
 */
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_lin_layer_id); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L4_error)

    /* "cupy/cudnn.pyx":850
 *     bias_desc = cudnn.createFilterDescriptor()
 *     try:
 *         cudnn.getRNNLinLayerBiasParams(             # <<<<<<<<<<<<<<
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, bias_desc, <size_t>&ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerBiasParams(__pyx_t_1, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_v_w->data->ptr, __pyx_t_7, __pyx_v_bias_desc, ((size_t)(&__pyx_v_ptr)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 850, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":853
 *             handle, rnn_desc.value, layer, x_desc.value, w_desc.value,
 *             w.data.ptr, lin_layer_id, bias_desc, <size_t>&ptr)
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(bias_desc, 3)             # <<<<<<<<<<<<<<
 *     finally:
 *         cudnn.destroyFilterDescriptor(bias_desc)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getFilterNdDescriptor(__pyx_v_bias_desc, 3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 853, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 853, __pyx_L4_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_11);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 853, __pyx_L4_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
      __pyx_t_12 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 853, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_13(__pyx_t_12); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 4) < 0) __PYX_ERR(0, 853, __pyx_L4_error)
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 853, __pyx_L4_error)
      __pyx_L7_unpacking_done:;
    }
    __pyx_v_data_type = __pyx_t_8;
    __pyx_t_8 = 0;
    __pyx_v__ = __pyx_t_9;
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v__, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_v_dim = __pyx_t_11;
    __pyx_t_11 = 0;
  }

  /* "cupy/cudnn.pyx":855
 *         data_type, _, _, dim = cudnn.getFilterNdDescriptor(bias_desc, 3)
 *     finally:
 *         cudnn.destroyFilterDescriptor(bias_desc)             # <<<<<<<<<<<<<<
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_bias_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      __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_XGOTREF(__pyx_t_20);
      __pyx_t_7 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_bias_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 855, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __pyx_lineno = __pyx_t_7; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "cupy/cudnn.pyx":856
 *     finally:
 *         cudnn.destroyFilterDescriptor(bias_desc)
 *     byte_size = _get_byte_size(data_type)             # <<<<<<<<<<<<<<
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)
 */
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_data_type); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 856, __pyx_L1_error)
  __pyx_t_7 = __pyx_f_4cupy_5cudnn__get_byte_size(__pyx_t_4, 0); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 856, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_byte_size = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":857
 *         cudnn.destroyFilterDescriptor(bias_desc)
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size             # <<<<<<<<<<<<<<
 *     size = internal.prod_sequence(dim)
 *     bias = w[offset:offset + size]
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((__pyx_v_ptr - __pyx_v_w->data->ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_11 = PyNumber_FloorDivide(__pyx_t_2, __pyx_v_byte_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_offset = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/cudnn.pyx":858
 *     byte_size = _get_byte_size(data_type)
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)             # <<<<<<<<<<<<<<
 *     bias = w[offset:offset + size]
 *     return bias
 */
  __pyx_t_11 = PyInt_FromSsize_t(__pyx_f_4cupy_4core_8internal_prod_sequence(__pyx_v_dim, 0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_v_size = __pyx_t_11;
  __pyx_t_11 = 0;

  /* "cupy/cudnn.pyx":859
 *     offset = (ptr - w.data.ptr) // byte_size
 *     size = internal.prod_sequence(dim)
 *     bias = w[offset:offset + size]             # <<<<<<<<<<<<<<
 *     return bias
 * 
 */
  __pyx_t_11 = PyNumber_Add(__pyx_v_offset, __pyx_v_size); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_w), 0, 0, &__pyx_v_offset, &__pyx_t_11, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 859, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_bias = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":860
 *     size = internal.prod_sequence(dim)
 *     bias = w[offset:offset + size]
 *     return bias             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_bias);
  __pyx_r = __pyx_v_bias;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":845
 * 
 * 
 * def get_rnn_lin_layer_bias_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.get_rnn_lin_layer_bias_params", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data_type);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XDECREF(__pyx_v_dim);
  __Pyx_XDECREF(__pyx_v_byte_size);
  __Pyx_XDECREF(__pyx_v_offset);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_bias);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":869
 *         object _destroy
 * 
 *     def __init__(self, destroyer):             # <<<<<<<<<<<<<<
 *         self._destroy = destroyer
 * 
 */

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_16_DescriptorArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_5cudnn_16_DescriptorArray_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_destroyer = 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_destroyer,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_destroyer)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 869, __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_destroyer = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 869, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._DescriptorArray.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_DescriptorArray___init__(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self), __pyx_v_destroyer);

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

static int __pyx_pf_4cupy_5cudnn_16_DescriptorArray___init__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v_destroyer) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cudnn.pyx":870
 * 
 *     def __init__(self, destroyer):
 *         self._destroy = destroyer             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __Pyx_INCREF(__pyx_v_destroyer);
  __Pyx_GIVEREF(__pyx_v_destroyer);
  __Pyx_GOTREF(__pyx_v_self->_destroy);
  __Pyx_DECREF(__pyx_v_self->_destroy);
  __pyx_v_self->_destroy = __pyx_v_destroyer;

  /* "cupy/cudnn.pyx":869
 *         object _destroy
 * 
 *     def __init__(self, destroyer):             # <<<<<<<<<<<<<<
 *         self._destroy = destroyer
 * 
 */

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

/* "cupy/cudnn.pyx":872
 *         self._destroy = destroyer
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         for desc in self._value:
 *             self._destroy(desc)
 */

/* Python wrapper */
static void __pyx_pw_4cupy_5cudnn_16_DescriptorArray_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4cupy_5cudnn_16_DescriptorArray_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4cupy_5cudnn_16_DescriptorArray_2__dealloc__(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self));

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

static void __pyx_pf_4cupy_5cudnn_16_DescriptorArray_2__dealloc__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self) {
  size_t __pyx_v_desc;
  __Pyx_RefNannyDeclarations
  std::vector<size_t> ::iterator __pyx_t_1;
  std::vector<size_t>  *__pyx_t_2;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  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("__dealloc__", 0);

  /* "cupy/cudnn.pyx":873
 * 
 *     def __dealloc__(self):
 *         for desc in self._value:             # <<<<<<<<<<<<<<
 *             self._destroy(desc)
 * 
 */
  __pyx_t_2 = &__pyx_v_self->_value;
  __pyx_t_1 = __pyx_t_2->begin();
  for (;;) {
    if (!(__pyx_t_1 != __pyx_t_2->end())) break;
    __pyx_t_3 = *__pyx_t_1;
    ++__pyx_t_1;
    __pyx_v_desc = __pyx_t_3;

    /* "cupy/cudnn.pyx":874
 *     def __dealloc__(self):
 *         for desc in self._value:
 *             self._destroy(desc)             # <<<<<<<<<<<<<<
 * 
 *     def append(self, desc):
 */
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_desc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self->_destroy);
    __pyx_t_6 = __pyx_v_self->_destroy; __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":873
 * 
 *     def __dealloc__(self):
 *         for desc in self._value:             # <<<<<<<<<<<<<<
 *             self._destroy(desc)
 * 
 */
  }

  /* "cupy/cudnn.pyx":872
 *         self._destroy = destroyer
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         for desc in self._value:
 *             self._destroy(desc)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("cupy.cudnn._DescriptorArray.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "cupy/cudnn.pyx":876
 *             self._destroy(desc)
 * 
 *     def append(self, desc):             # <<<<<<<<<<<<<<
 *         self._value.push_back(desc)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_5append(PyObject *__pyx_v_self, PyObject *__pyx_v_desc); /*proto*/
static char __pyx_doc_4cupy_5cudnn_16_DescriptorArray_4append[] = "_DescriptorArray.append(self, desc)";
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_5append(PyObject *__pyx_v_self, PyObject *__pyx_v_desc) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("append (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_DescriptorArray_4append(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self), ((PyObject *)__pyx_v_desc));

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

static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_4append(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v_desc) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("append", 0);

  /* "cupy/cudnn.pyx":877
 * 
 *     def append(self, desc):
 *         self._value.push_back(desc)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_desc); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 877, __pyx_L1_error)
  try {
    __pyx_v_self->_value.push_back(__pyx_t_1);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 877, __pyx_L1_error)
  }

  /* "cupy/cudnn.pyx":876
 *             self._destroy(desc)
 * 
 *     def append(self, desc):             # <<<<<<<<<<<<<<
 *         self._value.push_back(desc)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cudnn._DescriptorArray.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":880
 * 
 *     @property
 *     def data(self):             # <<<<<<<<<<<<<<
 *         return <size_t>&self._value[0]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_4data_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_4data_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_DescriptorArray_4data___get__(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_4data___get__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__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);

  /* "cupy/cudnn.pyx":881
 *     @property
 *     def data(self):
 *         return <size_t>&self._value[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)(&(__pyx_v_self->_value[0])))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":880
 * 
 *     @property
 *     def data(self):             # <<<<<<<<<<<<<<
 *         return <size_t>&self._value[0]
 * 
 */

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_16_DescriptorArray_6__reduce_cython__[] = "_DescriptorArray.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_DescriptorArray_6__reduce_cython__(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_6__reduce_cython__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._destroy, self._value)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_size_t(__pyx_v_self->_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_destroy);
  __Pyx_GIVEREF(__pyx_v_self->_destroy);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_destroy);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._destroy, self._value)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self._destroy, self._value)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._destroy is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._destroy, self._value)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._destroy is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->_destroy != Py_None);
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._destroy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self._destroy is not None
 *     if use_setstate:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle__DescriptorArray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_266093133);
    __Pyx_GIVEREF(__pyx_int_266093133);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_266093133);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._destroy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, None), state
 *     else:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__DescriptorArray__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle__DescriptorArray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_266093133);
    __Pyx_GIVEREF(__pyx_int_266093133);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_266093133);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn._DescriptorArray.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__DescriptorArray__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_5cudnn_16_DescriptorArray_8__setstate_cython__[] = "_DescriptorArray.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_5cudnn_16_DescriptorArray_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_16_DescriptorArray_8__setstate_cython__(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_5cudnn_16_DescriptorArray_8__setstate_cython__(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle__DescriptorArray__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_5cudnn___pyx_unpickle__DescriptorArray__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle__DescriptorArray, (type(self), 0xfdc424d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle__DescriptorArray__set_state(self, __pyx_state)
 */

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

/* "cupy/cudnn.pyx":884
 * 
 * 
 * cdef _DescriptorArray _make_tensor_descriptor_array(xs, lengths):             # <<<<<<<<<<<<<<
 *     """Make an array of pointers denoting pointers of tensor descriptors.
 * 
 */

static struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(PyObject *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_descs = 0;
  size_t __pyx_v_desc;
  int __pyx_v_data_type;
  std::vector<int>  __pyx_v_c_shape;
  std::vector<int>  __pyx_v_c_strides;
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_s;
  int __pyx_v_length;
  CYTHON_UNUSED Py_ssize_t __pyx_v__;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__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)(PyObject *);
  Py_ssize_t __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  size_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_tensor_descriptor_array", 0);

  /* "cupy/cudnn.pyx":889
 *     """
 *     cdef _DescriptorArray descs = _DescriptorArray(
 *         py_cudnn.destroyTensorDescriptor)             # <<<<<<<<<<<<<<
 *     cdef size_t desc
 *     cdef int data_type = get_data_type(xs.dtype)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_destroyTensorDescriptor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":888
 * 
 *     """
 *     cdef _DescriptorArray descs = _DescriptorArray(             # <<<<<<<<<<<<<<
 *         py_cudnn.destroyTensorDescriptor)
 *     cdef size_t desc
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_5cudnn__DescriptorArray), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":891
 *         py_cudnn.destroyTensorDescriptor)
 *     cdef size_t desc
 *     cdef int data_type = get_data_type(xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef vector.vector[int] c_shape, c_strides
 *     cdef Py_ssize_t itemsize = xs.itemsize
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_1, 0); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_data_type = __pyx_t_3;

  /* "cupy/cudnn.pyx":893
 *     cdef int data_type = get_data_type(xs.dtype)
 *     cdef vector.vector[int] c_shape, c_strides
 *     cdef Py_ssize_t itemsize = xs.itemsize             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t s
 *     cdef int length
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_itemsize = __pyx_t_4;

  /* "cupy/cudnn.pyx":898
 * 
 *     # RNN APIs assumes ndim == 3.
 *     for s in xs._strides:             # <<<<<<<<<<<<<<
 *         c_strides.push_back(s // itemsize)
 *     for _ in range(3 - len(xs._strides)):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __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_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 898, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 898, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 898, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 898, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 898, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 898, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 898, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_s = __pyx_t_6;

    /* "cupy/cudnn.pyx":899
 *     # RNN APIs assumes ndim == 3.
 *     for s in xs._strides:
 *         c_strides.push_back(s // itemsize)             # <<<<<<<<<<<<<<
 *     for _ in range(3 - len(xs._strides)):
 *         c_strides.push_back(1)
 */
    if (unlikely(__pyx_v_itemsize == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      __PYX_ERR(0, 899, __pyx_L1_error)
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_s))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      __PYX_ERR(0, 899, __pyx_L1_error)
    }
    try {
      __pyx_v_c_strides.push_back(__Pyx_div_Py_ssize_t(__pyx_v_s, __pyx_v_itemsize));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 899, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":898
 * 
 *     # RNN APIs assumes ndim == 3.
 *     for s in xs._strides:             # <<<<<<<<<<<<<<
 *         c_strides.push_back(s // itemsize)
 *     for _ in range(3 - len(xs._strides)):
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":900
 *     for s in xs._strides:
 *         c_strides.push_back(s // itemsize)
 *     for _ in range(3 - len(xs._strides)):             # <<<<<<<<<<<<<<
 *         c_strides.push_back(1)
 *     for s in xs._shape:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = (3 - __pyx_t_4);
  __pyx_t_4 = __pyx_t_6;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_4; __pyx_t_7+=1) {
    __pyx_v__ = __pyx_t_7;

    /* "cupy/cudnn.pyx":901
 *         c_strides.push_back(s // itemsize)
 *     for _ in range(3 - len(xs._strides)):
 *         c_strides.push_back(1)             # <<<<<<<<<<<<<<
 *     for s in xs._shape:
 *         c_shape.push_back(s)
 */
    try {
      __pyx_v_c_strides.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 901, __pyx_L1_error)
    }
  }

  /* "cupy/cudnn.pyx":902
 *     for _ in range(3 - len(xs._strides)):
 *         c_strides.push_back(1)
 *     for s in xs._shape:             # <<<<<<<<<<<<<<
 *         c_shape.push_back(s)
 *     for _ in range(3 - len(xs._strides)):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  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_6 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 902, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 902, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 902, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 902, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 902, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_4 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 902, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_s = __pyx_t_4;

    /* "cupy/cudnn.pyx":903
 *         c_strides.push_back(1)
 *     for s in xs._shape:
 *         c_shape.push_back(s)             # <<<<<<<<<<<<<<
 *     for _ in range(3 - len(xs._strides)):
 *         c_shape.push_back(1)
 */
    try {
      __pyx_v_c_shape.push_back(__pyx_v_s);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 903, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":902
 *     for _ in range(3 - len(xs._strides)):
 *         c_strides.push_back(1)
 *     for s in xs._shape:             # <<<<<<<<<<<<<<
 *         c_shape.push_back(s)
 *     for _ in range(3 - len(xs._strides)):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":904
 *     for s in xs._shape:
 *         c_shape.push_back(s)
 *     for _ in range(3 - len(xs._strides)):             # <<<<<<<<<<<<<<
 *         c_shape.push_back(1)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_strides); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 904, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 904, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (3 - __pyx_t_6);
  __pyx_t_6 = __pyx_t_4;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v__ = __pyx_t_7;

    /* "cupy/cudnn.pyx":905
 *         c_shape.push_back(s)
 *     for _ in range(3 - len(xs._strides)):
 *         c_shape.push_back(1)             # <<<<<<<<<<<<<<
 * 
 *     for length in lengths:
 */
    try {
      __pyx_v_c_shape.push_back(1);
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 905, __pyx_L1_error)
    }
  }

  /* "cupy/cudnn.pyx":907
 *         c_shape.push_back(1)
 * 
 *     for length in lengths:             # <<<<<<<<<<<<<<
 *         c_shape[0] = length
 *         desc = cudnn.createTensorDescriptor()
 */
  if (likely(PyList_CheckExact(__pyx_v_lengths)) || PyTuple_CheckExact(__pyx_v_lengths)) {
    __pyx_t_1 = __pyx_v_lengths; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_lengths); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 907, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 907, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 907, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 907, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 907, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 907, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_length = __pyx_t_3;

    /* "cupy/cudnn.pyx":908
 * 
 *     for length in lengths:
 *         c_shape[0] = length             # <<<<<<<<<<<<<<
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)
 */
    (__pyx_v_c_shape[0]) = __pyx_v_length;

    /* "cupy/cudnn.pyx":909
 *     for length in lengths:
 *         c_shape[0] = length
 *         desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *         descs.append(desc)
 *         cudnn.setTensorNdDescriptor(
 */
    __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 909, __pyx_L1_error)
    __pyx_v_desc = __pyx_t_8;

    /* "cupy/cudnn.pyx":910
 *         c_shape[0] = length
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)             # <<<<<<<<<<<<<<
 *         cudnn.setTensorNdDescriptor(
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 */
    __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_desc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_descs), __pyx_t_2); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 910, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":911
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)
 *         cudnn.setTensorNdDescriptor(             # <<<<<<<<<<<<<<
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 * 
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setTensorNdDescriptor(__pyx_v_desc, __pyx_v_data_type, 3, ((size_t)(&(__pyx_v_c_shape[0]))), ((size_t)(&(__pyx_v_c_strides[0]))), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 911, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":907
 *         c_shape.push_back(1)
 * 
 *     for length in lengths:             # <<<<<<<<<<<<<<
 *         c_shape[0] = length
 *         desc = cudnn.createTensorDescriptor()
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":914
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 * 
 *     return descs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_descs));
  __pyx_r = __pyx_v_descs;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":884
 * 
 * 
 * cdef _DescriptorArray _make_tensor_descriptor_array(xs, lengths):             # <<<<<<<<<<<<<<
 *     """Make an array of pointers denoting pointers of tensor descriptors.
 * 
 */

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

/* "cupy/cudnn.pyx":917
 * 
 * 
 * cdef _DescriptorArray _make_tensor_descriptor_array_for_padded(xs):             # <<<<<<<<<<<<<<
 *     assert xs.ndim == 3
 * 
 */

static struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array_for_padded(PyObject *__pyx_v_xs) {
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_descs = 0;
  size_t __pyx_v_desc;
  int __pyx_v_data_type;
  Py_ssize_t __pyx_v_itemsize;
  std::vector<int>  __pyx_v_c_shape;
  std::vector<int>  __pyx_v_c_strides;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  std::vector<int>  __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  size_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_tensor_descriptor_array_for_padded", 0);

  /* "cupy/cudnn.pyx":918
 * 
 * cdef _DescriptorArray _make_tensor_descriptor_array_for_padded(xs):
 *     assert xs.ndim == 3             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray descs = _DescriptorArray(
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 918, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 918, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":921
 * 
 *     cdef _DescriptorArray descs = _DescriptorArray(
 *         py_cudnn.destroyTensorDescriptor)             # <<<<<<<<<<<<<<
 *     cdef size_t desc
 *     cdef int data_type = get_data_type(xs.dtype)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_destroyTensorDescriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":920
 *     assert xs.ndim == 3
 * 
 *     cdef _DescriptorArray descs = _DescriptorArray(             # <<<<<<<<<<<<<<
 *         py_cudnn.destroyTensorDescriptor)
 *     cdef size_t desc
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4cupy_5cudnn__DescriptorArray), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":923
 *         py_cudnn.destroyTensorDescriptor)
 *     cdef size_t desc
 *     cdef int data_type = get_data_type(xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t itemsize = xs.itemsize
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_2, 0); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_data_type = __pyx_t_4;

  /* "cupy/cudnn.pyx":924
 *     cdef size_t desc
 *     cdef int data_type = get_data_type(xs.dtype)
 *     cdef Py_ssize_t itemsize = xs.itemsize             # <<<<<<<<<<<<<<
 * 
 *     # RNN APIs assumes ndim == 3.
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 924, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_itemsize = __pyx_t_5;

  /* "cupy/cudnn.pyx":927
 * 
 *     # RNN APIs assumes ndim == 3.
 *     cdef vector.vector[int] c_shape = [xs._shape[1], xs._shape[2], 1]             # <<<<<<<<<<<<<<
 *     cdef vector.vector[int] c_strides = [
 *         xs._strides[1] // itemsize, xs._strides[2] // itemsize, 1]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_6);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_1);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = __pyx_convert_vector_from_py_int(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 927, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_c_shape = __pyx_t_7;

  /* "cupy/cudnn.pyx":929
 *     cdef vector.vector[int] c_shape = [xs._shape[1], xs._shape[2], 1]
 *     cdef vector.vector[int] c_strides = [
 *         xs._strides[1] // itemsize, xs._strides[2] // itemsize, 1]             # <<<<<<<<<<<<<<
 * 
 *     for _ in range(xs._shape[0]):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_FloorDivide(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_strides); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_2, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = PyNumber_FloorDivide(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 929, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":928
 *     # RNN APIs assumes ndim == 3.
 *     cdef vector.vector[int] c_shape = [xs._shape[1], xs._shape[2], 1]
 *     cdef vector.vector[int] c_strides = [             # <<<<<<<<<<<<<<
 *         xs._strides[1] // itemsize, xs._strides[2] // itemsize, 1]
 * 
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_8);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_1);
  __pyx_t_1 = 0;
  __pyx_t_8 = 0;
  __pyx_t_7 = __pyx_convert_vector_from_py_int(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 928, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_c_strides = __pyx_t_7;

  /* "cupy/cudnn.pyx":931
 *         xs._strides[1] // itemsize, xs._strides[2] // itemsize, 1]
 * 
 *     for _ in range(xs._shape[0]):             # <<<<<<<<<<<<<<
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_xs, __pyx_n_s_shape_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_8 = __pyx_t_2; __Pyx_INCREF(__pyx_t_8); __pyx_t_5 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 931, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 931, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 931, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_9(__pyx_t_8);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 931, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":932
 * 
 *     for _ in range(xs._shape[0]):
 *         desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *         descs.append(desc)
 *         cudnn.setTensorNdDescriptor(
 */
    __pyx_t_10 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_10 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 932, __pyx_L1_error)
    __pyx_v_desc = __pyx_t_10;

    /* "cupy/cudnn.pyx":933
 *     for _ in range(xs._shape[0]):
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)             # <<<<<<<<<<<<<<
 *         cudnn.setTensorNdDescriptor(
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 */
    __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_desc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 933, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_descs), __pyx_t_2); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 933, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":934
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)
 *         cudnn.setTensorNdDescriptor(             # <<<<<<<<<<<<<<
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 * 
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setTensorNdDescriptor(__pyx_v_desc, __pyx_v_data_type, 3, ((size_t)(&(__pyx_v_c_shape[0]))), ((size_t)(&(__pyx_v_c_strides[0]))), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 934, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":931
 *         xs._strides[1] // itemsize, xs._strides[2] // itemsize, 1]
 * 
 *     for _ in range(xs._shape[0]):             # <<<<<<<<<<<<<<
 *         desc = cudnn.createTensorDescriptor()
 *         descs.append(desc)
 */
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cudnn.pyx":937
 *             desc, data_type, 3, <size_t>&c_shape[0], <size_t>&c_strides[0])
 * 
 *     return descs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_descs));
  __pyx_r = __pyx_v_descs;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":917
 * 
 * 
 * cdef _DescriptorArray _make_tensor_descriptor_array_for_padded(xs):             # <<<<<<<<<<<<<<
 *     assert xs.ndim == 3
 * 
 */

  /* 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_AddTraceback("cupy.cudnn._make_tensor_descriptor_array_for_padded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descs);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":940
 * 
 * 
 * cdef memory.MemoryPointer _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 */

static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_f_4cupy_5cudnn__make_rnn_workspace(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc, int __pyx_v_length, struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_descs) {
  size_t __pyx_v_handle;
  size_t __pyx_v_work_size;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  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("_make_rnn_workspace", 0);

  /* "cupy/cudnn.pyx":942
 * cdef memory.MemoryPointer _make_rnn_workspace(
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef size_t work_size = cudnn.getRNNWorkspaceSize(
 *         handle, rnn_desc.value, length, descs.data)
 */
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 942, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_1;

  /* "cupy/cudnn.pyx":944
 *     cdef size_t handle = get_handle()
 *     cdef size_t work_size = cudnn.getRNNWorkspaceSize(
 *         handle, rnn_desc.value, length, descs.data)             # <<<<<<<<<<<<<<
 *     return memory.alloc(work_size)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 944, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":943
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 *     cdef size_t work_size = cudnn.getRNNWorkspaceSize(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length, descs.data)
 *     return memory.alloc(work_size)
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getRNNWorkspaceSize(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 943, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 943, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_work_size = __pyx_t_1;

  /* "cupy/cudnn.pyx":945
 *     cdef size_t work_size = cudnn.getRNNWorkspaceSize(
 *         handle, rnn_desc.value, length, descs.data)
 *     return memory.alloc(work_size)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_work_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_2, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 945, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":940
 * 
 * 
 * cdef memory.MemoryPointer _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 */

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

/* "cupy/cudnn.pyx":948
 * 
 * 
 * cdef memory.MemoryPointer _make_rnn_reserve_space(             # <<<<<<<<<<<<<<
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 */

static struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_f_4cupy_5cudnn__make_rnn_reserve_space(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc, int __pyx_v_length, struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_descs) {
  size_t __pyx_v_handle;
  size_t __pyx_v_reserve_size;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  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("_make_rnn_reserve_space", 0);

  /* "cupy/cudnn.pyx":950
 * cdef memory.MemoryPointer _make_rnn_reserve_space(
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef size_t reserve_size = cudnn.getRNNTrainingReserveSize(
 *         handle, rnn_desc.value, length, descs.data)
 */
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 950, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_1;

  /* "cupy/cudnn.pyx":952
 *     cdef size_t handle = get_handle()
 *     cdef size_t reserve_size = cudnn.getRNNTrainingReserveSize(
 *         handle, rnn_desc.value, length, descs.data)             # <<<<<<<<<<<<<<
 *     return memory.alloc(reserve_size)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":951
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 *     cdef size_t reserve_size = cudnn.getRNNTrainingReserveSize(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length, descs.data)
 *     return memory.alloc(reserve_size)
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getRNNTrainingReserveSize(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 951, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_reserve_size = __pyx_t_1;

  /* "cupy/cudnn.pyx":953
 *     cdef size_t reserve_size = cudnn.getRNNTrainingReserveSize(
 *         handle, rnn_desc.value, length, descs.data)
 *     return memory.alloc(reserve_size)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_reserve_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_2, 0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":948
 * 
 * 
 * cdef memory.MemoryPointer _make_rnn_reserve_space(             # <<<<<<<<<<<<<<
 *         Descriptor rnn_desc, int length, _DescriptorArray descs):
 *     cdef size_t handle = get_handle()
 */

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

/* "cupy/cudnn.pyx":956
 * 
 * 
 * cdef Py_ssize_t _get_n_layers(int direction_mode, core.ndarray hx):             # <<<<<<<<<<<<<<
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:
 *         return hx._shape[0] // 2
 */

static Py_ssize_t __pyx_f_4cupy_5cudnn__get_n_layers(int __pyx_v_direction_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_get_n_layers", 0);

  /* "cupy/cudnn.pyx":957
 * 
 * cdef Py_ssize_t _get_n_layers(int direction_mode, core.ndarray hx):
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:             # <<<<<<<<<<<<<<
 *         return hx._shape[0] // 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 */
  __pyx_t_1 = ((__pyx_v_direction_mode == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BIDIRECTIONAL) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":958
 * cdef Py_ssize_t _get_n_layers(int direction_mode, core.ndarray hx):
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:
 *         return hx._shape[0] // 2             # <<<<<<<<<<<<<<
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 *         return hx._shape[0]
 */
    __pyx_r = __Pyx_div_Py_ssize_t((__pyx_v_hx->_shape[0]), 2);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":957
 * 
 * cdef Py_ssize_t _get_n_layers(int direction_mode, core.ndarray hx):
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:             # <<<<<<<<<<<<<<
 *         return hx._shape[0] // 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 */
  }

  /* "cupy/cudnn.pyx":960
 *         return hx._shape[0] // 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 *         return hx._shape[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_r = (__pyx_v_hx->_shape[0]);
    goto __pyx_L0;
  }

  /* "cupy/cudnn.pyx":956
 * 
 * 
 * cdef Py_ssize_t _get_n_layers(int direction_mode, core.ndarray hx):             # <<<<<<<<<<<<<<
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:
 *         return hx._shape[0] // 2
 */

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

/* "cupy/cudnn.pyx":963
 * 
 * 
 * cdef core.ndarray _make_rnn_result_array(             # <<<<<<<<<<<<<<
 *         int direction_mode, Py_ssize_t n_units, core.ndarray xs):
 *     cdef int output_units
 */

static struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_f_4cupy_5cudnn__make_rnn_result_array(int __pyx_v_direction_mode, Py_ssize_t __pyx_v_n_units, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs) {
  int __pyx_v_output_units;
  PyObject *__pyx_v_shape = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_make_rnn_result_array", 0);

  /* "cupy/cudnn.pyx":966
 *         int direction_mode, Py_ssize_t n_units, core.ndarray xs):
 *     cdef int output_units
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:             # <<<<<<<<<<<<<<
 *         output_units = n_units * 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 */
  __pyx_t_1 = ((__pyx_v_direction_mode == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BIDIRECTIONAL) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":967
 *     cdef int output_units
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:
 *         output_units = n_units * 2             # <<<<<<<<<<<<<<
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 *         output_units = n_units
 */
    __pyx_v_output_units = (__pyx_v_n_units * 2);

    /* "cupy/cudnn.pyx":966
 *         int direction_mode, Py_ssize_t n_units, core.ndarray xs):
 *     cdef int output_units
 *     if direction_mode == cudnn.CUDNN_BIDIRECTIONAL:             # <<<<<<<<<<<<<<
 *         output_units = n_units * 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":969
 *         output_units = n_units * 2
 *     else:  # cudnn.CUDNN_UNIDIRECTIONAL
 *         output_units = n_units             # <<<<<<<<<<<<<<
 * 
 *     shape = xs.shape[:-1] + (output_units,)
 */
  /*else*/ {
    __pyx_v_output_units = __pyx_v_n_units;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":971
 *         output_units = n_units
 * 
 *     shape = xs.shape[:-1] + (output_units,)             # <<<<<<<<<<<<<<
 *     return core.ndarray(shape, dtype=xs.dtype)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs), __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, -1L, NULL, NULL, &__pyx_slice__14, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_output_units); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __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;
  __pyx_v_shape = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":972
 * 
 *     shape = xs.shape[:-1] + (output_units,)
 *     return core.ndarray(shape, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 972, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 972, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":963
 * 
 * 
 * cdef core.ndarray _make_rnn_result_array(             # <<<<<<<<<<<<<<
 *         int direction_mode, Py_ssize_t n_units, core.ndarray xs):
 *     cdef int output_units
 */

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

/* "cupy/cudnn.pyx":975
 * 
 * 
 * def rnn_forward_inference(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_71rnn_forward_inference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_70rnn_forward_inference[] = "rnn_forward_inference(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_71rnn_forward_inference = {"rnn_forward_inference", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_71rnn_forward_inference, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_70rnn_forward_inference};
static PyObject *__pyx_pw_4cupy_5cudnn_71rnn_forward_inference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_forward_inference (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_lengths,0};
    PyObject* values[8] = {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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 1); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 2); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 3); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 4); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 5); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 6); __PYX_ERR(0, 975, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, 7); __PYX_ERR(0, 975, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_forward_inference") < 0)) __PYX_ERR(0, 975, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 976, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 976, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_lengths = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_forward_inference", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 975, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_inference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 976, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 977, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 977, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 977, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 977, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_70rnn_forward_inference(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_70rnn_forward_inference(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cy = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_ys_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cy_desc = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  size_t __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_forward_inference", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);

  /* "cupy/cudnn.pyx":979
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":980
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":981
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":980
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":982
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":983
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = len(lengths)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":985
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 *     cdef int length = len(lengths)             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_lengths); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 985, __pyx_L1_error)
  __pyx_v_length = __pyx_t_4;

  /* "cupy/cudnn.pyx":986
 * 
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx.shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":987
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 987, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 987, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n_units = __pyx_t_6;

  /* "cupy/cudnn.pyx":989
 *     cdef int n_units = hx.shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 */
  __pyx_t_7 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 989, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_7;

  /* "cupy/cudnn.pyx":991
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 991, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":992
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 992, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":993
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/cudnn.pyx":994
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 */
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_13);
  __pyx_t_6 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_13, 0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 994, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 991, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 991, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_6, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_6, __pyx_t_9);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_6, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_6, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_6, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_6, __pyx_t_13);
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":991
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 991, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":996
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_result_array(__pyx_v_direction_mode, __pyx_v_n_units, __pyx_v_xs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":997
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_hx->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_hy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":998
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":999
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 999, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 999, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":998
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":1000
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_cx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1000, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_cy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1002
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_xs), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1003
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1003, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1004
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1004, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1005
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1005, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1006
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_ys), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1006, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ys_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1007
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_hy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_hy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1007, __pyx_L1_error)
  __pyx_v_hy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1008
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)             # <<<<<<<<<<<<<<
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_cy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_cy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1008, __pyx_L1_error)
  __pyx_v_cy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1010
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1015
 *     cudnn.RNNForwardInference(
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,             # <<<<<<<<<<<<<<
 *         cx_desc.value, cx.data.ptr, w_desc.value, w.data.ptr,
 *         ys_descs.data, ys.data.ptr, hy_desc.value, hy.data.ptr,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1015, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1015, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1017
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,
 *         cx_desc.value, cx.data.ptr, w_desc.value, w.data.ptr,
 *         ys_descs.data, ys.data.ptr, hy_desc.value, hy.data.ptr,             # <<<<<<<<<<<<<<
 *         cy_desc.value, cy.data.ptr, workspace.ptr, workspace.mem.size)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ys_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1013
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNForwardInference(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_RNNForwardInference(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_7, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_t_16, __pyx_v_ys->data->ptr, __pyx_v_hy_desc->value, __pyx_v_hy->data->ptr, __pyx_v_cy_desc->value, __pyx_v_cy->data->ptr, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1020
 *         cy_desc.value, cy.data.ptr, workspace.ptr, workspace.mem.size)
 * 
 *     return hy, cy, ys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_hy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_hy));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_hy));
  __Pyx_INCREF(((PyObject *)__pyx_v_cy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cy));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_cy));
  __Pyx_INCREF(((PyObject *)__pyx_v_ys));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ys));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_ys));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":975
 * 
 * 
 * def rnn_forward_inference(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_inference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1023
 * 
 * 
 * def rnn_forward_training(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_73rnn_forward_training(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_72rnn_forward_training[] = "rnn_forward_training(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_73rnn_forward_training = {"rnn_forward_training", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_73rnn_forward_training, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_72rnn_forward_training};
static PyObject *__pyx_pw_4cupy_5cudnn_73rnn_forward_training(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_forward_training (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_lengths,0};
    PyObject* values[8] = {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  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 1); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 2); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 3); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 4); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 5); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 6); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, 7); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_forward_training") < 0)) __PYX_ERR(0, 1023, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1024, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_lengths = values[7];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_forward_training", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1023, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_training", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 1024, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 1025, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 1025, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 1025, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 1025, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_72rnn_forward_training(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_72rnn_forward_training(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cy = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_ys_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cy_desc = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  size_t __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_forward_training", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);

  /* "cupy/cudnn.pyx":1027
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1028
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":1029
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1028
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":1030
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1030, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1031
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = len(lengths)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1033
 *     xs = core._internal_ascontiguousarray(xs)
 * 
 *     cdef int length = len(lengths)             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_lengths); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1033, __pyx_L1_error)
  __pyx_v_length = __pyx_t_4;

  /* "cupy/cudnn.pyx":1034
 * 
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx.shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":1035
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n_units = __pyx_t_6;

  /* "cupy/cudnn.pyx":1037
 *     cdef int n_units = hx.shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 */
  __pyx_t_7 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1037, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_7;

  /* "cupy/cudnn.pyx":1039
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":1040
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":1041
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1041, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/cudnn.pyx":1042
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 */
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_13);
  __pyx_t_6 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_13, 0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1042, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_6, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_6, __pyx_t_9);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_6, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_6, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_6, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_6, __pyx_t_13);
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1039
 *     cdef size_t handle = get_handle()
 * 
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1039, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1044
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_result_array(__pyx_v_direction_mode, __pyx_v_n_units, __pyx_v_xs)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1045
 * 
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_hx->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_hy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1046
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1047
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 1047, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1046
 *     cdef core.ndarray ys = _make_rnn_result_array(direction_mode, n_units, xs)
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":1048
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_cx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_cy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1050
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_xs), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1051
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1051, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1052
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1052, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1052, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1053
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1053, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1053, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1054
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_ys), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ys_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1055
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_hy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_hy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1055, __pyx_L1_error)
  __pyx_v_hy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1056
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef Descriptor hy_desc = create_tensor_nd_descriptor(hy)
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)             # <<<<<<<<<<<<<<
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_cy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_cy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1056, __pyx_L1_error)
  __pyx_v_cy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1058
 *     cdef Descriptor cy_desc = create_tensor_nd_descriptor(cy)
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 *     cdef memory.MemoryPointer reserve_space = _make_rnn_reserve_space(
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1060
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 *         rnn_desc, length, xs_descs)
 *     cdef memory.MemoryPointer reserve_space = _make_rnn_reserve_space(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_reserve_space(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1065
 *     cudnn.RNNForwardTraining(
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,             # <<<<<<<<<<<<<<
 *         cx_desc.value, cx.data.ptr, w_desc.value, w.data.ptr,
 *         ys_descs.data, ys.data.ptr, hy_desc.value, hy.data.ptr,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1065, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1065, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1067
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,
 *         cx_desc.value, cx.data.ptr, w_desc.value, w.data.ptr,
 *         ys_descs.data, ys.data.ptr, hy_desc.value, hy.data.ptr,             # <<<<<<<<<<<<<<
 *         cy_desc.value, cy.data.ptr, workspace.ptr, workspace.mem.size,
 *         reserve_space.ptr, reserve_space.mem.size)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ys_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1063
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNForwardTraining(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr, hx_desc.value, hx.data.ptr,
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_RNNForwardTraining(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_7, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_t_16, __pyx_v_ys->data->ptr, __pyx_v_hy_desc->value, __pyx_v_hy->data->ptr, __pyx_v_cy_desc->value, __pyx_v_cy->data->ptr, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1071
 *         reserve_space.ptr, reserve_space.mem.size)
 * 
 *     return reserve_space, hy, cy, ys             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_reserve_space));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_reserve_space));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_reserve_space));
  __Pyx_INCREF(((PyObject *)__pyx_v_hy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_hy));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_hy));
  __Pyx_INCREF(((PyObject *)__pyx_v_cy));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cy));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_cy));
  __Pyx_INCREF(((PyObject *)__pyx_v_ys));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ys));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_ys));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1023
 * 
 * 
 * def rnn_forward_training(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.cudnn.rnn_forward_training", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_reserve_space);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1074
 * 
 * 
 * def rnn_backward_data(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_75rnn_backward_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_74rnn_backward_data[] = "rnn_backward_data(DropoutStates states, int direction_mode, int rnn_mode, ndarray hx, ndarray cx, ndarray w, ndarray xs, ndarray ys, MemoryPointer reserve_space, ndarray dhy, ndarray dcy, ndarray dys, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_75rnn_backward_data = {"rnn_backward_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_75rnn_backward_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_74rnn_backward_data};
static PyObject *__pyx_pw_4cupy_5cudnn_75rnn_backward_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_backward_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_hx,&__pyx_n_s_cx,&__pyx_n_s_w,&__pyx_n_s_xs,&__pyx_n_s_ys,&__pyx_n_s_reserve_space,&__pyx_n_s_dhy,&__pyx_n_s_dcy,&__pyx_n_s_dys,&__pyx_n_s_lengths,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 1); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 2); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 3); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 4); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 5); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 6); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 7); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reserve_space)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 8); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dhy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 9); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dcy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 10); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 11); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, 12); __PYX_ERR(0, 1074, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_backward_data") < 0)) __PYX_ERR(0, 1074, __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_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1075, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1075, __pyx_L3_error)
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_cx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[7]);
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)values[8]);
    __pyx_v_dhy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[9]);
    __pyx_v_dcy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[10]);
    __pyx_v_dys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[11]);
    __pyx_v_lengths = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_backward_data", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1074, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 1075, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 1076, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "cx", 0))) __PYX_ERR(0, 1076, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 1076, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 1076, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ys", 0))) __PYX_ERR(0, 1077, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer, 1, "reserve_space", 0))) __PYX_ERR(0, 1077, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dhy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dhy", 0))) __PYX_ERR(0, 1078, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dcy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dcy", 0))) __PYX_ERR(0, 1078, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dys", 0))) __PYX_ERR(0, 1078, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_74rnn_backward_data(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_hx, __pyx_v_cx, __pyx_v_w, __pyx_v_xs, __pyx_v_ys, __pyx_v_reserve_space, __pyx_v_dhy, __pyx_v_dcy, __pyx_v_dys, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_74rnn_backward_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_cx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dys, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dxs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dhx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dcx = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_ys_descs = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_dys_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dhy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dcy_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_w_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_cx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_dxs_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dhx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dcx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  size_t __pyx_t_16;
  size_t __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_backward_data", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_cx);
  __Pyx_INCREF((PyObject *)__pyx_v_w);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);
  __Pyx_INCREF((PyObject *)__pyx_v_ys);
  __Pyx_INCREF((PyObject *)__pyx_v_dhy);
  __Pyx_INCREF((PyObject *)__pyx_v_dcy);
  __Pyx_INCREF((PyObject *)__pyx_v_dys);

  /* "cupy/cudnn.pyx":1080
 *         core.ndarray dhy, core.ndarray dcy, core.ndarray dys,
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1081
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":1082
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_cx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1081
 *         lengths):
 *     hx = core._internal_ascontiguousarray(hx)
 *     if cx is not None:             # <<<<<<<<<<<<<<
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 */
  }

  /* "cupy/cudnn.pyx":1083
 *     if cx is not None:
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = _ascontiguousarray_normalized_strides(ys)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1083, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1084
 *         cx = core._internal_ascontiguousarray(cx)
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 *     ys = _ascontiguousarray_normalized_strides(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1085
 *     w = core._internal_ascontiguousarray(w)
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = _ascontiguousarray_normalized_strides(ys)             # <<<<<<<<<<<<<<
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__ascontiguousarray_normalized_strides(__pyx_v_ys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_ys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1086
 *     xs = core._internal_ascontiguousarray(xs)
 *     ys = _ascontiguousarray_normalized_strides(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)             # <<<<<<<<<<<<<<
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dhy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dhy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1087
 *     ys = _ascontiguousarray_normalized_strides(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:             # <<<<<<<<<<<<<<
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = _ascontiguousarray_normalized_strides(dys)
 */
  __pyx_t_3 = (((PyObject *)__pyx_v_dcy) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1088
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)             # <<<<<<<<<<<<<<
 *     dys = _ascontiguousarray_normalized_strides(dys)
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dcy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1088, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_dcy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1087
 *     ys = _ascontiguousarray_normalized_strides(ys)
 *     dhy = core._internal_ascontiguousarray(dhy)
 *     if dcy is not None:             # <<<<<<<<<<<<<<
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = _ascontiguousarray_normalized_strides(dys)
 */
  }

  /* "cupy/cudnn.pyx":1089
 *     if dcy is not None:
 *         dcy = core._internal_ascontiguousarray(dcy)
 *     dys = _ascontiguousarray_normalized_strides(dys)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = len(lengths)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__ascontiguousarray_normalized_strides(__pyx_v_dys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_dys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1091
 *     dys = _ascontiguousarray_normalized_strides(dys)
 * 
 *     cdef int length = len(lengths)             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_lengths); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1091, __pyx_L1_error)
  __pyx_v_length = __pyx_t_4;

  /* "cupy/cudnn.pyx":1092
 * 
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx.shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":1093
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1093, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_n_units = __pyx_t_6;

  /* "cupy/cudnn.pyx":1095
 *     cdef int n_units = hx.shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 */
  __pyx_t_7 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1095, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_7;

  /* "cupy/cudnn.pyx":1096
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1096, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":1097
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1097, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":1098
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1098, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "cupy/cudnn.pyx":1099
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 * 
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 */
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_13);
  __pyx_t_6 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_13, 0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1099, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1096, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_14, __pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_v_states->_desc), __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 7+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1096, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(7+__pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_14) {
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_6, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_6, __pyx_t_9);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_6, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_6, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 5+__pyx_t_6, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_15, 6+__pyx_t_6, __pyx_t_13);
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_13 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1096, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1096
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1096, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1101
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_xs->dtype);
  __Pyx_GIVEREF(__pyx_v_xs->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_xs->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dxs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1102
 * 
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)             # <<<<<<<<<<<<<<
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_hx->dtype);
  __Pyx_GIVEREF(__pyx_v_hx->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_hx->dtype);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1102, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dhx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1103
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_cx) == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":1104
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 * 
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_xs->dtype) < 0) __PYX_ERR(0, 1104, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_tuple__12, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_cx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_dcy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1103
 *     cdef core.ndarray dxs = core.ndarray(xs.shape, xs.dtype)
 *     cdef core.ndarray dhx = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:             # <<<<<<<<<<<<<<
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 */
  }

  /* "cupy/cudnn.pyx":1105
 *     if cx is None:
 *         cx = dcy = core.ndarray(0, dtype=xs.dtype)
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_cx->dtype);
  __Pyx_GIVEREF(__pyx_v_cx->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_cx->dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dcx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1107
 *     cdef core.ndarray dcx = core.ndarray(cx.shape, cx.dtype)
 * 
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)             # <<<<<<<<<<<<<<
 *     cdef _DescriptorArray dys_descs = _make_tensor_descriptor_array(
 *         dys, lengths)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_ys), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ys_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1108
 * 
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 *     cdef _DescriptorArray dys_descs = _make_tensor_descriptor_array(             # <<<<<<<<<<<<<<
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_dys), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_dys_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1110
 *     cdef _DescriptorArray dys_descs = _make_tensor_descriptor_array(
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_dhy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_dhy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1110, __pyx_L1_error)
  __pyx_v_dhy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1111
 *         dys, lengths)
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)             # <<<<<<<<<<<<<<
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_dcy)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_dcy));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1111, __pyx_L1_error)
  __pyx_v_dcy_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1112
 *     cdef Descriptor dhy_desc = create_tensor_nd_descriptor(dhy)
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_w)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_w));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1112, __pyx_L1_error)
  __pyx_v_w_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1113
 *     cdef Descriptor dcy_desc = create_tensor_nd_descriptor(dcy)
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef _DescriptorArray dxs_descs = _make_tensor_descriptor_array(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1113, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1114
 *     cdef Descriptor w_desc = create_filter_descriptor(w)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)             # <<<<<<<<<<<<<<
 *     cdef _DescriptorArray dxs_descs = _make_tensor_descriptor_array(
 *         dxs, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_cx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_cx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1114, __pyx_L1_error)
  __pyx_v_cx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1115
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef Descriptor cx_desc = create_tensor_nd_descriptor(cx)
 *     cdef _DescriptorArray dxs_descs = _make_tensor_descriptor_array(             # <<<<<<<<<<<<<<
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_dxs), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_dxs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1117
 *     cdef _DescriptorArray dxs_descs = _make_tensor_descriptor_array(
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)             # <<<<<<<<<<<<<<
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_dhx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_dhx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1117, __pyx_L1_error)
  __pyx_v_dhx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1118
 *         dxs, lengths)
 *     cdef Descriptor dhx_desc = create_tensor_nd_descriptor(dhx)
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_15 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_15)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_15, ((PyObject *)__pyx_v_dcx)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_dcx));
  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1118, __pyx_L1_error)
  __pyx_v_dcx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1120
 *     cdef Descriptor dcx_desc = create_tensor_nd_descriptor(dcx)
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)             # <<<<<<<<<<<<<<
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 *         rnn_desc, length, xs_descs)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_xs), __pyx_v_lengths)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1120, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1121
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1126
 *     cudnn.RNNBackwardData(
 *         handle, rnn_desc.value, length,
 *         ys_descs.data, ys.data.ptr,             # <<<<<<<<<<<<<<
 *         dys_descs.data, dys.data.ptr, dhy_desc.value, dhy.data.ptr,
 *         dcy_desc.value, dcy.data.ptr, w_desc.value, w.data.ptr,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ys_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1127
 *         handle, rnn_desc.value, length,
 *         ys_descs.data, ys.data.ptr,
 *         dys_descs.data, dys.data.ptr, dhy_desc.value, dhy.data.ptr,             # <<<<<<<<<<<<<<
 *         dcy_desc.value, dcy.data.ptr, w_desc.value, w.data.ptr,
 *         hx_desc.value, hx.data.ptr, cx_desc.value, cx.data.ptr,
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dys_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_16 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1130
 *         dcy_desc.value, dcy.data.ptr, w_desc.value, w.data.ptr,
 *         hx_desc.value, hx.data.ptr, cx_desc.value, cx.data.ptr,
 *         dxs_descs.data, dxs.data.ptr, dhx_desc.value, dhx.data.ptr,             # <<<<<<<<<<<<<<
 *         dcx_desc.value, dcx.data.ptr, workspace.ptr, workspace.mem.size,
 *         reserve_space.ptr, reserve_space.mem.size)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dxs_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_17 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1130, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1124
 *         rnn_desc, length, xs_descs)
 * 
 *     cudnn.RNNBackwardData(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length,
 *         ys_descs.data, ys.data.ptr,
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_RNNBackwardData(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_7, __pyx_v_ys->data->ptr, __pyx_t_16, __pyx_v_dys->data->ptr, __pyx_v_dhy_desc->value, __pyx_v_dhy->data->ptr, __pyx_v_dcy_desc->value, __pyx_v_dcy->data->ptr, __pyx_v_w_desc->value, __pyx_v_w->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_v_cx_desc->value, __pyx_v_cx->data->ptr, __pyx_t_17, __pyx_v_dxs->data->ptr, __pyx_v_dhx_desc->value, __pyx_v_dhx->data->ptr, __pyx_v_dcx_desc->value, __pyx_v_dcx->data->ptr, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1134
 *         reserve_space.ptr, reserve_space.mem.size)
 * 
 *     return dhx, dcx, dxs             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_dhx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dhx));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_dhx));
  __Pyx_INCREF(((PyObject *)__pyx_v_dcx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dcx));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_dcx));
  __Pyx_INCREF(((PyObject *)__pyx_v_dxs));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dxs));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_dxs));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1074
 * 
 * 
 * def rnn_backward_data(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dxs);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhx);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcx);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_dys_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcy_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_w_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dxs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_cx);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_dhy);
  __Pyx_XDECREF((PyObject *)__pyx_v_dcy);
  __Pyx_XDECREF((PyObject *)__pyx_v_dys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1137
 * 
 * 
 * def rnn_backward_weights(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_77rnn_backward_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_76rnn_backward_weights[] = "rnn_backward_weights(DropoutStates states, int direction_mode, int rnn_mode, ndarray xs, ndarray hx, ndarray ys, ndarray w, MemoryPointer reserve_space, lengths)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_77rnn_backward_weights = {"rnn_backward_weights", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_77rnn_backward_weights, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_76rnn_backward_weights};
static PyObject *__pyx_pw_4cupy_5cudnn_77rnn_backward_weights(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states = 0;
  int __pyx_v_direction_mode;
  int __pyx_v_rnn_mode;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  PyObject *__pyx_v_lengths = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rnn_backward_weights (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_states,&__pyx_n_s_direction_mode,&__pyx_n_s_rnn_mode,&__pyx_n_s_xs,&__pyx_n_s_hx,&__pyx_n_s_ys,&__pyx_n_s_w,&__pyx_n_s_reserve_space,&__pyx_n_s_lengths,0};
    PyObject* values[9] = {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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_states)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 1); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 2); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_xs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 3); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 4); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ys)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 5); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_w)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 6); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reserve_space)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 7); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lengths)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, 8); __PYX_ERR(0, 1137, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rnn_backward_weights") < 0)) __PYX_ERR(0, 1137, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      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);
    }
    __pyx_v_states = ((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)values[0]);
    __pyx_v_direction_mode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_direction_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1138, __pyx_L3_error)
    __pyx_v_rnn_mode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1138, __pyx_L3_error)
    __pyx_v_xs = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_hx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_ys = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[5]);
    __pyx_v_w = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[6]);
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)values[7]);
    __pyx_v_lengths = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rnn_backward_weights", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1137, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_states), __pyx_ptype_4cupy_5cudnn_DropoutStates, 1, "states", 0))) __PYX_ERR(0, 1138, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_xs), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "xs", 0))) __PYX_ERR(0, 1139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hx), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "hx", 0))) __PYX_ERR(0, 1139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ys), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "ys", 0))) __PYX_ERR(0, 1139, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_w), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "w", 0))) __PYX_ERR(0, 1140, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer, 1, "reserve_space", 0))) __PYX_ERR(0, 1141, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_76rnn_backward_weights(__pyx_self, __pyx_v_states, __pyx_v_direction_mode, __pyx_v_rnn_mode, __pyx_v_xs, __pyx_v_hx, __pyx_v_ys, __pyx_v_w, __pyx_v_reserve_space, __pyx_v_lengths);

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

static PyObject *__pyx_pf_4cupy_5cudnn_76rnn_backward_weights(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_states, int __pyx_v_direction_mode, int __pyx_v_rnn_mode, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_xs, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_hx, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ys, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_w, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space, PyObject *__pyx_v_lengths) {
  int __pyx_v_length;
  int __pyx_v_n_layers;
  int __pyx_v_n_units;
  size_t __pyx_v_handle;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_rnn_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_xs_descs = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_hx_desc = 0;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v_ys_descs = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dw = 0;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_dw_desc = 0;
  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;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  size_t __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("rnn_backward_weights", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_xs);
  __Pyx_INCREF((PyObject *)__pyx_v_hx);
  __Pyx_INCREF((PyObject *)__pyx_v_ys);
  __Pyx_INCREF((PyObject *)__pyx_v_w);

  /* "cupy/cudnn.pyx":1142
 *         core.ndarray w,
 *         memory.MemoryPointer reserve_space, lengths):
 *     xs = core._internal_ascontiguousarray(xs)             # <<<<<<<<<<<<<<
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_xs, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1143
 *         memory.MemoryPointer reserve_space, lengths):
 *     xs = core._internal_ascontiguousarray(xs)
 *     hx = core._internal_ascontiguousarray(hx)             # <<<<<<<<<<<<<<
 *     ys = core._internal_ascontiguousarray(ys)
 *     w = core._internal_ascontiguousarray(w)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_hx, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_hx, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1144
 *     xs = core._internal_ascontiguousarray(xs)
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)             # <<<<<<<<<<<<<<
 *     w = core._internal_ascontiguousarray(w)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_ys, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_ys, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1145
 *     hx = core._internal_ascontiguousarray(hx)
 *     ys = core._internal_ascontiguousarray(ys)
 *     w = core._internal_ascontiguousarray(w)             # <<<<<<<<<<<<<<
 * 
 *     cdef int length = len(lengths)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_w, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_w, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1147
 *     w = core._internal_ascontiguousarray(w)
 * 
 *     cdef int length = len(lengths)             # <<<<<<<<<<<<<<
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_lengths); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1147, __pyx_L1_error)
  __pyx_v_length = __pyx_t_2;

  /* "cupy/cudnn.pyx":1148
 * 
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)             # <<<<<<<<<<<<<<
 *     cdef int n_units = hx.shape[2]
 * 
 */
  __pyx_v_n_layers = __pyx_f_4cupy_5cudnn__get_n_layers(__pyx_v_direction_mode, __pyx_v_hx);

  /* "cupy/cudnn.pyx":1149
 *     cdef int length = len(lengths)
 *     cdef int n_layers = _get_n_layers(direction_mode, hx)
 *     cdef int n_units = hx.shape[2]             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t handle = get_handle()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_hx), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_n_units = __pyx_t_4;

  /* "cupy/cudnn.pyx":1151
 *     cdef int n_units = hx.shape[2]
 * 
 *     cdef size_t handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 */
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_5 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1151, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_5;

  /* "cupy/cudnn.pyx":1152
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_rnn_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "cupy/cudnn.pyx":1153
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,             # <<<<<<<<<<<<<<
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_units); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_n_layers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "cupy/cudnn.pyx":1154
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,             # <<<<<<<<<<<<<<
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_LINEAR_INPUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_direction_mode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1154, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "cupy/cudnn.pyx":1155
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 *         rnn_mode, get_data_type(xs.dtype))             # <<<<<<<<<<<<<<
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_rnn_mode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __pyx_v_xs->dtype;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_11, 0); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_12, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[8] = {__pyx_t_12, __pyx_t_6, __pyx_t_7, ((PyObject *)__pyx_v_states->_desc), __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_13 = PyTuple_New(7+__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_4, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_4, __pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_states->_desc));
    PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_4, ((PyObject *)__pyx_v_states->_desc));
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_13, 3+__pyx_t_4, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_13, 4+__pyx_t_4, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_13, 5+__pyx_t_4, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_13, 6+__pyx_t_4, __pyx_t_11);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1152
 * 
 *     cdef size_t handle = get_handle()
 *     cdef Descriptor rnn_desc = create_rnn_descriptor(             # <<<<<<<<<<<<<<
 *         n_units, n_layers, states._desc,
 *         cudnn.CUDNN_LINEAR_INPUT, direction_mode,
 */
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1152, __pyx_L1_error)
  __pyx_v_rnn_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1157
 *         rnn_mode, get_data_type(xs.dtype))
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)             # <<<<<<<<<<<<<<
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_xs), __pyx_v_lengths)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_xs_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1158
 * 
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)             # <<<<<<<<<<<<<<
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_tensor_nd_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_13, ((PyObject *)__pyx_v_hx)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_hx));
  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1158, __pyx_L1_error)
  __pyx_v_hx_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1159
 *     cdef _DescriptorArray xs_descs = _make_tensor_descriptor_array(xs, lengths)
 *     cdef Descriptor hx_desc = create_tensor_nd_descriptor(hx)
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)             # <<<<<<<<<<<<<<
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_tensor_descriptor_array(((PyObject *)__pyx_v_ys), __pyx_v_lengths)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_ys_descs = ((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1161
 *     cdef _DescriptorArray ys_descs = _make_tensor_descriptor_array(ys, lengths)
 * 
 *     cdef memory.MemoryPointer workspace = _make_rnn_workspace(             # <<<<<<<<<<<<<<
 *         rnn_desc, length, xs_descs)
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_f_4cupy_5cudnn__make_rnn_workspace(__pyx_v_rnn_desc, __pyx_v_length, __pyx_v_xs_descs)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1164
 *         rnn_desc, length, xs_descs)
 * 
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)             # <<<<<<<<<<<<<<
 *     dw[...] = 0
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_w), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_w->dtype);
  __Pyx_GIVEREF(__pyx_v_w->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_w->dtype);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_dw = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1165
 * 
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)
 *     dw[...] = 0             # <<<<<<<<<<<<<<
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 * 
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dw), Py_Ellipsis, __pyx_int_0) < 0)) __PYX_ERR(0, 1165, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1166
 *     cdef core.ndarray dw = core.ndarray(w.shape, w.dtype)
 *     dw[...] = 0
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)             # <<<<<<<<<<<<<<
 * 
 *     cudnn.RNNBackwardWeights(
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_filter_descriptor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_13, ((PyObject *)__pyx_v_dw)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_dw));
  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1166, __pyx_L1_error)
  __pyx_v_dw_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1170
 *     cudnn.RNNBackwardWeights(
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr,             # <<<<<<<<<<<<<<
 *         hx_desc.value, hx.data.ptr, ys_descs.data, ys.data.ptr,
 *         workspace.ptr, workspace.mem.size, dw_desc.value, dw.data.ptr,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_xs_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1171
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr,
 *         hx_desc.value, hx.data.ptr, ys_descs.data, ys.data.ptr,             # <<<<<<<<<<<<<<
 *         workspace.ptr, workspace.mem.size, dw_desc.value, dw.data.ptr,
 *         reserve_space.ptr, reserve_space.mem.size)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ys_descs), __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_14 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1168
 *     cdef Descriptor dw_desc = create_filter_descriptor(dw)
 * 
 *     cudnn.RNNBackwardWeights(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc.value, length,
 *         xs_descs.data, xs.data.ptr,
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeights(__pyx_v_handle, __pyx_v_rnn_desc->value, __pyx_v_length, __pyx_t_5, __pyx_v_xs->data->ptr, __pyx_v_hx_desc->value, __pyx_v_hx->data->ptr, __pyx_t_14, __pyx_v_ys->data->ptr, __pyx_v_workspace->ptr, __pyx_v_workspace->mem->size, __pyx_v_dw_desc->value, __pyx_v_dw->data->ptr, __pyx_v_reserve_space->ptr, __pyx_v_reserve_space->mem->size, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1174
 *         workspace.ptr, workspace.mem.size, dw_desc.value, dw.data.ptr,
 *         reserve_space.ptr, reserve_space.mem.size)
 *     return dw             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_dw));
  __pyx_r = ((PyObject *)__pyx_v_dw);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1137
 * 
 * 
 * def rnn_backward_weights(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.cudnn.rnn_backward_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rnn_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys_descs);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_dw);
  __Pyx_XDECREF((PyObject *)__pyx_v_dw_desc);
  __Pyx_XDECREF((PyObject *)__pyx_v_xs);
  __Pyx_XDECREF((PyObject *)__pyx_v_hx);
  __Pyx_XDECREF((PyObject *)__pyx_v_ys);
  __Pyx_XDECREF((PyObject *)__pyx_v_w);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1177
 * 
 * 
 * def create_dropout_states(handle):             # <<<<<<<<<<<<<<
 *     warnings.warn('create_dropout_states is deprecated.'
 *                   'Please use DropoutStates class instead.',
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_79create_dropout_states(PyObject *__pyx_self, PyObject *__pyx_v_handle); /*proto*/
static char __pyx_doc_4cupy_5cudnn_78create_dropout_states[] = "create_dropout_states(handle)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_79create_dropout_states = {"create_dropout_states", (PyCFunction)__pyx_pw_4cupy_5cudnn_79create_dropout_states, METH_O, __pyx_doc_4cupy_5cudnn_78create_dropout_states};
static PyObject *__pyx_pw_4cupy_5cudnn_79create_dropout_states(PyObject *__pyx_self, PyObject *__pyx_v_handle) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_dropout_states (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_78create_dropout_states(__pyx_self, ((PyObject *)__pyx_v_handle));

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

static PyObject *__pyx_pf_4cupy_5cudnn_78create_dropout_states(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle) {
  Py_ssize_t __pyx_v_state_size;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_dropout_states", 0);

  /* "cupy/cudnn.pyx":1178
 * 
 * def create_dropout_states(handle):
 *     warnings.warn('create_dropout_states is deprecated.'             # <<<<<<<<<<<<<<
 *                   'Please use DropoutStates class instead.',
 *                   DeprecationWarning)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1180
 *     warnings.warn('create_dropout_states is deprecated.'
 *                   'Please use DropoutStates class instead.',
 *                   DeprecationWarning)             # <<<<<<<<<<<<<<
 *     state_size = cudnn.dropoutGetStatesSize(handle)
 *     return core.ndarray((state_size,), 'b')
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1181
 *                   'Please use DropoutStates class instead.',
 *                   DeprecationWarning)
 *     state_size = cudnn.dropoutGetStatesSize(handle)             # <<<<<<<<<<<<<<
 *     return core.ndarray((state_size,), 'b')
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1181, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_dropoutGetStatesSize(__pyx_t_3, 0); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1181, __pyx_L1_error)
  __pyx_v_state_size = __pyx_t_4;

  /* "cupy/cudnn.pyx":1182
 *                   DeprecationWarning)
 *     state_size = cudnn.dropoutGetStatesSize(handle)
 *     return core.ndarray((state_size,), 'b')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_state_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1182, __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 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_n_u_b);
  __Pyx_GIVEREF(__pyx_n_u_b);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_b);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1182, __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/cudnn.pyx":1177
 * 
 * 
 * def create_dropout_states(handle):             # <<<<<<<<<<<<<<
 *     warnings.warn('create_dropout_states is deprecated.'
 *                   'Please use DropoutStates class instead.',
 */

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

/* "cupy/cudnn.pyx":1185
 * 
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_81create_spatial_transformer_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_80create_spatial_transformer_descriptor[] = "create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_81create_spatial_transformer_descriptor = {"create_spatial_transformer_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_81create_spatial_transformer_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_80create_spatial_transformer_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_81create_spatial_transformer_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sampler_type = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_nb_dims = 0;
  PyObject *__pyx_v_dim_A = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_spatial_transformer_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sampler_type,&__pyx_n_s_dtype,&__pyx_n_s_nb_dims,&__pyx_n_s_dim_A,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sampler_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_spatial_transformer_descriptor", 1, 4, 4, 1); __PYX_ERR(0, 1185, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nb_dims)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_spatial_transformer_descriptor", 1, 4, 4, 2); __PYX_ERR(0, 1185, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dim_A)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_spatial_transformer_descriptor", 1, 4, 4, 3); __PYX_ERR(0, 1185, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_spatial_transformer_descriptor") < 0)) __PYX_ERR(0, 1185, __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_sampler_type = values[0];
    __pyx_v_dtype = values[1];
    __pyx_v_nb_dims = values[2];
    __pyx_v_dim_A = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_spatial_transformer_descriptor", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1185, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_spatial_transformer_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_80create_spatial_transformer_descriptor(__pyx_self, __pyx_v_sampler_type, __pyx_v_dtype, __pyx_v_nb_dims, __pyx_v_dim_A);

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

static PyObject *__pyx_pf_4cupy_5cudnn_80create_spatial_transformer_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sampler_type, PyObject *__pyx_v_dtype, PyObject *__pyx_v_nb_dims, PyObject *__pyx_v_dim_A) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  int __pyx_v_data_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  size_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_spatial_transformer_descriptor", 0);

  /* "cupy/cudnn.pyx":1186
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createSpatialTransformerDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1186, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":1187
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(dtype)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroySpatialTransformerDescrip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1186
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1188
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 *     data_type = get_data_type(dtype)             # <<<<<<<<<<<<<<
 * 
 *     cudnn.setSpatialTransformerDescriptor(
 */
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_v_dtype, 0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1188, __pyx_L1_error)
  __pyx_v_data_type = __pyx_t_5;

  /* "cupy/cudnn.pyx":1191
 * 
 *     cudnn.setSpatialTransformerDescriptor(
 *         desc.value, sampler_type, data_type, nb_dims, dim_A)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_sampler_type); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1191, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_nb_dims); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1191, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_v_dim_A); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1191, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1190
 *     data_type = get_data_type(dtype)
 * 
 *     cudnn.setSpatialTransformerDescriptor(             # <<<<<<<<<<<<<<
 *         desc.value, sampler_type, data_type, nb_dims, dim_A)
 *     return desc
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setSpatialTransformerDescriptor(__pyx_v_desc->value, __pyx_t_1, __pyx_v_data_type, __pyx_t_5, __pyx_t_6, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1192
 *     cudnn.setSpatialTransformerDescriptor(
 *         desc.value, sampler_type, data_type, nb_dims, dim_A)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1185
 * 
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_spatial_transformer_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1195
 * 
 * 
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,             # <<<<<<<<<<<<<<
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_83add_tensor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_82add_tensor[] = "add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc, srcDestData)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_83add_tensor = {"add_tensor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_83add_tensor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_82add_tensor};
static PyObject *__pyx_pw_4cupy_5cudnn_83add_tensor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_alpha = 0;
  PyObject *__pyx_v_biasDesc = 0;
  PyObject *__pyx_v_biasData = 0;
  PyObject *__pyx_v_beta = 0;
  PyObject *__pyx_v_srcDestDesc = 0;
  PyObject *__pyx_v_srcDestData = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_tensor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_alpha,&__pyx_n_s_biasDesc,&__pyx_n_s_biasData,&__pyx_n_s_beta,&__pyx_n_s_srcDestDesc,&__pyx_n_s_srcDestData,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 1); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_biasDesc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 2); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_biasData)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 3); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 4); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_srcDestDesc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 5); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_srcDestData)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, 6); __PYX_ERR(0, 1195, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_tensor") < 0)) __PYX_ERR(0, 1195, __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_handle = values[0];
    __pyx_v_alpha = values[1];
    __pyx_v_biasDesc = values[2];
    __pyx_v_biasData = values[3];
    __pyx_v_beta = values[4];
    __pyx_v_srcDestDesc = values[5];
    __pyx_v_srcDestData = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_tensor", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1195, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.add_tensor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_82add_tensor(__pyx_self, __pyx_v_handle, __pyx_v_alpha, __pyx_v_biasDesc, __pyx_v_biasData, __pyx_v_beta, __pyx_v_srcDestDesc, __pyx_v_srcDestData);

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

static PyObject *__pyx_pf_4cupy_5cudnn_82add_tensor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_alpha, PyObject *__pyx_v_biasDesc, PyObject *__pyx_v_biasData, PyObject *__pyx_v_beta, PyObject *__pyx_v_srcDestDesc, PyObject *__pyx_v_srcDestData) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  size_t __pyx_t_5;
  size_t __pyx_t_6;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_tensor", 0);

  /* "cupy/cudnn.pyx":1197
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,             # <<<<<<<<<<<<<<
 *                        biasData, beta, srcDestDesc, srcDestData)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1197, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_As_size_t(__pyx_v_alpha); if (unlikely((__pyx_t_2 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1197, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_biasDesc); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1197, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1198
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,
 *                        biasData, beta, srcDestDesc, srcDestData)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_As_size_t(__pyx_v_biasData); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1198, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_v_beta); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1198, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_v_srcDestDesc); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1198, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_srcDestData); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1198, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1197
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,             # <<<<<<<<<<<<<<
 *                        biasData, beta, srcDestDesc, srcDestData)
 * 
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_addTensor_v3(__pyx_t_1, __pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cudnn.pyx":1195
 * 
 * 
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,             # <<<<<<<<<<<<<<
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn.add_tensor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1201
 * 
 * 
 * def create_op_tensor_descriptor(op_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_85create_op_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_84create_op_tensor_descriptor[] = "create_op_tensor_descriptor(op_type, dtype)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_85create_op_tensor_descriptor = {"create_op_tensor_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_85create_op_tensor_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_84create_op_tensor_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_85create_op_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_op_type = 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("create_op_tensor_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_op_type,&__pyx_n_s_dtype,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_op_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_op_tensor_descriptor", 1, 2, 2, 1); __PYX_ERR(0, 1201, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_op_tensor_descriptor") < 0)) __PYX_ERR(0, 1201, __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_op_type = values[0];
    __pyx_v_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_op_tensor_descriptor", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1201, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_op_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_84create_op_tensor_descriptor(__pyx_self, __pyx_v_op_type, __pyx_v_dtype);

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

static PyObject *__pyx_pf_4cupy_5cudnn_84create_op_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_op_type, PyObject *__pyx_v_dtype) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  int __pyx_v_data_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_op_tensor_descriptor", 0);

  /* "cupy/cudnn.pyx":1202
 * 
 * def create_op_tensor_descriptor(op_type, dtype):
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyOpTensorDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createOpTensorDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1202, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":1203
 * def create_op_tensor_descriptor(op_type, dtype):
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(dtype)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyOpTensorDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1202
 * 
 * def create_op_tensor_descriptor(op_type, dtype):
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyOpTensorDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1204
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)
 *     data_type = get_data_type(dtype)             # <<<<<<<<<<<<<<
 * 
 *     cudnn.setOpTensorDescriptor(desc.value, op_type, data_type,
 */
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_v_dtype, 0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1204, __pyx_L1_error)
  __pyx_v_data_type = __pyx_t_5;

  /* "cupy/cudnn.pyx":1206
 *     data_type = get_data_type(dtype)
 * 
 *     cudnn.setOpTensorDescriptor(desc.value, op_type, data_type,             # <<<<<<<<<<<<<<
 *                                 cudnn.CUDNN_NOT_PROPAGATE_NAN)
 *     return desc
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_op_type); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1206, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1207
 * 
 *     cudnn.setOpTensorDescriptor(desc.value, op_type, data_type,
 *                                 cudnn.CUDNN_NOT_PROPAGATE_NAN)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setOpTensorDescriptor(__pyx_v_desc->value, __pyx_t_5, __pyx_v_data_type, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1208
 *     cudnn.setOpTensorDescriptor(desc.value, op_type, data_type,
 *                                 cudnn.CUDNN_NOT_PROPAGATE_NAN)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1201
 * 
 * 
 * def create_op_tensor_descriptor(op_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_op_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1211
 * 
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_87create_reduce_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_86create_reduce_tensor_descriptor[] = "create_reduce_tensor_descriptor(reduce_type, dtype)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_87create_reduce_tensor_descriptor = {"create_reduce_tensor_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_87create_reduce_tensor_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_86create_reduce_tensor_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_87create_reduce_tensor_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_reduce_type = 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("create_reduce_tensor_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_reduce_type,&__pyx_n_s_dtype,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_reduce_tensor_descriptor", 1, 2, 2, 1); __PYX_ERR(0, 1211, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_reduce_tensor_descriptor") < 0)) __PYX_ERR(0, 1211, __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_reduce_type = values[0];
    __pyx_v_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_reduce_tensor_descriptor", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1211, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_reduce_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_86create_reduce_tensor_descriptor(__pyx_self, __pyx_v_reduce_type, __pyx_v_dtype);

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

static PyObject *__pyx_pf_4cupy_5cudnn_86create_reduce_tensor_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_reduce_type, PyObject *__pyx_v_dtype) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  int __pyx_v_data_type;
  int __pyx_v_indices;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_reduce_tensor_descriptor", 0);

  /* "cupy/cudnn.pyx":1212
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createReduceTensorDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1212, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":1213
 * def create_reduce_tensor_descriptor(reduce_type, dtype):
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(dtype)
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyReduceTensorDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":1212
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1214
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)             # <<<<<<<<<<<<<<
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):
 */
  __pyx_t_5 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_v_dtype, 0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1214, __pyx_L1_error)
  __pyx_v_data_type = __pyx_t_5;

  /* "cupy/cudnn.pyx":1215
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES
 */
  __Pyx_INCREF(__pyx_v_reduce_type);
  __pyx_t_4 = __pyx_v_reduce_type;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MIN); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L4_bool_binop_done;
  }

  /* "cupy/cudnn.pyx":1216
 *     data_type = get_data_type(dtype)
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):             # <<<<<<<<<<<<<<
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES
 *     else:
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1215
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "cupy/cudnn.pyx":1217
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES             # <<<<<<<<<<<<<<
 *     else:
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_NO_INDICES
 */
    __pyx_v_indices = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_FLATTENED_INDICES;

    /* "cupy/cudnn.pyx":1215
 *                       py_cudnn.destroyReduceTensorDescriptor)
 *     data_type = get_data_type(dtype)
 *     if reduce_type in (cudnn.CUDNN_REDUCE_TENSOR_MIN,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_REDUCE_TENSOR_MAX):
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1219
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_FLATTENED_INDICES
 *     else:
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_NO_INDICES             # <<<<<<<<<<<<<<
 * 
 *     cudnn.setReduceTensorDescriptor(desc.value, reduce_type, data_type,
 */
  /*else*/ {
    __pyx_v_indices = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_REDUCE_TENSOR_NO_INDICES;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1221
 *         indices = cudnn.CUDNN_REDUCE_TENSOR_NO_INDICES
 * 
 *     cudnn.setReduceTensorDescriptor(desc.value, reduce_type, data_type,             # <<<<<<<<<<<<<<
 *                                     cudnn.CUDNN_NOT_PROPAGATE_NAN,
 *                                     indices,
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_reduce_type); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1221, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1224
 *                                     cudnn.CUDNN_NOT_PROPAGATE_NAN,
 *                                     indices,
 *                                     cudnn.CUDNN_32BIT_INDICES)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setReduceTensorDescriptor(__pyx_v_desc->value, __pyx_t_5, __pyx_v_data_type, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_NOT_PROPAGATE_NAN, __pyx_v_indices, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_32BIT_INDICES, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1225
 *                                     indices,
 *                                     cudnn.CUDNN_32BIT_INDICES)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1211
 * 
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_reduce_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1228
 * 
 * 
 * cpdef bint is_tensor_core_available(dtype) except *:             # <<<<<<<<<<<<<<
 *     return (_cudnn_version >= 7000 and
 *             (<str>dtype.char) == 'e' and
 */

static PyObject *__pyx_pw_4cupy_5cudnn_89is_tensor_core_available(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static int __pyx_f_4cupy_5cudnn_is_tensor_core_available(PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_tensor_core_available", 0);

  /* "cupy/cudnn.pyx":1229
 * 
 * cpdef bint is_tensor_core_available(dtype) except *:
 *     return (_cudnn_version >= 7000 and             # <<<<<<<<<<<<<<
 *             (<str>dtype.char) == 'e' and
 *             int(device.get_compute_capability()) == 70)
 */
  __pyx_t_2 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }

  /* "cupy/cudnn.pyx":1230
 * cpdef bint is_tensor_core_available(dtype) except *:
 *     return (_cudnn_version >= 7000 and
 *             (<str>dtype.char) == 'e' and             # <<<<<<<<<<<<<<
 *             int(device.get_compute_capability()) == 70)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_char); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_e, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1230, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L3_bool_binop_done;
  }

  /* "cupy/cudnn.pyx":1231
 *     return (_cudnn_version >= 7000 and
 *             (<str>dtype.char) == 'e' and
 *             int(device.get_compute_capability()) == 70)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_6device_get_compute_capability(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_5, __pyx_int_70, 70, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_4;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1228
 * 
 * 
 * cpdef bint is_tensor_core_available(dtype) except *:             # <<<<<<<<<<<<<<
 *     return (_cudnn_version >= 7000 and
 *             (<str>dtype.char) == 'e' and
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.is_tensor_core_available", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_89is_tensor_core_available(PyObject *__pyx_self, PyObject *__pyx_v_dtype); /*proto*/
static char __pyx_doc_4cupy_5cudnn_88is_tensor_core_available[] = "is_tensor_core_available(dtype) -> bool";
static PyObject *__pyx_pw_4cupy_5cudnn_89is_tensor_core_available(PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_tensor_core_available (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_88is_tensor_core_available(__pyx_self, ((PyObject *)__pyx_v_dtype));

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

static PyObject *__pyx_pf_4cupy_5cudnn_88is_tensor_core_available(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __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("is_tensor_core_available", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_is_tensor_core_available(__pyx_v_dtype, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1228, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1228, __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.cudnn.is_tensor_core_available", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1242
 *         Descriptor _desc
 * 
 *     def __init__(self, handle, seed):             # <<<<<<<<<<<<<<
 *         cdef size_t cudnn_handle
 *         if handle is None:
 */

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  PyObject *__pyx_v_seed = 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_handle,&__pyx_n_s_seed,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 1242, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1242, __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_handle = values[0];
    __pyx_v_seed = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1242, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates___init__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), __pyx_v_handle, __pyx_v_seed);

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

static int __pyx_pf_4cupy_5cudnn_13DropoutStates___init__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, PyObject *__pyx_v_seed) {
  size_t __pyx_v_cudnn_handle;
  Py_ssize_t __pyx_v_state_size;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  size_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 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cudnn.pyx":1244
 *     def __init__(self, handle, seed):
 *         cdef size_t cudnn_handle
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_handle == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1245
 *         cdef size_t cudnn_handle
 *         if handle is None:
 *             cudnn_handle = get_handle()             # <<<<<<<<<<<<<<
 *         else:
 *             cudnn_handle = handle
 */
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1245, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;

    /* "cupy/cudnn.pyx":1244
 *     def __init__(self, handle, seed):
 *         cdef size_t cudnn_handle
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1247
 *             cudnn_handle = get_handle()
 *         else:
 *             cudnn_handle = handle             # <<<<<<<<<<<<<<
 *         state_size = cudnn.dropoutGetStatesSize(cudnn_handle)
 *         self._states = memory.alloc(state_size)
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1247, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1248
 *         else:
 *             cudnn_handle = handle
 *         state_size = cudnn.dropoutGetStatesSize(cudnn_handle)             # <<<<<<<<<<<<<<
 *         self._states = memory.alloc(state_size)
 *         self._desc = create_dropout_descriptor(
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_dropoutGetStatesSize(__pyx_v_cudnn_handle, 0); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1248, __pyx_L1_error)
  __pyx_v_state_size = __pyx_t_4;

  /* "cupy/cudnn.pyx":1249
 *             cudnn_handle = handle
 *         state_size = cudnn.dropoutGetStatesSize(cudnn_handle)
 *         self._states = memory.alloc(state_size)             # <<<<<<<<<<<<<<
 *         self._desc = create_dropout_descriptor(
 *             cudnn_handle, 0., self._states.ptr,
 */
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_state_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->_states);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_states));
  __pyx_v_self->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1250
 *         state_size = cudnn.dropoutGetStatesSize(cudnn_handle)
 *         self._states = memory.alloc(state_size)
 *         self._desc = create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *             cudnn_handle, 0., self._states.ptr,
 *             state_size, seed)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_create_dropout_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1251
 *         self._states = memory.alloc(state_size)
 *         self._desc = create_dropout_descriptor(
 *             cudnn_handle, 0., self._states.ptr,             # <<<<<<<<<<<<<<
 *             state_size, seed)
 * 
 */
  __pyx_t_7 = __Pyx_PyInt_FromSize_t(__pyx_v_cudnn_handle); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_self->_states->ptr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "cupy/cudnn.pyx":1252
 *         self._desc = create_dropout_descriptor(
 *             cudnn_handle, 0., self._states.ptr,
 *             state_size, seed)             # <<<<<<<<<<<<<<
 * 
 *     def set_dropout_ratio(self, dropout_ratio):
 */
  __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_state_size); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_7, __pyx_float_0_, __pyx_t_8, __pyx_t_9, __pyx_v_seed};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_7, __pyx_float_0_, __pyx_t_8, __pyx_t_9, __pyx_v_seed};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_7);
    __Pyx_INCREF(__pyx_float_0_);
    __Pyx_GIVEREF(__pyx_float_0_);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_float_0_);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_9);
    __Pyx_INCREF(__pyx_v_seed);
    __Pyx_GIVEREF(__pyx_v_seed);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_v_seed);
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1250
 *         state_size = cudnn.dropoutGetStatesSize(cudnn_handle)
 *         self._states = memory.alloc(state_size)
 *         self._desc = create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *             cudnn_handle, 0., self._states.ptr,
 *             state_size, seed)
 */
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->_desc);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_desc));
  __pyx_v_self->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1242
 *         Descriptor _desc
 * 
 *     def __init__(self, handle, seed):             # <<<<<<<<<<<<<<
 *         cdef size_t cudnn_handle
 *         if handle is None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1254
 *             state_size, seed)
 * 
 *     def set_dropout_ratio(self, dropout_ratio):             # <<<<<<<<<<<<<<
 *         cudnn_handle = get_handle()
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_3set_dropout_ratio(PyObject *__pyx_v_self, PyObject *__pyx_v_dropout_ratio); /*proto*/
static char __pyx_doc_4cupy_5cudnn_13DropoutStates_2set_dropout_ratio[] = "DropoutStates.set_dropout_ratio(self, dropout_ratio)";
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_3set_dropout_ratio(PyObject *__pyx_v_self, PyObject *__pyx_v_dropout_ratio) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_dropout_ratio (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_2set_dropout_ratio(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), ((PyObject *)__pyx_v_dropout_ratio));

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_2set_dropout_ratio(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_dropout_ratio) {
  size_t __pyx_v_cudnn_handle;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_dropout_ratio", 0);

  /* "cupy/cudnn.pyx":1255
 * 
 *     def set_dropout_ratio(self, dropout_ratio):
 *         cudnn_handle = get_handle()             # <<<<<<<<<<<<<<
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L1_error)
  __pyx_v_cudnn_handle = __pyx_t_1;

  /* "cupy/cudnn.pyx":1256
 *     def set_dropout_ratio(self, dropout_ratio):
 *         cudnn_handle = get_handle()
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)             # <<<<<<<<<<<<<<
 * 
 *     def forward(self, handle, core.ndarray x, dropout_ratio):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_set_dropout_descriptor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_cudnn_handle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self->_desc), __pyx_t_4, __pyx_v_dropout_ratio};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_self->_desc), __pyx_t_4, __pyx_v_dropout_ratio};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_desc));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_dropout_ratio);
    __Pyx_GIVEREF(__pyx_v_dropout_ratio);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_dropout_ratio);
    __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1254
 *             state_size, seed)
 * 
 *     def set_dropout_ratio(self, dropout_ratio):             # <<<<<<<<<<<<<<
 *         cudnn_handle = get_handle()
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.set_dropout_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1258
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 *     def forward(self, handle, core.ndarray x, dropout_ratio):             # <<<<<<<<<<<<<<
 *         cdef core.ndarray y, reserve_space
 *         cdef size_t cudnn_handle
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_5forward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_13DropoutStates_4forward[] = "DropoutStates.forward(self, handle, ndarray x, dropout_ratio)";
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_5forward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  PyObject *__pyx_v_dropout_ratio = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("forward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_x,&__pyx_n_s_dropout_ratio,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("forward", 1, 3, 3, 1); __PYX_ERR(0, 1258, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dropout_ratio)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("forward", 1, 3, 3, 2); __PYX_ERR(0, 1258, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "forward") < 0)) __PYX_ERR(0, 1258, __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_handle = values[0];
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_dropout_ratio = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("forward", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1258, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1258, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_4forward(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), __pyx_v_handle, __pyx_v_x, __pyx_v_dropout_ratio);

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_4forward(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, PyObject *__pyx_v_dropout_ratio) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reserve_space = 0;
  size_t __pyx_v_cudnn_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_reserve_size;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char const *__pyx_t_11;
  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("forward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);

  /* "cupy/cudnn.pyx":1262
 *         cdef size_t cudnn_handle
 *         # This is for backward compatibility.
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_handle == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1263
 *         # This is for backward compatibility.
 *         if handle is None:
 *             cudnn_handle = get_handle()             # <<<<<<<<<<<<<<
 *         else:
 *             cudnn_handle = handle
 */
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1263, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;

    /* "cupy/cudnn.pyx":1262
 *         cdef size_t cudnn_handle
 *         # This is for backward compatibility.
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1265
 *             cudnn_handle = get_handle()
 *         else:
 *             cudnn_handle = handle             # <<<<<<<<<<<<<<
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1265, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1266
 *         else:
 *             cudnn_handle = handle
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)             # <<<<<<<<<<<<<<
 * 
 *         x = core._internal_ascontiguousarray(x)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_set_dropout_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_cudnn_handle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self->_desc), __pyx_t_6, __pyx_v_dropout_ratio};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1266, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self->_desc), __pyx_t_6, __pyx_v_dropout_ratio};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1266, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1266, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_desc));
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_dropout_ratio);
    __Pyx_GIVEREF(__pyx_v_dropout_ratio);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_v_dropout_ratio);
    __pyx_t_6 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1266, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1268
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 *         x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *         y = core.ndarray(x._shape, x.dtype)
 * 
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1269
 * 
 *         x = core._internal_ascontiguousarray(x)
 *         y = core.ndarray(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 * 
 *         x_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_x->dtype);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1271
 *         y = core.ndarray(x._shape, x.dtype)
 * 
 *         x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *         try:
 *             _create_tensor_descriptor_as4darray(x_desc, x)
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1271, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_3;

  /* "cupy/cudnn.pyx":1272
 * 
 *         x_desc = cudnn.createTensorDescriptor()
 *         try:             # <<<<<<<<<<<<<<
 *             _create_tensor_descriptor_as4darray(x_desc, x)
 *             reserve_size = cudnn.getDropoutReserveSpaceSize(x_desc)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1273
 *         x_desc = cudnn.createTensorDescriptor()
 *         try:
 *             _create_tensor_descriptor_as4darray(x_desc, x)             # <<<<<<<<<<<<<<
 *             reserve_size = cudnn.getDropoutReserveSpaceSize(x_desc)
 *             reserve_space = core.ndarray((reserve_size,), 'b')
 */
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(__pyx_v_x_desc, __pyx_v_x, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1273, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":1274
 *         try:
 *             _create_tensor_descriptor_as4darray(x_desc, x)
 *             reserve_size = cudnn.getDropoutReserveSpaceSize(x_desc)             # <<<<<<<<<<<<<<
 *             reserve_space = core.ndarray((reserve_size,), 'b')
 * 
 */
    __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_getDropoutReserveSpaceSize(__pyx_v_x_desc, 0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1274, __pyx_L5_error)
    __pyx_v_reserve_size = __pyx_t_3;

    /* "cupy/cudnn.pyx":1275
 *             _create_tensor_descriptor_as4darray(x_desc, x)
 *             reserve_size = cudnn.getDropoutReserveSpaceSize(x_desc)
 *             reserve_space = core.ndarray((reserve_size,), 'b')             # <<<<<<<<<<<<<<
 * 
 *             cudnn.dropoutForward(cudnn_handle, self._desc.value,
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_reserve_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1275, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1275, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1275, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_n_u_b);
    __Pyx_GIVEREF(__pyx_n_u_b);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_b);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1275, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "cupy/cudnn.pyx":1277
 *             reserve_space = core.ndarray((reserve_size,), 'b')
 * 
 *             cudnn.dropoutForward(cudnn_handle, self._desc.value,             # <<<<<<<<<<<<<<
 *                                  x_desc, x.data.ptr, x_desc, y.data.ptr,
 *                                  reserve_space.data.ptr, reserve_size)
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_dropoutForward(__pyx_v_cudnn_handle, __pyx_v_self->_desc->value, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, __pyx_v_y->data->ptr, __pyx_v_reserve_space->data->ptr, __pyx_v_reserve_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1277, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }

  /* "cupy/cudnn.pyx":1281
 *                                  reserve_space.data.ptr, reserve_size)
 *         finally:
 *             cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         return reserve_space, y
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1281, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
      {
        __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1281, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __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;
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":1282
 *         finally:
 *             cudnn.destroyTensorDescriptor(x_desc)
 *         return reserve_space, y             # <<<<<<<<<<<<<<
 * 
 *     def backward(self, handle, core.ndarray dy, dropout_ratio,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_reserve_space));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_reserve_space));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_reserve_space));
  __Pyx_INCREF(((PyObject *)__pyx_v_y));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_y));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_y));
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1258
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 *     def forward(self, handle, core.ndarray x, dropout_ratio):             # <<<<<<<<<<<<<<
 *         cdef core.ndarray y, reserve_space
 *         cdef size_t cudnn_handle
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_reserve_space);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1284
 *         return reserve_space, y
 * 
 *     def backward(self, handle, core.ndarray dy, dropout_ratio,             # <<<<<<<<<<<<<<
 *                  core.ndarray reserve_space):
 *         cdef core.ndarray dx
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_7backward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_13DropoutStates_6backward[] = "DropoutStates.backward(self, handle, ndarray dy, dropout_ratio, ndarray reserve_space)";
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_7backward(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_handle = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy = 0;
  PyObject *__pyx_v_dropout_ratio = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reserve_space = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("backward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_handle,&__pyx_n_s_dy,&__pyx_n_s_dropout_ratio,&__pyx_n_s_reserve_space,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("backward", 1, 4, 4, 1); __PYX_ERR(0, 1284, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dropout_ratio)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("backward", 1, 4, 4, 2); __PYX_ERR(0, 1284, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reserve_space)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("backward", 1, 4, 4, 3); __PYX_ERR(0, 1284, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "backward") < 0)) __PYX_ERR(0, 1284, __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_handle = values[0];
    __pyx_v_dy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_dropout_ratio = values[2];
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("backward", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1284, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dy", 0))) __PYX_ERR(0, 1284, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "reserve_space", 0))) __PYX_ERR(0, 1285, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_6backward(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), __pyx_v_handle, __pyx_v_dy, __pyx_v_dropout_ratio, __pyx_v_reserve_space);

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_6backward(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v_handle, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, PyObject *__pyx_v_dropout_ratio, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_reserve_space) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dx = 0;
  size_t __pyx_v_cudnn_handle;
  size_t __pyx_v_dy_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  char const *__pyx_t_11;
  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("backward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_dy);

  /* "cupy/cudnn.pyx":1289
 *         cdef size_t cudnn_handle
 *         # This is for backward compatibility.
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
  __pyx_t_1 = (__pyx_v_handle == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1290
 *         # This is for backward compatibility.
 *         if handle is None:
 *             cudnn_handle = get_handle()             # <<<<<<<<<<<<<<
 *         else:
 *             cudnn_handle = handle
 */
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1290, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;

    /* "cupy/cudnn.pyx":1289
 *         cdef size_t cudnn_handle
 *         # This is for backward compatibility.
 *         if handle is None:             # <<<<<<<<<<<<<<
 *             cudnn_handle = get_handle()
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1292
 *             cudnn_handle = get_handle()
 *         else:
 *             cudnn_handle = handle             # <<<<<<<<<<<<<<
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_handle); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1292, __pyx_L1_error)
    __pyx_v_cudnn_handle = __pyx_t_3;
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1293
 *         else:
 *             cudnn_handle = handle
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)             # <<<<<<<<<<<<<<
 * 
 *         dy = core._internal_ascontiguousarray(dy)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_set_dropout_descriptor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_cudnn_handle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self->_desc), __pyx_t_6, __pyx_v_dropout_ratio};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1293, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, ((PyObject *)__pyx_v_self->_desc), __pyx_t_6, __pyx_v_dropout_ratio};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1293, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_desc));
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_self->_desc));
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_dropout_ratio);
    __Pyx_GIVEREF(__pyx_v_dropout_ratio);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_v_dropout_ratio);
    __pyx_t_6 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1293, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1295
 *         set_dropout_descriptor(self._desc, cudnn_handle, dropout_ratio)
 * 
 *         dy = core._internal_ascontiguousarray(dy)             # <<<<<<<<<<<<<<
 *         dx = core.ndarray(dy._shape, dy.dtype)
 * 
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_dy, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_dy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1296
 * 
 *         dy = core._internal_ascontiguousarray(dy)
 *         dx = core.ndarray(dy._shape, dy.dtype)             # <<<<<<<<<<<<<<
 * 
 *         dy_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_dy->_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_dy->dtype);
  __Pyx_GIVEREF(__pyx_v_dy->dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dy->dtype);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1298
 *         dx = core.ndarray(dy._shape, dy.dtype)
 * 
 *         dy_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *         try:
 *             _create_tensor_descriptor_as4darray(dy_desc, dy)
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1298, __pyx_L1_error)
  __pyx_v_dy_desc = __pyx_t_3;

  /* "cupy/cudnn.pyx":1299
 * 
 *         dy_desc = cudnn.createTensorDescriptor()
 *         try:             # <<<<<<<<<<<<<<
 *             _create_tensor_descriptor_as4darray(dy_desc, dy)
 *             cudnn.dropoutBackward(cudnn_handle, self._desc.value,
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1300
 *         dy_desc = cudnn.createTensorDescriptor()
 *         try:
 *             _create_tensor_descriptor_as4darray(dy_desc, dy)             # <<<<<<<<<<<<<<
 *             cudnn.dropoutBackward(cudnn_handle, self._desc.value,
 *                                   dy_desc, dy.data.ptr,
 */
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_as4darray(__pyx_v_dy_desc, __pyx_v_dy, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1300, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":1301
 *         try:
 *             _create_tensor_descriptor_as4darray(dy_desc, dy)
 *             cudnn.dropoutBackward(cudnn_handle, self._desc.value,             # <<<<<<<<<<<<<<
 *                                   dy_desc, dy.data.ptr,
 *                                   dy_desc, dx.data.ptr,
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_dropoutBackward(__pyx_v_cudnn_handle, __pyx_v_self->_desc->value, __pyx_v_dy_desc, __pyx_v_dy->data->ptr, __pyx_v_dy_desc, __pyx_v_dx->data->ptr, __pyx_v_reserve_space->data->ptr, __pyx_v_reserve_space->size, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1301, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "cupy/cudnn.pyx":1307
 *                                   reserve_space.size)
 *         finally:
 *             cudnn.destroyTensorDescriptor(dy_desc)             # <<<<<<<<<<<<<<
 *         return dx
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_dy_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1307, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __pyx_t_8 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
      {
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_dy_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1307, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      }
      __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;
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":1308
 *         finally:
 *             cudnn.destroyTensorDescriptor(dy_desc)
 *         return dx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_dx));
  __pyx_r = ((PyObject *)__pyx_v_dx);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1284
 *         return reserve_space, y
 * 
 *     def backward(self, handle, core.ndarray dy, dropout_ratio,             # <<<<<<<<<<<<<<
 *                  core.ndarray reserve_space):
 *         cdef core.ndarray dx
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_dx);
  __Pyx_XDECREF((PyObject *)__pyx_v_dy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1239
 *         # TODO(unno): Make these attributes private. This is for backward
 *         # compatibility.
 *         memory.MemoryPointer _states             # <<<<<<<<<<<<<<
 *         Descriptor _desc
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states___get__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_7_states___get__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_states));
  __pyx_r = ((PyObject *)__pyx_v_self->_states);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_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_5cudnn_13DropoutStates_7_states_2__set__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states_2__set__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__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(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(0, 1239, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_states);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_states));
  __pyx_v_self->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__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.cudnn.DropoutStates._states.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states_4__del__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self));

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

static int __pyx_pf_4cupy_5cudnn_13DropoutStates_7_states_4__del__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__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->_states);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_states));
  __pyx_v_self->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None);

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

/* "cupy/cudnn.pyx":1240
 *         # compatibility.
 *         memory.MemoryPointer _states
 *         Descriptor _desc             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, handle, seed):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc___get__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc___get__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_desc));
  __pyx_r = ((PyObject *)__pyx_v_self->_desc);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_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_5cudnn_13DropoutStates_5_desc_2__set__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc_2__set__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__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(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(0, 1240, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_desc);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_desc));
  __pyx_v_self->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__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.cudnn.DropoutStates._desc.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc_4__del__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self));

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

static int __pyx_pf_4cupy_5cudnn_13DropoutStates_5_desc_4__del__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__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->_desc);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_desc));
  __pyx_v_self->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)Py_None);

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_13DropoutStates_8__reduce_cython__[] = "DropoutStates.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_8__reduce_cython__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_8__reduce_cython__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._desc, self._states)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_desc));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_desc));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->_desc));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_states));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_states));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self->_states));
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._desc, self._states)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self._desc, self._states)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._desc is not None or self._states is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._desc, self._states)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._desc is not None or self._states is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, None), state
 */
  /*else*/ {
    __pyx_t_2 = (((PyObject *)__pyx_v_self->_desc) != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->_states) != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._desc is not None or self._states is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self._desc is not None or self._states is not None
 *     if use_setstate:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_DropoutStates); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_44931744);
    __Pyx_GIVEREF(__pyx_int_44931744);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_44931744);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._desc is not None or self._states is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, None), state
 *     else:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_DropoutStates__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_DropoutStates); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_44931744);
    __Pyx_GIVEREF(__pyx_int_44931744);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_44931744);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.cudnn.DropoutStates.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_DropoutStates__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_5cudnn_13DropoutStates_10__setstate_cython__[] = "DropoutStates.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_5cudnn_13DropoutStates_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_13DropoutStates_10__setstate_cython__(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_5cudnn_13DropoutStates_10__setstate_cython__(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_DropoutStates__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4cupy_5cudnn___pyx_unpickle_DropoutStates__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_DropoutStates, (type(self), 0x2ad9aa0, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_DropoutStates__set_state(self, __pyx_state)
 */

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

/* "cupy/cudnn.pyx":1317
 *         size_t memory
 * 
 *     def __cinit__(self, int algo, size_t memory, int mathType=0):             # <<<<<<<<<<<<<<
 *         self.algo = algo
 *         self.memory = memory
 */

/* Python wrapper */
static int __pyx_pw_4cupy_5cudnn_10_Algorithm_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4cupy_5cudnn_10_Algorithm_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_algo;
  size_t __pyx_v_memory;
  int __pyx_v_mathType;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_algo,&__pyx_n_s_memory,&__pyx_n_s_mathType,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_algo)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_memory)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(0, 1317, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mathType);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1317, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_algo = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_algo == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1317, __pyx_L3_error)
    __pyx_v_memory = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_memory == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1317, __pyx_L3_error)
    if (values[2]) {
      __pyx_v_mathType = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_mathType == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1317, __pyx_L3_error)
    } else {
      __pyx_v_mathType = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1317, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._Algorithm.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_10_Algorithm___cinit__(((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_self), __pyx_v_algo, __pyx_v_memory, __pyx_v_mathType);

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

static int __pyx_pf_4cupy_5cudnn_10_Algorithm___cinit__(struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_self, int __pyx_v_algo, size_t __pyx_v_memory, int __pyx_v_mathType) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "cupy/cudnn.pyx":1318
 * 
 *     def __cinit__(self, int algo, size_t memory, int mathType=0):
 *         self.algo = algo             # <<<<<<<<<<<<<<
 *         self.memory = memory
 *         self.mathType = mathType
 */
  __pyx_v_self->algo = __pyx_v_algo;

  /* "cupy/cudnn.pyx":1319
 *     def __cinit__(self, int algo, size_t memory, int mathType=0):
 *         self.algo = algo
 *         self.memory = memory             # <<<<<<<<<<<<<<
 *         self.mathType = mathType
 * 
 */
  __pyx_v_self->memory = __pyx_v_memory;

  /* "cupy/cudnn.pyx":1320
 *         self.algo = algo
 *         self.memory = memory
 *         self.mathType = mathType             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->mathType = __pyx_v_mathType;

  /* "cupy/cudnn.pyx":1317
 *         size_t memory
 * 
 *     def __cinit__(self, int algo, size_t memory, int mathType=0):             # <<<<<<<<<<<<<<
 *         self.algo = algo
 *         self.memory = memory
 */

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_10_Algorithm_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_5cudnn_10_Algorithm_2__reduce_cython__[] = "_Algorithm.__reduce_cython__(self)";
static PyObject *__pyx_pw_4cupy_5cudnn_10_Algorithm_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10_Algorithm_2__reduce_cython__(((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10_Algorithm_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_5cudnn__Algorithm *__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("__reduce_cython__", 0);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 2, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn._Algorithm.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_10_Algorithm_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4cupy_5cudnn_10_Algorithm_4__setstate_cython__[] = "_Algorithm.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4cupy_5cudnn_10_Algorithm_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_10_Algorithm_4__setstate_cython__(((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4cupy_5cudnn_10_Algorithm_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  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("__setstate_cython__", 0);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_ERR(1, 4, __pyx_L1_error)

  /* "(tree fragment)":3
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn._Algorithm.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1331
 * 
 * 
 * cpdef _warn_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param):
 *     warnings.warn(
 */

static PyObject *__pyx_pw_4cupy_5cudnn_91_warn_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_warn_algorithm_fwd", 0);

  /* "cupy/cudnn.pyx":1333
 * cpdef _warn_algorithm_fwd(
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param):
 *     warnings.warn(             # <<<<<<<<<<<<<<
 *         'Tensor Core mode is set but the selected convolution forward '
 *         'algorithm is not a Tensor Core enabled algorithm. '
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1338
 *         'This might be due to lack of workspace memory. '
 *         'x.shape:{}, W.shape:{}, y.shape:{}, pad:{}, stride:{}'
 *         .format(x.shape, W.shape, y.shape, conv_param[0], conv_param[1]),             # <<<<<<<<<<<<<<
 *         util.PerformanceWarning)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Tensor_Core_mode_is_set_but_the, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1338, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1338, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1339
 *         'x.shape:{}, W.shape:{}, y.shape:{}, pad:{}, stride:{}'
 *         .format(x.shape, W.shape, y.shape, conv_param[0], conv_param[1]),
 *         util.PerformanceWarning)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_util); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1333, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1333, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_12);
    __pyx_t_2 = 0;
    __pyx_t_12 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1333, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1331
 * 
 * 
 * cpdef _warn_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param):
 *     warnings.warn(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_fwd", __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_5cudnn_91_warn_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_90_warn_algorithm_fwd[] = "_warn_algorithm_fwd(ndarray x, ndarray W, ndarray y, tuple conv_param)";
static PyObject *__pyx_pw_4cupy_5cudnn_91_warn_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_warn_algorithm_fwd (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_W,&__pyx_n_s_y,&__pyx_n_s_conv_param,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_fwd", 1, 4, 4, 1); __PYX_ERR(0, 1331, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_fwd", 1, 4, 4, 2); __PYX_ERR(0, 1331, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_fwd", 1, 4, 4, 3); __PYX_ERR(0, 1331, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_warn_algorithm_fwd") < 0)) __PYX_ERR(0, 1331, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_warn_algorithm_fwd", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1331, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_fwd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1332, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1332, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1332, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1332, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_90_warn_algorithm_fwd(__pyx_self, __pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param);

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

static PyObject *__pyx_pf_4cupy_5cudnn_90_warn_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param) {
  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("_warn_algorithm_fwd", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__warn_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1342
 * 
 * 
 * cpdef _Algorithm _find_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_93_find_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_algo = NULL;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_algorithm_fwd", 0);

  /* "cupy/cudnn.pyx":1347
 *         size_t y_desc, size_t max_workspace_size, bint use_tensor_core):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_fwd_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1348
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _algorithm_fwd_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1347
 *         size_t y_desc, size_t max_workspace_size, bint use_tensor_core):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_fwd_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1349
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,
 *            max_workspace_size)
 *     algo = _algorithm_fwd_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1349, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_algo = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1350
 *            max_workspace_size)
 *     algo = _algorithm_fwd_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  __pyx_t_7 = (__pyx_v_algo != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1351
 *     algo = _algorithm_fwd_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(((__pyx_v_algo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1351, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_algo);
    __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1350
 *            max_workspace_size)
 *     algo = _algorithm_fwd_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  }

  /* "cupy/cudnn.pyx":1352
 *     if algo is not None:
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)             # <<<<<<<<<<<<<<
 *     if _cudnn_version >= 7000:
 *         perf = cudnn.findConvolutionForwardAlgorithmEx_v7(
 */
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_6, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1353
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         perf = cudnn.findConvolutionForwardAlgorithmEx_v7(
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 */
  __pyx_t_8 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1354
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 *         perf = cudnn.findConvolutionForwardAlgorithmEx_v7(             # <<<<<<<<<<<<<<
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx_v7(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_y->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1354, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__pyx_t_5 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1354, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1356
 *         perf = cudnn.findConvolutionForwardAlgorithmEx_v7(
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 */
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1356, __pyx_L1_error)
    __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1357
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *     else:
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_perf->mathType != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1358
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_fwd(x, W, y, conv_param)             # <<<<<<<<<<<<<<
 *     else:
 *         perf = cudnn.findConvolutionForwardAlgorithmEx(
 */
      __pyx_t_6 = __pyx_f_4cupy_5cudnn__warn_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1358, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1357
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *     else:
 */
    }

    /* "cupy/cudnn.pyx":1353
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         perf = cudnn.findConvolutionForwardAlgorithmEx_v7(
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1362
 *         perf = cudnn.findConvolutionForwardAlgorithmEx(
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1360
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *     else:
 *         perf = cudnn.findConvolutionForwardAlgorithmEx(             # <<<<<<<<<<<<<<
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_y->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__pyx_t_6 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1360, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1362
 *         perf = cudnn.findConvolutionForwardAlgorithmEx(
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
    __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1362, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1362, __pyx_L1_error)
    __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1363
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  __pyx_t_8 = ((__pyx_v_perf->status != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/cudnn.pyx":1364
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')             # <<<<<<<<<<<<<<
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_fwd_cache[key] = algo
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1364, __pyx_L1_error)

    /* "cupy/cudnn.pyx":1363
 *             handle, x_desc, x.data.ptr, filter_desc, W.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  }

  /* "cupy/cudnn.pyx":1365
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     _algorithm_fwd_cache[key] = algo
 *     return algo
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1365, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1366
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_fwd_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1366, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache, __pyx_v_key, __pyx_v_algo) < 0)) __PYX_ERR(0, 1366, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1367
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_fwd_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm)))) __PYX_ERR(0, 1367, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_algo);
  __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1342
 * 
 * 
 * cpdef _Algorithm _find_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc,
 */

  /* function 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.cudnn._find_algorithm_fwd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_algo);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_93_find_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_92_find_algorithm_fwd[] = "_find_algorithm_fwd(ndarray x, ndarray W, ndarray y, tuple conv_param, size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc, size_t y_desc, size_t max_workspace_size, bool use_tensor_core) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_93_find_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_algorithm_fwd (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_W,&__pyx_n_s_y,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_x_desc,&__pyx_n_s_filter_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_y_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,0};
    PyObject* values[11] = {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 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 1); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 2); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 3); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 4); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 5); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 6); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 7); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 8); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 9); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, 10); __PYX_ERR(0, 1342, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_algorithm_fwd") < 0)) __PYX_ERR(0, 1342, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
      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);
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1344, __pyx_L3_error)
    __pyx_v_y_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_y_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1345, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_find_algorithm_fwd", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1342, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._find_algorithm_fwd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1343, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1343, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1343, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1343, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_92_find_algorithm_fwd(__pyx_self, __pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core);

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

static PyObject *__pyx_pf_4cupy_5cudnn_92_find_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core) {
  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("_find_algorithm_fwd", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1370
 * 
 * 
 * cpdef _Algorithm _get_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_95_get_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_fwd(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_algo = NULL;
  PyObject *__pyx_v_ret = 0;
  int __pyx_v_skip;
  size_t __pyx_v_workspace_size;
  int __pyx_v_math_type;
  int __pyx_v_algo_no;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_algorithm_fwd", 0);

  /* "cupy/cudnn.pyx":1375
 *         size_t y_desc, size_t max_workspace_size, bint use_tensor_core):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1376
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1375
 *         size_t y_desc, size_t max_workspace_size, bint use_tensor_core):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1377
 *     key = (x.data.device.id, x.shape, W.shape, y.shape, conv_param,
 *            max_workspace_size)
 *     algo = _get_algorithm_fwd_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1377, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_algo = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1378
 *            max_workspace_size)
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  __pyx_t_7 = (__pyx_v_algo != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1379
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     cdef list ret
 *     cdef bint skip
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(((__pyx_v_algo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_algo);
    __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1378
 *            max_workspace_size)
 *     algo = _get_algorithm_fwd_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  }

  /* "cupy/cudnn.pyx":1382
 *     cdef list ret
 *     cdef bint skip
 *     if (use_tensor_core and _cudnn_version >= 7000) or _cudnn_version >= 8000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionForwardAlgorithm_v7(
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 */
  __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
  if (!__pyx_t_7) {
    goto __pyx_L6_next_or;
  } else {
  }
  __pyx_t_7 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (!__pyx_t_7) {
  } else {
    __pyx_t_8 = __pyx_t_7;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_L6_next_or:;
  __pyx_t_7 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1F40) != 0);
  __pyx_t_8 = __pyx_t_7;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1383
 *     cdef bint skip
 *     if (use_tensor_core and _cudnn_version >= 7000) or _cudnn_version >= 8000:
 *         ret = cudnn.getConvolutionForwardAlgorithm_v7(             # <<<<<<<<<<<<<<
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 *         skip = False
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v7(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, 10, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1385
 *         ret = cudnn.getConvolutionForwardAlgorithm_v7(
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 *         skip = False             # <<<<<<<<<<<<<<
 *         for perf in ret:
 *             if perf.memory <= max_workspace_size:
 */
    __pyx_v_skip = 0;

    /* "cupy/cudnn.pyx":1386
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if perf.memory <= max_workspace_size:
 *                 break
 */
    if (unlikely(__pyx_v_ret == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1386, __pyx_L1_error)
    }
    __pyx_t_6 = __pyx_v_ret; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0;
    for (;;) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1386, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1386, __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_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1386, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_perf, ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1387
 *         skip = False
 *         for perf in ret:
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      __pyx_t_8 = ((__pyx_v_perf->memory <= __pyx_v_max_workspace_size) != 0);
      if (__pyx_t_8) {

        /* "cupy/cudnn.pyx":1388
 *         for perf in ret:
 *             if perf.memory <= max_workspace_size:
 *                 break             # <<<<<<<<<<<<<<
 *             skip = True
 *         else:
 */
        goto __pyx_L9_break;

        /* "cupy/cudnn.pyx":1387
 *         skip = False
 *         for perf in ret:
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      }

      /* "cupy/cudnn.pyx":1389
 *             if perf.memory <= max_workspace_size:
 *                 break
 *             skip = True             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError('No conv fwd algo available with workspace size'
 */
      __pyx_v_skip = 1;

      /* "cupy/cudnn.pyx":1386
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if perf.memory <= max_workspace_size:
 *                 break
 */
    }
    /*else*/ {

      /* "cupy/cudnn.pyx":1392
 *         else:
 *             raise RuntimeError('No conv fwd algo available with workspace size'
 *                                ' less equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         if skip:
 *             warnings.warn(
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_fwd_algo_available_with, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1392, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1391
 *             skip = True
 *         else:
 *             raise RuntimeError('No conv fwd algo available with workspace size'             # <<<<<<<<<<<<<<
 *                                ' less equal {}'.format(max_workspace_size))
 *         if skip:
 */
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1391, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1391, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1386
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if perf.memory <= max_workspace_size:
 *                 break
 */
    __pyx_L9_break:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1393
 *             raise RuntimeError('No conv fwd algo available with workspace size'
 *                                ' less equal {}'.format(max_workspace_size))
 *         if skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv fwd might not be selected due to '
 */
    __pyx_t_8 = (__pyx_v_skip != 0);
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1394
 *                                ' less equal {}'.format(max_workspace_size))
 *         if skip:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'The best algo of conv fwd might not be selected due to '
 *                 'lack of workspace size ({})'.format(max_workspace_size),
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1394, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1396
 *             warnings.warn(
 *                 'The best algo of conv fwd might not be selected due to '
 *                 'lack of workspace size ({})'.format(max_workspace_size),             # <<<<<<<<<<<<<<
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_The_best_algo_of_conv_fwd_might, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1396, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/cudnn.pyx":1397
 *                 'The best algo of conv fwd might not be selected due to '
 *                 'lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)             # <<<<<<<<<<<<<<
 *         algo = perf.algo
 *         workspace_size = perf.memory
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1397, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1394, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1394, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1394, __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_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_10, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_10, __pyx_t_1);
        __pyx_t_4 = 0;
        __pyx_t_1 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1394, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1393
 *             raise RuntimeError('No conv fwd algo available with workspace size'
 *                                ' less equal {}'.format(max_workspace_size))
 *         if skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv fwd might not be selected due to '
 */
    }

    /* "cupy/cudnn.pyx":1398
 *                 'lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)
 *         algo = perf.algo             # <<<<<<<<<<<<<<
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1399
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 *         workspace_size = perf.memory             # <<<<<<<<<<<<<<
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 */
    __pyx_t_11 = __pyx_v_perf->memory;
    __pyx_v_workspace_size = __pyx_t_11;

    /* "cupy/cudnn.pyx":1400
 *         algo = perf.algo
 *         workspace_size = perf.memory
 *         math_type = perf.mathType             # <<<<<<<<<<<<<<
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 */
    __pyx_t_10 = __pyx_v_perf->mathType;
    __pyx_v_math_type = __pyx_t_10;

    /* "cupy/cudnn.pyx":1401
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_math_type != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L14_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1402
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_fwd(x, W, y, conv_param)             # <<<<<<<<<<<<<<
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 */
      __pyx_t_6 = __pyx_f_4cupy_5cudnn__warn_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1402, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1401
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    }

    /* "cupy/cudnn.pyx":1403
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_fwd(x, W, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     else:
 *         algo_no = cudnn.getConvolutionForwardAlgorithm_v6(
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1382
 *     cdef list ret
 *     cdef bint skip
 *     if (use_tensor_core and _cudnn_version >= 7000) or _cudnn_version >= 8000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionForwardAlgorithm_v7(
 *             handle, x_desc, filter_desc, conv_desc, y_desc, 10)
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1405
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 *         algo_no = cudnn.getConvolutionForwardAlgorithm_v6(             # <<<<<<<<<<<<<<
 *             handle, x_desc, filter_desc, conv_desc, y_desc,
 *             cudnn.CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1408
 *             handle, x_desc, filter_desc, conv_desc, y_desc,
 *             cudnn.CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)             # <<<<<<<<<<<<<<
 *         workspace_size = cudnn.getConvolutionForwardWorkspaceSize(
 *             handle, x_desc, filter_desc, conv_desc, y_desc, algo_no)
 */
    __pyx_t_10 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v6(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT, __pyx_v_max_workspace_size, 0); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1405, __pyx_L1_error)
    __pyx_v_algo_no = __pyx_t_10;

    /* "cupy/cudnn.pyx":1409
 *             cudnn.CUDNN_CONVOLUTION_FWD_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)
 *         workspace_size = cudnn.getConvolutionForwardWorkspaceSize(             # <<<<<<<<<<<<<<
 *             handle, x_desc, filter_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 */
    __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardWorkspaceSize(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_algo_no, 0); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1409, __pyx_L1_error)
    __pyx_v_workspace_size = __pyx_t_9;

    /* "cupy/cudnn.pyx":1411
 *         workspace_size = cudnn.getConvolutionForwardWorkspaceSize(
 *             handle, x_desc, filter_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)             # <<<<<<<<<<<<<<
 *     _get_algorithm_fwd_cache[key] = algo
 *     return algo
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_algo_no); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1411, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1412
 *             handle, x_desc, filter_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_fwd_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1412, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache, __pyx_v_key, __pyx_v_algo) < 0)) __PYX_ERR(0, 1412, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1413
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_fwd_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm)))) __PYX_ERR(0, 1413, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_algo);
  __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1370
 * 
 * 
 * cpdef _Algorithm _get_algorithm_fwd(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc,
 */

  /* function 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.cudnn._get_algorithm_fwd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_algo);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_95_get_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_94_get_algorithm_fwd[] = "_get_algorithm_fwd(ndarray x, ndarray W, ndarray y, tuple conv_param, size_t handle, size_t x_desc, size_t filter_desc, size_t conv_desc, size_t y_desc, size_t max_workspace_size, bool use_tensor_core) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_95_get_algorithm_fwd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_algorithm_fwd (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_W,&__pyx_n_s_y,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_x_desc,&__pyx_n_s_filter_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_y_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,0};
    PyObject* values[11] = {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 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 1); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 2); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 3); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 4); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 5); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 6); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 7); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 8); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 9); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, 10); __PYX_ERR(0, 1370, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_algorithm_fwd") < 0)) __PYX_ERR(0, 1370, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
      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);
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1372, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1372, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1372, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1372, __pyx_L3_error)
    __pyx_v_y_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_y_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1373, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1373, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1373, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_algorithm_fwd", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1370, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._get_algorithm_fwd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1371, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1371, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1371, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1371, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_94_get_algorithm_fwd(__pyx_self, __pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core);

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

static PyObject *__pyx_pf_4cupy_5cudnn_94_get_algorithm_fwd(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core) {
  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_algorithm_fwd", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1416
 * 
 * 
 * cpdef _warn_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param):
 *     warnings.warn(
 */

static PyObject *__pyx_pw_4cupy_5cudnn_97_warn_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_warn_algorithm_bwd_filter", 0);

  /* "cupy/cudnn.pyx":1418
 * cpdef _warn_algorithm_bwd_filter(
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param):
 *     warnings.warn(             # <<<<<<<<<<<<<<
 *         'Tensor Core mode is set but the selected convolution backward '
 *         'filter algorithm is not a Tensor Core enabled algorithm. '
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1423
 *         'This might be due to lack of workspace memory. '
 *         'x.shape:{}, dy.shape:{}, dW.shape:{}, pad:{}, stride:{}'
 *         .format(x.shape, dy.shape, dW.shape, conv_param[0], conv_param[1]),             # <<<<<<<<<<<<<<
 *         util.PerformanceWarning)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Tensor_Core_mode_is_set_but_the_2, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dy), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dW), __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1423, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1423, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1424
 *         'x.shape:{}, dy.shape:{}, dW.shape:{}, pad:{}, stride:{}'
 *         .format(x.shape, dy.shape, dW.shape, conv_param[0], conv_param[1]),
 *         util.PerformanceWarning)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_util); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1418, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_12);
    __pyx_t_2 = 0;
    __pyx_t_12 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1416
 * 
 * 
 * cpdef _warn_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param):
 *     warnings.warn(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_bwd_filter", __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_5cudnn_97_warn_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_96_warn_algorithm_bwd_filter[] = "_warn_algorithm_bwd_filter(ndarray x, ndarray dy, ndarray dW, tuple conv_param)";
static PyObject *__pyx_pw_4cupy_5cudnn_97_warn_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW = 0;
  PyObject *__pyx_v_conv_param = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_warn_algorithm_bwd_filter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_dy,&__pyx_n_s_dW,&__pyx_n_s_conv_param,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_filter", 1, 4, 4, 1); __PYX_ERR(0, 1416, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dW)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_filter", 1, 4, 4, 2); __PYX_ERR(0, 1416, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_filter", 1, 4, 4, 3); __PYX_ERR(0, 1416, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_warn_algorithm_bwd_filter") < 0)) __PYX_ERR(0, 1416, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_dW = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_filter", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1416, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_bwd_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1417, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dy", 0))) __PYX_ERR(0, 1417, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dW), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dW", 0))) __PYX_ERR(0, 1417, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1417, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_96_warn_algorithm_bwd_filter(__pyx_self, __pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param);

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

static PyObject *__pyx_pf_4cupy_5cudnn_96_warn_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param) {
  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("_warn_algorithm_bwd_filter", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_filter(__pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1427
 * 
 * 
 * cpdef _Algorithm _find_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t dy_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_99_find_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_dy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_algo = 0;
  PyObject *__pyx_v_key = NULL;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  PyObject *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_algorithm_bwd_filter", 0);

  /* "cupy/cudnn.pyx":1434
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     cdef _Algorithm algo
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dW), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dy), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1435
 *     cdef _Algorithm algo
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1434
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     cdef _Algorithm algo
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1436
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,
 *            max_workspace_size)
 *     algo = _algorithm_bwd_filter_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1436, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1436, __pyx_L1_error)
  __pyx_v_algo = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1437
 *            max_workspace_size)
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_algo) != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1438
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_algo));
    __pyx_r = __pyx_v_algo;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1437
 *            max_workspace_size)
 *     algo = _algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  }

  /* "cupy/cudnn.pyx":1439
 *     if algo is not None:
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)             # <<<<<<<<<<<<<<
 *     if _cudnn_version >= 7000:
 *         if deterministic:
 */
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_6, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1440
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(
 */
  __pyx_t_8 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1441
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 *         if deterministic:             # <<<<<<<<<<<<<<
 *             ret = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 */
    __pyx_t_8 = (__pyx_v_deterministic != 0);
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1442
 *     if _cudnn_version >= 7000:
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(             # <<<<<<<<<<<<<<
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *                 filter_desc, dW.data.ptr, 10, workspace.ptr,
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx_v7(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_dy_desc, __pyx_v_dy->data->ptr, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_dW->data->ptr, 10, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1442, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_ret = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1446
 *                 filter_desc, dW.data.ptr, 10, workspace.ptr,
 *                 max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      if (unlikely(__pyx_v_ret == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 1446, __pyx_L1_error)
      }
      __pyx_t_5 = __pyx_v_ret; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0;
      for (;;) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1446, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1446, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1446, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_perf, ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_6));
        __pyx_t_6 = 0;

        /* "cupy/cudnn.pyx":1447
 *                 max_workspace_size)
 *             for perf in ret:
 *                 if perf.determinism:             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
        __pyx_t_8 = (__pyx_v_perf->determinism != 0);
        if (__pyx_t_8) {

          /* "cupy/cudnn.pyx":1448
 *             for perf in ret:
 *                 if perf.determinism:
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 raise RuntimeError(
 */
          goto __pyx_L7_break;

          /* "cupy/cudnn.pyx":1447
 *                 max_workspace_size)
 *             for perf in ret:
 *                 if perf.determinism:             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
        }

        /* "cupy/cudnn.pyx":1446
 *                 filter_desc, dW.data.ptr, 10, workspace.ptr,
 *                 max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      }
      /*else*/ {

        /* "cupy/cudnn.pyx":1452
 *                 raise RuntimeError(
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         else:
 *             perf = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_filter_algo_availabl, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1452, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1450
 *                     break
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))
 */
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1450, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 1450, __pyx_L1_error)
      }

      /* "cupy/cudnn.pyx":1446
 *                 filter_desc, dW.data.ptr, 10, workspace.ptr,
 *                 max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      __pyx_L7_break:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1441
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 *         if deterministic:             # <<<<<<<<<<<<<<
 *             ret = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 */
      goto __pyx_L5;
    }

    /* "cupy/cudnn.pyx":1457
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *                 filter_desc, dW.data.ptr, 1, workspace.ptr,
 *                 max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 */
    /*else*/ {

      /* "cupy/cudnn.pyx":1454
 *                     'less equal {}'.format(max_workspace_size))
 *         else:
 *             perf = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(             # <<<<<<<<<<<<<<
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *                 filter_desc, dW.data.ptr, 1, workspace.ptr,
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx_v7(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_dy_desc, __pyx_v_dy->data->ptr, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_dW->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__pyx_t_5 == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1454, __pyx_L1_error)
      }

      /* "cupy/cudnn.pyx":1457
 *                 handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *                 filter_desc, dW.data.ptr, 1, workspace.ptr,
 *                 max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 */
      __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1457, __pyx_L1_error)
      __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L5:;

    /* "cupy/cudnn.pyx":1458
 *                 filter_desc, dW.data.ptr, 1, workspace.ptr,
 *                 max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *     else:
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_perf->mathType != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1459
 *                 max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)             # <<<<<<<<<<<<<<
 *     else:
 *         perf = cudnn.findConvolutionBackwardFilterAlgorithmEx(
 */
      __pyx_t_4 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_filter(__pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1459, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1458
 *                 filter_desc, dW.data.ptr, 1, workspace.ptr,
 *                 max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *     else:
 */
    }

    /* "cupy/cudnn.pyx":1440
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardFilterAlgorithmEx_v7(
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1463
 *         perf = cudnn.findConvolutionBackwardFilterAlgorithmEx(
 *             handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1461
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *     else:
 *         perf = cudnn.findConvolutionBackwardFilterAlgorithmEx(             # <<<<<<<<<<<<<<
 *             handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_dy_desc, __pyx_v_dy->data->ptr, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_dW->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1461, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1461, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1463
 *         perf = cudnn.findConvolutionBackwardFilterAlgorithmEx(
 *             handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
    __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1463, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __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_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1463, __pyx_L1_error)
    __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1464
 *             handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  __pyx_t_8 = ((__pyx_v_perf->status != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/cudnn.pyx":1465
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')             # <<<<<<<<<<<<<<
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_filter_cache[key] = algo
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1465, __pyx_L1_error)

    /* "cupy/cudnn.pyx":1464
 *             handle, x_desc, x.data.ptr, dy_desc, dy.data.ptr, conv_desc,
 *             filter_desc, dW.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  }

  /* "cupy/cudnn.pyx":1466
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     _algorithm_bwd_filter_cache[key] = algo
 *     return algo
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_algo, ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1467
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_filter_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1467, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache, __pyx_v_key, ((PyObject *)__pyx_v_algo)) < 0)) __PYX_ERR(0, 1467, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1468
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_filter_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_algo));
  __pyx_r = __pyx_v_algo;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1427
 * 
 * 
 * cpdef _Algorithm _find_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t dy_desc, size_t conv_desc,
 */

  /* function 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.cudnn._find_algorithm_bwd_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF((PyObject *)__pyx_v_algo);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_99_find_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_98_find_algorithm_bwd_filter[] = "_find_algorithm_bwd_filter(ndarray x, ndarray dy, ndarray dW, tuple conv_param, size_t handle, size_t x_desc, size_t dy_desc, size_t conv_desc, size_t filter_desc, size_t max_workspace_size, bool use_tensor_core, bool deterministic) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_99_find_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_dy_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_v_deterministic;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_algorithm_bwd_filter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_dy,&__pyx_n_s_dW,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_x_desc,&__pyx_n_s_dy_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_filter_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,&__pyx_n_s_deterministic,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 1); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dW)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 2); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 3); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 4); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 5); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 6); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 7); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 8); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 9); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 10); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, 11); __PYX_ERR(0, 1427, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_algorithm_bwd_filter") < 0)) __PYX_ERR(0, 1427, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_dW = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1429, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1429, __pyx_L3_error)
    __pyx_v_dy_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_dy_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1429, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1429, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1430, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1430, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1430, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1431, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_filter", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1427, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._find_algorithm_bwd_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1428, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dy", 0))) __PYX_ERR(0, 1428, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dW), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dW", 0))) __PYX_ERR(0, 1428, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1428, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_98_find_algorithm_bwd_filter(__pyx_self, __pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_dy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic);

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

static PyObject *__pyx_pf_4cupy_5cudnn_98_find_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_dy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic) {
  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("_find_algorithm_bwd_filter", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_bwd_filter(__pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_dy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1471
 * 
 * 
 * cpdef _Algorithm _get_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t gy_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_101_get_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_bwd_filter(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_gy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_algo = NULL;
  PyObject *__pyx_v_ret = 0;
  int __pyx_v_skip;
  size_t __pyx_v_workspace_size;
  int __pyx_v_math_type;
  int __pyx_v_algo_no;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_algorithm_bwd_filter", 0);

  /* "cupy/cudnn.pyx":1477
 *         bint deterministic):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dW), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dy), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1478
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1478, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1477
 *         bint deterministic):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1479
 *     key = (x.data.device.id, x.shape, dW.shape, dy.shape, conv_param,
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1479, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1479, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_algo = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1480
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  __pyx_t_7 = (__pyx_v_algo != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1481
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     cdef list ret
 *     cdef bint skip
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(((__pyx_v_algo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1481, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_algo);
    __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1480
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_filter_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  }

  /* "cupy/cudnn.pyx":1484
 *     cdef list ret
 *     cdef bint skip
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionBackwardFilterAlgorithm_v7(
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 */
  __pyx_t_8 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1485
 *     cdef bint skip
 *     if _cudnn_version >= 7000:
 *         ret = cudnn.getConvolutionBackwardFilterAlgorithm_v7(             # <<<<<<<<<<<<<<
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 *         skip = False
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v7(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, 10, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1487
 *         ret = cudnn.getConvolutionBackwardFilterAlgorithm_v7(
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 *         skip = False             # <<<<<<<<<<<<<<
 *         for perf in ret:
 *             if deterministic and not perf.determinism:
 */
    __pyx_v_skip = 0;

    /* "cupy/cudnn.pyx":1488
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
    if (unlikely(__pyx_v_ret == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1488, __pyx_L1_error)
    }
    __pyx_t_6 = __pyx_v_ret; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0;
    for (;;) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1488, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1488, __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_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1488, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_perf, ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1489
 *         skip = False
 *         for perf in ret:
 *             if deterministic and not perf.determinism:             # <<<<<<<<<<<<<<
 *                 continue
 *             if perf.memory <= max_workspace_size:
 */
      __pyx_t_7 = (__pyx_v_deterministic != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_8 = __pyx_t_7;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_7 = ((!(__pyx_v_perf->determinism != 0)) != 0);
      __pyx_t_8 = __pyx_t_7;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_8) {

        /* "cupy/cudnn.pyx":1490
 *         for perf in ret:
 *             if deterministic and not perf.determinism:
 *                 continue             # <<<<<<<<<<<<<<
 *             if perf.memory <= max_workspace_size:
 *                 break
 */
        goto __pyx_L5_continue;

        /* "cupy/cudnn.pyx":1489
 *         skip = False
 *         for perf in ret:
 *             if deterministic and not perf.determinism:             # <<<<<<<<<<<<<<
 *                 continue
 *             if perf.memory <= max_workspace_size:
 */
      }

      /* "cupy/cudnn.pyx":1491
 *             if deterministic and not perf.determinism:
 *                 continue
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      __pyx_t_8 = ((__pyx_v_perf->memory <= __pyx_v_max_workspace_size) != 0);
      if (__pyx_t_8) {

        /* "cupy/cudnn.pyx":1492
 *                 continue
 *             if perf.memory <= max_workspace_size:
 *                 break             # <<<<<<<<<<<<<<
 *             skip = True
 *         else:
 */
        goto __pyx_L6_break;

        /* "cupy/cudnn.pyx":1491
 *             if deterministic and not perf.determinism:
 *                 continue
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      }

      /* "cupy/cudnn.pyx":1493
 *             if perf.memory <= max_workspace_size:
 *                 break
 *             skip = True             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError(
 */
      __pyx_v_skip = 1;

      /* "cupy/cudnn.pyx":1488
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
      __pyx_L5_continue:;
    }
    /*else*/ {

      /* "cupy/cudnn.pyx":1497
 *             raise RuntimeError(
 *                 'No conv bwd filter algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         if use_tensor_core and skip:
 *             warnings.warn(
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_filter_algo_availabl, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1497, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1497, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1497, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1495
 *             skip = True
 *         else:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'No conv bwd filter algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 */
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1495, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1495, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1488
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1498
 *                 'No conv bwd filter algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv bwd filter might not not selected due '
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_skip != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1499
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'The best algo of conv bwd filter might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1499, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1499, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1501
 *             warnings.warn(
 *                 'The best algo of conv bwd filter might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),             # <<<<<<<<<<<<<<
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_The_best_algo_of_conv_bwd_filter, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1501, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/cudnn.pyx":1502
 *                 'The best algo of conv bwd filter might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)             # <<<<<<<<<<<<<<
 *         algo = perf.algo
 *         workspace_size = perf.memory
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1502, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1502, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1499, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1499, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1499, __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_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_10, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_10, __pyx_t_1);
        __pyx_t_4 = 0;
        __pyx_t_1 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1499, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1498
 *                 'No conv bwd filter algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv bwd filter might not not selected due '
 */
    }

    /* "cupy/cudnn.pyx":1503
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)
 *         algo = perf.algo             # <<<<<<<<<<<<<<
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1504
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 *         workspace_size = perf.memory             # <<<<<<<<<<<<<<
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 */
    __pyx_t_11 = __pyx_v_perf->memory;
    __pyx_v_workspace_size = __pyx_t_11;

    /* "cupy/cudnn.pyx":1505
 *         algo = perf.algo
 *         workspace_size = perf.memory
 *         math_type = perf.mathType             # <<<<<<<<<<<<<<
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 */
    __pyx_t_10 = __pyx_v_perf->mathType;
    __pyx_v_math_type = __pyx_t_10;

    /* "cupy/cudnn.pyx":1506
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_math_type != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L16_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1507
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)             # <<<<<<<<<<<<<<
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 */
      __pyx_t_6 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_filter(__pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1507, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1506
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    }

    /* "cupy/cudnn.pyx":1508
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_filter(x, dy, dW, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     else:
 *         algo_no = cudnn.getConvolutionBackwardFilterAlgorithm_v6(
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1484
 *     cdef list ret
 *     cdef bint skip
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionBackwardFilterAlgorithm_v7(
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, 10)
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1510
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 *         algo_no = cudnn.getConvolutionBackwardFilterAlgorithm_v6(             # <<<<<<<<<<<<<<
 *             handle, x_desc, gy_desc, conv_desc, filter_desc,
 *             cudnn.CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1513
 *             handle, x_desc, gy_desc, conv_desc, filter_desc,
 *             cudnn.CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)             # <<<<<<<<<<<<<<
 *         workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, algo_no)
 */
    __pyx_t_10 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v6(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT, __pyx_v_max_workspace_size, 0); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1510, __pyx_L1_error)
    __pyx_v_algo_no = __pyx_t_10;

    /* "cupy/cudnn.pyx":1514
 *             cudnn.CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)
 *         workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(             # <<<<<<<<<<<<<<
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 */
    __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterWorkspaceSize(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_algo_no, 0); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1514, __pyx_L1_error)
    __pyx_v_workspace_size = __pyx_t_9;

    /* "cupy/cudnn.pyx":1516
 *         workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)             # <<<<<<<<<<<<<<
 *     _get_algorithm_bwd_filter_cache[key] = algo
 *     return algo
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_algo_no); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1516, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1517
 *             handle, x_desc, gy_desc, conv_desc, filter_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_bwd_filter_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1517, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache, __pyx_v_key, __pyx_v_algo) < 0)) __PYX_ERR(0, 1517, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1518
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_bwd_filter_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm)))) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_algo);
  __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1471
 * 
 * 
 * cpdef _Algorithm _get_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray dy, core.ndarray dW, tuple conv_param,
 *         size_t handle, size_t x_desc, size_t gy_desc, size_t conv_desc,
 */

  /* function 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.cudnn._get_algorithm_bwd_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_algo);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_101_get_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_100_get_algorithm_bwd_filter[] = "_get_algorithm_bwd_filter(ndarray x, ndarray dy, ndarray dW, tuple conv_param, size_t handle, size_t x_desc, size_t gy_desc, size_t conv_desc, size_t filter_desc, size_t max_workspace_size, bool use_tensor_core, bool deterministic) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_101_get_algorithm_bwd_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_gy_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_v_deterministic;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_algorithm_bwd_filter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_dy,&__pyx_n_s_dW,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_x_desc,&__pyx_n_s_gy_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_filter_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,&__pyx_n_s_deterministic,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 1); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dW)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 2); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 3); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 4); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 5); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 6); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 7); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 8); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 9); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 10); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, 11); __PYX_ERR(0, 1471, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_algorithm_bwd_filter") < 0)) __PYX_ERR(0, 1471, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_dy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_dW = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1473, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1473, __pyx_L3_error)
    __pyx_v_gy_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_gy_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1473, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1473, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1474, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1474, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1474, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1475, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_filter", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1471, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._get_algorithm_bwd_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1472, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dy", 0))) __PYX_ERR(0, 1472, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dW), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "dW", 0))) __PYX_ERR(0, 1472, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1472, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_100_get_algorithm_bwd_filter(__pyx_self, __pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic);

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

static PyObject *__pyx_pf_4cupy_5cudnn_100_get_algorithm_bwd_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_dW, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_x_desc, size_t __pyx_v_gy_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_filter_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic) {
  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_algorithm_bwd_filter", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_bwd_filter(__pyx_v_x, __pyx_v_dy, __pyx_v_dW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1521
 * 
 * 
 * cpdef _warn_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param):
 *     warnings.warn(
 */

static PyObject *__pyx_pw_4cupy_5cudnn_103_warn_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn__warn_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_warn_algorithm_bwd_data", 0);

  /* "cupy/cudnn.pyx":1523
 * cpdef _warn_algorithm_bwd_data(
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param):
 *     warnings.warn(             # <<<<<<<<<<<<<<
 *         'Tensor Core mode is set but the selected convolution backward '
 *         'data algorithm is not a Tensor Core enabled algorithm. '
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1528
 *         'This might be due to lack of workspace memory. '
 *         'W.shape:{}, x.shape:{}, y.shape:{}, pad:{}, stride:{}'
 *         .format(W.shape, x.shape, y.shape, conv_param[0], conv_param[1]),             # <<<<<<<<<<<<<<
 *         util.PerformanceWarning)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Tensor_Core_mode_is_set_but_the_3, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1528, __pyx_L1_error)
  }
  __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (unlikely(__pyx_v_conv_param == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1528, __pyx_L1_error)
  }
  __pyx_t_9 = __Pyx_GetItemInt_Tuple(__pyx_v_conv_param, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_10, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_9};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_9);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1529
 *         'W.shape:{}, x.shape:{}, y.shape:{}, pad:{}, stride:{}'
 *         .format(W.shape, x.shape, y.shape, conv_param[0], conv_param[1]),
 *         util.PerformanceWarning)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_util); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_12);
    __pyx_t_2 = 0;
    __pyx_t_12 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1523, __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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1521
 * 
 * 
 * cpdef _warn_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param):
 *     warnings.warn(
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_bwd_data", __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_5cudnn_103_warn_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_102_warn_algorithm_bwd_data[] = "_warn_algorithm_bwd_data(ndarray W, ndarray x, ndarray y, tuple conv_param)";
static PyObject *__pyx_pw_4cupy_5cudnn_103_warn_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_warn_algorithm_bwd_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_W,&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_conv_param,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_data", 1, 4, 4, 1); __PYX_ERR(0, 1521, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_data", 1, 4, 4, 2); __PYX_ERR(0, 1521, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_data", 1, 4, 4, 3); __PYX_ERR(0, 1521, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_warn_algorithm_bwd_data") < 0)) __PYX_ERR(0, 1521, __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_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_warn_algorithm_bwd_data", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1521, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._warn_algorithm_bwd_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1522, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1522, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1522, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1522, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_102_warn_algorithm_bwd_data(__pyx_self, __pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param);

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

static PyObject *__pyx_pf_4cupy_5cudnn_102_warn_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param) {
  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("_warn_algorithm_bwd_data", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1532
 * 
 * 
 * cpdef _Algorithm _find_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_105_find_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__find_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_algo = 0;
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  PyObject *__pyx_v_key = NULL;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  PyObject *__pyx_v_ret = NULL;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_algorithm_bwd_data", 0);

  /* "cupy/cudnn.pyx":1539
 *     cdef _Algorithm algo
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1540
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1539
 *     cdef _Algorithm algo
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1541
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,
 *            max_workspace_size)
 *     algo = _algorithm_bwd_data_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1541, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1541, __pyx_L1_error)
  __pyx_v_algo = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1542
 *            max_workspace_size)
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  __pyx_t_7 = (((PyObject *)__pyx_v_algo) != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1543
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_algo));
    __pyx_r = __pyx_v_algo;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1542
 *            max_workspace_size)
 *     algo = _algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 */
  }

  /* "cupy/cudnn.pyx":1544
 *     if algo is not None:
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)             # <<<<<<<<<<<<<<
 *     if _cudnn_version >= 7000:
 *         if deterministic:
 */
  __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_6, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cudnn.pyx":1545
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 */
  __pyx_t_8 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1546
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 *         if deterministic:             # <<<<<<<<<<<<<<
 *             ret = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 */
    __pyx_t_8 = (__pyx_v_deterministic != 0);
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1547
 *     if _cudnn_version >= 7000:
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(             # <<<<<<<<<<<<<<
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx_v7(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_y->data->ptr, 10, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1547, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_ret = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1550
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      if (unlikely(__pyx_v_ret == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 1550, __pyx_L1_error)
      }
      __pyx_t_5 = __pyx_v_ret; __Pyx_INCREF(__pyx_t_5); __pyx_t_9 = 0;
      for (;;) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_9); __Pyx_INCREF(__pyx_t_6); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1550, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1550, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1550, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_perf, ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_6));
        __pyx_t_6 = 0;

        /* "cupy/cudnn.pyx":1551
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 *             for perf in ret:
 *                 if perf.determinism:             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
        __pyx_t_8 = (__pyx_v_perf->determinism != 0);
        if (__pyx_t_8) {

          /* "cupy/cudnn.pyx":1552
 *             for perf in ret:
 *                 if perf.determinism:
 *                     break             # <<<<<<<<<<<<<<
 *             else:
 *                 raise RuntimeError(
 */
          goto __pyx_L7_break;

          /* "cupy/cudnn.pyx":1551
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 *             for perf in ret:
 *                 if perf.determinism:             # <<<<<<<<<<<<<<
 *                     break
 *             else:
 */
        }

        /* "cupy/cudnn.pyx":1550
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      }
      /*else*/ {

        /* "cupy/cudnn.pyx":1556
 *                 raise RuntimeError(
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         else:
 *             perf = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_filter_algo_availabl, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1554
 *                     break
 *             else:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))
 */
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 1554, __pyx_L1_error)
      }

      /* "cupy/cudnn.pyx":1550
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 10, workspace.ptr, max_workspace_size)
 *             for perf in ret:             # <<<<<<<<<<<<<<
 *                 if perf.determinism:
 *                     break
 */
      __pyx_L7_break:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1546
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:
 *         if deterministic:             # <<<<<<<<<<<<<<
 *             ret = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 */
      goto __pyx_L5;
    }

    /* "cupy/cudnn.pyx":1560
 *             perf = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 */
    /*else*/ {

      /* "cupy/cudnn.pyx":1558
 *                     'less equal {}'.format(max_workspace_size))
 *         else:
 *             perf = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(             # <<<<<<<<<<<<<<
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx_v7(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_y->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1558, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__pyx_t_5 == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1558, __pyx_L1_error)
      }

      /* "cupy/cudnn.pyx":1560
 *             perf = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 */
      __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1560, __pyx_L1_error)
      __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L5:;

    /* "cupy/cudnn.pyx":1561
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *     else:
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_perf->mathType != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1562
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)             # <<<<<<<<<<<<<<
 *     else:
 *         perf = cudnn.findConvolutionBackwardDataAlgorithmEx(
 */
      __pyx_t_4 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1562, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1561
 *                 handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *                 y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *         if use_tensor_core and perf.mathType != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *     else:
 */
    }

    /* "cupy/cudnn.pyx":1545
 *         return algo
 *     workspace = memory.alloc(max_workspace_size)
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         if deterministic:
 *             ret = cudnn.findConvolutionBackwardDataAlgorithmEx_v7(
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1566
 *         perf = cudnn.findConvolutionBackwardDataAlgorithmEx(
 *             handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1564
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *     else:
 *         perf = cudnn.findConvolutionBackwardDataAlgorithmEx(             # <<<<<<<<<<<<<<
 *             handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_y->data->ptr, 1, __pyx_v_workspace->ptr, __pyx_v_max_workspace_size, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__pyx_t_4 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1564, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1566
 *         perf = cudnn.findConvolutionBackwardDataAlgorithmEx(
 *             handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]             # <<<<<<<<<<<<<<
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 */
    __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __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_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1566, __pyx_L1_error)
    __pyx_v_perf = ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1567
 *             handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  __pyx_t_8 = ((__pyx_v_perf->status != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS) != 0);
  if (unlikely(__pyx_t_8)) {

    /* "cupy/cudnn.pyx":1568
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')             # <<<<<<<<<<<<<<
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_data_cache[key] = algo
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 1568, __pyx_L1_error)

    /* "cupy/cudnn.pyx":1567
 *             handle, filter_desc, W.data.ptr, x_desc, x.data.ptr, conv_desc,
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
  }

  /* "cupy/cudnn.pyx":1569
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     _algorithm_bwd_data_cache[key] = algo
 *     return algo
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_4 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_algo, ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1570
 *         raise RuntimeError('No available algorithm found.')
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_data_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1570, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache, __pyx_v_key, ((PyObject *)__pyx_v_algo)) < 0)) __PYX_ERR(0, 1570, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1571
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_bwd_data_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_algo));
  __pyx_r = __pyx_v_algo;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1532
 * 
 * 
 * cpdef _Algorithm _find_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc,
 */

  /* function 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.cudnn._find_algorithm_bwd_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_algo);
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_105_find_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_104_find_algorithm_bwd_data[] = "_find_algorithm_bwd_data(ndarray W, ndarray x, ndarray y, tuple conv_param, size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc, size_t y_desc, size_t max_workspace_size, bool use_tensor_core, bool deterministic) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_105_find_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_v_deterministic;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_algorithm_bwd_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_W,&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_filter_desc,&__pyx_n_s_x_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_y_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,&__pyx_n_s_deterministic,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 1); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 2); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 3); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 4); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 5); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 6); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 7); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 8); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 9); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 10); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, 11); __PYX_ERR(0, 1532, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_algorithm_bwd_data") < 0)) __PYX_ERR(0, 1532, __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_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1534, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1534, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1534, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1534, __pyx_L3_error)
    __pyx_v_y_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_y_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1535, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1535, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1535, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1536, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_find_algorithm_bwd_data", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1532, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._find_algorithm_bwd_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1533, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1533, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1533, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1533, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_104_find_algorithm_bwd_data(__pyx_self, __pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic);

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

static PyObject *__pyx_pf_4cupy_5cudnn_104_find_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic) {
  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("_find_algorithm_bwd_data", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1574
 * 
 * 
 * cpdef _Algorithm _get_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc,
 */

static PyObject *__pyx_pw_4cupy_5cudnn_107_get_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_f_4cupy_5cudnn__get_algorithm_bwd_data(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *__pyx_v_perf = 0;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_algo = NULL;
  PyObject *__pyx_v_ret = 0;
  int __pyx_v_skip;
  size_t __pyx_v_workspace_size;
  int __pyx_v_math_type;
  int __pyx_v_algo_no;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_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;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  size_t __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_algorithm_bwd_data", 0);

  /* "cupy/cudnn.pyx":1580
 *         bint deterministic):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W), __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1581
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,
 *            max_workspace_size)             # <<<<<<<<<<<<<<
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "cupy/cudnn.pyx":1580
 *         bint deterministic):
 *     cdef cudnn.CuDNNAlgoPerf perf
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,             # <<<<<<<<<<<<<<
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 */
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_v_conv_param);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_conv_param);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_v_key = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1582
 *     key = (x.data.device.id, W.shape, x.shape, y.shape, conv_param,
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)             # <<<<<<<<<<<<<<
 *     if algo is not None:
 *         return algo
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get");
    __PYX_ERR(0, 1582, __pyx_L1_error)
  }
  __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache, __pyx_v_key, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1582, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_algo = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":1583
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  __pyx_t_7 = (__pyx_v_algo != Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1584
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:
 *         return algo             # <<<<<<<<<<<<<<
 *     cdef list ret
 *     cdef bint skip
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    if (!(likely(((__pyx_v_algo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm))))) __PYX_ERR(0, 1584, __pyx_L1_error)
    __Pyx_INCREF(__pyx_v_algo);
    __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1583
 *            max_workspace_size)
 *     algo = _get_algorithm_bwd_data_cache.get(key, None)
 *     if algo is not None:             # <<<<<<<<<<<<<<
 *         return algo
 *     cdef list ret
 */
  }

  /* "cupy/cudnn.pyx":1587
 *     cdef list ret
 *     cdef bint skip
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionBackwardDataAlgorithm_v7(
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 */
  __pyx_t_8 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
  if (__pyx_t_8) {

    /* "cupy/cudnn.pyx":1588
 *     cdef bint skip
 *     if _cudnn_version >= 7000:
 *         ret = cudnn.getConvolutionBackwardDataAlgorithm_v7(             # <<<<<<<<<<<<<<
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 *         skip = False
 */
    __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v7(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, 10, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_ret = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1590
 *         ret = cudnn.getConvolutionBackwardDataAlgorithm_v7(
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 *         skip = False             # <<<<<<<<<<<<<<
 *         for perf in ret:
 *             if deterministic and not perf.determinism:
 */
    __pyx_v_skip = 0;

    /* "cupy/cudnn.pyx":1591
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
    if (unlikely(__pyx_v_ret == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1591, __pyx_L1_error)
    }
    __pyx_t_6 = __pyx_v_ret; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0;
    for (;;) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 1591, __pyx_L1_error)
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1591, __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_4cuda_5cudnn_CuDNNAlgoPerf))))) __PYX_ERR(0, 1591, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_perf, ((struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":1592
 *         skip = False
 *         for perf in ret:
 *             if deterministic and not perf.determinism:             # <<<<<<<<<<<<<<
 *                 continue
 *             if perf.memory <= max_workspace_size:
 */
      __pyx_t_7 = (__pyx_v_deterministic != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_8 = __pyx_t_7;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_7 = ((!(__pyx_v_perf->determinism != 0)) != 0);
      __pyx_t_8 = __pyx_t_7;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_8) {

        /* "cupy/cudnn.pyx":1593
 *         for perf in ret:
 *             if deterministic and not perf.determinism:
 *                 continue             # <<<<<<<<<<<<<<
 *             if perf.memory <= max_workspace_size:
 *                 break
 */
        goto __pyx_L5_continue;

        /* "cupy/cudnn.pyx":1592
 *         skip = False
 *         for perf in ret:
 *             if deterministic and not perf.determinism:             # <<<<<<<<<<<<<<
 *                 continue
 *             if perf.memory <= max_workspace_size:
 */
      }

      /* "cupy/cudnn.pyx":1594
 *             if deterministic and not perf.determinism:
 *                 continue
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      __pyx_t_8 = ((__pyx_v_perf->memory <= __pyx_v_max_workspace_size) != 0);
      if (__pyx_t_8) {

        /* "cupy/cudnn.pyx":1595
 *                 continue
 *             if perf.memory <= max_workspace_size:
 *                 break             # <<<<<<<<<<<<<<
 *             skip = True
 *         else:
 */
        goto __pyx_L6_break;

        /* "cupy/cudnn.pyx":1594
 *             if deterministic and not perf.determinism:
 *                 continue
 *             if perf.memory <= max_workspace_size:             # <<<<<<<<<<<<<<
 *                 break
 *             skip = True
 */
      }

      /* "cupy/cudnn.pyx":1596
 *             if perf.memory <= max_workspace_size:
 *                 break
 *             skip = True             # <<<<<<<<<<<<<<
 *         else:
 *             raise RuntimeError(
 */
      __pyx_v_skip = 1;

      /* "cupy/cudnn.pyx":1591
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
      __pyx_L5_continue:;
    }
    /*else*/ {

      /* "cupy/cudnn.pyx":1600
 *             raise RuntimeError(
 *                 'No conv bwd data algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         if use_tensor_core and skip:
 *             warnings.warn(
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_data_algo_available, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1600, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1600, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1600, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1598
 *             skip = True
 *         else:
 *             raise RuntimeError(             # <<<<<<<<<<<<<<
 *                 'No conv bwd data algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 */
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1598, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 1598, __pyx_L1_error)
    }

    /* "cupy/cudnn.pyx":1591
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 *         skip = False
 *         for perf in ret:             # <<<<<<<<<<<<<<
 *             if deterministic and not perf.determinism:
 *                 continue
 */
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1601
 *                 'No conv bwd data algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv bwd data might not not selected due '
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_skip != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1602
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:
 *             warnings.warn(             # <<<<<<<<<<<<<<
 *                 'The best algo of conv bwd data might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1602, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1602, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1604
 *             warnings.warn(
 *                 'The best algo of conv bwd data might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),             # <<<<<<<<<<<<<<
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_The_best_algo_of_conv_bwd_data_m, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1604, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1604, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1604, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cupy/cudnn.pyx":1605
 *                 'The best algo of conv bwd data might not not selected due '
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)             # <<<<<<<<<<<<<<
 *         algo = perf.algo
 *         workspace_size = perf.memory
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_util); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1605, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1605, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_10 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1602, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_1};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1602, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1602, __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_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_10, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_10, __pyx_t_1);
        __pyx_t_4 = 0;
        __pyx_t_1 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1602, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1601
 *                 'No conv bwd data algo available with workspace size less '
 *                 'equal {}'.format(max_workspace_size))
 *         if use_tensor_core and skip:             # <<<<<<<<<<<<<<
 *             warnings.warn(
 *                 'The best algo of conv bwd data might not not selected due '
 */
    }

    /* "cupy/cudnn.pyx":1606
 *                 'to lack of workspace size ({})'.format(max_workspace_size),
 *                 util.PerformanceWarning)
 *         algo = perf.algo             # <<<<<<<<<<<<<<
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":1607
 *                 util.PerformanceWarning)
 *         algo = perf.algo
 *         workspace_size = perf.memory             # <<<<<<<<<<<<<<
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 */
    __pyx_t_11 = __pyx_v_perf->memory;
    __pyx_v_workspace_size = __pyx_t_11;

    /* "cupy/cudnn.pyx":1608
 *         algo = perf.algo
 *         workspace_size = perf.memory
 *         math_type = perf.mathType             # <<<<<<<<<<<<<<
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 */
    __pyx_t_10 = __pyx_v_perf->mathType;
    __pyx_v_math_type = __pyx_t_10;

    /* "cupy/cudnn.pyx":1609
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    __pyx_t_7 = (__pyx_v_use_tensor_core != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_8 = __pyx_t_7;
      goto __pyx_L16_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_math_type != __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_OP_MATH) != 0);
    __pyx_t_8 = __pyx_t_7;
    __pyx_L16_bool_binop_done:;
    if (__pyx_t_8) {

      /* "cupy/cudnn.pyx":1610
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)             # <<<<<<<<<<<<<<
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 */
      __pyx_t_6 = __pyx_f_4cupy_5cudnn__warn_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1610, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cupy/cudnn.pyx":1609
 *         workspace_size = perf.memory
 *         math_type = perf.mathType
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:             # <<<<<<<<<<<<<<
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 */
    }

    /* "cupy/cudnn.pyx":1611
 *         if use_tensor_core and math_type != cudnn.CUDNN_TENSOR_OP_MATH:
 *             _warn_algorithm_bwd_data(W, x, y, conv_param)
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)             # <<<<<<<<<<<<<<
 *     else:
 *         algo_no = cudnn.getConvolutionBackwardDataAlgorithm_v6(
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_perf->algo); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_perf->mathType); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1611, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1587
 *     cdef list ret
 *     cdef bint skip
 *     if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *         ret = cudnn.getConvolutionBackwardDataAlgorithm_v7(
 *             handle, filter_desc, x_desc, conv_desc, y_desc, 10)
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":1613
 *         algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     else:
 *         algo_no = cudnn.getConvolutionBackwardDataAlgorithm_v6(             # <<<<<<<<<<<<<<
 *             handle, filter_desc, x_desc, conv_desc, y_desc,
 *             cudnn.CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
 */
  /*else*/ {

    /* "cupy/cudnn.pyx":1616
 *             handle, filter_desc, x_desc, conv_desc, y_desc,
 *             cudnn.CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)             # <<<<<<<<<<<<<<
 *         workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(
 *             handle, filter_desc, x_desc, conv_desc, y_desc, algo_no)
 */
    __pyx_t_10 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v6(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT, __pyx_v_max_workspace_size, 0); if (unlikely(__pyx_t_10 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1613, __pyx_L1_error)
    __pyx_v_algo_no = __pyx_t_10;

    /* "cupy/cudnn.pyx":1617
 *             cudnn.CUDNN_CONVOLUTION_BWD_DATA_SPECIFY_WORKSPACE_LIMIT,
 *             max_workspace_size)
 *         workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(             # <<<<<<<<<<<<<<
 *             handle, filter_desc, x_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 */
    __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataWorkspaceSize(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_algo_no, 0); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1617, __pyx_L1_error)
    __pyx_v_workspace_size = __pyx_t_9;

    /* "cupy/cudnn.pyx":1619
 *         workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(
 *             handle, filter_desc, x_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)             # <<<<<<<<<<<<<<
 *     _get_algorithm_bwd_data_cache[key] = algo
 *     return algo
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_algo_no); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1619, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn__Algorithm), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_algo, __pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":1620
 *             handle, filter_desc, x_desc, conv_desc, y_desc, algo_no)
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_bwd_data_cache[key] = algo             # <<<<<<<<<<<<<<
 *     return algo
 * 
 */
  if (unlikely(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1620, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache, __pyx_v_key, __pyx_v_algo) < 0)) __PYX_ERR(0, 1620, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1621
 *         algo = _Algorithm(algo_no, workspace_size)
 *     _get_algorithm_bwd_data_cache[key] = algo
 *     return algo             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(__Pyx_TypeTest(__pyx_v_algo, __pyx_ptype_4cupy_5cudnn__Algorithm)))) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_algo);
  __pyx_r = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_v_algo);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1574
 * 
 * 
 * cpdef _Algorithm _get_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray y, tuple conv_param,
 *         size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc,
 */

  /* function 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.cudnn._get_algorithm_bwd_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_algo);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_107_get_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_106_get_algorithm_bwd_data[] = "_get_algorithm_bwd_data(ndarray W, ndarray x, ndarray y, tuple conv_param, size_t handle, size_t filter_desc, size_t x_desc, size_t conv_desc, size_t y_desc, size_t max_workspace_size, bool use_tensor_core, bool deterministic) -> _Algorithm";
static PyObject *__pyx_pw_4cupy_5cudnn_107_get_algorithm_bwd_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_max_workspace_size;
  int __pyx_v_use_tensor_core;
  int __pyx_v_deterministic;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_algorithm_bwd_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_W,&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_conv_param,&__pyx_n_s_handle,&__pyx_n_s_filter_desc,&__pyx_n_s_x_desc,&__pyx_n_s_conv_desc,&__pyx_n_s_y_desc,&__pyx_n_s_max_workspace_size,&__pyx_n_s_use_tensor_core,&__pyx_n_s_deterministic,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 1); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 2); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 3); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 4); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filter_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 5); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 6); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conv_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 7); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y_desc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 8); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_workspace_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 9); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_use_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 10); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, 11); __PYX_ERR(0, 1574, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_algorithm_bwd_data") < 0)) __PYX_ERR(0, 1574, __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_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_conv_param = ((PyObject*)values[3]);
    __pyx_v_handle = __Pyx_PyInt_As_size_t(values[4]); if (unlikely((__pyx_v_handle == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1576, __pyx_L3_error)
    __pyx_v_filter_desc = __Pyx_PyInt_As_size_t(values[5]); if (unlikely((__pyx_v_filter_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1576, __pyx_L3_error)
    __pyx_v_x_desc = __Pyx_PyInt_As_size_t(values[6]); if (unlikely((__pyx_v_x_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1576, __pyx_L3_error)
    __pyx_v_conv_desc = __Pyx_PyInt_As_size_t(values[7]); if (unlikely((__pyx_v_conv_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1576, __pyx_L3_error)
    __pyx_v_y_desc = __Pyx_PyInt_As_size_t(values[8]); if (unlikely((__pyx_v_y_desc == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1577, __pyx_L3_error)
    __pyx_v_max_workspace_size = __Pyx_PyInt_As_size_t(values[9]); if (unlikely((__pyx_v_max_workspace_size == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1577, __pyx_L3_error)
    __pyx_v_use_tensor_core = __Pyx_PyObject_IsTrue(values[10]); if (unlikely((__pyx_v_use_tensor_core == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1577, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1578, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_algorithm_bwd_data", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1574, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._get_algorithm_bwd_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1575, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1575, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1575, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_conv_param), (&PyTuple_Type), 1, "conv_param", 1))) __PYX_ERR(0, 1575, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_106_get_algorithm_bwd_data(__pyx_self, __pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic);

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

static PyObject *__pyx_pf_4cupy_5cudnn_106_get_algorithm_bwd_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_conv_param, size_t __pyx_v_handle, size_t __pyx_v_filter_desc, size_t __pyx_v_x_desc, size_t __pyx_v_conv_desc, size_t __pyx_v_y_desc, size_t __pyx_v_max_workspace_size, int __pyx_v_use_tensor_core, int __pyx_v_deterministic) {
  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_algorithm_bwd_data", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":1624
 * 
 * 
 * cpdef bint _should_use_tensor_core(             # <<<<<<<<<<<<<<
 *         tensor_core_mode, object dtype) except *:
 *     if tensor_core_mode == 'auto':
 */

static PyObject *__pyx_pw_4cupy_5cudnn_109_should_use_tensor_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_4cupy_5cudnn__should_use_tensor_core(PyObject *__pyx_v_tensor_core_mode, PyObject *__pyx_v_dtype, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __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("_should_use_tensor_core", 0);

  /* "cupy/cudnn.pyx":1626
 * cpdef bint _should_use_tensor_core(
 *         tensor_core_mode, object dtype) except *:
 *     if tensor_core_mode == 'auto':             # <<<<<<<<<<<<<<
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'always':
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_tensor_core_mode, __pyx_n_u_auto, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1626, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":1627
 *         tensor_core_mode, object dtype) except *:
 *     if tensor_core_mode == 'auto':
 *         return is_tensor_core_available(dtype)             # <<<<<<<<<<<<<<
 *     elif tensor_core_mode == 'always':
 *         # TODO(oktua): more strict condition
 */
    __pyx_t_1 = __pyx_f_4cupy_5cudnn_is_tensor_core_available(__pyx_v_dtype, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1627, __pyx_L1_error)
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1626
 * cpdef bint _should_use_tensor_core(
 *         tensor_core_mode, object dtype) except *:
 *     if tensor_core_mode == 'auto':             # <<<<<<<<<<<<<<
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'always':
 */
  }

  /* "cupy/cudnn.pyx":1628
 *     if tensor_core_mode == 'auto':
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'always':             # <<<<<<<<<<<<<<
 *         # TODO(oktua): more strict condition
 *         return is_tensor_core_available(dtype)
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_tensor_core_mode, __pyx_n_u_always, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1628, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":1630
 *     elif tensor_core_mode == 'always':
 *         # TODO(oktua): more strict condition
 *         return is_tensor_core_available(dtype)             # <<<<<<<<<<<<<<
 *     elif tensor_core_mode == 'never':
 *         return False
 */
    __pyx_t_1 = __pyx_f_4cupy_5cudnn_is_tensor_core_available(__pyx_v_dtype, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1630, __pyx_L1_error)
    __pyx_r = __pyx_t_1;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1628
 *     if tensor_core_mode == 'auto':
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'always':             # <<<<<<<<<<<<<<
 *         # TODO(oktua): more strict condition
 *         return is_tensor_core_available(dtype)
 */
  }

  /* "cupy/cudnn.pyx":1631
 *         # TODO(oktua): more strict condition
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'never':             # <<<<<<<<<<<<<<
 *         return False
 *     else:
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_tensor_core_mode, __pyx_n_u_never, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1631, __pyx_L1_error)
  if (likely(__pyx_t_1)) {

    /* "cupy/cudnn.pyx":1632
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'never':
 *         return False             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError(
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1631
 *         # TODO(oktua): more strict condition
 *         return is_tensor_core_available(dtype)
 *     elif tensor_core_mode == 'never':             # <<<<<<<<<<<<<<
 *         return False
 *     else:
 */
  }

  /* "cupy/cudnn.pyx":1634
 *         return False
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'tensor_code_mode must be either of "always", "auto", or "never".')
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1634, __pyx_L1_error)
  }

  /* "cupy/cudnn.pyx":1624
 * 
 * 
 * cpdef bint _should_use_tensor_core(             # <<<<<<<<<<<<<<
 *         tensor_core_mode, object dtype) except *:
 *     if tensor_core_mode == 'auto':
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn._should_use_tensor_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_109_should_use_tensor_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_108_should_use_tensor_core[] = "_should_use_tensor_core(tensor_core_mode, dtype) -> bool";
static PyObject *__pyx_pw_4cupy_5cudnn_109_should_use_tensor_core(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tensor_core_mode = 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("_should_use_tensor_core (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tensor_core_mode,&__pyx_n_s_dtype,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tensor_core_mode)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_should_use_tensor_core", 1, 2, 2, 1); __PYX_ERR(0, 1624, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_should_use_tensor_core") < 0)) __PYX_ERR(0, 1624, __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_tensor_core_mode = values[0];
    __pyx_v_dtype = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_should_use_tensor_core", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1624, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn._should_use_tensor_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_108_should_use_tensor_core(__pyx_self, __pyx_v_tensor_core_mode, __pyx_v_dtype);

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

static PyObject *__pyx_pf_4cupy_5cudnn_108_should_use_tensor_core(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_tensor_core_mode, PyObject *__pyx_v_dtype) {
  PyObject *__pyx_r = NULL;
  __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("_should_use_tensor_core", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__should_use_tensor_core(__pyx_v_tensor_core_mode, __pyx_v_dtype, 0); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1624, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1624, __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.cudnn._should_use_tensor_core", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1638
 * 
 * 
 * def _get_array_info(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr is None:
 *         return 'None'
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_111_get_array_info(PyObject *__pyx_self, PyObject *__pyx_v_arr); /*proto*/
static char __pyx_doc_4cupy_5cudnn_110_get_array_info[] = "_get_array_info(ndarray arr)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_111_get_array_info = {"_get_array_info", (PyCFunction)__pyx_pw_4cupy_5cudnn_111_get_array_info, METH_O, __pyx_doc_4cupy_5cudnn_110_get_array_info};
static PyObject *__pyx_pw_4cupy_5cudnn_111_get_array_info(PyObject *__pyx_self, PyObject *__pyx_v_arr) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_array_info (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arr), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "arr", 0))) __PYX_ERR(0, 1638, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_110_get_array_info(__pyx_self, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_v_arr));

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

static PyObject *__pyx_pf_4cupy_5cudnn_110_get_array_info(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_array_info", 0);

  /* "cupy/cudnn.pyx":1639
 * 
 * def _get_array_info(core.ndarray arr):
 *     if arr is None:             # <<<<<<<<<<<<<<
 *         return 'None'
 *     return 'shape={!r}, dtype={}, strides={!r}'.format(
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_arr) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/cudnn.pyx":1640
 * def _get_array_info(core.ndarray arr):
 *     if arr is None:
 *         return 'None'             # <<<<<<<<<<<<<<
 *     return 'shape={!r}, dtype={}, strides={!r}'.format(
 *         arr.shape, arr.dtype.name, arr.strides)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_n_u_None);
    __pyx_r = __pyx_n_u_None;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":1639
 * 
 * def _get_array_info(core.ndarray arr):
 *     if arr is None:             # <<<<<<<<<<<<<<
 *         return 'None'
 *     return 'shape={!r}, dtype={}, strides={!r}'.format(
 */
  }

  /* "cupy/cudnn.pyx":1641
 *     if arr is None:
 *         return 'None'
 *     return 'shape={!r}, dtype={}, strides={!r}'.format(             # <<<<<<<<<<<<<<
 *         arr.shape, arr.dtype.name, arr.strides)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_shape_r_dtype_strides_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "cupy/cudnn.pyx":1642
 *         return 'None'
 *     return 'shape={!r}, dtype={}, strides={!r}'.format(
 *         arr.shape, arr.dtype.name, arr.strides)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr->dtype, __pyx_n_s_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_arr), __pyx_n_s_strides_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  __pyx_t_9 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_9 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1641, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_8, __pyx_t_5, __pyx_t_6, __pyx_t_7};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 3+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1641, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_7);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1638
 * 
 * 
 * def _get_array_info(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr is None:
 *         return '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_10);
  __Pyx_AddTraceback("cupy.cudnn._get_array_info", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1645
 * 
 * 
 * def convolution_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_113convolution_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_112convolution_forward[] = "convolution_forward(ndarray x, ndarray W, ndarray b, ndarray y, tuple pad, tuple stride, tuple dilation, int groups, *, bool auto_tune, tensor_core, int d_layout=cudnn.CUDNN_TENSOR_NCHW, int w_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_113convolution_forward = {"convolution_forward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_113convolution_forward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_112convolution_forward};
static PyObject *__pyx_pw_4cupy_5cudnn_113convolution_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_dilation = 0;
  int __pyx_v_groups;
  int __pyx_v_auto_tune;
  PyObject *__pyx_v_tensor_core = 0;
  int __pyx_v_d_layout;
  int __pyx_v_w_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convolution_forward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_W,&__pyx_n_s_b,&__pyx_n_s_y,&__pyx_n_s_pad,&__pyx_n_s_stride,&__pyx_n_s_dilation,&__pyx_n_s_groups,&__pyx_n_s_auto_tune,&__pyx_n_s_tensor_core,&__pyx_n_s_d_layout,&__pyx_n_s_w_layout,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 1); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 2); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 3); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 4); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 5); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dilation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 6); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_groups)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, 7); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_auto_tune)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_forward", __pyx_n_s_auto_tune); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_forward", __pyx_n_s_tensor_core); __PYX_ERR(0, 1645, __pyx_L3_error)
        }
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 10; index < 12 && kw_args > 0; index++) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "convolution_forward") < 0)) __PYX_ERR(0, 1645, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("convolution_forward", __pyx_n_s_auto_tune); __PYX_ERR(0, 1645, __pyx_L3_error)
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_pad = ((PyObject*)values[4]);
    __pyx_v_stride = ((PyObject*)values[5]);
    __pyx_v_dilation = ((PyObject*)values[6]);
    __pyx_v_groups = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_groups == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1647, __pyx_L3_error)
    __pyx_v_auto_tune = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_auto_tune == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1648, __pyx_L3_error)
    __pyx_v_tensor_core = values[9];
    if (values[10]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1649, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__20;
    }
    if (values[11]) {
      __pyx_v_w_layout = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_w_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1650, __pyx_L3_error)
    } else {
      __pyx_v_w_layout = __pyx_k__21;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("convolution_forward", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1645, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.convolution_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1646, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1646, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 1646, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1646, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 1647, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 1647, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dilation), (&PyTuple_Type), 1, "dilation", 1))) __PYX_ERR(0, 1647, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_112convolution_forward(__pyx_self, __pyx_v_x, __pyx_v_W, __pyx_v_b, __pyx_v_y, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_v_auto_tune, __pyx_v_tensor_core, __pyx_v_d_layout, __pyx_v_w_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_112convolution_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout) {
  int __pyx_v_dev_id;
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  int __pyx_v_use_tensor_core;
  PyObject *__pyx_v_conv_param = 0;
  PyObject *__pyx_v_i = NULL;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_b_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_conv_desc;
  size_t __pyx_v_max_workspace_size;
  std::vector<Py_ssize_t>  __pyx_v_b_shape;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_perf = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_v_infos = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  size_t __pyx_t_7;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_8;
  struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_t_25;
  char const *__pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  int __pyx_t_33;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor __pyx_t_34;
  char const *__pyx_t_35;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convolution_forward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_W);
  __Pyx_INCREF((PyObject *)__pyx_v_b);

  /* "cupy/cudnn.pyx":1651
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == W.data.device.id
 *     assert dev_id == y.data.device.id
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1651, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dev_id = __pyx_t_3;

  /* "cupy/cudnn.pyx":1652
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == W.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == y.data.device.id
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1652, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1652, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1653
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == W.data.device.id
 *     assert dev_id == y.data.device.id             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_zero = 0, float_one = 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y->data), __pyx_n_s_device); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1653, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1653, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1653, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1655
 *     assert dev_id == y.data.device.id
 * 
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":1656
 * 
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":1658
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1658, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":1659
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":1660
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":1658
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1662
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":1663
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     cdef bint use_tensor_core = _should_use_tensor_core(tensor_core, x.dtype)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1665
 *         one = <size_t>&float_one
 * 
 *     cdef bint use_tensor_core = _should_use_tensor_core(tensor_core, x.dtype)             # <<<<<<<<<<<<<<
 *     cdef tuple conv_param = (pad, stride, x.dtype, use_tensor_core)
 * 
 */
  __pyx_t_4 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = __pyx_f_4cupy_5cudnn__should_use_tensor_core(__pyx_v_tensor_core, __pyx_t_4, 0); if (unlikely(__pyx_t_5 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1665, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_use_tensor_core = __pyx_t_5;

  /* "cupy/cudnn.pyx":1666
 * 
 *     cdef bint use_tensor_core = _should_use_tensor_core(tensor_core, x.dtype)
 *     cdef tuple conv_param = (pad, stride, x.dtype, use_tensor_core)             # <<<<<<<<<<<<<<
 * 
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_tensor_core); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_pad);
  __Pyx_GIVEREF(__pyx_v_pad);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pad);
  __Pyx_INCREF(__pyx_v_stride);
  __Pyx_GIVEREF(__pyx_v_stride);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_stride);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_conv_param = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1670
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:             # <<<<<<<<<<<<<<
 *         for i in dilation:
 *             if i > 1:
 */
  __pyx_t_5 = (__pyx_v_use_tensor_core != 0);
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":1671
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:
 *         for i in dilation:             # <<<<<<<<<<<<<<
 *             if i > 1:
 *                 use_tensor_core = False
 */
    if (unlikely(__pyx_v_dilation == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1671, __pyx_L1_error)
    }
    __pyx_t_2 = __pyx_v_dilation; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
    for (;;) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1671, __pyx_L1_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1672
 *     if use_tensor_core:
 *         for i in dilation:
 *             if i > 1:             # <<<<<<<<<<<<<<
 *                 use_tensor_core = False
 *                 break
 */
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_i, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1672, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1672, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_5) {

        /* "cupy/cudnn.pyx":1673
 *         for i in dilation:
 *             if i > 1:
 *                 use_tensor_core = False             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        __pyx_v_use_tensor_core = 0;

        /* "cupy/cudnn.pyx":1674
 *             if i > 1:
 *                 use_tensor_core = False
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
        goto __pyx_L6_break;

        /* "cupy/cudnn.pyx":1672
 *     if use_tensor_core:
 *         for i in dilation:
 *             if i > 1:             # <<<<<<<<<<<<<<
 *                 use_tensor_core = False
 *                 break
 */
      }

      /* "cupy/cudnn.pyx":1671
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:
 *         for i in dilation:             # <<<<<<<<<<<<<<
 *             if i > 1:
 *                 use_tensor_core = False
 */
    }
    __pyx_L6_break:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1670
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:             # <<<<<<<<<<<<<<
 *         for i in dilation:
 *             if i > 1:
 */
  }

  /* "cupy/cudnn.pyx":1676
 *                 break
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     W = core._internal_ascontiguousarray(W)
 */
  __pyx_t_7 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1676, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_7;

  /* "cupy/cudnn.pyx":1677
 * 
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     W = core._internal_ascontiguousarray(W)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1677, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1678
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)
 *     W = core._internal_ascontiguousarray(W)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta) check performance
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_W, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1678, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_W, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1681
 * 
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1681, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_7;

  /* "cupy/cudnn.pyx":1682
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1682, __pyx_L1_error)
  __pyx_v_y_desc = __pyx_t_7;

  /* "cupy/cudnn.pyx":1683
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1683, __pyx_L1_error)
  __pyx_v_b_desc = __pyx_t_7;

  /* "cupy/cudnn.pyx":1684
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 * 
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1684, __pyx_L1_error)
  __pyx_v_filter_desc = __pyx_t_7;

  /* "cupy/cudnn.pyx":1685
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t max_workspace_size = get_max_workspace_size()
 */
  __pyx_t_7 = __pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor(0); if (unlikely(__pyx_t_7 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1685, __pyx_L1_error)
  __pyx_v_conv_desc = __pyx_t_7;

  /* "cupy/cudnn.pyx":1687
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 * 
 *     cdef size_t max_workspace_size = get_max_workspace_size()             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] b_shape
 *     cdef _Algorithm perf
 */
  __pyx_v_max_workspace_size = __pyx_f_4cupy_5cudnn_get_max_workspace_size(0);

  /* "cupy/cudnn.pyx":1690
 *     cdef vector.vector[Py_ssize_t] b_shape
 *     cdef _Algorithm perf
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1691
 *     cdef _Algorithm perf
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.format = __pyx_v_d_layout;
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_x_desc, __pyx_v_x, 0, &__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1691, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1692
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(
 */
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.format = __pyx_v_d_layout;
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_y_desc, __pyx_v_y, 0, &__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1692, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1693
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)             # <<<<<<<<<<<<<<
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.format = __pyx_v_w_layout;
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_filter_descriptor(__pyx_v_filter_desc, __pyx_v_W, 0, &__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1693, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1695
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,             # <<<<<<<<<<<<<<
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 */
    __pyx_t_2 = __pyx_v_x->dtype;
    __Pyx_INCREF(__pyx_t_2);

    /* "cupy/cudnn.pyx":1694
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 */
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_convolution_descriptor(__pyx_v_conv_desc, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_t_2, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CROSS_CORRELATION, __pyx_v_use_tensor_core, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1694, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":1698
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if auto_tune:             # <<<<<<<<<<<<<<
 *             perf = _find_algorithm_fwd(
 *                 x, W, y, conv_param, handle, x_desc, filter_desc,
 */
    __pyx_t_5 = (__pyx_v_auto_tune != 0);
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1699
 * 
 *         if auto_tune:
 *             perf = _find_algorithm_fwd(             # <<<<<<<<<<<<<<
 *                 x, W, y, conv_param, handle, x_desc, filter_desc,
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1699, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1698
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if auto_tune:             # <<<<<<<<<<<<<<
 *             perf = _find_algorithm_fwd(
 *                 x, W, y, conv_param, handle, x_desc, filter_desc,
 */
      goto __pyx_L11;
    }

    /* "cupy/cudnn.pyx":1703
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)
 *         else:
 *             perf = _get_algorithm_fwd(             # <<<<<<<<<<<<<<
 *                 x, W, y, conv_param, handle, x_desc, filter_desc,
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)
 */
    /*else*/ {

      /* "cupy/cudnn.pyx":1705
 *             perf = _get_algorithm_fwd(
 *                 x, W, y, conv_param, handle, x_desc, filter_desc,
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)             # <<<<<<<<<<<<<<
 * 
 *         if _cudnn_version >= 7000:
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_fwd(__pyx_v_x, __pyx_v_W, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_filter_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1703, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L11:;

    /* "cupy/cudnn.pyx":1707
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, perf.mathType)
 * 
 */
    __pyx_t_5 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1708
 * 
 *         if _cudnn_version >= 7000:
 *             cudnn.setConvolutionMathType(conv_desc, perf.mathType)             # <<<<<<<<<<<<<<
 * 
 *         workspace = memory.alloc(perf.memory)
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType(__pyx_v_conv_desc, __pyx_v_perf->mathType, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1708, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1707
 *                 conv_desc, y_desc, max_workspace_size, use_tensor_core)
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, perf.mathType)
 * 
 */
    }

    /* "cupy/cudnn.pyx":1710
 *             cudnn.setConvolutionMathType(conv_desc, perf.mathType)
 * 
 *         workspace = memory.alloc(perf.memory)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
    __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_perf->memory); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1710, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_4, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1710, __pyx_L9_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1712
 *         workspace = memory.alloc(perf.memory)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             cudnn.convolutionForward(
 *                 handle, one, x_desc, x.data.ptr, filter_desc, W.data.ptr,
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      /*try:*/ {

        /* "cupy/cudnn.pyx":1713
 * 
 *         try:
 *             cudnn.convolutionForward(             # <<<<<<<<<<<<<<
 *                 handle, one, x_desc, x.data.ptr, filter_desc, W.data.ptr,
 *                 conv_desc, perf.algo, workspace.ptr, perf.memory, zero, y_desc,
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_convolutionForward(__pyx_v_handle, __pyx_v_one, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_conv_desc, __pyx_v_perf->algo, __pyx_v_workspace->ptr, __pyx_v_perf->memory, __pyx_v_zero, __pyx_v_y_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1713, __pyx_L13_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1712
 *         workspace = memory.alloc(perf.memory)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             cudnn.convolutionForward(
 *                 handle, one, x_desc, x.data.ptr, filter_desc, W.data.ptr,
 */
      }
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L18_try_end;
      __pyx_L13_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1717
 *                 conv_desc, perf.algo, workspace.ptr, perf.memory, zero, y_desc,
 *                 y.data.ptr)
 *         except py_cudnn.CuDNNError as e:             # <<<<<<<<<<<<<<
 *             infos = [
 *                 'func: cudnnConvolutionForward',
 */
      __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_4, &__pyx_t_1);
      __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1717, __pyx_L15_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_CuDNNError); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1717, __pyx_L15_except_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_3 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_14);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_ErrRestore(__pyx_t_2, __pyx_t_4, __pyx_t_1);
      __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0;
      if (__pyx_t_3) {
        __Pyx_AddTraceback("cupy.cudnn.convolution_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2) < 0) __PYX_ERR(0, 1717, __pyx_L15_except_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_v_e = __pyx_t_4;
        /*try:*/ {

          /* "cupy/cudnn.pyx":1720
 *             infos = [
 *                 'func: cudnnConvolutionForward',
 *                 'x: {}'.format(_get_array_info(x)),             # <<<<<<<<<<<<<<
 *                 'W: {}'.format(_get_array_info(W)),
 *                 'b: {}'.format(_get_array_info(b)),
 */
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_x_2, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1720, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_get_array_info); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1720, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_17 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_16, function);
            }
          }
          __pyx_t_15 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_17, ((PyObject *)__pyx_v_x)) : __Pyx_PyObject_CallOneArg(__pyx_t_16, ((PyObject *)__pyx_v_x));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1720, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_16 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_13);
            if (likely(__pyx_t_16)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_13, function);
            }
          }
          __pyx_t_14 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_16, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1720, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "cupy/cudnn.pyx":1721
 *                 'func: cudnnConvolutionForward',
 *                 'x: {}'.format(_get_array_info(x)),
 *                 'W: {}'.format(_get_array_info(W)),             # <<<<<<<<<<<<<<
 *                 'b: {}'.format(_get_array_info(b)),
 *                 'y: {}'.format(_get_array_info(y)),
 */
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_W_2, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1721, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_get_array_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1721, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
            }
          }
          __pyx_t_16 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_18, ((PyObject *)__pyx_v_W)) : __Pyx_PyObject_CallOneArg(__pyx_t_17, ((PyObject *)__pyx_v_W));
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1721, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_17 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_15, function);
            }
          }
          __pyx_t_13 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_17, __pyx_t_16) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_16);
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1721, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

          /* "cupy/cudnn.pyx":1722
 *                 'x: {}'.format(_get_array_info(x)),
 *                 'W: {}'.format(_get_array_info(W)),
 *                 'b: {}'.format(_get_array_info(b)),             # <<<<<<<<<<<<<<
 *                 'y: {}'.format(_get_array_info(y)),
 *                 'pad={!r}, stride={!r}, dilation={!r}, groups={!r}'.format(
 */
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_b_2, __pyx_n_s_format); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1722, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_get_array_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1722, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
            if (likely(__pyx_t_19)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_18, function);
            }
          }
          __pyx_t_17 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_19, ((PyObject *)__pyx_v_b)) : __Pyx_PyObject_CallOneArg(__pyx_t_18, ((PyObject *)__pyx_v_b));
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1722, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_18 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_16);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_16, function);
            }
          }
          __pyx_t_15 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_18, __pyx_t_17) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1722, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "cupy/cudnn.pyx":1723
 *                 'W: {}'.format(_get_array_info(W)),
 *                 'b: {}'.format(_get_array_info(b)),
 *                 'y: {}'.format(_get_array_info(y)),             # <<<<<<<<<<<<<<
 *                 'pad={!r}, stride={!r}, dilation={!r}, groups={!r}'.format(
 *                     pad, stride, dilation, groups),
 */
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_y_2, __pyx_n_s_format); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1723, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_get_array_info); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1723, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_19);
            if (likely(__pyx_t_20)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
              __Pyx_INCREF(__pyx_t_20);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_19, function);
            }
          }
          __pyx_t_18 = (__pyx_t_20) ? __Pyx_PyObject_Call2Args(__pyx_t_19, __pyx_t_20, ((PyObject *)__pyx_v_y)) : __Pyx_PyObject_CallOneArg(__pyx_t_19, ((PyObject *)__pyx_v_y));
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1723, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_19 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_19)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
            }
          }
          __pyx_t_16 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_19, __pyx_t_18) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_18);
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1723, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "cupy/cudnn.pyx":1724
 *                 'b: {}'.format(_get_array_info(b)),
 *                 'y: {}'.format(_get_array_info(y)),
 *                 'pad={!r}, stride={!r}, dilation={!r}, groups={!r}'.format(             # <<<<<<<<<<<<<<
 *                     pad, stride, dilation, groups),
 *                 'auto_tune={!r}, tensor_core={!r}'.format(
 */
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_pad_r_stride_r_dilation_r_groups, __pyx_n_s_format); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1724, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_18);

          /* "cupy/cudnn.pyx":1725
 *                 'y: {}'.format(_get_array_info(y)),
 *                 'pad={!r}, stride={!r}, dilation={!r}, groups={!r}'.format(
 *                     pad, stride, dilation, groups),             # <<<<<<<<<<<<<<
 *                 'auto_tune={!r}, tensor_core={!r}'.format(
 *                     auto_tune, tensor_core),
 */
          __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_groups); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1725, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = NULL;
          __pyx_t_3 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_18))) {
            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_18);
            if (likely(__pyx_t_20)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
              __Pyx_INCREF(__pyx_t_20);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_18, function);
              __pyx_t_3 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_18)) {
            PyObject *__pyx_temp[5] = {__pyx_t_20, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_t_19};
            __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_3, 4+__pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1724, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_18)) {
            PyObject *__pyx_temp[5] = {__pyx_t_20, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_t_19};
            __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_18, __pyx_temp+1-__pyx_t_3, 4+__pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1724, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          {
            __pyx_t_21 = PyTuple_New(4+__pyx_t_3); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1724, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_21);
            if (__pyx_t_20) {
              __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL;
            }
            __Pyx_INCREF(__pyx_v_pad);
            __Pyx_GIVEREF(__pyx_v_pad);
            PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_3, __pyx_v_pad);
            __Pyx_INCREF(__pyx_v_stride);
            __Pyx_GIVEREF(__pyx_v_stride);
            PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_3, __pyx_v_stride);
            __Pyx_INCREF(__pyx_v_dilation);
            __Pyx_GIVEREF(__pyx_v_dilation);
            PyTuple_SET_ITEM(__pyx_t_21, 2+__pyx_t_3, __pyx_v_dilation);
            __Pyx_GIVEREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_21, 3+__pyx_t_3, __pyx_t_19);
            __pyx_t_19 = 0;
            __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_21, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1724, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "cupy/cudnn.pyx":1726
 *                 'pad={!r}, stride={!r}, dilation={!r}, groups={!r}'.format(
 *                     pad, stride, dilation, groups),
 *                 'auto_tune={!r}, tensor_core={!r}'.format(             # <<<<<<<<<<<<<<
 *                     auto_tune, tensor_core),
 *                 'd_layout={!r}, w_layout={!r}'.format(d_layout, w_layout),
 */
          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_auto_tune_r_tensor_core_r, __pyx_n_s_format); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1726, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_21);

          /* "cupy/cudnn.pyx":1727
 *                     pad, stride, dilation, groups),
 *                 'auto_tune={!r}, tensor_core={!r}'.format(
 *                     auto_tune, tensor_core),             # <<<<<<<<<<<<<<
 *                 'd_layout={!r}, w_layout={!r}'.format(d_layout, w_layout),
 *             ]
 */
          __pyx_t_19 = __Pyx_PyBool_FromLong(__pyx_v_auto_tune); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1727, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = NULL;
          __pyx_t_3 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_21))) {
            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
            if (likely(__pyx_t_20)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21);
              __Pyx_INCREF(__pyx_t_20);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_21, function);
              __pyx_t_3 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_21)) {
            PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_19, __pyx_v_tensor_core};
            __pyx_t_18 = __Pyx_PyFunction_FastCall(__pyx_t_21, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1726, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_21)) {
            PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_19, __pyx_v_tensor_core};
            __pyx_t_18 = __Pyx_PyCFunction_FastCall(__pyx_t_21, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1726, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          {
            __pyx_t_22 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1726, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_22);
            if (__pyx_t_20) {
              __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_20); __pyx_t_20 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_3, __pyx_t_19);
            __Pyx_INCREF(__pyx_v_tensor_core);
            __Pyx_GIVEREF(__pyx_v_tensor_core);
            PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_3, __pyx_v_tensor_core);
            __pyx_t_19 = 0;
            __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_22, NULL); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1726, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
          }
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

          /* "cupy/cudnn.pyx":1728
 *                 'auto_tune={!r}, tensor_core={!r}'.format(
 *                     auto_tune, tensor_core),
 *                 'd_layout={!r}, w_layout={!r}'.format(d_layout, w_layout),             # <<<<<<<<<<<<<<
 *             ]
 *             e.add_infos(infos)
 */
          __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_d_layout_r_w_layout_r, __pyx_n_s_format); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1728, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_22);
          __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_d_layout); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1728, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_w_layout); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1728, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_23 = NULL;
          __pyx_t_3 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_22))) {
            __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_22);
            if (likely(__pyx_t_23)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_22, function);
              __pyx_t_3 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_22)) {
            PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_19, __pyx_t_20};
            __pyx_t_21 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1728, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_GOTREF(__pyx_t_21);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
            PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_19, __pyx_t_20};
            __pyx_t_21 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1728, __pyx_L24_error)
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_GOTREF(__pyx_t_21);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          } else
          #endif
          {
            __pyx_t_24 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 1728, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_24);
            if (__pyx_t_23) {
              __Pyx_GIVEREF(__pyx_t_23); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_23); __pyx_t_23 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_3, __pyx_t_19);
            __Pyx_GIVEREF(__pyx_t_20);
            PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_3, __pyx_t_20);
            __pyx_t_19 = 0;
            __pyx_t_20 = 0;
            __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_24, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1728, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_21);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          }
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

          /* "cupy/cudnn.pyx":1718
 *                 y.data.ptr)
 *         except py_cudnn.CuDNNError as e:
 *             infos = [             # <<<<<<<<<<<<<<
 *                 'func: cudnnConvolutionForward',
 *                 'x: {}'.format(_get_array_info(x)),
 */
          __pyx_t_22 = PyList_New(8); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1718, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_22);
          __Pyx_INCREF(__pyx_kp_u_func_cudnnConvolutionForward);
          __Pyx_GIVEREF(__pyx_kp_u_func_cudnnConvolutionForward);
          PyList_SET_ITEM(__pyx_t_22, 0, __pyx_kp_u_func_cudnnConvolutionForward);
          __Pyx_GIVEREF(__pyx_t_14);
          PyList_SET_ITEM(__pyx_t_22, 1, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_13);
          PyList_SET_ITEM(__pyx_t_22, 2, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_15);
          PyList_SET_ITEM(__pyx_t_22, 3, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_16);
          PyList_SET_ITEM(__pyx_t_22, 4, __pyx_t_16);
          __Pyx_GIVEREF(__pyx_t_17);
          PyList_SET_ITEM(__pyx_t_22, 5, __pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_18);
          PyList_SET_ITEM(__pyx_t_22, 6, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_21);
          PyList_SET_ITEM(__pyx_t_22, 7, __pyx_t_21);
          __pyx_t_14 = 0;
          __pyx_t_13 = 0;
          __pyx_t_15 = 0;
          __pyx_t_16 = 0;
          __pyx_t_17 = 0;
          __pyx_t_18 = 0;
          __pyx_t_21 = 0;
          __pyx_v_infos = ((PyObject*)__pyx_t_22);
          __pyx_t_22 = 0;

          /* "cupy/cudnn.pyx":1730
 *                 'd_layout={!r}, w_layout={!r}'.format(d_layout, w_layout),
 *             ]
 *             e.add_infos(infos)             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_add_infos); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1730, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_21);
          __pyx_t_18 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_21))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_21);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_21, function);
            }
          }
          __pyx_t_22 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_21, __pyx_t_18, __pyx_v_infos) : __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_v_infos);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1730, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_22);
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

          /* "cupy/cudnn.pyx":1731
 *             ]
 *             e.add_infos(infos)
 *             raise             # <<<<<<<<<<<<<<
 * 
 *         del workspace, x, W
 */
          __Pyx_GIVEREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_4);
          __Pyx_XGIVEREF(__pyx_t_2);
          __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_2);
          __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_2 = 0; 
          __PYX_ERR(0, 1731, __pyx_L24_error)
        }

        /* "cupy/cudnn.pyx":1717
 *                 conv_desc, perf.algo, workspace.ptr, perf.memory, zero, y_desc,
 *                 y.data.ptr)
 *         except py_cudnn.CuDNNError as e:             # <<<<<<<<<<<<<<
 *             infos = [
 *                 'func: cudnnConvolutionForward',
 */
        /*finally:*/ {
          __pyx_L24_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __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_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
            if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
            __Pyx_XGOTREF(__pyx_t_27);
            __Pyx_XGOTREF(__pyx_t_28);
            __Pyx_XGOTREF(__pyx_t_29);
            __Pyx_XGOTREF(__pyx_t_30);
            __Pyx_XGOTREF(__pyx_t_31);
            __Pyx_XGOTREF(__pyx_t_32);
            __pyx_t_3 = __pyx_lineno; __pyx_t_25 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
            {
              __Pyx_DECREF(__pyx_v_e);
              __pyx_v_e = NULL;
            }
            if (PY_MAJOR_VERSION >= 3) {
              __Pyx_XGIVEREF(__pyx_t_30);
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_XGIVEREF(__pyx_t_32);
              __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
            }
            __Pyx_XGIVEREF(__pyx_t_27);
            __Pyx_XGIVEREF(__pyx_t_28);
            __Pyx_XGIVEREF(__pyx_t_29);
            __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29);
            __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
            __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_25; __pyx_filename = __pyx_t_26;
            goto __pyx_L15_except_error;
          }
        }
      }
      goto __pyx_L15_except_error;
      __pyx_L15_except_error:;

      /* "cupy/cudnn.pyx":1712
 *         workspace = memory.alloc(perf.memory)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             cudnn.convolutionForward(
 *                 handle, one, x_desc, x.data.ptr, filter_desc, W.data.ptr,
 */
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      goto __pyx_L9_error;
      __pyx_L18_try_end:;
    }

    /* "cupy/cudnn.pyx":1733
 *             raise
 * 
 *         del workspace, x, W             # <<<<<<<<<<<<<<
 * 
 *         if b is not None:
 */
    __Pyx_DECREF(((PyObject *)__pyx_v_workspace));
    __pyx_v_workspace = NULL;
    __Pyx_DECREF(((PyObject *)__pyx_v_x));
    __pyx_v_x = NULL;
    __Pyx_DECREF(((PyObject *)__pyx_v_W));
    __pyx_v_W = NULL;

    /* "cupy/cudnn.pyx":1735
 *         del workspace, x, W
 * 
 *         if b is not None:             # <<<<<<<<<<<<<<
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 */
    __pyx_t_5 = (((PyObject *)__pyx_v_b) != Py_None);
    __pyx_t_33 = (__pyx_t_5 != 0);
    if (__pyx_t_33) {

      /* "cupy/cudnn.pyx":1736
 * 
 *         if b is not None:
 *             assert dev_id == b.data.device.id             # <<<<<<<<<<<<<<
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1736, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b->data), __pyx_n_s_device); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1736, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1736, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1736, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_33 < 0)) __PYX_ERR(0, 1736, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_33)) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 1736, __pyx_L9_error)
        }
      }
      #endif

      /* "cupy/cudnn.pyx":1737
 *         if b is not None:
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)             # <<<<<<<<<<<<<<
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(
 */
      __pyx_v_b_shape.assign(__pyx_v_y->_shape.size(), 1);

      /* "cupy/cudnn.pyx":1738
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1             # <<<<<<<<<<<<<<
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)
 */
      (__pyx_v_b_shape[1]) = -1L;

      /* "cupy/cudnn.pyx":1740
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)             # <<<<<<<<<<<<<<
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 *             cudnn.addTensor_v3(handle, one, b_desc,
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_b, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1740, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_4);

      /* "cupy/cudnn.pyx":1739
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(             # <<<<<<<<<<<<<<
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 */
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4), __pyx_v_b_shape, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1739, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1741
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)             # <<<<<<<<<<<<<<
 *             cudnn.addTensor_v3(handle, one, b_desc,
 *                                b.data.ptr, one, y_desc, y.data.ptr)
 */
      __pyx_t_34.__pyx_n = 1;
      __pyx_t_34.data_type = -1;
      __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_b_desc, __pyx_v_b, 0, &__pyx_t_34); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1741, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1742
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 *             cudnn.addTensor_v3(handle, one, b_desc,             # <<<<<<<<<<<<<<
 *                                b.data.ptr, one, y_desc, y.data.ptr)
 *     finally:
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_addTensor_v3(__pyx_v_handle, __pyx_v_one, __pyx_v_b_desc, __pyx_v_b->data->ptr, __pyx_v_one, __pyx_v_y_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1735
 *         del workspace, x, W
 * 
 *         if b is not None:             # <<<<<<<<<<<<<<
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 */
    }
  }

  /* "cupy/cudnn.pyx":1745
 *                                b.data.ptr, one, y_desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1745, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1746
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1747
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_b_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1748
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1749
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L10;
    }
    __pyx_L9_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __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_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_32);
      __Pyx_XGOTREF(__pyx_t_31);
      __Pyx_XGOTREF(__pyx_t_30);
      __pyx_t_25 = __pyx_lineno; __pyx_t_3 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":1745
 *                                b.data.ptr, one, y_desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1745, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1746
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1746, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1747
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_b_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1747, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1748
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1748, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1749
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1749, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_32);
        __Pyx_XGIVEREF(__pyx_t_31);
        __Pyx_XGIVEREF(__pyx_t_30);
        __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_31, __pyx_t_30);
      }
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
      __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0;
      __pyx_lineno = __pyx_t_25; __pyx_clineno = __pyx_t_3; __pyx_filename = __pyx_t_35;
      goto __pyx_L1_error;
      __pyx_L32_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_32);
        __Pyx_XGIVEREF(__pyx_t_31);
        __Pyx_XGIVEREF(__pyx_t_30);
        __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_31, __pyx_t_30);
      }
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L10:;
  }

  /* "cupy/cudnn.pyx":1645
 * 
 * 
 * def convolution_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

  /* 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_4);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_AddTraceback("cupy.cudnn.convolution_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conv_param);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_infos);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_W);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1752
 * 
 * 
 * def convolution_backward_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gy, core.ndarray gW,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_115convolution_backward_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_114convolution_backward_filter[] = "convolution_backward_filter(ndarray x, ndarray gy, ndarray gW, tuple pad, tuple stride, tuple dilation, int groups, *, bool deterministic, bool auto_tune, tensor_core, int d_layout=cudnn.CUDNN_TENSOR_NCHW, int w_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_115convolution_backward_filter = {"convolution_backward_filter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_115convolution_backward_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_114convolution_backward_filter};
static PyObject *__pyx_pw_4cupy_5cudnn_115convolution_backward_filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gW = 0;
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_dilation = 0;
  int __pyx_v_groups;
  int __pyx_v_deterministic;
  int __pyx_v_auto_tune;
  PyObject *__pyx_v_tensor_core = 0;
  int __pyx_v_d_layout;
  int __pyx_v_w_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convolution_backward_filter (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_gy,&__pyx_n_s_gW,&__pyx_n_s_pad,&__pyx_n_s_stride,&__pyx_n_s_dilation,&__pyx_n_s_groups,&__pyx_n_s_deterministic,&__pyx_n_s_auto_tune,&__pyx_n_s_tensor_core,&__pyx_n_s_d_layout,&__pyx_n_s_w_layout,0};
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 1); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gW)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 2); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 3); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 4); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dilation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 5); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_groups)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, 6); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_filter", __pyx_n_s_deterministic); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_auto_tune)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_filter", __pyx_n_s_auto_tune); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_filter", __pyx_n_s_tensor_core); __PYX_ERR(0, 1752, __pyx_L3_error)
        }
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 10; index < 12 && kw_args > 0; index++) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "convolution_backward_filter") < 0)) __PYX_ERR(0, 1752, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("convolution_backward_filter", __pyx_n_s_deterministic); __PYX_ERR(0, 1752, __pyx_L3_error)
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_gW = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_pad = ((PyObject*)values[3]);
    __pyx_v_stride = ((PyObject*)values[4]);
    __pyx_v_dilation = ((PyObject*)values[5]);
    __pyx_v_groups = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_groups == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1754, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1755, __pyx_L3_error)
    __pyx_v_auto_tune = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_auto_tune == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1755, __pyx_L3_error)
    __pyx_v_tensor_core = values[9];
    if (values[10]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1756, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__22;
    }
    if (values[11]) {
      __pyx_v_w_layout = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_w_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1757, __pyx_L3_error)
    } else {
      __pyx_v_w_layout = __pyx_k__23;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("convolution_backward_filter", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1752, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.convolution_backward_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1753, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gy", 0))) __PYX_ERR(0, 1753, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gW), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gW", 0))) __PYX_ERR(0, 1753, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 1754, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 1754, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dilation), (&PyTuple_Type), 1, "dilation", 1))) __PYX_ERR(0, 1754, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_114convolution_backward_filter(__pyx_self, __pyx_v_x, __pyx_v_gy, __pyx_v_gW, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_v_deterministic, __pyx_v_auto_tune, __pyx_v_tensor_core, __pyx_v_d_layout, __pyx_v_w_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_114convolution_backward_filter(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gW, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_deterministic, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout) {
  int __pyx_v_dev_id;
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  int __pyx_v_use_tensor_core;
  PyObject *__pyx_v_conv_param = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_gy_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_conv_desc;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_perf = 0;
  int __pyx_v_algo;
  size_t __pyx_v_max_workspace_size;
  size_t __pyx_v_workspace_size;
  int __pyx_v_math_type;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  size_t __pyx_t_8;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_9;
  struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  char const *__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("convolution_backward_filter", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_gy);

  /* "cupy/cudnn.pyx":1758
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == gy.data.device.id
 *     assert dev_id == gW.data.device.id
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1758, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dev_id = __pyx_t_3;

  /* "cupy/cudnn.pyx":1759
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == gy.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == gW.data.device.id
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_gy->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1759, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1759, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1760
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == gy.data.device.id
 *     assert dev_id == gW.data.device.id             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_zero = 0, float_one = 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_gW->data), __pyx_n_s_device); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1760, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1762
 *     assert dev_id == gW.data.device.id
 * 
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":1763
 * 
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":1765
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1765, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":1766
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":1767
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":1765
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1769
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":1770
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     # Disable use_tensor_core in deterministic mode because
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1775
 *     # CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 does not use Tensor Core.
 *     cdef bint use_tensor_core = (
 *         not deterministic and _should_use_tensor_core(tensor_core, x.dtype))             # <<<<<<<<<<<<<<
 *     cdef tuple conv_param = (
 *         pad, stride, x.dtype, use_tensor_core, deterministic)
 */
  __pyx_t_6 = ((!(__pyx_v_deterministic != 0)) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_6 = __pyx_f_4cupy_5cudnn__should_use_tensor_core(__pyx_v_tensor_core, __pyx_t_4, 0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1775, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_5 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  __pyx_v_use_tensor_core = __pyx_t_5;

  /* "cupy/cudnn.pyx":1777
 *         not deterministic and _should_use_tensor_core(tensor_core, x.dtype))
 *     cdef tuple conv_param = (
 *         pad, stride, x.dtype, use_tensor_core, deterministic)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_tensor_core); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_deterministic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_pad);
  __Pyx_GIVEREF(__pyx_v_pad);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pad);
  __Pyx_INCREF(__pyx_v_stride);
  __Pyx_GIVEREF(__pyx_v_stride);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_stride);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_v_conv_param = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1779
 *         pad, stride, x.dtype, use_tensor_core, deterministic)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     gy = core._internal_ascontiguousarray(gy)
 */
  __pyx_t_8 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1779, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_8;

  /* "cupy/cudnn.pyx":1780
 * 
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1781
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)
 *     gy = core._internal_ascontiguousarray(gy)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta) check performance
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_gy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1784
 * 
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t gy_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1784, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_8;

  /* "cupy/cudnn.pyx":1785
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t gy_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L1_error)
  __pyx_v_gy_desc = __pyx_t_8;

  /* "cupy/cudnn.pyx":1786
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t gy_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 * 
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1786, __pyx_L1_error)
  __pyx_v_filter_desc = __pyx_t_8;

  /* "cupy/cudnn.pyx":1787
 *     cdef size_t gy_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()             # <<<<<<<<<<<<<<
 * 
 *     cdef _Algorithm perf
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor(0); if (unlikely(__pyx_t_8 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1787, __pyx_L1_error)
  __pyx_v_conv_desc = __pyx_t_8;

  /* "cupy/cudnn.pyx":1791
 *     cdef _Algorithm perf
 *     cdef int algo
 *     cdef size_t max_workspace_size = get_max_workspace_size()             # <<<<<<<<<<<<<<
 *     cdef size_t workspace_size = 0
 *     try:
 */
  __pyx_v_max_workspace_size = __pyx_f_4cupy_5cudnn_get_max_workspace_size(0);

  /* "cupy/cudnn.pyx":1792
 *     cdef int algo
 *     cdef size_t max_workspace_size = get_max_workspace_size()
 *     cdef size_t workspace_size = 0             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 */
  __pyx_v_workspace_size = 0;

  /* "cupy/cudnn.pyx":1793
 *     cdef size_t max_workspace_size = get_max_workspace_size()
 *     cdef size_t workspace_size = 0
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(gy_desc, gy, format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1794
 *     cdef size_t workspace_size = 0
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(gy_desc, gy, format=d_layout)
 *         _create_filter_descriptor(filter_desc, gW, w_layout)
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_x_desc, __pyx_v_x, 0, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1794, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1795
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(gy_desc, gy, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_filter_descriptor(filter_desc, gW, w_layout)
 *         _create_convolution_descriptor(
 */
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_gy_desc, __pyx_v_gy, 0, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1795, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1796
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(gy_desc, gy, format=d_layout)
 *         _create_filter_descriptor(filter_desc, gW, w_layout)             # <<<<<<<<<<<<<<
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 */
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.format = __pyx_v_w_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_filter_descriptor(__pyx_v_filter_desc, __pyx_v_gW, 0, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1796, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1798
 *         _create_filter_descriptor(filter_desc, gW, w_layout)
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,             # <<<<<<<<<<<<<<
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 */
    __pyx_t_1 = __pyx_v_x->dtype;
    __Pyx_INCREF(__pyx_t_1);

    /* "cupy/cudnn.pyx":1797
 *         _create_tensor_descriptor(gy_desc, gy, format=d_layout)
 *         _create_filter_descriptor(filter_desc, gW, w_layout)
 *         _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_convolution_descriptor(__pyx_v_conv_desc, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_t_1, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CROSS_CORRELATION, __pyx_v_use_tensor_core, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1797, __pyx_L7_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/cudnn.pyx":1801
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if deterministic and _cudnn_version < 7000:             # <<<<<<<<<<<<<<
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1
 */
    __pyx_t_7 = (__pyx_v_deterministic != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_5 = __pyx_t_7;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_4cupy_5cudnn__cudnn_version < 0x1B58) != 0);
    __pyx_t_5 = __pyx_t_7;
    __pyx_L10_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1803
 *         if deterministic and _cudnn_version < 7000:
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1             # <<<<<<<<<<<<<<
 *             workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(
 *                 handle, x_desc, gy_desc, conv_desc, filter_desc, algo)
 */
      __pyx_v_algo = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1;

      /* "cupy/cudnn.pyx":1804
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1
 *             workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(             # <<<<<<<<<<<<<<
 *                 handle, x_desc, gy_desc, conv_desc, filter_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 */
      __pyx_t_11 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterWorkspaceSize(__pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_algo, 0); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1804, __pyx_L7_error)
      __pyx_v_workspace_size = __pyx_t_11;

      /* "cupy/cudnn.pyx":1806
 *             workspace_size = cudnn.getConvolutionBackwardFilterWorkspaceSize(
 *                 handle, x_desc, gy_desc, conv_desc, filter_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH             # <<<<<<<<<<<<<<
 *             if workspace_size > max_workspace_size:
 *                 raise RuntimeError(
 */
      __pyx_v_math_type = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DEFAULT_MATH;

      /* "cupy/cudnn.pyx":1807
 *                 handle, x_desc, gy_desc, conv_desc, filter_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'No conv bwd filter algo available with workspace size '
 */
      __pyx_t_5 = ((__pyx_v_workspace_size > __pyx_v_max_workspace_size) != 0);
      if (unlikely(__pyx_t_5)) {

        /* "cupy/cudnn.pyx":1810
 *                 raise RuntimeError(
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         else:
 *             if auto_tune and not deterministic:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_filter_algo_availabl, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1810, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1810, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1810, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1808
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'No conv bwd filter algo available with workspace size '
 *                     'less equal {}'.format(max_workspace_size))
 */
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1808, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 1808, __pyx_L7_error)

        /* "cupy/cudnn.pyx":1807
 *                 handle, x_desc, gy_desc, conv_desc, filter_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'No conv bwd filter algo available with workspace size '
 */
      }

      /* "cupy/cudnn.pyx":1801
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if deterministic and _cudnn_version < 7000:             # <<<<<<<<<<<<<<
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1
 */
      goto __pyx_L9;
    }

    /* "cupy/cudnn.pyx":1812
 *                     'less equal {}'.format(max_workspace_size))
 *         else:
 *             if auto_tune and not deterministic:             # <<<<<<<<<<<<<<
 *                 perf = _find_algorithm_bwd_filter(
 *                     x, gy, gW, conv_param, handle, x_desc, gy_desc, conv_desc,
 */
    /*else*/ {
      __pyx_t_7 = (__pyx_v_auto_tune != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_5 = __pyx_t_7;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_7 = ((!(__pyx_v_deterministic != 0)) != 0);
      __pyx_t_5 = __pyx_t_7;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_5) {

        /* "cupy/cudnn.pyx":1813
 *         else:
 *             if auto_tune and not deterministic:
 *                 perf = _find_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *                     x, gy, gW, conv_param, handle, x_desc, gy_desc, conv_desc,
 *                     filter_desc, max_workspace_size, use_tensor_core,
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_bwd_filter(__pyx_v_x, __pyx_v_gy, __pyx_v_gW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1812
 *                     'less equal {}'.format(max_workspace_size))
 *         else:
 *             if auto_tune and not deterministic:             # <<<<<<<<<<<<<<
 *                 perf = _find_algorithm_bwd_filter(
 *                     x, gy, gW, conv_param, handle, x_desc, gy_desc, conv_desc,
 */
        goto __pyx_L13;
      }

      /* "cupy/cudnn.pyx":1818
 *                     deterministic)
 *             else:
 *                 perf = _get_algorithm_bwd_filter(             # <<<<<<<<<<<<<<
 *                     x, gy, gW, conv_param, handle, x_desc, gy_desc, conv_desc,
 *                     filter_desc, max_workspace_size, use_tensor_core,
 */
      /*else*/ {

        /* "cupy/cudnn.pyx":1821
 *                     x, gy, gW, conv_param, handle, x_desc, gy_desc, conv_desc,
 *                     filter_desc, max_workspace_size, use_tensor_core,
 *                     deterministic)             # <<<<<<<<<<<<<<
 *             algo = perf.algo
 *             workspace_size = perf.memory
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_bwd_filter(__pyx_v_x, __pyx_v_gy, __pyx_v_gW, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_x_desc, __pyx_v_gy_desc, __pyx_v_conv_desc, __pyx_v_filter_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1818, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_1);
        __pyx_t_1 = 0;
      }
      __pyx_L13:;

      /* "cupy/cudnn.pyx":1822
 *                     filter_desc, max_workspace_size, use_tensor_core,
 *                     deterministic)
 *             algo = perf.algo             # <<<<<<<<<<<<<<
 *             workspace_size = perf.memory
 *             math_type = perf.mathType
 */
      __pyx_t_3 = __pyx_v_perf->algo;
      __pyx_v_algo = __pyx_t_3;

      /* "cupy/cudnn.pyx":1823
 *                     deterministic)
 *             algo = perf.algo
 *             workspace_size = perf.memory             # <<<<<<<<<<<<<<
 *             math_type = perf.mathType
 * 
 */
      __pyx_t_8 = __pyx_v_perf->memory;
      __pyx_v_workspace_size = __pyx_t_8;

      /* "cupy/cudnn.pyx":1824
 *             algo = perf.algo
 *             workspace_size = perf.memory
 *             math_type = perf.mathType             # <<<<<<<<<<<<<<
 * 
 *         if _cudnn_version >= 7000:
 */
      __pyx_t_3 = __pyx_v_perf->mathType;
      __pyx_v_math_type = __pyx_t_3;
    }
    __pyx_L9:;

    /* "cupy/cudnn.pyx":1826
 *             math_type = perf.mathType
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 */
    __pyx_t_5 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1827
 * 
 *         if _cudnn_version >= 7000:
 *             cudnn.setConvolutionMathType(conv_desc, math_type)             # <<<<<<<<<<<<<<
 * 
 *         workspace = memory.alloc(workspace_size)
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType(__pyx_v_conv_desc, __pyx_v_math_type, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1827, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1826
 *             math_type = perf.mathType
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 */
    }

    /* "cupy/cudnn.pyx":1829
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 *         workspace = memory.alloc(workspace_size)             # <<<<<<<<<<<<<<
 * 
 *         cudnn.convolutionBackwardFilter_v3(
 */
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1829, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_1, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1829, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1831
 *         workspace = memory.alloc(workspace_size)
 * 
 *         cudnn.convolutionBackwardFilter_v3(             # <<<<<<<<<<<<<<
 *             handle, one, x_desc, x.data.ptr, gy_desc,
 *             gy.data.ptr, conv_desc, algo, workspace.ptr,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardFilter_v3(__pyx_v_handle, __pyx_v_one, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_gy_desc, __pyx_v_gy->data->ptr, __pyx_v_conv_desc, __pyx_v_algo, __pyx_v_workspace->ptr, __pyx_v_workspace_size, __pyx_v_zero, __pyx_v_filter_desc, __pyx_v_gW->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1831, __pyx_L7_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":1836
 *             workspace_size, zero, filter_desc, gW.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1837
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(gy_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_gy_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1838
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1838, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1839
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1839, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L8;
    }
    __pyx_L7_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
      __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_XGOTREF(__pyx_t_20);
      __pyx_t_3 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":1836
 *             workspace_size, zero, filter_desc, gW.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1836, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1837
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(gy_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_gy_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1837, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1838
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1838, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1839
 *         cudnn.destroyTensorDescriptor(gy_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1839, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
      __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
      goto __pyx_L1_error;
      __pyx_L18_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      }
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L8:;
  }

  /* "cupy/cudnn.pyx":1752
 * 
 * 
 * def convolution_backward_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gy, core.ndarray gW,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

  /* 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_4);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.convolution_backward_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conv_param);
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_gy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1842
 * 
 * 
 * def convolution_backward_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_117convolution_backward_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_116convolution_backward_data[] = "convolution_backward_data(ndarray W, ndarray x, ndarray b, ndarray y, tuple pad, tuple stride, tuple dilation, int groups, *, bool deterministic, bool auto_tune, tensor_core, int d_layout=cudnn.CUDNN_TENSOR_NCHW, int w_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_117convolution_backward_data = {"convolution_backward_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_117convolution_backward_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_116convolution_backward_data};
static PyObject *__pyx_pw_4cupy_5cudnn_117convolution_backward_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_dilation = 0;
  int __pyx_v_groups;
  int __pyx_v_deterministic;
  int __pyx_v_auto_tune;
  PyObject *__pyx_v_tensor_core = 0;
  int __pyx_v_d_layout;
  int __pyx_v_w_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("convolution_backward_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_W,&__pyx_n_s_x,&__pyx_n_s_b,&__pyx_n_s_y,&__pyx_n_s_pad,&__pyx_n_s_stride,&__pyx_n_s_dilation,&__pyx_n_s_groups,&__pyx_n_s_deterministic,&__pyx_n_s_auto_tune,&__pyx_n_s_tensor_core,&__pyx_n_s_d_layout,&__pyx_n_s_w_layout,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (likely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_W)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 1); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 2); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 3); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 4); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 5); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dilation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 6); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_groups)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, 7); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deterministic)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_data", __pyx_n_s_deterministic); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_auto_tune)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_data", __pyx_n_s_auto_tune); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tensor_core)) != 0)) kw_args--;
        else {
          __Pyx_RaiseKeywordRequired("convolution_backward_data", __pyx_n_s_tensor_core); __PYX_ERR(0, 1842, __pyx_L3_error)
        }
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 11; index < 13 && kw_args > 0; index++) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
          if (value) { values[index] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "convolution_backward_data") < 0)) __PYX_ERR(0, 1842, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      goto __pyx_L5_argtuple_error;
    } else {
      __Pyx_RaiseKeywordRequired("convolution_backward_data", __pyx_n_s_deterministic); __PYX_ERR(0, 1842, __pyx_L3_error)
    }
    __pyx_v_W = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_b = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_pad = ((PyObject*)values[4]);
    __pyx_v_stride = ((PyObject*)values[5]);
    __pyx_v_dilation = ((PyObject*)values[6]);
    __pyx_v_groups = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_groups == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1844, __pyx_L3_error)
    __pyx_v_deterministic = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_deterministic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1845, __pyx_L3_error)
    __pyx_v_auto_tune = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_auto_tune == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1845, __pyx_L3_error)
    __pyx_v_tensor_core = values[10];
    if (values[11]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1846, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__24;
    }
    if (values[12]) {
      __pyx_v_w_layout = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_w_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1847, __pyx_L3_error)
    } else {
      __pyx_v_w_layout = __pyx_k__25;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("convolution_backward_data", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1842, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.convolution_backward_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_W), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "W", 0))) __PYX_ERR(0, 1843, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1843, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "b", 0))) __PYX_ERR(0, 1843, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1843, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 1844, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 1844, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dilation), (&PyTuple_Type), 1, "dilation", 1))) __PYX_ERR(0, 1844, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_116convolution_backward_data(__pyx_self, __pyx_v_W, __pyx_v_x, __pyx_v_b, __pyx_v_y, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_v_deterministic, __pyx_v_auto_tune, __pyx_v_tensor_core, __pyx_v_d_layout, __pyx_v_w_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_116convolution_backward_data(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_W, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_b, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_pad, PyObject *__pyx_v_stride, PyObject *__pyx_v_dilation, int __pyx_v_groups, int __pyx_v_deterministic, int __pyx_v_auto_tune, PyObject *__pyx_v_tensor_core, int __pyx_v_d_layout, int __pyx_v_w_layout) {
  int __pyx_v_dev_id;
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  int __pyx_v_use_tensor_core;
  PyObject *__pyx_v_conv_param = 0;
  PyObject *__pyx_v_i = NULL;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_b_desc;
  size_t __pyx_v_filter_desc;
  size_t __pyx_v_conv_desc;
  struct __pyx_obj_4cupy_5cudnn__Algorithm *__pyx_v_perf = 0;
  int __pyx_v_algo;
  size_t __pyx_v_max_workspace_size;
  size_t __pyx_v_workspace_size;
  std::vector<Py_ssize_t>  __pyx_v_b_shape;
  int __pyx_v_math_type;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_10;
  struct __pyx_opt_args_4cupy_5cudnn__create_filter_descriptor __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_nd_descriptor __pyx_t_13;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convolution_backward_data", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_W);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_b);

  /* "cupy/cudnn.pyx":1848
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = W.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == x.data.device.id
 *     assert dev_id == y.data.device.id
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_W->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1848, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dev_id = __pyx_t_3;

  /* "cupy/cudnn.pyx":1849
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = W.data.device.id
 *     assert dev_id == x.data.device.id             # <<<<<<<<<<<<<<
 *     assert dev_id == y.data.device.id
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1849, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1849, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1849, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1849, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1850
 *     cdef int dev_id = W.data.device.id
 *     assert dev_id == x.data.device.id
 *     assert dev_id == y.data.device.id             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_zero = 0, float_one = 1
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_y->data), __pyx_n_s_device); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1850, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1850, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_5)) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 1850, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":1852
 *     assert dev_id == y.data.device.id
 * 
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":1853
 * 
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":1855
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1855, __pyx_L1_error)
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":1856
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":1857
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":1855
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1859
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":1860
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     # Disable use_tensor_core in deterministic mode because
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1865
 *     # CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 does not use Tensor Core.
 *     cdef bint use_tensor_core = (
 *         not deterministic and _should_use_tensor_core(tensor_core, x.dtype))             # <<<<<<<<<<<<<<
 *     cdef tuple conv_param = (
 *         pad, stride, x.dtype, use_tensor_core, deterministic)
 */
  __pyx_t_6 = ((!(__pyx_v_deterministic != 0)) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_5 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_6 = __pyx_f_4cupy_5cudnn__should_use_tensor_core(__pyx_v_tensor_core, __pyx_t_4, 0); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_5 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  __pyx_v_use_tensor_core = __pyx_t_5;

  /* "cupy/cudnn.pyx":1867
 *         not deterministic and _should_use_tensor_core(tensor_core, x.dtype))
 *     cdef tuple conv_param = (
 *         pad, stride, x.dtype, use_tensor_core, deterministic)             # <<<<<<<<<<<<<<
 * 
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_tensor_core); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_deterministic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_pad);
  __Pyx_GIVEREF(__pyx_v_pad);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pad);
  __Pyx_INCREF(__pyx_v_stride);
  __Pyx_GIVEREF(__pyx_v_stride);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_stride);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_v_conv_param = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1871
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:             # <<<<<<<<<<<<<<
 *         for i in dilation:
 *             if i > 1:
 */
  __pyx_t_5 = (__pyx_v_use_tensor_core != 0);
  if (__pyx_t_5) {

    /* "cupy/cudnn.pyx":1872
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:
 *         for i in dilation:             # <<<<<<<<<<<<<<
 *             if i > 1:
 *                 use_tensor_core = False
 */
    if (unlikely(__pyx_v_dilation == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1872, __pyx_L1_error)
    }
    __pyx_t_1 = __pyx_v_dilation; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
    for (;;) {
      if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1872, __pyx_L1_error)
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1873
 *     if use_tensor_core:
 *         for i in dilation:
 *             if i > 1:             # <<<<<<<<<<<<<<
 *                 use_tensor_core = False
 *                 break
 */
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_i, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1873, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1873, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_5) {

        /* "cupy/cudnn.pyx":1874
 *         for i in dilation:
 *             if i > 1:
 *                 use_tensor_core = False             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        __pyx_v_use_tensor_core = 0;

        /* "cupy/cudnn.pyx":1875
 *             if i > 1:
 *                 use_tensor_core = False
 *                 break             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
        goto __pyx_L8_break;

        /* "cupy/cudnn.pyx":1873
 *     if use_tensor_core:
 *         for i in dilation:
 *             if i > 1:             # <<<<<<<<<<<<<<
 *                 use_tensor_core = False
 *                 break
 */
      }

      /* "cupy/cudnn.pyx":1872
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:
 *         for i in dilation:             # <<<<<<<<<<<<<<
 *             if i > 1:
 *                 use_tensor_core = False
 */
    }
    __pyx_L8_break:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1871
 *     # cuDNN 7 supports dilation only in *_FWD_ALGO_IMPLICIT_GEMM, but
 *     # it supports Tensor Cores only in *_FWD_ALGO_IMPLICIT_PRECOMP_GEMM.
 *     if use_tensor_core:             # <<<<<<<<<<<<<<
 *         for i in dilation:
 *             if i > 1:
 */
  }

  /* "cupy/cudnn.pyx":1877
 *                 break
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     W = core._internal_ascontiguousarray(W)
 */
  __pyx_t_9 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1877, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_9;

  /* "cupy/cudnn.pyx":1878
 * 
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     W = core._internal_ascontiguousarray(W)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1879
 *     handle = get_handle()
 *     x = core._internal_ascontiguousarray(x)
 *     W = core._internal_ascontiguousarray(W)             # <<<<<<<<<<<<<<
 * 
 *     # TODO(okuta) check performance
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_W, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1879, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_W, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":1882
 * 
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1882, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_9;

  /* "cupy/cudnn.pyx":1883
 *     # TODO(okuta) check performance
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1883, __pyx_L1_error)
  __pyx_v_y_desc = __pyx_t_9;

  /* "cupy/cudnn.pyx":1884
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1884, __pyx_L1_error)
  __pyx_v_b_desc = __pyx_t_9;

  /* "cupy/cudnn.pyx":1885
 *     cdef size_t y_desc = cudnn.createTensorDescriptor()
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()
 * 
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1885, __pyx_L1_error)
  __pyx_v_filter_desc = __pyx_t_9;

  /* "cupy/cudnn.pyx":1886
 *     cdef size_t b_desc = cudnn.createTensorDescriptor()
 *     cdef size_t filter_desc = cudnn.createFilterDescriptor()
 *     cdef size_t conv_desc = cudnn.createConvolutionDescriptor()             # <<<<<<<<<<<<<<
 * 
 *     cdef _Algorithm perf
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor(0); if (unlikely(__pyx_t_9 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1886, __pyx_L1_error)
  __pyx_v_conv_desc = __pyx_t_9;

  /* "cupy/cudnn.pyx":1890
 *     cdef _Algorithm perf
 *     cdef int algo
 *     cdef size_t max_workspace_size = get_max_workspace_size()             # <<<<<<<<<<<<<<
 *     cdef size_t workspace_size = 0
 *     cdef vector.vector[Py_ssize_t] b_shape
 */
  __pyx_v_max_workspace_size = __pyx_f_4cupy_5cudnn_get_max_workspace_size(0);

  /* "cupy/cudnn.pyx":1891
 *     cdef int algo
 *     cdef size_t max_workspace_size = get_max_workspace_size()
 *     cdef size_t workspace_size = 0             # <<<<<<<<<<<<<<
 *     cdef vector.vector[Py_ssize_t] b_shape
 *     try:
 */
  __pyx_v_workspace_size = 0;

  /* "cupy/cudnn.pyx":1893
 *     cdef size_t workspace_size = 0
 *     cdef vector.vector[Py_ssize_t] b_shape
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1894
 *     cdef vector.vector[Py_ssize_t] b_shape
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 */
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_x_desc, __pyx_v_x, 0, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1894, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1895
 *     try:
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)             # <<<<<<<<<<<<<<
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(
 */
    __pyx_t_10.__pyx_n = 1;
    __pyx_t_10.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_y_desc, __pyx_v_y, 0, &__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1895, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1896
 *         _create_tensor_descriptor(x_desc, x, format=d_layout)
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)             # <<<<<<<<<<<<<<
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 */
    __pyx_t_11.__pyx_n = 1;
    __pyx_t_11.format = __pyx_v_w_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_filter_descriptor(__pyx_v_filter_desc, __pyx_v_W, 0, &__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1896, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":1898
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(
 *             conv_desc, pad, stride, dilation, groups, x.dtype,             # <<<<<<<<<<<<<<
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 */
    __pyx_t_1 = __pyx_v_x->dtype;
    __Pyx_INCREF(__pyx_t_1);

    /* "cupy/cudnn.pyx":1897
 *         _create_tensor_descriptor(y_desc, y, format=d_layout)
 *         _create_filter_descriptor(filter_desc, W, w_layout)
 *         _create_convolution_descriptor(             # <<<<<<<<<<<<<<
 *             conv_desc, pad, stride, dilation, groups, x.dtype,
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_convolution_descriptor(__pyx_v_conv_desc, __pyx_v_pad, __pyx_v_stride, __pyx_v_dilation, __pyx_v_groups, __pyx_t_1, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CROSS_CORRELATION, __pyx_v_use_tensor_core, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1897, __pyx_L11_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/cudnn.pyx":1901
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if deterministic and _cudnn_version < 7000:             # <<<<<<<<<<<<<<
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_DATA_ALGO_1
 */
    __pyx_t_7 = (__pyx_v_deterministic != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_5 = __pyx_t_7;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_7 = ((__pyx_v_4cupy_5cudnn__cudnn_version < 0x1B58) != 0);
    __pyx_t_5 = __pyx_t_7;
    __pyx_L14_bool_binop_done:;
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1903
 *         if deterministic and _cudnn_version < 7000:
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_DATA_ALGO_1             # <<<<<<<<<<<<<<
 *             workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(
 *                 handle, filter_desc, x_desc, conv_desc, y_desc, algo)
 */
      __pyx_v_algo = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_CONVOLUTION_BWD_DATA_ALGO_1;

      /* "cupy/cudnn.pyx":1904
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_DATA_ALGO_1
 *             workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(             # <<<<<<<<<<<<<<
 *                 handle, filter_desc, x_desc, conv_desc, y_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 */
      __pyx_t_8 = __pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataWorkspaceSize(__pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_algo, 0); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 1904, __pyx_L11_error)
      __pyx_v_workspace_size = __pyx_t_8;

      /* "cupy/cudnn.pyx":1906
 *             workspace_size = cudnn.getConvolutionBackwardDataWorkspaceSize(
 *                 handle, filter_desc, x_desc, conv_desc, y_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH             # <<<<<<<<<<<<<<
 *             if workspace_size > max_workspace_size:
 *                 raise RuntimeError(
 */
      __pyx_v_math_type = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_DEFAULT_MATH;

      /* "cupy/cudnn.pyx":1907
 *                 handle, filter_desc, x_desc, conv_desc, y_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'No conv bwd data algo available with workspace size less '
 */
      __pyx_t_5 = ((__pyx_v_workspace_size > __pyx_v_max_workspace_size) != 0);
      if (unlikely(__pyx_t_5)) {

        /* "cupy/cudnn.pyx":1910
 *                 raise RuntimeError(
 *                     'No conv bwd data algo available with workspace size less '
 *                     'equal {}'.format(max_workspace_size))             # <<<<<<<<<<<<<<
 *         else:
 *             if auto_tune and not deterministic:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_No_conv_bwd_data_algo_available, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1910, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_max_workspace_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1910, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        __pyx_t_2 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1910, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1908
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:
 *                 raise RuntimeError(             # <<<<<<<<<<<<<<
 *                     'No conv bwd data algo available with workspace size less '
 *                     'equal {}'.format(max_workspace_size))
 */
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1908, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 1908, __pyx_L11_error)

        /* "cupy/cudnn.pyx":1907
 *                 handle, filter_desc, x_desc, conv_desc, y_desc, algo)
 *             math_type = cudnn.CUDNN_DEFAULT_MATH
 *             if workspace_size > max_workspace_size:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(
 *                     'No conv bwd data algo available with workspace size less '
 */
      }

      /* "cupy/cudnn.pyx":1901
 *             cudnn.CUDNN_CROSS_CORRELATION, use_tensor_core)
 * 
 *         if deterministic and _cudnn_version < 7000:             # <<<<<<<<<<<<<<
 *             # TODO(imanishi): Support Tensor Core in deterministic mode.
 *             algo = cudnn.CUDNN_CONVOLUTION_BWD_DATA_ALGO_1
 */
      goto __pyx_L13;
    }

    /* "cupy/cudnn.pyx":1912
 *                     'equal {}'.format(max_workspace_size))
 *         else:
 *             if auto_tune and not deterministic:             # <<<<<<<<<<<<<<
 *                 perf = _find_algorithm_bwd_data(
 *                     W, x, y, conv_param, handle, filter_desc, x_desc,
 */
    /*else*/ {
      __pyx_t_7 = (__pyx_v_auto_tune != 0);
      if (__pyx_t_7) {
      } else {
        __pyx_t_5 = __pyx_t_7;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_7 = ((!(__pyx_v_deterministic != 0)) != 0);
      __pyx_t_5 = __pyx_t_7;
      __pyx_L18_bool_binop_done:;
      if (__pyx_t_5) {

        /* "cupy/cudnn.pyx":1913
 *         else:
 *             if auto_tune and not deterministic:
 *                 perf = _find_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *                     W, x, y, conv_param, handle, filter_desc, x_desc,
 *                     conv_desc, y_desc, max_workspace_size, use_tensor_core,
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__find_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1913, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":1912
 *                     'equal {}'.format(max_workspace_size))
 *         else:
 *             if auto_tune and not deterministic:             # <<<<<<<<<<<<<<
 *                 perf = _find_algorithm_bwd_data(
 *                     W, x, y, conv_param, handle, filter_desc, x_desc,
 */
        goto __pyx_L17;
      }

      /* "cupy/cudnn.pyx":1918
 *                     deterministic)
 *             else:
 *                 perf = _get_algorithm_bwd_data(             # <<<<<<<<<<<<<<
 *                     W, x, y, conv_param, handle, filter_desc, x_desc,
 *                     conv_desc, y_desc, max_workspace_size, use_tensor_core,
 */
      /*else*/ {

        /* "cupy/cudnn.pyx":1921
 *                     W, x, y, conv_param, handle, filter_desc, x_desc,
 *                     conv_desc, y_desc, max_workspace_size, use_tensor_core,
 *                     deterministic)             # <<<<<<<<<<<<<<
 *             algo = perf.algo
 *             workspace_size = perf.memory
 */
        __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_5cudnn__get_algorithm_bwd_data(__pyx_v_W, __pyx_v_x, __pyx_v_y, __pyx_v_conv_param, __pyx_v_handle, __pyx_v_filter_desc, __pyx_v_x_desc, __pyx_v_conv_desc, __pyx_v_y_desc, __pyx_v_max_workspace_size, __pyx_v_use_tensor_core, __pyx_v_deterministic, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1918, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_v_perf = ((struct __pyx_obj_4cupy_5cudnn__Algorithm *)__pyx_t_1);
        __pyx_t_1 = 0;
      }
      __pyx_L17:;

      /* "cupy/cudnn.pyx":1922
 *                     conv_desc, y_desc, max_workspace_size, use_tensor_core,
 *                     deterministic)
 *             algo = perf.algo             # <<<<<<<<<<<<<<
 *             workspace_size = perf.memory
 *             math_type = perf.mathType
 */
      __pyx_t_3 = __pyx_v_perf->algo;
      __pyx_v_algo = __pyx_t_3;

      /* "cupy/cudnn.pyx":1923
 *                     deterministic)
 *             algo = perf.algo
 *             workspace_size = perf.memory             # <<<<<<<<<<<<<<
 *             math_type = perf.mathType
 * 
 */
      __pyx_t_9 = __pyx_v_perf->memory;
      __pyx_v_workspace_size = __pyx_t_9;

      /* "cupy/cudnn.pyx":1924
 *             algo = perf.algo
 *             workspace_size = perf.memory
 *             math_type = perf.mathType             # <<<<<<<<<<<<<<
 * 
 *         if _cudnn_version >= 7000:
 */
      __pyx_t_3 = __pyx_v_perf->mathType;
      __pyx_v_math_type = __pyx_t_3;
    }
    __pyx_L13:;

    /* "cupy/cudnn.pyx":1926
 *             math_type = perf.mathType
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 */
    __pyx_t_5 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1B58) != 0);
    if (__pyx_t_5) {

      /* "cupy/cudnn.pyx":1927
 * 
 *         if _cudnn_version >= 7000:
 *             cudnn.setConvolutionMathType(conv_desc, math_type)             # <<<<<<<<<<<<<<
 * 
 *         workspace = memory.alloc(workspace_size)
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType(__pyx_v_conv_desc, __pyx_v_math_type, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1927, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":1926
 *             math_type = perf.mathType
 * 
 *         if _cudnn_version >= 7000:             # <<<<<<<<<<<<<<
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 */
    }

    /* "cupy/cudnn.pyx":1929
 *             cudnn.setConvolutionMathType(conv_desc, math_type)
 * 
 *         workspace = memory.alloc(workspace_size)             # <<<<<<<<<<<<<<
 * 
 *         cudnn.convolutionBackwardData_v3(
 */
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1929, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_1, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1929, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1931
 *         workspace = memory.alloc(workspace_size)
 * 
 *         cudnn.convolutionBackwardData_v3(             # <<<<<<<<<<<<<<
 *             handle, one, filter_desc, W.data.ptr, x_desc, x.data.ptr,
 *             conv_desc, algo, workspace.ptr, workspace_size, zero, y_desc,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardData_v3(__pyx_v_handle, __pyx_v_one, __pyx_v_filter_desc, __pyx_v_W->data->ptr, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_conv_desc, __pyx_v_algo, __pyx_v_workspace->ptr, __pyx_v_workspace_size, __pyx_v_zero, __pyx_v_y_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1931, __pyx_L11_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1936
 *             y.data.ptr)
 * 
 *         del workspace, x, W             # <<<<<<<<<<<<<<
 * 
 *         if b is not None:
 */
    __Pyx_DECREF(((PyObject *)__pyx_v_workspace));
    __pyx_v_workspace = NULL;
    __Pyx_DECREF(((PyObject *)__pyx_v_x));
    __pyx_v_x = NULL;
    __Pyx_DECREF(((PyObject *)__pyx_v_W));
    __pyx_v_W = NULL;

    /* "cupy/cudnn.pyx":1938
 *         del workspace, x, W
 * 
 *         if b is not None:             # <<<<<<<<<<<<<<
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 */
    __pyx_t_5 = (((PyObject *)__pyx_v_b) != Py_None);
    __pyx_t_7 = (__pyx_t_5 != 0);
    if (__pyx_t_7) {

      /* "cupy/cudnn.pyx":1939
 * 
 *         if b is not None:
 *             assert dev_id == b.data.device.id             # <<<<<<<<<<<<<<
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_dev_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b->data), __pyx_n_s_device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1939, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1939, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1939, __pyx_L11_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 1939, __pyx_L11_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_7)) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 1939, __pyx_L11_error)
        }
      }
      #endif

      /* "cupy/cudnn.pyx":1940
 *         if b is not None:
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)             # <<<<<<<<<<<<<<
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(
 */
      __pyx_v_b_shape.assign(__pyx_v_y->_shape.size(), 1);

      /* "cupy/cudnn.pyx":1941
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1             # <<<<<<<<<<<<<<
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)
 */
      (__pyx_v_b_shape[1]) = -1L;

      /* "cupy/cudnn.pyx":1943
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)             # <<<<<<<<<<<<<<
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 *             cudnn.addTensor_v3(handle, one, b_desc, b.data.ptr, one, y_desc,
 */
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_b, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1943, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_1);

      /* "cupy/cudnn.pyx":1942
 *             b_shape.assign(y._shape.size(), 1)
 *             b_shape[1] = -1
 *             b = _manipulation._reshape(             # <<<<<<<<<<<<<<
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_22_routines_manipulation__reshape(((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1), __pyx_v_b_shape, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1942, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_b, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1944
 *             b = _manipulation._reshape(
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)             # <<<<<<<<<<<<<<
 *             cudnn.addTensor_v3(handle, one, b_desc, b.data.ptr, one, y_desc,
 *                                y.data.ptr)
 */
      __pyx_t_13.__pyx_n = 1;
      __pyx_t_13.data_type = -1;
      __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_b_desc, __pyx_v_b, 0, &__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1944, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1945
 *                 core._internal_ascontiguousarray(b), b_shape)
 *             _create_tensor_nd_descriptor(b_desc, b, -1)
 *             cudnn.addTensor_v3(handle, one, b_desc, b.data.ptr, one, y_desc,             # <<<<<<<<<<<<<<
 *                                y.data.ptr)
 *     finally:
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_addTensor_v3(__pyx_v_handle, __pyx_v_one, __pyx_v_b_desc, __pyx_v_b->data->ptr, __pyx_v_one, __pyx_v_y_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1945, __pyx_L11_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1938
 *         del workspace, x, W
 * 
 *         if b is not None:             # <<<<<<<<<<<<<<
 *             assert dev_id == b.data.device.id
 *             b_shape.assign(y._shape.size(), 1)
 */
    }
  }

  /* "cupy/cudnn.pyx":1948
 *                                y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1948, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1949
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1949, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1950
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_b_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1950, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1951
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1951, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":1952
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1952, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L12;
    }
    __pyx_L11_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_21);
      __pyx_t_3 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":1948
 *                                y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1948, __pyx_L23_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1949
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1949, __pyx_L23_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1950
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_b_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1950, __pyx_L23_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1951
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyConvolutionDescriptor(conv_desc)
 * 
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor(__pyx_v_filter_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1951, __pyx_L23_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":1952
 *         cudnn.destroyTensorDescriptor(b_desc)
 *         cudnn.destroyFilterDescriptor(filter_desc)
 *         cudnn.destroyConvolutionDescriptor(conv_desc)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor(__pyx_v_conv_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1952, __pyx_L23_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      __pyx_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
      goto __pyx_L1_error;
      __pyx_L23_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L12:;
  }

  /* "cupy/cudnn.pyx":1842
 * 
 * 
 * def convolution_backward_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */

  /* 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_4);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.convolution_backward_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conv_param);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF((PyObject *)__pyx_v_perf);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_W);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1955
 * 
 * 
 * def pooling_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_119pooling_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_118pooling_forward[] = "pooling_forward(ndarray x, ndarray y, tuple ksize, tuple stride, tuple pad, int mode)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_119pooling_forward = {"pooling_forward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_119pooling_forward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_118pooling_forward};
static PyObject *__pyx_pw_4cupy_5cudnn_119pooling_forward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  PyObject *__pyx_v_ksize = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_pad = 0;
  int __pyx_v_mode;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pooling_forward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_ksize,&__pyx_n_s_stride,&__pyx_n_s_pad,&__pyx_n_s_mode,0};
    PyObject* values[6] = {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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, 1); __PYX_ERR(0, 1955, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ksize)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, 2); __PYX_ERR(0, 1955, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, 3); __PYX_ERR(0, 1955, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, 4); __PYX_ERR(0, 1955, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, 5); __PYX_ERR(0, 1955, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pooling_forward") < 0)) __PYX_ERR(0, 1955, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
      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);
    }
    __pyx_v_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_ksize = ((PyObject*)values[2]);
    __pyx_v_stride = ((PyObject*)values[3]);
    __pyx_v_pad = ((PyObject*)values[4]);
    __pyx_v_mode = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1957, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pooling_forward", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1955, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.pooling_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1956, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1956, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ksize), (&PyTuple_Type), 1, "ksize", 1))) __PYX_ERR(0, 1957, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 1957, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 1957, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_118pooling_forward(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_ksize, __pyx_v_stride, __pyx_v_pad, __pyx_v_mode);

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

static PyObject *__pyx_pf_4cupy_5cudnn_118pooling_forward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_pool_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("pooling_forward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);

  /* "cupy/cudnn.pyx":1958
 *         core.ndarray x, core.ndarray y,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":1959
 *         tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":1961
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1961, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":1962
 *     cdef size_t zero, one
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":1963
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":1961
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1965
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 *     x = core._internal_ascontiguousarray(x)
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":1966
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     if not y._c_contiguous:
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":1967
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     if not y._c_contiguous:
 *         raise ValueError('pooling_forward supports c-contiguous y only')
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1967, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":1968
 *         one = <size_t>&float_one
 *     x = core._internal_ascontiguousarray(x)
 *     if not y._c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('pooling_forward supports c-contiguous y only')
 *     handle = get_handle()
 */
  __pyx_t_1 = ((!(__pyx_v_y->_c_contiguous != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/cudnn.pyx":1969
 *     x = core._internal_ascontiguousarray(x)
 *     if not y._c_contiguous:
 *         raise ValueError('pooling_forward supports c-contiguous y only')             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1969, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1969, __pyx_L1_error)

    /* "cupy/cudnn.pyx":1968
 *         one = <size_t>&float_one
 *     x = core._internal_ascontiguousarray(x)
 *     if not y._c_contiguous:             # <<<<<<<<<<<<<<
 *         raise ValueError('pooling_forward supports c-contiguous y only')
 *     handle = get_handle()
 */
  }

  /* "cupy/cudnn.pyx":1970
 *     if not y._c_contiguous:
 *         raise ValueError('pooling_forward supports c-contiguous y only')
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_3 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1970, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_3;

  /* "cupy/cudnn.pyx":1971
 *         raise ValueError('pooling_forward supports c-contiguous y only')
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1971, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_3;

  /* "cupy/cudnn.pyx":1972
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1972, __pyx_L1_error)
  __pyx_v_y_desc = __pyx_t_3;

  /* "cupy/cudnn.pyx":1973
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createPoolingDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 1973, __pyx_L1_error)
  __pyx_v_pool_desc = __pyx_t_3;

  /* "cupy/cudnn.pyx":1974
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":1975
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)             # <<<<<<<<<<<<<<
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_x_desc, __pyx_v_x, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1975, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1976
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)             # <<<<<<<<<<<<<<
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 *         cudnn.poolingForward(
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_y_desc, __pyx_v_y, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1976, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1977
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)             # <<<<<<<<<<<<<<
 *         cudnn.poolingForward(
 *             handle, pool_desc, one, x_desc,
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_pooling_descriptor(__pyx_v_pool_desc, __pyx_v_ksize, __pyx_v_stride, __pyx_v_pad, __pyx_v_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1977, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":1978
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 *         cudnn.poolingForward(             # <<<<<<<<<<<<<<
 *             handle, pool_desc, one, x_desc,
 *             x.data.ptr, zero, y_desc, y.data.ptr)
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_poolingForward(__pyx_v_handle, __pyx_v_pool_desc, __pyx_v_one, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_zero, __pyx_v_y_desc, __pyx_v_y->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1978, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":1982
 *             x.data.ptr, zero, y_desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1983
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return y
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":1984
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor(__pyx_v_pool_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1984, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L6_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":1982
 *             x.data.ptr, zero, y_desc, y.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1982, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1983
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return y
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1983, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":1984
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor(__pyx_v_pool_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1984, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "cupy/cudnn.pyx":1985
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_y));
  __pyx_r = ((PyObject *)__pyx_v_y);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1955
 * 
 * 
 * def pooling_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn.pooling_forward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":1988
 * 
 * 
 * def pooling_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y, core.ndarray gy,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_121pooling_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_120pooling_backward[] = "pooling_backward(ndarray x, ndarray y, ndarray gy, tuple ksize, tuple stride, tuple pad, int mode)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_121pooling_backward = {"pooling_backward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_121pooling_backward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_120pooling_backward};
static PyObject *__pyx_pw_4cupy_5cudnn_121pooling_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy = 0;
  PyObject *__pyx_v_ksize = 0;
  PyObject *__pyx_v_stride = 0;
  PyObject *__pyx_v_pad = 0;
  int __pyx_v_mode;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pooling_backward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_gy,&__pyx_n_s_ksize,&__pyx_n_s_stride,&__pyx_n_s_pad,&__pyx_n_s_mode,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 1); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 2); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ksize)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 3); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 4); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 5); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, 6); __PYX_ERR(0, 1988, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pooling_backward") < 0)) __PYX_ERR(0, 1988, __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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_y = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_gy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_ksize = ((PyObject*)values[3]);
    __pyx_v_stride = ((PyObject*)values[4]);
    __pyx_v_pad = ((PyObject*)values[5]);
    __pyx_v_mode = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1990, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("pooling_backward", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1988, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.pooling_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 1989, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "y", 0))) __PYX_ERR(0, 1989, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gy", 0))) __PYX_ERR(0, 1989, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ksize), (&PyTuple_Type), 1, "ksize", 1))) __PYX_ERR(0, 1990, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stride), (&PyTuple_Type), 1, "stride", 1))) __PYX_ERR(0, 1990, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pad), (&PyTuple_Type), 1, "pad", 1))) __PYX_ERR(0, 1990, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_120pooling_backward(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_gy, __pyx_v_ksize, __pyx_v_stride, __pyx_v_pad, __pyx_v_mode);

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

static PyObject *__pyx_pf_4cupy_5cudnn_120pooling_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_y, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, PyObject *__pyx_v_ksize, PyObject *__pyx_v_stride, PyObject *__pyx_v_pad, int __pyx_v_mode) {
  float __pyx_v_float_zero;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gx = 0;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_y_desc;
  size_t __pyx_v_pool_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  char const *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("pooling_backward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_y);
  __Pyx_INCREF((PyObject *)__pyx_v_gy);

  /* "cupy/cudnn.pyx":1991
 *         core.ndarray x, core.ndarray y, core.ndarray gy,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef float float_zero = 0, float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero, one
 */
  __pyx_v_float_zero = 0.0;
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":1992
 *         tuple ksize, tuple stride, tuple pad, int mode):
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":1995
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1995, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":1996
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

    /* "cupy/cudnn.pyx":1997
 *     if x.dtype == 'd':
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         zero = <size_t>&float_zero
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":1995
 *     cdef size_t zero, one
 *     cdef core.ndarray gx
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         zero = <size_t>&double_zero
 *         one = <size_t>&double_one
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":1999
 *         one = <size_t>&double_one
 *     else:
 *         zero = <size_t>&float_zero             # <<<<<<<<<<<<<<
 *         one = <size_t>&float_one
 * 
 */
  /*else*/ {
    __pyx_v_zero = ((size_t)(&__pyx_v_float_zero));

    /* "cupy/cudnn.pyx":2000
 *     else:
 *         zero = <size_t>&float_zero
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     gx = core.ndarray(x._shape, x.dtype)
 */
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":2002
 *         one = <size_t>&float_one
 * 
 *     gx = core.ndarray(x._shape, x.dtype)             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)
 */
  __pyx_t_2 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_x->dtype);
  __Pyx_GIVEREF(__pyx_v_x->dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_x->dtype);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_gx = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2003
 * 
 *     gx = core.ndarray(x._shape, x.dtype)
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2004
 *     gx = core.ndarray(x._shape, x.dtype)
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)             # <<<<<<<<<<<<<<
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_y, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2004, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_y, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2005
 *     x = core._internal_ascontiguousarray(x)
 *     y = core._internal_ascontiguousarray(y)
 *     gy = core._internal_ascontiguousarray(gy)             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gy, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF_SET(__pyx_v_gy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_2));
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2007
 *     gy = core._internal_ascontiguousarray(gy)
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2007, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":2008
 * 
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2008, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2009
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2009, __pyx_L1_error)
  __pyx_v_y_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2010
 *     x_desc = cudnn.createTensorDescriptor()
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createPoolingDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2010, __pyx_L1_error)
  __pyx_v_pool_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2011
 *     y_desc = cudnn.createTensorDescriptor()
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":2012
 *     pool_desc = cudnn.createPoolingDescriptor()
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)             # <<<<<<<<<<<<<<
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_x_desc, __pyx_v_x, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2012, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2013
 *     try:
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)             # <<<<<<<<<<<<<<
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 *         cudnn.poolingBackward(
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_nd_descriptor(__pyx_v_y_desc, __pyx_v_y, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2013, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2014
 *         _create_tensor_nd_descriptor(x_desc, x)
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)             # <<<<<<<<<<<<<<
 *         cudnn.poolingBackward(
 *             handle, pool_desc,
 */
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_pooling_descriptor(__pyx_v_pool_desc, __pyx_v_ksize, __pyx_v_stride, __pyx_v_pad, __pyx_v_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2014, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2015
 *         _create_tensor_nd_descriptor(y_desc, y)
 *         _create_pooling_descriptor(pool_desc, ksize, stride, pad, mode)
 *         cudnn.poolingBackward(             # <<<<<<<<<<<<<<
 *             handle, pool_desc,
 *             one, y_desc, y.data.ptr, y_desc, gy.data.ptr,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_poolingBackward(__pyx_v_handle, __pyx_v_pool_desc, __pyx_v_one, __pyx_v_y_desc, __pyx_v_y->data->ptr, __pyx_v_y_desc, __pyx_v_gy->data->ptr, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_gx->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2015, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":2020
 *             x_desc, x.data.ptr, zero, x_desc, gx.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2020, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2021
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return gx
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2021, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2022
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)             # <<<<<<<<<<<<<<
 *     return gx
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor(__pyx_v_pool_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2022, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __pyx_t_5 = __pyx_lineno; __pyx_t_6 = __pyx_clineno; __pyx_t_7 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":2020
 *             x_desc, x.data.ptr, zero, x_desc, gx.data.ptr)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2020, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":2021
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return gx
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_y_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2021, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":2022
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)             # <<<<<<<<<<<<<<
 *     return gx
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor(__pyx_v_pool_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2022, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ErrRestore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_6; __pyx_filename = __pyx_t_7;
      goto __pyx_L1_error;
      __pyx_L8_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":2023
 *         cudnn.destroyTensorDescriptor(y_desc)
 *         cudnn.destroyPoolingDescriptor(pool_desc)
 *     return gx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_gx));
  __pyx_r = ((PyObject *)__pyx_v_gx);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":1988
 * 
 * 
 * def pooling_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y, core.ndarray gy,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cudnn.pooling_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_gx);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_y);
  __Pyx_XDECREF((PyObject *)__pyx_v_gy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2026
 * 
 * 
 * cdef _create_tensor_descriptor_for_bn(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, bint is_for_conv2d,
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 */

static PyObject *__pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_bn(size_t __pyx_v_desc, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_arr, int __pyx_v_is_for_conv2d, struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn *__pyx_optional_args) {
  int __pyx_v_format = __pyx_k__27;
  int __pyx_v_data_type;
  Py_ssize_t __pyx_v_dim1;
  Py_ssize_t __pyx_v_dim2;
  int __pyx_v_ndim;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_tensor_descriptor_for_bn", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_format = __pyx_optional_args->format;
    }
  }

  /* "cupy/cudnn.pyx":2029
 *         size_t desc, core.ndarray arr, bint is_for_conv2d,
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 *     assert arr._c_contiguous             # <<<<<<<<<<<<<<
 *     if is_for_conv2d:
 *         _create_tensor_descriptor(desc, arr, format)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!(__pyx_v_arr->_c_contiguous != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 2029, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cudnn.pyx":2030
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 *     assert arr._c_contiguous
 *     if is_for_conv2d:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(desc, arr, format)
 *         return
 */
  __pyx_t_1 = (__pyx_v_is_for_conv2d != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":2031
 *     assert arr._c_contiguous
 *     if is_for_conv2d:
 *         _create_tensor_descriptor(desc, arr, format)             # <<<<<<<<<<<<<<
 *         return
 *     data_type = get_data_type(arr.dtype)
 */
    __pyx_t_3.__pyx_n = 1;
    __pyx_t_3.format = __pyx_v_format;
    __pyx_t_2 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor(__pyx_v_desc, __pyx_v_arr, 0, &__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2032
 *     if is_for_conv2d:
 *         _create_tensor_descriptor(desc, arr, format)
 *         return             # <<<<<<<<<<<<<<
 *     data_type = get_data_type(arr.dtype)
 *     cdef Py_ssize_t dim1, dim2
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2030
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 *     assert arr._c_contiguous
 *     if is_for_conv2d:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor(desc, arr, format)
 *         return
 */
  }

  /* "cupy/cudnn.pyx":2033
 *         _create_tensor_descriptor(desc, arr, format)
 *         return
 *     data_type = get_data_type(arr.dtype)             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dim1, dim2
 *     cdef int ndim = arr._shape.size()
 */
  __pyx_t_2 = __pyx_v_arr->dtype;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_data_type(__pyx_t_2, 0); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2033, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_data_type = __pyx_t_4;

  /* "cupy/cudnn.pyx":2035
 *     data_type = get_data_type(arr.dtype)
 *     cdef Py_ssize_t dim1, dim2
 *     cdef int ndim = arr._shape.size()             # <<<<<<<<<<<<<<
 *     dim2 = 1
 *     if ndim > 0:
 */
  __pyx_v_ndim = __pyx_v_arr->_shape.size();

  /* "cupy/cudnn.pyx":2036
 *     cdef Py_ssize_t dim1, dim2
 *     cdef int ndim = arr._shape.size()
 *     dim2 = 1             # <<<<<<<<<<<<<<
 *     if ndim > 0:
 *         dim2 = arr._shape[ndim - 1]
 */
  __pyx_v_dim2 = 1;

  /* "cupy/cudnn.pyx":2037
 *     cdef int ndim = arr._shape.size()
 *     dim2 = 1
 *     if ndim > 0:             # <<<<<<<<<<<<<<
 *         dim2 = arr._shape[ndim - 1]
 *     dim1 = arr.size // dim2
 */
  __pyx_t_1 = ((__pyx_v_ndim > 0) != 0);
  if (__pyx_t_1) {

    /* "cupy/cudnn.pyx":2038
 *     dim2 = 1
 *     if ndim > 0:
 *         dim2 = arr._shape[ndim - 1]             # <<<<<<<<<<<<<<
 *     dim1 = arr.size // dim2
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 */
    __pyx_v_dim2 = (__pyx_v_arr->_shape[(__pyx_v_ndim - 1)]);

    /* "cupy/cudnn.pyx":2037
 *     cdef int ndim = arr._shape.size()
 *     dim2 = 1
 *     if ndim > 0:             # <<<<<<<<<<<<<<
 *         dim2 = arr._shape[ndim - 1]
 *     dim1 = arr.size // dim2
 */
  }

  /* "cupy/cudnn.pyx":2039
 *     if ndim > 0:
 *         dim2 = arr._shape[ndim - 1]
 *     dim1 = arr.size // dim2             # <<<<<<<<<<<<<<
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,
 *                                 dim1, dim2, 1, 1)
 */
  if (unlikely(__pyx_v_dim2 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
    __PYX_ERR(0, 2039, __pyx_L1_error)
  }
  else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_dim2 == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_arr->size))) {
    PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
    __PYX_ERR(0, 2039, __pyx_L1_error)
  }
  __pyx_v_dim1 = __Pyx_div_Py_ssize_t(__pyx_v_arr->size, __pyx_v_dim2);

  /* "cupy/cudnn.pyx":2040
 *         dim2 = arr._shape[ndim - 1]
 *     dim1 = arr.size // dim2
 *     cudnn.setTensor4dDescriptor(desc, cudnn.CUDNN_TENSOR_NCHW, data_type,             # <<<<<<<<<<<<<<
 *                                 dim1, dim2, 1, 1)
 * 
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor(__pyx_v_desc, __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW, __pyx_v_data_type, __pyx_v_dim1, __pyx_v_dim2, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2040, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2026
 * 
 * 
 * cdef _create_tensor_descriptor_for_bn(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, bint is_for_conv2d,
 *         int format=cudnn.CUDNN_TENSOR_NCHW):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn._create_tensor_descriptor_for_bn", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2044
 * 
 * 
 * cdef _get_dtype_of_tensor_descriptor(size_t desc):             # <<<<<<<<<<<<<<
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 */

static PyObject *__pyx_f_4cupy_5cudnn__get_dtype_of_tensor_descriptor(size_t __pyx_v_desc) {
  PyObject *__pyx_v_cudnn_dtype = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_dtype_of_tensor_descriptor", 0);

  /* "cupy/cudnn.pyx":2045
 * 
 * cdef _get_dtype_of_tensor_descriptor(size_t desc):
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)             # <<<<<<<<<<<<<<
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 *         return numpy.dtype(numpy.float64)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getTensor4dDescriptor(__pyx_v_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 9)) {
      if (size > 9) __Pyx_RaiseTooManyValuesError(9);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2045, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 4); 
    __pyx_t_7 = PyTuple_GET_ITEM(sequence, 5); 
    __pyx_t_8 = PyTuple_GET_ITEM(sequence, 6); 
    __pyx_t_9 = PyTuple_GET_ITEM(sequence, 7); 
    __pyx_t_10 = PyTuple_GET_ITEM(sequence, 8); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_10);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[9] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
      for (i=0; i < 9; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2045, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 2045, __pyx_L1_error)
  }
  __pyx_v_cudnn_dtype = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v__ = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_8);
  __pyx_t_8 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_9);
  __pyx_t_9 = 0;
  __Pyx_DECREF_SET(__pyx_v__, __pyx_t_10);
  __pyx_t_10 = 0;

  /* "cupy/cudnn.pyx":2046
 * cdef _get_dtype_of_tensor_descriptor(size_t desc):
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float64)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_DOUBLE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2046, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = PyObject_RichCompare(__pyx_v_cudnn_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2046, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2046, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_11) {

    /* "cupy/cudnn.pyx":2047
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 *         return numpy.dtype(numpy.float64)             # <<<<<<<<<<<<<<
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 *         return numpy.dtype(numpy.float32)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_10 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_1, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2047, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_r = __pyx_t_10;
    __pyx_t_10 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2046
 * cdef _get_dtype_of_tensor_descriptor(size_t desc):
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float64)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 */
  }

  /* "cupy/cudnn.pyx":2048
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 *         return numpy.dtype(numpy.float64)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float32)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:
 */
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_FLOAT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_9 = PyObject_RichCompare(__pyx_v_cudnn_dtype, __pyx_t_10, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2048, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_11) {

    /* "cupy/cudnn.pyx":2049
 *         return numpy.dtype(numpy.float64)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 *         return numpy.dtype(numpy.float32)             # <<<<<<<<<<<<<<
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:
 *         return numpy.dtype(numpy.float16)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_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_9 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_10, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2049, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_r = __pyx_t_9;
    __pyx_t_9 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2048
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 *         return numpy.dtype(numpy.float64)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float32)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:
 */
  }

  /* "cupy/cudnn.pyx":2050
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 *         return numpy.dtype(numpy.float32)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float16)
 *     else:
 */
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_DATA_HALF); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = PyObject_RichCompare(__pyx_v_cudnn_dtype, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 2050, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (likely(__pyx_t_11)) {

    /* "cupy/cudnn.pyx":2051
 *         return numpy.dtype(numpy.float32)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:
 *         return numpy.dtype(numpy.float16)             # <<<<<<<<<<<<<<
 *     else:
 *         raise RuntimeError('Unknown cudnn data type {} '.format(cudnn_dtype))
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_float16); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_8 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2051, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2050
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_FLOAT:
 *         return numpy.dtype(numpy.float32)
 *     elif cudnn_dtype == cudnn.CUDNN_DATA_HALF:             # <<<<<<<<<<<<<<
 *         return numpy.dtype(numpy.float16)
 *     else:
 */
  }

  /* "cupy/cudnn.pyx":2053
 *         return numpy.dtype(numpy.float16)
 *     else:
 *         raise RuntimeError('Unknown cudnn data type {} '.format(cudnn_dtype))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Unknown_cudnn_data_type, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_8 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_10, __pyx_v_cudnn_dtype) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_cudnn_dtype);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_RuntimeError, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2053, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 2053, __pyx_L1_error)
  }

  /* "cupy/cudnn.pyx":2044
 * 
 * 
 * cdef _get_dtype_of_tensor_descriptor(size_t desc):             # <<<<<<<<<<<<<<
 *     cudnn_dtype, _, _, _, _, _, _, _, _ = cudnn.getTensor4dDescriptor(desc)
 *     if cudnn_dtype == cudnn.CUDNN_DATA_DOUBLE:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.cudnn._get_dtype_of_tensor_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cudnn_dtype);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2056
 * 
 * 
 * def batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_123batch_normalization_forward_training(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_122batch_normalization_forward_training[] = "batch_normalization_forward_training(ndarray x, ndarray gamma, ndarray beta, ndarray running_mean, ndarray running_var, mean, inv_std, double eps, double decay, bool is_for_conv2d, int cudnn_mode, bool debug, int d_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_123batch_normalization_forward_training = {"batch_normalization_forward_training", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_123batch_normalization_forward_training, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_122batch_normalization_forward_training};
static PyObject *__pyx_pw_4cupy_5cudnn_123batch_normalization_forward_training(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var = 0;
  PyObject *__pyx_v_mean = 0;
  PyObject *__pyx_v_inv_std = 0;
  double __pyx_v_eps;
  double __pyx_v_decay;
  int __pyx_v_is_for_conv2d;
  int __pyx_v_cudnn_mode;
  int __pyx_v_debug;
  int __pyx_v_d_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("batch_normalization_forward_training (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_gamma,&__pyx_n_s_beta,&__pyx_n_s_running_mean,&__pyx_n_s_running_var,&__pyx_n_s_mean,&__pyx_n_s_inv_std,&__pyx_n_s_eps,&__pyx_n_s_decay,&__pyx_n_s_is_for_conv2d,&__pyx_n_s_cudnn_mode,&__pyx_n_s_debug,&__pyx_n_s_d_layout,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 1); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 2); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_running_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 3); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_running_var)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 4); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 5); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inv_std)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 6); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_eps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 7); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decay)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 8); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_is_for_conv2d)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 9); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cudnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 10); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debug)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, 11); __PYX_ERR(0, 2056, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d_layout);
          if (value) { values[12] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "batch_normalization_forward_training") < 0)) __PYX_ERR(0, 2056, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        values[7] = PyTuple_GET_ITEM(__pyx_args, 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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gamma = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_beta = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_running_mean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_running_var = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_mean = values[5];
    __pyx_v_inv_std = values[6];
    __pyx_v_eps = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_eps == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2059, __pyx_L3_error)
    __pyx_v_decay = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_decay == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2059, __pyx_L3_error)
    __pyx_v_is_for_conv2d = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_is_for_conv2d == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2060, __pyx_L3_error)
    __pyx_v_cudnn_mode = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_cudnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2060, __pyx_L3_error)
    __pyx_v_debug = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_debug == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2060, __pyx_L3_error)
    if (values[12]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2061, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__28;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training", 0, 12, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2056, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_training", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 2057, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gamma), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gamma", 0))) __PYX_ERR(0, 2057, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_beta), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "beta", 0))) __PYX_ERR(0, 2057, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_running_mean), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "running_mean", 0))) __PYX_ERR(0, 2058, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_running_var), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "running_var", 0))) __PYX_ERR(0, 2058, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_122batch_normalization_forward_training(__pyx_self, __pyx_v_x, __pyx_v_gamma, __pyx_v_beta, __pyx_v_running_mean, __pyx_v_running_var, __pyx_v_mean, __pyx_v_inv_std, __pyx_v_eps, __pyx_v_decay, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_debug, __pyx_v_d_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_122batch_normalization_forward_training(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var, PyObject *__pyx_v_mean, PyObject *__pyx_v_inv_std, double __pyx_v_eps, double __pyx_v_decay, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout) {
  PyObject *__pyx_v_reserve_space = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_save_mean = NULL;
  PyObject *__pyx_v_save_inv_std = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training __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)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("batch_normalization_forward_training", 0);

  /* "cupy/cudnn.pyx":2064
 * 
 *     reserve_space, y, save_mean, save_inv_std = (
 *         _batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *             x, gamma, beta,
 *             running_mean, running_var,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.d_layout = __pyx_v_d_layout;
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__batch_normalization_forward_training(__pyx_v_x, __pyx_v_gamma, __pyx_v_beta, __pyx_v_running_mean, __pyx_v_running_var, __pyx_v_mean, __pyx_v_inv_std, __pyx_v_eps, __pyx_v_decay, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_debug, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2063, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2063, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2063, __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;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_8(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 4) < 0) __PYX_ERR(0, 2063, __pyx_L1_error)
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2063, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "cupy/cudnn.pyx":2063
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):
 * 
 *     reserve_space, y, save_mean, save_inv_std = (             # <<<<<<<<<<<<<<
 *         _batch_normalization_forward_training(
 *             x, gamma, beta,
 */
  __pyx_v_reserve_space = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_y = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_save_mean = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_save_inv_std = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":2073
 *             debug,
 *             d_layout))
 *     if reserve_space is not None:             # <<<<<<<<<<<<<<
 *         warnings.warn(
 *             'Could be faster by calling '
 */
  __pyx_t_9 = (__pyx_v_reserve_space != Py_None);
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "cupy/cudnn.pyx":2074
 *             d_layout))
 *     if reserve_space is not None:
 *         warnings.warn(             # <<<<<<<<<<<<<<
 *             'Could be faster by calling '
 *             'batch_normalization_forward_training_ex() instead of '
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_warnings); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2074, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cupy/cudnn.pyx":2078
 *             'batch_normalization_forward_training_ex() instead of '
 *             'batch_normalization_forward_training().',
 *             util.PerformanceWarning)             # <<<<<<<<<<<<<<
 *     if mean is None:
 *         return y, save_mean, save_inv_std
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_util); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_PerformanceWarning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_u_Could_be_faster_by_calling_batch, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2074, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_u_Could_be_faster_by_calling_batch, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2074, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2074, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_u_Could_be_faster_by_calling_batch);
      __Pyx_GIVEREF(__pyx_kp_u_Could_be_faster_by_calling_batch);
      PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_kp_u_Could_be_faster_by_calling_batch);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2074, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2073
 *             debug,
 *             d_layout))
 *     if reserve_space is not None:             # <<<<<<<<<<<<<<
 *         warnings.warn(
 *             'Could be faster by calling '
 */
  }

  /* "cupy/cudnn.pyx":2079
 *             'batch_normalization_forward_training().',
 *             util.PerformanceWarning)
 *     if mean is None:             # <<<<<<<<<<<<<<
 *         return y, save_mean, save_inv_std
 *     else:
 */
  __pyx_t_10 = (__pyx_v_mean == Py_None);
  __pyx_t_9 = (__pyx_t_10 != 0);
  if (__pyx_t_9) {

    /* "cupy/cudnn.pyx":2080
 *             util.PerformanceWarning)
 *     if mean is None:
 *         return y, save_mean, save_inv_std             # <<<<<<<<<<<<<<
 *     else:
 *         return y
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2080, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_y);
    __Pyx_INCREF(__pyx_v_save_mean);
    __Pyx_GIVEREF(__pyx_v_save_mean);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_save_mean);
    __Pyx_INCREF(__pyx_v_save_inv_std);
    __Pyx_GIVEREF(__pyx_v_save_inv_std);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_save_inv_std);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2079
 *             'batch_normalization_forward_training().',
 *             util.PerformanceWarning)
 *     if mean is None:             # <<<<<<<<<<<<<<
 *         return y, save_mean, save_inv_std
 *     else:
 */
  }

  /* "cupy/cudnn.pyx":2082
 *         return y, save_mean, save_inv_std
 *     else:
 *         return y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_y);
    __pyx_r = __pyx_v_y;
    goto __pyx_L0;
  }

  /* "cupy/cudnn.pyx":2056
 * 
 * 
 * def batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_training", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reserve_space);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_save_mean);
  __Pyx_XDECREF(__pyx_v_save_inv_std);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2085
 * 
 * 
 * def batch_normalization_forward_training_ex(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_125batch_normalization_forward_training_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_124batch_normalization_forward_training_ex[] = "batch_normalization_forward_training_ex(ndarray x, ndarray gamma, ndarray beta, ndarray running_mean, ndarray running_var, mean, inv_std, double eps, double decay, bool is_for_conv2d, int cudnn_mode, bool debug, int d_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_125batch_normalization_forward_training_ex = {"batch_normalization_forward_training_ex", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_125batch_normalization_forward_training_ex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_124batch_normalization_forward_training_ex};
static PyObject *__pyx_pw_4cupy_5cudnn_125batch_normalization_forward_training_ex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var = 0;
  PyObject *__pyx_v_mean = 0;
  PyObject *__pyx_v_inv_std = 0;
  double __pyx_v_eps;
  double __pyx_v_decay;
  int __pyx_v_is_for_conv2d;
  int __pyx_v_cudnn_mode;
  int __pyx_v_debug;
  int __pyx_v_d_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("batch_normalization_forward_training_ex (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_gamma,&__pyx_n_s_beta,&__pyx_n_s_running_mean,&__pyx_n_s_running_var,&__pyx_n_s_mean,&__pyx_n_s_inv_std,&__pyx_n_s_eps,&__pyx_n_s_decay,&__pyx_n_s_is_for_conv2d,&__pyx_n_s_cudnn_mode,&__pyx_n_s_debug,&__pyx_n_s_d_layout,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 1); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 2); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_running_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 3); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_running_var)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 4); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 5); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inv_std)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 6); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_eps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 7); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decay)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 8); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_is_for_conv2d)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 9); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cudnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 10); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debug)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, 11); __PYX_ERR(0, 2085, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d_layout);
          if (value) { values[12] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "batch_normalization_forward_training_ex") < 0)) __PYX_ERR(0, 2085, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        values[7] = PyTuple_GET_ITEM(__pyx_args, 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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gamma = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_beta = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_running_mean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_running_var = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_mean = values[5];
    __pyx_v_inv_std = values[6];
    __pyx_v_eps = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_eps == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2088, __pyx_L3_error)
    __pyx_v_decay = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_decay == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2088, __pyx_L3_error)
    __pyx_v_is_for_conv2d = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_is_for_conv2d == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2089, __pyx_L3_error)
    __pyx_v_cudnn_mode = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_cudnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2089, __pyx_L3_error)
    __pyx_v_debug = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_debug == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2089, __pyx_L3_error)
    if (values[12]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[12]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2090, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__29;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_training_ex", 0, 12, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2085, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_training_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 2086, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gamma), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gamma", 0))) __PYX_ERR(0, 2086, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_beta), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "beta", 0))) __PYX_ERR(0, 2086, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_running_mean), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "running_mean", 0))) __PYX_ERR(0, 2087, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_running_var), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "running_var", 0))) __PYX_ERR(0, 2087, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_124batch_normalization_forward_training_ex(__pyx_self, __pyx_v_x, __pyx_v_gamma, __pyx_v_beta, __pyx_v_running_mean, __pyx_v_running_var, __pyx_v_mean, __pyx_v_inv_std, __pyx_v_eps, __pyx_v_decay, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_debug, __pyx_v_d_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_124batch_normalization_forward_training_ex(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var, PyObject *__pyx_v_mean, PyObject *__pyx_v_inv_std, double __pyx_v_eps, double __pyx_v_decay, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout) {
  PyObject *__pyx_v_reserve_space = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_save_mean = NULL;
  PyObject *__pyx_v_save_inv_std = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training __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)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("batch_normalization_forward_training_ex", 0);

  /* "cupy/cudnn.pyx":2093
 * 
 *     reserve_space, y, save_mean, save_inv_std = (
 *         _batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *             x, gamma, beta,
 *             running_mean, running_var,
 */
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.d_layout = __pyx_v_d_layout;
  __pyx_t_1 = __pyx_f_4cupy_5cudnn__batch_normalization_forward_training(__pyx_v_x, __pyx_v_gamma, __pyx_v_beta, __pyx_v_running_mean, __pyx_v_running_var, __pyx_v_mean, __pyx_v_inv_std, __pyx_v_eps, __pyx_v_decay, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_debug, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 2092, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2092, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_5,&__pyx_t_6};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2092, __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;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_8(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 4) < 0) __PYX_ERR(0, 2092, __pyx_L1_error)
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2092, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "cupy/cudnn.pyx":2092
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):
 * 
 *     reserve_space, y, save_mean, save_inv_std = (             # <<<<<<<<<<<<<<
 *         _batch_normalization_forward_training(
 *             x, gamma, beta,
 */
  __pyx_v_reserve_space = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_y = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_save_mean = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_save_inv_std = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cupy/cudnn.pyx":2102
 *             debug,
 *             d_layout))
 *     if mean is None:             # <<<<<<<<<<<<<<
 *         return reserve_space, y, save_mean, save_inv_std
 *     else:
 */
  __pyx_t_9 = (__pyx_v_mean == Py_None);
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "cupy/cudnn.pyx":2103
 *             d_layout))
 *     if mean is None:
 *         return reserve_space, y, save_mean, save_inv_std             # <<<<<<<<<<<<<<
 *     else:
 *         return reserve_space, y
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_reserve_space);
    __Pyx_GIVEREF(__pyx_v_reserve_space);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reserve_space);
    __Pyx_INCREF(__pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y);
    __Pyx_INCREF(__pyx_v_save_mean);
    __Pyx_GIVEREF(__pyx_v_save_mean);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_save_mean);
    __Pyx_INCREF(__pyx_v_save_inv_std);
    __Pyx_GIVEREF(__pyx_v_save_inv_std);
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_save_inv_std);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2102
 *             debug,
 *             d_layout))
 *     if mean is None:             # <<<<<<<<<<<<<<
 *         return reserve_space, y, save_mean, save_inv_std
 *     else:
 */
  }

  /* "cupy/cudnn.pyx":2105
 *         return reserve_space, y, save_mean, save_inv_std
 *     else:
 *         return reserve_space, y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_reserve_space);
    __Pyx_GIVEREF(__pyx_v_reserve_space);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reserve_space);
    __Pyx_INCREF(__pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cupy/cudnn.pyx":2085
 * 
 * 
 * def batch_normalization_forward_training_ex(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_training_ex", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reserve_space);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_save_mean);
  __Pyx_XDECREF(__pyx_v_save_inv_std);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2108
 * 
 * 
 * cdef _batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

static PyObject *__pyx_f_4cupy_5cudnn__batch_normalization_forward_training(struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var, PyObject *__pyx_v_mean, PyObject *__pyx_v_inv_std, double __pyx_v_eps, double __pyx_v_decay, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, struct __pyx_opt_args_4cupy_5cudnn__batch_normalization_forward_training *__pyx_optional_args) {
  int __pyx_v_d_layout = __pyx_k__30;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_y = NULL;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_derivedBnDesc;
  PyObject *__pyx_v_dtype_param = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_mean_tmp = NULL;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_running_var_tmp = NULL;
  PyObject *__pyx_v_save_mean = NULL;
  PyObject *__pyx_v_save_inv_std = NULL;
  double __pyx_v_factor;
  int __pyx_v_bn_ops;
  size_t __pyx_v_workspace_size;
  size_t __pyx_v_reserve_space_size;
  int __pyx_v_query_mode;
  PyObject *__pyx_v_rstatus = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn __pyx_t_7;
  size_t __pyx_t_8;
  size_t __pyx_t_9;
  size_t __pyx_t_10;
  size_t __pyx_t_11;
  size_t __pyx_t_12;
  size_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_batch_normalization_forward_training", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_d_layout = __pyx_optional_args->d_layout;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_gamma);
  __Pyx_INCREF((PyObject *)__pyx_v_beta);

  /* "cupy/cudnn.pyx":2115
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):
 * 
 *     cdef memory.MemoryPointer workspace = None             # <<<<<<<<<<<<<<
 *     cdef memory.MemoryPointer reserve_space = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None);

  /* "cupy/cudnn.pyx":2116
 * 
 *     cdef memory.MemoryPointer workspace = None
 *     cdef memory.MemoryPointer reserve_space = None             # <<<<<<<<<<<<<<
 * 
 *     # Usually supply None to mean and inv_std, which are left for backward
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None);

  /* "cupy/cudnn.pyx":2120
 *     # Usually supply None to mean and inv_std, which are left for backward
 *     # compatibility. See cupy#2060 and cupy#2070.
 *     if (mean is None) != (inv_std is None):             # <<<<<<<<<<<<<<
 *         raise ValueError('Both mean and inv_std must be None if one is.')
 * 
 */
  __pyx_t_1 = (__pyx_v_mean == Py_None);
  __pyx_t_2 = (__pyx_v_inv_std == Py_None);
  __pyx_t_3 = ((__pyx_t_1 != __pyx_t_2) != 0);
  if (unlikely(__pyx_t_3)) {

    /* "cupy/cudnn.pyx":2121
 *     # compatibility. See cupy#2060 and cupy#2070.
 *     if (mean is None) != (inv_std is None):
 *         raise ValueError('Both mean and inv_std must be None if one is.')             # <<<<<<<<<<<<<<
 * 
 *     x = core._internal_ascontiguousarray(x)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 2121, __pyx_L1_error)

    /* "cupy/cudnn.pyx":2120
 *     # Usually supply None to mean and inv_std, which are left for backward
 *     # compatibility. See cupy#2060 and cupy#2070.
 *     if (mean is None) != (inv_std is None):             # <<<<<<<<<<<<<<
 *         raise ValueError('Both mean and inv_std must be None if one is.')
 * 
 */
  }

  /* "cupy/cudnn.pyx":2123
 *         raise ValueError('Both mean and inv_std must be None if one is.')
 * 
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     dtype = x.dtype
 *     y = core.ndarray(x._shape, dtype)
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2123, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2124
 * 
 *     x = core._internal_ascontiguousarray(x)
 *     dtype = x.dtype             # <<<<<<<<<<<<<<
 *     y = core.ndarray(x._shape, dtype)
 * 
 */
  __pyx_t_4 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2125
 *     x = core._internal_ascontiguousarray(x)
 *     dtype = x.dtype
 *     y = core.ndarray(x._shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_one = 1
 */
  __pyx_t_4 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_y = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2127
 *     y = core.ndarray(x._shape, dtype)
 * 
 *     cdef float float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 */
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":2128
 * 
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":2129
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one             # <<<<<<<<<<<<<<
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one
 */
  __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

  /* "cupy/cudnn.pyx":2130
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2130, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":2131
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         one = <size_t>&float_one
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":2130
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    goto __pyx_L4;
  }

  /* "cupy/cudnn.pyx":2133
 *         one = <size_t>&double_one
 *     else:
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  /*else*/ {
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L4:;

  /* "cupy/cudnn.pyx":2135
 *         one = <size_t>&float_one
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 */
  __pyx_t_6 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_6 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2135, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_6;

  /* "cupy/cudnn.pyx":2136
 * 
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 */
  __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_6 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2136, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_6;

  /* "cupy/cudnn.pyx":2137
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 */
  __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_6 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2137, __pyx_L1_error)
  __pyx_v_derivedBnDesc = __pyx_t_6;

  /* "cupy/cudnn.pyx":2138
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":2139
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,             # <<<<<<<<<<<<<<
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 */
    __pyx_t_7.__pyx_n = 1;
    __pyx_t_7.format = __pyx_v_d_layout;
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_bn(__pyx_v_x_desc, __pyx_v_x, __pyx_v_is_for_conv2d, &__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2139, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":2141
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)             # <<<<<<<<<<<<<<
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:
 */
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_deriveBNTensorDescriptor(__pyx_v_derivedBnDesc, __pyx_v_x_desc, __pyx_v_cudnn_mode, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2141, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":2142
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)
 */
    __pyx_t_4 = __pyx_f_4cupy_5cudnn__get_dtype_of_tensor_descriptor(__pyx_v_derivedBnDesc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2142, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_dtype_param = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "cupy/cudnn.pyx":2143
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_gamma->dtype, __pyx_v_dtype_param, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2143, __pyx_L6_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2143, __pyx_L6_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_3) {

      /* "cupy/cudnn.pyx":2144
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             beta = beta.astype(dtype_param)
 *             running_mean_tmp = running_mean.astype(dtype_param)
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_gamma->__pyx_vtab)->astype(__pyx_v_gamma, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2144, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2145
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             running_mean_tmp = running_mean.astype(dtype_param)
 *             running_var_tmp = running_var.astype(dtype_param)
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_beta->__pyx_vtab)->astype(__pyx_v_beta, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2145, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_beta, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2146
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 *             running_mean_tmp = running_mean.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             running_var_tmp = running_var.astype(dtype_param)
 *         else:
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_running_mean->__pyx_vtab)->astype(__pyx_v_running_mean, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2146, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_running_mean_tmp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2147
 *             beta = beta.astype(dtype_param)
 *             running_mean_tmp = running_mean.astype(dtype_param)
 *             running_var_tmp = running_var.astype(dtype_param)             # <<<<<<<<<<<<<<
 *         else:
 *             running_mean_tmp = running_mean
 */
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_running_var->__pyx_vtab)->astype(__pyx_v_running_var, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2147, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_running_var_tmp = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2143
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 */
      goto __pyx_L8;
    }

    /* "cupy/cudnn.pyx":2149
 *             running_var_tmp = running_var.astype(dtype_param)
 *         else:
 *             running_mean_tmp = running_mean             # <<<<<<<<<<<<<<
 *             running_var_tmp = running_var
 *             gamma = core._internal_ascontiguousarray(gamma)
 */
    /*else*/ {
      __Pyx_INCREF(((PyObject *)__pyx_v_running_mean));
      __pyx_v_running_mean_tmp = __pyx_v_running_mean;

      /* "cupy/cudnn.pyx":2150
 *         else:
 *             running_mean_tmp = running_mean
 *             running_var_tmp = running_var             # <<<<<<<<<<<<<<
 *             gamma = core._internal_ascontiguousarray(gamma)
 *             beta = core._internal_ascontiguousarray(beta)
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_running_var));
      __pyx_v_running_var_tmp = __pyx_v_running_var;

      /* "cupy/cudnn.pyx":2151
 *             running_mean_tmp = running_mean
 *             running_var_tmp = running_var
 *             gamma = core._internal_ascontiguousarray(gamma)             # <<<<<<<<<<<<<<
 *             beta = core._internal_ascontiguousarray(beta)
 *         if mean is None:
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gamma, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2151, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2152
 *             running_var_tmp = running_var
 *             gamma = core._internal_ascontiguousarray(gamma)
 *             beta = core._internal_ascontiguousarray(beta)             # <<<<<<<<<<<<<<
 *         if mean is None:
 *             save_mean = core.ndarray(gamma.shape, dtype_param)
 */
      __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_beta, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2152, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF_SET(__pyx_v_beta, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_4));
      __pyx_t_4 = 0;
    }
    __pyx_L8:;

    /* "cupy/cudnn.pyx":2153
 *             gamma = core._internal_ascontiguousarray(gamma)
 *             beta = core._internal_ascontiguousarray(beta)
 *         if mean is None:             # <<<<<<<<<<<<<<
 *             save_mean = core.ndarray(gamma.shape, dtype_param)
 *             save_inv_std = core.ndarray(gamma.shape, dtype_param)
 */
    __pyx_t_3 = (__pyx_v_mean == Py_None);
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":2154
 *             beta = core._internal_ascontiguousarray(beta)
 *         if mean is None:
 *             save_mean = core.ndarray(gamma.shape, dtype_param)             # <<<<<<<<<<<<<<
 *             save_inv_std = core.ndarray(gamma.shape, dtype_param)
 *         else:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_gamma), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2154, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2154, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_dtype_param);
      __Pyx_GIVEREF(__pyx_v_dtype_param);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype_param);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2154, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_save_mean = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2155
 *         if mean is None:
 *             save_mean = core.ndarray(gamma.shape, dtype_param)
 *             save_inv_std = core.ndarray(gamma.shape, dtype_param)             # <<<<<<<<<<<<<<
 *         else:
 *             save_mean = mean
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_gamma), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2155, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2155, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_dtype_param);
      __Pyx_GIVEREF(__pyx_v_dtype_param);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_dtype_param);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2155, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_save_inv_std = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2153
 *             gamma = core._internal_ascontiguousarray(gamma)
 *             beta = core._internal_ascontiguousarray(beta)
 *         if mean is None:             # <<<<<<<<<<<<<<
 *             save_mean = core.ndarray(gamma.shape, dtype_param)
 *             save_inv_std = core.ndarray(gamma.shape, dtype_param)
 */
      goto __pyx_L9;
    }

    /* "cupy/cudnn.pyx":2157
 *             save_inv_std = core.ndarray(gamma.shape, dtype_param)
 *         else:
 *             save_mean = mean             # <<<<<<<<<<<<<<
 *             save_inv_std = inv_std
 * 
 */
    /*else*/ {
      __Pyx_INCREF(__pyx_v_mean);
      __pyx_v_save_mean = __pyx_v_mean;

      /* "cupy/cudnn.pyx":2158
 *         else:
 *             save_mean = mean
 *             save_inv_std = inv_std             # <<<<<<<<<<<<<<
 * 
 *         # Factor used in the moving average
 */
      __Pyx_INCREF(__pyx_v_inv_std);
      __pyx_v_save_inv_std = __pyx_v_inv_std;
    }
    __pyx_L9:;

    /* "cupy/cudnn.pyx":2161
 * 
 *         # Factor used in the moving average
 *         factor = 1.0 - decay             # <<<<<<<<<<<<<<
 * 
 *         # Note: cuDNN computes the mini-batch mean and variance
 */
    __pyx_v_factor = (1.0 - __pyx_v_decay);

    /* "cupy/cudnn.pyx":2171
 *         # we can reduce the number of reduction kernels.
 * 
 *         if _cudnn_version >= 7401:             # <<<<<<<<<<<<<<
 * 
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 */
    __pyx_t_2 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1CE9) != 0);
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":2173
 *         if _cudnn_version >= 7401:
 * 
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN             # <<<<<<<<<<<<<<
 * 
 *             if (
 */
      __pyx_v_bn_ops = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_OPS_BN;

      /* "cupy/cudnn.pyx":2176
 * 
 *             if (
 *                     cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT             # <<<<<<<<<<<<<<
 *                     and x.dtype == numpy.float16
 *                     and d_layout == cudnn.CUDNN_TENSOR_NHWC
 */
      __pyx_t_3 = ((__pyx_v_cudnn_mode == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_SPATIAL_PERSISTENT) != 0);
      if (__pyx_t_3) {
      } else {
        __pyx_t_2 = __pyx_t_3;
        goto __pyx_L12_bool_binop_done;
      }

      /* "cupy/cudnn.pyx":2177
 *             if (
 *                     cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT
 *                     and x.dtype == numpy.float16             # <<<<<<<<<<<<<<
 *                     and d_layout == cudnn.CUDNN_TENSOR_NHWC
 *                     and x.shape[3] % 4 == 0  # C mod 4 == 0
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2177, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2177, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_x->dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2177, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2177, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_3) {
      } else {
        __pyx_t_2 = __pyx_t_3;
        goto __pyx_L12_bool_binop_done;
      }

      /* "cupy/cudnn.pyx":2178
 *                     cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT
 *                     and x.dtype == numpy.float16
 *                     and d_layout == cudnn.CUDNN_TENSOR_NHWC             # <<<<<<<<<<<<<<
 *                     and x.shape[3] % 4 == 0  # C mod 4 == 0
 *             ):
 */
      __pyx_t_3 = ((__pyx_v_d_layout == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NHWC) != 0);
      if (__pyx_t_3) {
      } else {
        __pyx_t_2 = __pyx_t_3;
        goto __pyx_L12_bool_binop_done;
      }

      /* "cupy/cudnn.pyx":2179
 *                     and x.dtype == numpy.float16
 *                     and d_layout == cudnn.CUDNN_TENSOR_NHWC
 *                     and x.shape[3] % 4 == 0  # C mod 4 == 0             # <<<<<<<<<<<<<<
 *             ):
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2179, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2179, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyInt_RemainderObjC(__pyx_t_5, __pyx_int_4, 4, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2179, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyInt_EqObjC(__pyx_t_4, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2179, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2179, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __pyx_t_3;
      __pyx_L12_bool_binop_done:;

      /* "cupy/cudnn.pyx":2175
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 * 
 *             if (             # <<<<<<<<<<<<<<
 *                     cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT
 *                     and x.dtype == numpy.float16
 */
      if (__pyx_t_2) {

        /* "cupy/cudnn.pyx":2186
 *                 # https://docs.nvidia.com/deeplearning/sdk/cudnn-archived/cudnn_741/cudnn-developer-guide/index.html#cudnnBatchNormalizationForwardTrainingEx  # NOQA
 *                 workspace_size = (
 *                     cudnn.getBatchNormalizationForwardTrainingExWorkspaceSize(             # <<<<<<<<<<<<<<
 *                         handle,
 *                         cudnn_mode,
 */
        __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationForwardTrainingExWorkspaceSize(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_bn_ops, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_derivedBnDesc, 0, 0); if (unlikely(__pyx_t_6 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2186, __pyx_L6_error)
        __pyx_v_workspace_size = __pyx_t_6;

        /* "cupy/cudnn.pyx":2196
 *                         0,  # activation desc
 *                     ))
 *                 workspace = memory.alloc(workspace_size)             # <<<<<<<<<<<<<<
 * 
 *                 reserve_space_size = (
 */
        __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2196, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2196, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF_SET(__pyx_v_workspace, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_4));
        __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":2199
 * 
 *                 reserve_space_size = (
 *                     cudnn.getBatchNormalizationTrainingExReserveSpaceSize(             # <<<<<<<<<<<<<<
 *                         handle,
 *                         cudnn_mode,
 */
        __pyx_t_6 = __pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationTrainingExReserveSpaceSize(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_bn_ops, 0, __pyx_v_x_desc, 0); if (unlikely(__pyx_t_6 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2199, __pyx_L6_error)
        __pyx_v_reserve_space_size = __pyx_t_6;

        /* "cupy/cudnn.pyx":2206
 *                         x_desc,
 *                     ))
 *                 reserve_space = memory.alloc(reserve_space_size)             # <<<<<<<<<<<<<<
 * 
 *             cudnn.batchNormalizationForwardTrainingEx(
 */
        __pyx_t_4 = __Pyx_PyInt_FromSize_t(__pyx_v_reserve_space_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2206, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_4, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2206, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF_SET(__pyx_v_reserve_space, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5));
        __pyx_t_5 = 0;

        /* "cupy/cudnn.pyx":2175
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 * 
 *             if (             # <<<<<<<<<<<<<<
 *                     cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT
 *                     and x.dtype == numpy.float16
 */
      }

      /* "cupy/cudnn.pyx":2216
 *                 x_desc, x.data.ptr,  # x
 *                 x_desc, 0,  # z
 *                 x_desc, y.data.ptr,  # y             # <<<<<<<<<<<<<<
 *                 derivedBnDesc,
 *                 gamma.data.ptr,
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2216, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2216, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2216, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2224
 *                 running_var_tmp.data.ptr,
 *                 eps,
 *                 save_mean.data.ptr,             # <<<<<<<<<<<<<<
 *                 save_inv_std.data.ptr,
 *                 0,  # activation
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_save_mean, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2224, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2224, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2224, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":2225
 *                 eps,
 *                 save_mean.data.ptr,
 *                 save_inv_std.data.ptr,             # <<<<<<<<<<<<<<
 *                 0,  # activation
 *                 0 if workspace is None else workspace.ptr,
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_save_inv_std, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2225, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2225, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_9 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2225, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2227
 *                 save_inv_std.data.ptr,
 *                 0,  # activation
 *                 0 if workspace is None else workspace.ptr,             # <<<<<<<<<<<<<<
 *                 0 if workspace is None else workspace.mem.size,
 *                 0 if reserve_space is None else reserve_space.ptr,
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_workspace) == Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_10 = 0;
      } else {
        __pyx_t_10 = __pyx_v_workspace->ptr;
      }

      /* "cupy/cudnn.pyx":2228
 *                 0,  # activation
 *                 0 if workspace is None else workspace.ptr,
 *                 0 if workspace is None else workspace.mem.size,             # <<<<<<<<<<<<<<
 *                 0 if reserve_space is None else reserve_space.ptr,
 *                 0 if reserve_space is None else reserve_space.mem.size,
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_workspace) == Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_11 = 0;
      } else {
        __pyx_t_11 = __pyx_v_workspace->mem->size;
      }

      /* "cupy/cudnn.pyx":2229
 *                 0 if workspace is None else workspace.ptr,
 *                 0 if workspace is None else workspace.mem.size,
 *                 0 if reserve_space is None else reserve_space.ptr,             # <<<<<<<<<<<<<<
 *                 0 if reserve_space is None else reserve_space.mem.size,
 *             )
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_reserve_space) == Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_12 = 0;
      } else {
        __pyx_t_12 = __pyx_v_reserve_space->ptr;
      }

      /* "cupy/cudnn.pyx":2230
 *                 0 if workspace is None else workspace.mem.size,
 *                 0 if reserve_space is None else reserve_space.ptr,
 *                 0 if reserve_space is None else reserve_space.mem.size,             # <<<<<<<<<<<<<<
 *             )
 * 
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_reserve_space) == Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_13 = 0;
      } else {
        __pyx_t_13 = __pyx_v_reserve_space->mem->size;
      }

      /* "cupy/cudnn.pyx":2208
 *                 reserve_space = memory.alloc(reserve_space_size)
 * 
 *             cudnn.batchNormalizationForwardTrainingEx(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 cudnn_mode,
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTrainingEx(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_bn_ops, __pyx_v_one, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, 0, __pyx_v_x_desc, __pyx_t_6, __pyx_v_derivedBnDesc, __pyx_v_gamma->data->ptr, __pyx_v_beta->data->ptr, __pyx_v_factor, __pyx_v_running_mean_tmp->data->ptr, __pyx_v_running_var_tmp->data->ptr, __pyx_v_eps, __pyx_t_8, __pyx_t_9, 0, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2208, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2171
 *         # we can reduce the number of reduction kernels.
 * 
 *         if _cudnn_version >= 7401:             # <<<<<<<<<<<<<<
 * 
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 */
      goto __pyx_L10;
    }

    /* "cupy/cudnn.pyx":2234
 * 
 *         else:  # cuDNN < 7401
 *             cudnn.batchNormalizationForwardTraining(             # <<<<<<<<<<<<<<
 *                 handle, cudnn_mode, one, zero,
 *                 x_desc, x.data.ptr, x_desc, y.data.ptr,
 */
    /*else*/ {

      /* "cupy/cudnn.pyx":2236
 *             cudnn.batchNormalizationForwardTraining(
 *                 handle, cudnn_mode, one, zero,
 *                 x_desc, x.data.ptr, x_desc, y.data.ptr,             # <<<<<<<<<<<<<<
 *                 derivedBnDesc, gamma.data.ptr,
 *                 beta.data.ptr, factor, running_mean_tmp.data.ptr,
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2236, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2236, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2236, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":2240
 *                 beta.data.ptr, factor, running_mean_tmp.data.ptr,
 *                 running_var_tmp.data.ptr, eps,
 *                 save_mean.data.ptr, save_inv_std.data.ptr)             # <<<<<<<<<<<<<<
 * 
 *         # Note: When the CUDNN_BATCHNORM_SPATIAL_PERSISTENT mode is used,
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_save_mean, __pyx_n_s_data); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_12 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_save_inv_std, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2240, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":2234
 * 
 *         else:  # cuDNN < 7401
 *             cudnn.batchNormalizationForwardTraining(             # <<<<<<<<<<<<<<
 *                 handle, cudnn_mode, one, zero,
 *                 x_desc, x.data.ptr, x_desc, y.data.ptr,
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTraining(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_one, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, __pyx_t_13, __pyx_v_derivedBnDesc, __pyx_v_gamma->data->ptr, __pyx_v_beta->data->ptr, __pyx_v_factor, __pyx_v_running_mean_tmp->data->ptr, __pyx_v_running_var_tmp->data->ptr, __pyx_v_eps, __pyx_t_12, __pyx_t_11, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2234, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __pyx_L10:;

    /* "cupy/cudnn.pyx":2246
 *         # queryRuntimeError() to make sure whether the overflow actually
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:             # <<<<<<<<<<<<<<
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 */
    __pyx_t_3 = (__pyx_v_debug != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_2 = __pyx_t_3;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_cudnn_mode == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_SPATIAL_PERSISTENT) != 0);
    __pyx_t_2 = __pyx_t_3;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_2) {

      /* "cupy/cudnn.pyx":2247
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING             # <<<<<<<<<<<<<<
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 */
      __pyx_v_query_mode = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ERRQUERY_BLOCKING;

      /* "cupy/cudnn.pyx":2248
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)             # <<<<<<<<<<<<<<
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 *                 warnings.warn(
 */
      __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_queryRuntimeError(__pyx_v_handle, __pyx_v_query_mode, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2248, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_rstatus = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "cupy/cudnn.pyx":2249
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 */
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2249, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_rstatus, __pyx_t_5, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2249, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2249, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {

        /* "cupy/cudnn.pyx":2250
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 *                 warnings.warn(             # <<<<<<<<<<<<<<
 *                     'A numerical overflow might have happend in cuDNN'
 *                     'batch normalization (status:{})'.format(rstatus))
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_warnings); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2250, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warn); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2250, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cupy/cudnn.pyx":2252
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 *                     'batch normalization (status:{})'.format(rstatus))             # <<<<<<<<<<<<<<
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 */
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_A_numerical_overflow_might_have, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2252, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15);
          if (likely(__pyx_t_16)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_15, function);
          }
        }
        __pyx_t_5 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_16, __pyx_v_rstatus) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_v_rstatus);
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2252, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
          if (likely(__pyx_t_15)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_14, function);
          }
        }
        __pyx_t_4 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_14, __pyx_t_15, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2250, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":2249
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 */
      }

      /* "cupy/cudnn.pyx":2246
 *         # queryRuntimeError() to make sure whether the overflow actually
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:             # <<<<<<<<<<<<<<
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 */
    }
  }

  /* "cupy/cudnn.pyx":2254
 *                     'batch normalization (status:{})'.format(rstatus))
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     if running_mean is not running_mean_tmp:
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2254, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cupy/cudnn.pyx":2255
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *     if running_mean is not running_mean_tmp:
 *         running_mean[...] = running_mean_tmp
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2255, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L7;
    }
    __pyx_L6_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
      __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_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_XGOTREF(__pyx_t_22);
      __Pyx_XGOTREF(__pyx_t_23);
      __Pyx_XGOTREF(__pyx_t_24);
      __Pyx_XGOTREF(__pyx_t_25);
      __pyx_t_17 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":2254
 *                     'batch normalization (status:{})'.format(rstatus))
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     if running_mean is not running_mean_tmp:
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2254, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "cupy/cudnn.pyx":2255
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *     if running_mean is not running_mean_tmp:
 *         running_mean[...] = running_mean_tmp
 */
        __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2255, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_XGIVEREF(__pyx_t_24);
        __Pyx_XGIVEREF(__pyx_t_25);
        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
      }
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_XGIVEREF(__pyx_t_21);
      __Pyx_XGIVEREF(__pyx_t_22);
      __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
      __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
      goto __pyx_L1_error;
      __pyx_L21_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_XGIVEREF(__pyx_t_24);
        __Pyx_XGIVEREF(__pyx_t_25);
        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
      }
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
      __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "cupy/cudnn.pyx":2256
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     if running_mean is not running_mean_tmp:             # <<<<<<<<<<<<<<
 *         running_mean[...] = running_mean_tmp
 *         running_var[...] = running_var_tmp
 */
  __pyx_t_2 = (__pyx_v_running_mean != __pyx_v_running_mean_tmp);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":2257
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     if running_mean is not running_mean_tmp:
 *         running_mean[...] = running_mean_tmp             # <<<<<<<<<<<<<<
 *         running_var[...] = running_var_tmp
 *     return reserve_space, y, save_mean, save_inv_std
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_running_mean), Py_Ellipsis, ((PyObject *)__pyx_v_running_mean_tmp)) < 0)) __PYX_ERR(0, 2257, __pyx_L1_error)

    /* "cupy/cudnn.pyx":2258
 *     if running_mean is not running_mean_tmp:
 *         running_mean[...] = running_mean_tmp
 *         running_var[...] = running_var_tmp             # <<<<<<<<<<<<<<
 *     return reserve_space, y, save_mean, save_inv_std
 * 
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_running_var), Py_Ellipsis, ((PyObject *)__pyx_v_running_var_tmp)) < 0)) __PYX_ERR(0, 2258, __pyx_L1_error)

    /* "cupy/cudnn.pyx":2256
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     if running_mean is not running_mean_tmp:             # <<<<<<<<<<<<<<
 *         running_mean[...] = running_mean_tmp
 *         running_var[...] = running_var_tmp
 */
  }

  /* "cupy/cudnn.pyx":2259
 *         running_mean[...] = running_mean_tmp
 *         running_var[...] = running_var_tmp
 *     return reserve_space, y, save_mean, save_inv_std             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_reserve_space));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_reserve_space));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_reserve_space));
  __Pyx_INCREF(__pyx_v_y);
  __Pyx_GIVEREF(__pyx_v_y);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_y);
  __Pyx_INCREF(__pyx_v_save_mean);
  __Pyx_GIVEREF(__pyx_v_save_mean);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_save_mean);
  __Pyx_INCREF(__pyx_v_save_inv_std);
  __Pyx_GIVEREF(__pyx_v_save_inv_std);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_save_inv_std);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2108
 * 
 * 
 * cdef _batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("cupy.cudnn._batch_normalization_forward_training", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF((PyObject *)__pyx_v_reserve_space);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_dtype_param);
  __Pyx_XDECREF((PyObject *)__pyx_v_running_mean_tmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_running_var_tmp);
  __Pyx_XDECREF(__pyx_v_save_mean);
  __Pyx_XDECREF(__pyx_v_save_inv_std);
  __Pyx_XDECREF(__pyx_v_rstatus);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_gamma);
  __Pyx_XDECREF((PyObject *)__pyx_v_beta);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2262
 * 
 * 
 * def batch_normalization_forward_inference(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray mean, core.ndarray var,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_127batch_normalization_forward_inference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_126batch_normalization_forward_inference[] = "batch_normalization_forward_inference(ndarray x, ndarray gamma, ndarray beta, ndarray mean, ndarray var, double eps, bool is_for_conv2d, int cudnn_mode, int d_layout=cudnn.CUDNN_TENSOR_NCHW)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_127batch_normalization_forward_inference = {"batch_normalization_forward_inference", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_127batch_normalization_forward_inference, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_126batch_normalization_forward_inference};
static PyObject *__pyx_pw_4cupy_5cudnn_127batch_normalization_forward_inference(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_var = 0;
  double __pyx_v_eps;
  int __pyx_v_is_for_conv2d;
  int __pyx_v_cudnn_mode;
  int __pyx_v_d_layout;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("batch_normalization_forward_inference (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_gamma,&__pyx_n_s_beta,&__pyx_n_s_mean,&__pyx_n_s_var,&__pyx_n_s_eps,&__pyx_n_s_is_for_conv2d,&__pyx_n_s_cudnn_mode,&__pyx_n_s_d_layout,0};
    PyObject* values[9] = {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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 1); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_beta)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 2); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 3); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_var)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 4); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_eps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 5); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_is_for_conv2d)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 6); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cudnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, 7); __PYX_ERR(0, 2262, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d_layout);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "batch_normalization_forward_inference") < 0)) __PYX_ERR(0, 2262, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gamma = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_beta = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_mean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_var = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_eps = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_eps == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2265, __pyx_L3_error)
    __pyx_v_is_for_conv2d = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_is_for_conv2d == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2265, __pyx_L3_error)
    __pyx_v_cudnn_mode = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_cudnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2265, __pyx_L3_error)
    if (values[8]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2266, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__32;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("batch_normalization_forward_inference", 0, 8, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2262, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_inference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 2263, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gamma), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gamma", 0))) __PYX_ERR(0, 2263, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_beta), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "beta", 0))) __PYX_ERR(0, 2263, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mean), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mean", 0))) __PYX_ERR(0, 2264, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_var), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "var", 0))) __PYX_ERR(0, 2264, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_126batch_normalization_forward_inference(__pyx_self, __pyx_v_x, __pyx_v_gamma, __pyx_v_beta, __pyx_v_mean, __pyx_v_var, __pyx_v_eps, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_d_layout);

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

static PyObject *__pyx_pf_4cupy_5cudnn_126batch_normalization_forward_inference(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_beta, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_var, double __pyx_v_eps, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_d_layout) {
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_y = NULL;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_derivedBnDesc;
  PyObject *__pyx_v_dtype_param = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  size_t __pyx_t_4;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  char const *__pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("batch_normalization_forward_inference", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_gamma);
  __Pyx_INCREF((PyObject *)__pyx_v_beta);
  __Pyx_INCREF((PyObject *)__pyx_v_mean);
  __Pyx_INCREF((PyObject *)__pyx_v_var);

  /* "cupy/cudnn.pyx":2267
 *         double eps, bint is_for_conv2d, int cudnn_mode,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     dtype = x.dtype
 *     y = core.ndarray(x._shape, dtype)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2268
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     x = core._internal_ascontiguousarray(x)
 *     dtype = x.dtype             # <<<<<<<<<<<<<<
 *     y = core.ndarray(x._shape, dtype)
 * 
 */
  __pyx_t_1 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2269
 *     x = core._internal_ascontiguousarray(x)
 *     dtype = x.dtype
 *     y = core.ndarray(x._shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_one = 1
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2269, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_y = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2271
 *     y = core.ndarray(x._shape, dtype)
 * 
 *     cdef float float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 */
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":2272
 * 
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":2273
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one             # <<<<<<<<<<<<<<
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one
 */
  __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

  /* "cupy/cudnn.pyx":2274
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2274, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":2275
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         one = <size_t>&float_one
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":2274
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":2277
 *         one = <size_t>&double_one
 *     else:
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  /*else*/ {
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":2279
 *         one = <size_t>&float_one
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2279, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":2280
 * 
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2280, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2281
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2281, __pyx_L1_error)
  __pyx_v_derivedBnDesc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2282
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":2283
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,             # <<<<<<<<<<<<<<
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 */
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_bn(__pyx_v_x_desc, __pyx_v_x, __pyx_v_is_for_conv2d, &__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2283, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2285
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)             # <<<<<<<<<<<<<<
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_deriveBNTensorDescriptor(__pyx_v_derivedBnDesc, __pyx_v_x_desc, __pyx_v_cudnn_mode, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2285, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2286
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)
 */
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__get_dtype_of_tensor_descriptor(__pyx_v_derivedBnDesc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2286, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_dtype_param = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2287
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_gamma->dtype, __pyx_v_dtype_param, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2287, __pyx_L5_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2287, __pyx_L5_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cupy/cudnn.pyx":2288
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             beta = beta.astype(dtype_param)
 *             mean = mean.astype(dtype_param)
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_gamma->__pyx_vtab)->astype(__pyx_v_gamma, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2288, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2289
 *         if gamma.dtype != dtype_param:
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             mean = mean.astype(dtype_param)
 *             var = var.astype(dtype_param)
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_beta->__pyx_vtab)->astype(__pyx_v_beta, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2289, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_beta, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2290
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 *             mean = mean.astype(dtype_param)             # <<<<<<<<<<<<<<
 *             var = var.astype(dtype_param)
 *         else:
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_mean->__pyx_vtab)->astype(__pyx_v_mean, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2290, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_mean, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2291
 *             beta = beta.astype(dtype_param)
 *             mean = mean.astype(dtype_param)
 *             var = var.astype(dtype_param)             # <<<<<<<<<<<<<<
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_var->__pyx_vtab)->astype(__pyx_v_var, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2291, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_var, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2287
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         if gamma.dtype != dtype_param:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *             beta = beta.astype(dtype_param)
 */
      goto __pyx_L7;
    }

    /* "cupy/cudnn.pyx":2293
 *             var = var.astype(dtype_param)
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)             # <<<<<<<<<<<<<<
 *             beta = core._internal_ascontiguousarray(beta)
 * 
 */
    /*else*/ {
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gamma, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2293, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2294
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)
 *             beta = core._internal_ascontiguousarray(beta)             # <<<<<<<<<<<<<<
 * 
 *         cudnn.batchNormalizationForwardInference(
 */
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_beta, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2294, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_beta, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;
    }
    __pyx_L7:;

    /* "cupy/cudnn.pyx":2298
 *         cudnn.batchNormalizationForwardInference(
 *             handle, cudnn_mode, one, zero,
 *             x_desc, x.data.ptr, x_desc, y.data.ptr,             # <<<<<<<<<<<<<<
 *             derivedBnDesc, gamma.data.ptr, beta.data.ptr,
 *             mean.data.ptr, var.data.ptr, eps)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2298, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2298, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2298, __pyx_L5_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2296
 *             beta = core._internal_ascontiguousarray(beta)
 * 
 *         cudnn.batchNormalizationForwardInference(             # <<<<<<<<<<<<<<
 *             handle, cudnn_mode, one, zero,
 *             x_desc, x.data.ptr, x_desc, y.data.ptr,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardInference(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_one, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, __pyx_t_4, __pyx_v_derivedBnDesc, __pyx_v_gamma->data->ptr, __pyx_v_beta->data->ptr, __pyx_v_mean->data->ptr, __pyx_v_var->data->ptr, __pyx_v_eps, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2296, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "cupy/cudnn.pyx":2302
 *             mean.data.ptr, var.data.ptr, eps)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     return y
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2303
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2303, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":2302
 *             mean.data.ptr, var.data.ptr, eps)
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     return y
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2302, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":2303
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *     return y
 * 
 */
        __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2303, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __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_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __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_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":2304
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 *     return y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_y);
  __pyx_r = __pyx_v_y;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2262
 * 
 * 
 * def batch_normalization_forward_inference(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray mean, core.ndarray var,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_forward_inference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_dtype_param);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_gamma);
  __Pyx_XDECREF((PyObject *)__pyx_v_beta);
  __Pyx_XDECREF((PyObject *)__pyx_v_mean);
  __Pyx_XDECREF((PyObject *)__pyx_v_var);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2307
 * 
 * 
 * def batch_normalization_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray gy,
 *         core.ndarray mean, core.ndarray inv_std,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_129batch_normalization_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_128batch_normalization_backward[] = "batch_normalization_backward(ndarray x, ndarray gamma, ndarray gy, ndarray mean, ndarray inv_std, double eps, bool is_for_conv2d, int cudnn_mode, bool debug, int d_layout=cudnn.CUDNN_TENSOR_NCHW, *, MemoryPointer reserve_space=None)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_129batch_normalization_backward = {"batch_normalization_backward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_129batch_normalization_backward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_128batch_normalization_backward};
static PyObject *__pyx_pw_4cupy_5cudnn_129batch_normalization_backward(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_inv_std = 0;
  double __pyx_v_eps;
  int __pyx_v_is_for_conv2d;
  int __pyx_v_cudnn_mode;
  int __pyx_v_debug;
  int __pyx_v_d_layout;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("batch_normalization_backward (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_gamma,&__pyx_n_s_gy,&__pyx_n_s_mean,&__pyx_n_s_inv_std,&__pyx_n_s_eps,&__pyx_n_s_is_for_conv2d,&__pyx_n_s_cudnn_mode,&__pyx_n_s_debug,&__pyx_n_s_d_layout,&__pyx_n_s_reserve_space,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};

    /* "cupy/cudnn.pyx":2313
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         *,
 *         memory.MemoryPointer reserve_space=None,             # <<<<<<<<<<<<<<
 * ):
 *     cdef core.ndarray ggamma, gbeta
 */
    values[10] = (PyObject *)((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)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 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 1); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gy)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 2); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mean)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 3); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inv_std)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 4); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_eps)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 5); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_is_for_conv2d)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 6); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cudnn_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 7); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_debug)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, 8); __PYX_ERR(0, 2307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d_layout);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (kw_args == 1) {
        const Py_ssize_t index = 10;
        PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "batch_normalization_backward") < 0)) __PYX_ERR(0, 2307, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        values[7] = PyTuple_GET_ITEM(__pyx_args, 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_x = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[0]);
    __pyx_v_gamma = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[1]);
    __pyx_v_gy = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[2]);
    __pyx_v_mean = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[3]);
    __pyx_v_inv_std = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)values[4]);
    __pyx_v_eps = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_eps == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2310, __pyx_L3_error)
    __pyx_v_is_for_conv2d = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_is_for_conv2d == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2310, __pyx_L3_error)
    __pyx_v_cudnn_mode = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_cudnn_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2310, __pyx_L3_error)
    __pyx_v_debug = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_debug == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2310, __pyx_L3_error)
    if (values[9]) {
      __pyx_v_d_layout = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_d_layout == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2311, __pyx_L3_error)
    } else {
      __pyx_v_d_layout = __pyx_k__33;
    }
    __pyx_v_reserve_space = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)values[10]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("batch_normalization_backward", 0, 9, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2307, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "x", 0))) __PYX_ERR(0, 2308, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gamma), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gamma", 0))) __PYX_ERR(0, 2308, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gy), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "gy", 0))) __PYX_ERR(0, 2308, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mean), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "mean", 0))) __PYX_ERR(0, 2309, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inv_std), __pyx_ptype_4cupy_4core_4core_ndarray, 1, "inv_std", 0))) __PYX_ERR(0, 2309, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reserve_space), __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer, 1, "reserve_space", 0))) __PYX_ERR(0, 2313, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_128batch_normalization_backward(__pyx_self, __pyx_v_x, __pyx_v_gamma, __pyx_v_gy, __pyx_v_mean, __pyx_v_inv_std, __pyx_v_eps, __pyx_v_is_for_conv2d, __pyx_v_cudnn_mode, __pyx_v_debug, __pyx_v_d_layout, __pyx_v_reserve_space);

  /* "cupy/cudnn.pyx":2307
 * 
 * 
 * def batch_normalization_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray gy,
 *         core.ndarray mean, core.ndarray inv_std,
 */

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

static PyObject *__pyx_pf_4cupy_5cudnn_128batch_normalization_backward(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_x, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gamma, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gy, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_mean, struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_inv_std, double __pyx_v_eps, int __pyx_v_is_for_conv2d, int __pyx_v_cudnn_mode, int __pyx_v_debug, int __pyx_v_d_layout, struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_reserve_space) {
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_ggamma = 0;
  struct __pyx_obj_4cupy_4core_4core_ndarray *__pyx_v_gbeta = 0;
  int __pyx_v_need_cast;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_workspace = 0;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_gx = NULL;
  float __pyx_v_float_one;
  double __pyx_v_double_zero;
  double __pyx_v_double_one;
  size_t __pyx_v_zero;
  size_t __pyx_v_one;
  size_t __pyx_v_handle;
  size_t __pyx_v_x_desc;
  size_t __pyx_v_derivedBnDesc;
  PyObject *__pyx_v_dtype_param = NULL;
  int __pyx_v_bn_ops;
  size_t __pyx_v_workspace_size;
  int __pyx_v_query_mode;
  PyObject *__pyx_v_rstatus = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  size_t __pyx_t_4;
  struct __pyx_opt_args_4cupy_5cudnn__create_tensor_descriptor_for_bn __pyx_t_5;
  size_t __pyx_t_6;
  size_t __pyx_t_7;
  size_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("batch_normalization_backward", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_gamma);
  __Pyx_INCREF((PyObject *)__pyx_v_gy);

  /* "cupy/cudnn.pyx":2317
 *     cdef core.ndarray ggamma, gbeta
 *     cdef bint need_cast
 *     cdef memory.MemoryPointer workspace = None             # <<<<<<<<<<<<<<
 * 
 *     x = core._internal_ascontiguousarray(x)
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_workspace = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None);

  /* "cupy/cudnn.pyx":2319
 *     cdef memory.MemoryPointer workspace = None
 * 
 *     x = core._internal_ascontiguousarray(x)             # <<<<<<<<<<<<<<
 *     gy = core._internal_ascontiguousarray(gy)
 *     dtype = x.dtype
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_x, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2320
 * 
 *     x = core._internal_ascontiguousarray(x)
 *     gy = core._internal_ascontiguousarray(gy)             # <<<<<<<<<<<<<<
 *     dtype = x.dtype
 *     gx = core.ndarray(x._shape, dtype)
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gy, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_gy, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2321
 *     x = core._internal_ascontiguousarray(x)
 *     gy = core._internal_ascontiguousarray(gy)
 *     dtype = x.dtype             # <<<<<<<<<<<<<<
 *     gx = core.ndarray(x._shape, dtype)
 * 
 */
  __pyx_t_1 = __pyx_v_x->dtype;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_dtype = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2322
 *     gy = core._internal_ascontiguousarray(gy)
 *     dtype = x.dtype
 *     gx = core.ndarray(x._shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     cdef float float_one = 1
 */
  __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_x->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2322, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_dtype);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_gx = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":2324
 *     gx = core.ndarray(x._shape, dtype)
 * 
 *     cdef float float_one = 1             # <<<<<<<<<<<<<<
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 */
  __pyx_v_float_one = 1.0;

  /* "cupy/cudnn.pyx":2325
 * 
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1             # <<<<<<<<<<<<<<
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 */
  __pyx_v_double_zero = 0.0;
  __pyx_v_double_one = 1.0;

  /* "cupy/cudnn.pyx":2326
 *     cdef float float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one             # <<<<<<<<<<<<<<
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one
 */
  __pyx_v_zero = ((size_t)(&__pyx_v_double_zero));

  /* "cupy/cudnn.pyx":2327
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
  __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_x->dtype, __pyx_n_u_d, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 2327, __pyx_L1_error)
  if (__pyx_t_3) {

    /* "cupy/cudnn.pyx":2328
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':
 *         one = <size_t>&double_one             # <<<<<<<<<<<<<<
 *     else:
 *         one = <size_t>&float_one
 */
    __pyx_v_one = ((size_t)(&__pyx_v_double_one));

    /* "cupy/cudnn.pyx":2327
 *     cdef double double_zero = 0, double_one = 1
 *     cdef size_t zero = <size_t>&double_zero, one
 *     if x.dtype == 'd':             # <<<<<<<<<<<<<<
 *         one = <size_t>&double_one
 *     else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cudnn.pyx":2330
 *         one = <size_t>&double_one
 *     else:
 *         one = <size_t>&float_one             # <<<<<<<<<<<<<<
 * 
 *     handle = get_handle()
 */
  /*else*/ {
    __pyx_v_one = ((size_t)(&__pyx_v_float_one));
  }
  __pyx_L3:;

  /* "cupy/cudnn.pyx":2332
 *         one = <size_t>&float_one
 * 
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 */
  __pyx_t_4 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2332, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_4;

  /* "cupy/cudnn.pyx":2333
 * 
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2333, __pyx_L1_error)
  __pyx_v_x_desc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2334
 *     handle = get_handle()
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 */
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2334, __pyx_L1_error)
  __pyx_v_derivedBnDesc = __pyx_t_4;

  /* "cupy/cudnn.pyx":2335
 *     cdef size_t x_desc = cudnn.createTensorDescriptor()
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:             # <<<<<<<<<<<<<<
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 */
  /*try:*/ {

    /* "cupy/cudnn.pyx":2336
 *     cdef size_t derivedBnDesc = cudnn.createTensorDescriptor()
 *     try:
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,             # <<<<<<<<<<<<<<
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 */
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.format = __pyx_v_d_layout;
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__create_tensor_descriptor_for_bn(__pyx_v_x_desc, __pyx_v_x, __pyx_v_is_for_conv2d, &__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2336, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2338
 *         _create_tensor_descriptor_for_bn(x_desc, x, is_for_conv2d,
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)             # <<<<<<<<<<<<<<
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         need_cast = gamma.dtype != dtype_param
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_deriveBNTensorDescriptor(__pyx_v_derivedBnDesc, __pyx_v_x_desc, __pyx_v_cudnn_mode, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2338, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2339
 *                                          format=d_layout)
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 *         need_cast = gamma.dtype != dtype_param
 *         if need_cast:
 */
    __pyx_t_1 = __pyx_f_4cupy_5cudnn__get_dtype_of_tensor_descriptor(__pyx_v_derivedBnDesc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2339, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_dtype_param = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2340
 *         cudnn.deriveBNTensorDescriptor(derivedBnDesc, x_desc, cudnn_mode)
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         need_cast = gamma.dtype != dtype_param             # <<<<<<<<<<<<<<
 *         if need_cast:
 *             gamma = gamma.astype(dtype_param)
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_gamma->dtype, __pyx_v_dtype_param, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2340, __pyx_L5_error)
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2340, __pyx_L5_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_need_cast = __pyx_t_3;

    /* "cupy/cudnn.pyx":2341
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         need_cast = gamma.dtype != dtype_param
 *         if need_cast:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *         else:
 */
    __pyx_t_3 = (__pyx_v_need_cast != 0);
    if (__pyx_t_3) {

      /* "cupy/cudnn.pyx":2342
 *         need_cast = gamma.dtype != dtype_param
 *         if need_cast:
 *             gamma = gamma.astype(dtype_param)             # <<<<<<<<<<<<<<
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_gamma->__pyx_vtab)->astype(__pyx_v_gamma, __pyx_v_dtype_param, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2342, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2341
 *         dtype_param = _get_dtype_of_tensor_descriptor(derivedBnDesc)
 *         need_cast = gamma.dtype != dtype_param
 *         if need_cast:             # <<<<<<<<<<<<<<
 *             gamma = gamma.astype(dtype_param)
 *         else:
 */
      goto __pyx_L7;
    }

    /* "cupy/cudnn.pyx":2344
 *             gamma = gamma.astype(dtype_param)
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)             # <<<<<<<<<<<<<<
 *         ggamma = core.ndarray(gamma._shape, dtype_param)
 *         gbeta = core.ndarray(gamma._shape, dtype_param)
 */
    /*else*/ {
      __pyx_t_1 = ((PyObject *)__pyx_f_4cupy_4core_4core__internal_ascontiguousarray(__pyx_v_gamma, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2344, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_gamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
      __pyx_t_1 = 0;
    }
    __pyx_L7:;

    /* "cupy/cudnn.pyx":2345
 *         else:
 *             gamma = core._internal_ascontiguousarray(gamma)
 *         ggamma = core.ndarray(gamma._shape, dtype_param)             # <<<<<<<<<<<<<<
 *         gbeta = core.ndarray(gamma._shape, dtype_param)
 * 
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_gamma->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2345, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2345, __pyx_L5_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_dtype_param);
    __Pyx_GIVEREF(__pyx_v_dtype_param);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_dtype_param);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2345, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_ggamma = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2346
 *             gamma = core._internal_ascontiguousarray(gamma)
 *         ggamma = core.ndarray(gamma._shape, dtype_param)
 *         gbeta = core.ndarray(gamma._shape, dtype_param)             # <<<<<<<<<<<<<<
 * 
 *         if _cudnn_version >= 7401:
 */
    __pyx_t_1 = __pyx_convert_vector_to_py_Py_ssize_t(__pyx_v_gamma->_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2346, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2346, __pyx_L5_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_dtype_param);
    __Pyx_GIVEREF(__pyx_v_dtype_param);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_dtype_param);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_4core_4core_ndarray), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2346, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_gbeta = ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2348
 *         gbeta = core.ndarray(gamma._shape, dtype_param)
 * 
 *         if _cudnn_version >= 7401:             # <<<<<<<<<<<<<<
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 * 
 */
    __pyx_t_3 = ((__pyx_v_4cupy_5cudnn__cudnn_version >= 0x1CE9) != 0);
    if (__pyx_t_3) {

      /* "cupy/cudnn.pyx":2349
 * 
 *         if _cudnn_version >= 7401:
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN             # <<<<<<<<<<<<<<
 * 
 *             workspace_size = (
 */
      __pyx_v_bn_ops = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_OPS_BN;

      /* "cupy/cudnn.pyx":2352
 * 
 *             workspace_size = (
 *                 cudnn.getBatchNormalizationBackwardExWorkspaceSize(             # <<<<<<<<<<<<<<
 *                     handle,
 *                     cudnn_mode,
 */
      __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationBackwardExWorkspaceSize(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_bn_ops, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_x_desc, __pyx_v_derivedBnDesc, 0, 0); if (unlikely(__pyx_t_4 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2352, __pyx_L5_error)
      __pyx_v_workspace_size = __pyx_t_4;

      /* "cupy/cudnn.pyx":2364
 *                     0,  # activation desc
 *                 ))
 *             workspace = memory.alloc(workspace_size)             # <<<<<<<<<<<<<<
 * 
 *             cudnn.batchNormalizationBackwardEx(
 */
      __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_workspace_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2364, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_1, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2364, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_workspace, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2375
 *                 x_desc, gy.data.ptr,
 *                 x_desc, 0,  # dz
 *                 x_desc, gx.data.ptr,             # <<<<<<<<<<<<<<
 *                 derivedBnDesc,
 *                 gamma.data.ptr,
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_gx, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2375, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2375, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2375, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2385
 *                 inv_std.data.ptr,
 *                 0,  # activation desc
 *                 workspace,             # <<<<<<<<<<<<<<
 *                 workspace_size,
 *                 0 if reserve_space is None else reserve_space.ptr,
 */
      __pyx_t_6 = __Pyx_PyInt_As_size_t(((PyObject *)__pyx_v_workspace)); if (unlikely((__pyx_t_6 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2385, __pyx_L5_error)

      /* "cupy/cudnn.pyx":2387
 *                 workspace,
 *                 workspace_size,
 *                 0 if reserve_space is None else reserve_space.ptr,             # <<<<<<<<<<<<<<
 *                 0 if reserve_space is None else reserve_space.mem.size,
 *             )
 */
      __pyx_t_3 = (((PyObject *)__pyx_v_reserve_space) == Py_None);
      if ((__pyx_t_3 != 0)) {
        __pyx_t_7 = 0;
      } else {
        __pyx_t_7 = __pyx_v_reserve_space->ptr;
      }

      /* "cupy/cudnn.pyx":2388
 *                 workspace_size,
 *                 0 if reserve_space is None else reserve_space.ptr,
 *                 0 if reserve_space is None else reserve_space.mem.size,             # <<<<<<<<<<<<<<
 *             )
 * 
 */
      __pyx_t_3 = (((PyObject *)__pyx_v_reserve_space) == Py_None);
      if ((__pyx_t_3 != 0)) {
        __pyx_t_8 = 0;
      } else {
        __pyx_t_8 = __pyx_v_reserve_space->mem->size;
      }

      /* "cupy/cudnn.pyx":2366
 *             workspace = memory.alloc(workspace_size)
 * 
 *             cudnn.batchNormalizationBackwardEx(             # <<<<<<<<<<<<<<
 *                 handle,
 *                 cudnn_mode,
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackwardEx(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_bn_ops, __pyx_v_one, __pyx_v_zero, __pyx_v_one, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, 0, __pyx_v_x_desc, __pyx_v_gy->data->ptr, __pyx_v_x_desc, 0, __pyx_v_x_desc, __pyx_t_4, __pyx_v_derivedBnDesc, __pyx_v_gamma->data->ptr, 0, __pyx_v_ggamma->data->ptr, __pyx_v_gbeta->data->ptr, __pyx_v_eps, __pyx_v_mean->data->ptr, __pyx_v_inv_std->data->ptr, 0, __pyx_t_6, __pyx_v_workspace_size, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2366, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2348
 *         gbeta = core.ndarray(gamma._shape, dtype_param)
 * 
 *         if _cudnn_version >= 7401:             # <<<<<<<<<<<<<<
 *             bn_ops = cudnn.CUDNN_BATCHNORM_OPS_BN
 * 
 */
      goto __pyx_L8;
    }

    /* "cupy/cudnn.pyx":2393
 *         else:
 *             # cuDNN < 7401
 *             if reserve_space is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'reserve_space can only be passed in cuDNN >= 7401')
 */
    /*else*/ {
      __pyx_t_3 = (((PyObject *)__pyx_v_reserve_space) != Py_None);
      __pyx_t_9 = (__pyx_t_3 != 0);
      if (unlikely(__pyx_t_9)) {

        /* "cupy/cudnn.pyx":2394
 *             # cuDNN < 7401
 *             if reserve_space is not None:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'reserve_space can only be passed in cuDNN >= 7401')
 *             cudnn.batchNormalizationBackward(
 */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2394, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __PYX_ERR(0, 2394, __pyx_L5_error)

        /* "cupy/cudnn.pyx":2393
 *         else:
 *             # cuDNN < 7401
 *             if reserve_space is not None:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     'reserve_space can only be passed in cuDNN >= 7401')
 */
      }

      /* "cupy/cudnn.pyx":2399
 *                 handle, cudnn_mode, one, zero, one, zero,
 *                 x_desc, x.data.ptr,
 *                 x_desc, gy.data.ptr, x_desc, gx.data.ptr,             # <<<<<<<<<<<<<<
 *                 derivedBnDesc, gamma.data.ptr, ggamma.data.ptr, gbeta.data.ptr,
 *                 eps, mean.data.ptr, inv_std.data.ptr)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_gx, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2399, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2399, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2399, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2396
 *                 raise ValueError(
 *                     'reserve_space can only be passed in cuDNN >= 7401')
 *             cudnn.batchNormalizationBackward(             # <<<<<<<<<<<<<<
 *                 handle, cudnn_mode, one, zero, one, zero,
 *                 x_desc, x.data.ptr,
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackward(__pyx_v_handle, __pyx_v_cudnn_mode, __pyx_v_one, __pyx_v_zero, __pyx_v_one, __pyx_v_zero, __pyx_v_x_desc, __pyx_v_x->data->ptr, __pyx_v_x_desc, __pyx_v_gy->data->ptr, __pyx_v_x_desc, __pyx_t_8, __pyx_v_derivedBnDesc, __pyx_v_gamma->data->ptr, __pyx_v_ggamma->data->ptr, __pyx_v_gbeta->data->ptr, __pyx_v_eps, __pyx_v_mean->data->ptr, __pyx_v_inv_std->data->ptr, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2396, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L8:;

    /* "cupy/cudnn.pyx":2407
 *         # queryRuntimeError() to make sure whether the overflow actually
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:             # <<<<<<<<<<<<<<
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 */
    __pyx_t_3 = (__pyx_v_debug != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_9 = __pyx_t_3;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_3 = ((__pyx_v_cudnn_mode == __pyx_e_4cupy_4cuda_5cudnn_CUDNN_BATCHNORM_SPATIAL_PERSISTENT) != 0);
    __pyx_t_9 = __pyx_t_3;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_9) {

      /* "cupy/cudnn.pyx":2408
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING             # <<<<<<<<<<<<<<
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 */
      __pyx_v_query_mode = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_ERRQUERY_BLOCKING;

      /* "cupy/cudnn.pyx":2409
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)             # <<<<<<<<<<<<<<
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 *                 warnings.warn(
 */
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_queryRuntimeError(__pyx_v_handle, __pyx_v_query_mode, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2409, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_v_rstatus = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cupy/cudnn.pyx":2410
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 */
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_STATUS_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2410, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_rstatus, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2410, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 2410, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_9) {

        /* "cupy/cudnn.pyx":2411
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:
 *                 warnings.warn(             # <<<<<<<<<<<<<<
 *                     'A numerical overflow might have happend in cuDNN'
 *                     'batch normalization (status:{})'.format(rstatus))
 */
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2411, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2411, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cupy/cudnn.pyx":2413
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 *                     'batch normalization (status:{})'.format(rstatus))             # <<<<<<<<<<<<<<
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_A_numerical_overflow_might_have, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2413, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        __pyx_t_2 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_v_rstatus) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_rstatus);
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2413, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
          }
        }
        __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2411, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":2410
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 *             if rstatus != cudnn.CUDNN_STATUS_SUCCESS:             # <<<<<<<<<<<<<<
 *                 warnings.warn(
 *                     'A numerical overflow might have happend in cuDNN'
 */
      }

      /* "cupy/cudnn.pyx":2407
 *         # queryRuntimeError() to make sure whether the overflow actually
 *         # occured or not during the batch normalization.
 *         if debug and cudnn_mode == cudnn.CUDNN_BATCHNORM_SPATIAL_PERSISTENT:             # <<<<<<<<<<<<<<
 *             query_mode = cudnn.CUDNN_ERRQUERY_BLOCKING
 *             rstatus = cudnn.queryRuntimeError(handle, query_mode)
 */
    }
  }

  /* "cupy/cudnn.pyx":2415
 *                     'batch normalization (status:{})'.format(rstatus))
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cupy/cudnn.pyx":2416
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 * 
 *     if need_cast:
 */
      __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2416, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_16);
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_21);
      __pyx_t_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
      {

        /* "cupy/cudnn.pyx":2415
 *                     'batch normalization (status:{})'.format(rstatus))
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)             # <<<<<<<<<<<<<<
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 * 
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_x_desc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cupy/cudnn.pyx":2416
 *     finally:
 *         cudnn.destroyTensorDescriptor(x_desc)
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)             # <<<<<<<<<<<<<<
 * 
 *     if need_cast:
 */
        __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor(__pyx_v_derivedBnDesc, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2416, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
      __Pyx_XGIVEREF(__pyx_t_16);
      __Pyx_XGIVEREF(__pyx_t_17);
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
      goto __pyx_L1_error;
      __pyx_L15_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_19);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }

  /* "cupy/cudnn.pyx":2418
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 * 
 *     if need_cast:             # <<<<<<<<<<<<<<
 *         ggamma = ggamma.astype(dtype)
 *         gbeta = gbeta.astype(dtype)
 */
  __pyx_t_9 = (__pyx_v_need_cast != 0);
  if (__pyx_t_9) {

    /* "cupy/cudnn.pyx":2419
 * 
 *     if need_cast:
 *         ggamma = ggamma.astype(dtype)             # <<<<<<<<<<<<<<
 *         gbeta = gbeta.astype(dtype)
 *     return gx, ggamma, gbeta
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_ggamma->__pyx_vtab)->astype(__pyx_v_ggamma, __pyx_v_dtype, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_ggamma, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2420
 *     if need_cast:
 *         ggamma = ggamma.astype(dtype)
 *         gbeta = gbeta.astype(dtype)             # <<<<<<<<<<<<<<
 *     return gx, ggamma, gbeta
 * 
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_4cupy_4core_4core_ndarray *)__pyx_v_gbeta->__pyx_vtab)->astype(__pyx_v_gbeta, __pyx_v_dtype, 0, NULL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_gbeta, ((struct __pyx_obj_4cupy_4core_4core_ndarray *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2418
 *         cudnn.destroyTensorDescriptor(derivedBnDesc)
 * 
 *     if need_cast:             # <<<<<<<<<<<<<<
 *         ggamma = ggamma.astype(dtype)
 *         gbeta = gbeta.astype(dtype)
 */
  }

  /* "cupy/cudnn.pyx":2421
 *         ggamma = ggamma.astype(dtype)
 *         gbeta = gbeta.astype(dtype)
 *     return gx, ggamma, gbeta             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_gx);
  __Pyx_GIVEREF(__pyx_v_gx);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_gx);
  __Pyx_INCREF(((PyObject *)__pyx_v_ggamma));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ggamma));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_ggamma));
  __Pyx_INCREF(((PyObject *)__pyx_v_gbeta));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_gbeta));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_gbeta));
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2307
 * 
 * 
 * def batch_normalization_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray gy,
 *         core.ndarray mean, core.ndarray inv_std,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cupy.cudnn.batch_normalization_backward", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ggamma);
  __Pyx_XDECREF((PyObject *)__pyx_v_gbeta);
  __Pyx_XDECREF((PyObject *)__pyx_v_workspace);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_gx);
  __Pyx_XDECREF(__pyx_v_dtype_param);
  __Pyx_XDECREF(__pyx_v_rstatus);
  __Pyx_XDECREF((PyObject *)__pyx_v_x);
  __Pyx_XDECREF((PyObject *)__pyx_v_gamma);
  __Pyx_XDECREF((PyObject *)__pyx_v_gy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2424
 * 
 * 
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_131create_activation_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_130create_activation_descriptor[] = "create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN, coef=0.0)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_131create_activation_descriptor = {"create_activation_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_131create_activation_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_130create_activation_descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_131create_activation_descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_relu_nan_opt = 0;
  PyObject *__pyx_v_coef = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_activation_descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mode,&__pyx_n_s_relu_nan_opt,&__pyx_n_s_coef,0};
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k__35;
    values[2] = ((PyObject *)__pyx_float_0_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_relu_nan_opt);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_coef);
          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_activation_descriptor") < 0)) __PYX_ERR(0, 2424, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_mode = values[0];
    __pyx_v_relu_nan_opt = values[1];
    __pyx_v_coef = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_activation_descriptor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2424, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_activation_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_130create_activation_descriptor(__pyx_self, __pyx_v_mode, __pyx_v_relu_nan_opt, __pyx_v_coef);

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

static PyObject *__pyx_pf_4cupy_5cudnn_130create_activation_descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mode, PyObject *__pyx_v_relu_nan_opt, PyObject *__pyx_v_coef) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  double __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_activation_descriptor", 0);

  /* "cupy/cudnn.pyx":2426
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, relu_nan_opt, coef)
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2426, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":2427
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 *                       py_cudnn.destroyActivationDescriptor)             # <<<<<<<<<<<<<<
 *     cudnn.setActivationDescriptor(desc.value, mode, relu_nan_opt, coef)
 *     return desc
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyActivationDescriptor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":2426
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, relu_nan_opt, coef)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2428
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, relu_nan_opt, coef)             # <<<<<<<<<<<<<<
 *     return desc
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_mode); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2428, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_relu_nan_opt); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2428, __pyx_L1_error)
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_coef); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2428, __pyx_L1_error)
  __pyx_t_4 = __pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor(__pyx_v_desc->value, __pyx_t_5, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2429
 *                       py_cudnn.destroyActivationDescriptor)
 *     cudnn.setActivationDescriptor(desc.value, mode, relu_nan_opt, coef)
 *     return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_desc));
  __pyx_r = ((PyObject *)__pyx_v_desc);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2424
 * 
 * 
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_activation_descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2432
 * 
 * 
 * def create_fused_ops_plan(ops):             # <<<<<<<<<<<<<<
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_133create_fused_ops_plan(PyObject *__pyx_self, PyObject *__pyx_v_ops); /*proto*/
static char __pyx_doc_4cupy_5cudnn_132create_fused_ops_plan[] = "create_fused_ops_plan(ops)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_133create_fused_ops_plan = {"create_fused_ops_plan", (PyCFunction)__pyx_pw_4cupy_5cudnn_133create_fused_ops_plan, METH_O, __pyx_doc_4cupy_5cudnn_132create_fused_ops_plan};
static PyObject *__pyx_pw_4cupy_5cudnn_133create_fused_ops_plan(PyObject *__pyx_self, PyObject *__pyx_v_ops) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_fused_ops_plan (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_5cudnn_132create_fused_ops_plan(__pyx_self, ((PyObject *)__pyx_v_ops));

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

static PyObject *__pyx_pf_4cupy_5cudnn_132create_fused_ops_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_plan = 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_fused_ops_plan", 0);

  /* "cupy/cudnn.pyx":2433
 * 
 * def create_fused_ops_plan(ops):
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyFusedOpsPlan)
 *     return plan
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_ops); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2433, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_createFusedOpsPlan(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":2434
 * def create_fused_ops_plan(ops):
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)             # <<<<<<<<<<<<<<
 *     return plan
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyFusedOpsPlan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":2433
 * 
 * def create_fused_ops_plan(ops):
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),             # <<<<<<<<<<<<<<
 *                       py_cudnn.destroyFusedOpsPlan)
 *     return plan
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_plan = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2435
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)
 *     return plan             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_plan));
  __pyx_r = ((PyObject *)__pyx_v_plan);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2432
 * 
 * 
 * def create_fused_ops_plan(ops):             # <<<<<<<<<<<<<<
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cudnn.create_fused_ops_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_plan);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2438
 * 
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_135create_fused_ops_const_param_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_134create_fused_ops_const_param_pack[] = "create_fused_ops_const_param_pack(ops, list_attr_param)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_135create_fused_ops_const_param_pack = {"create_fused_ops_const_param_pack", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_135create_fused_ops_const_param_pack, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_134create_fused_ops_const_param_pack};
static PyObject *__pyx_pw_4cupy_5cudnn_135create_fused_ops_const_param_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_list_attr_param = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_fused_ops_const_param_pack (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ops,&__pyx_n_s_list_attr_param,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_attr_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_fused_ops_const_param_pack", 1, 2, 2, 1); __PYX_ERR(0, 2438, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_fused_ops_const_param_pack") < 0)) __PYX_ERR(0, 2438, __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_ops = values[0];
    __pyx_v_list_attr_param = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_fused_ops_const_param_pack", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2438, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_fused_ops_const_param_pack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_134create_fused_ops_const_param_pack(__pyx_self, __pyx_v_ops, __pyx_v_list_attr_param);

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

static PyObject *__pyx_pf_4cupy_5cudnn_134create_fused_ops_const_param_pack(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops, PyObject *__pyx_v_list_attr_param) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack = NULL;
  PyObject *__pyx_v_attr = NULL;
  PyObject *__pyx_v_param = 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)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_fused_ops_const_param_pack", 0);

  /* "cupy/cudnn.pyx":2439
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),             # <<<<<<<<<<<<<<
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 *     for attr, param in list_attr_param:
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_ops); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2439, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_createFusedOpsConstParamPack(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":2440
 * def create_fused_ops_const_param_pack(ops, list_attr_param):
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)             # <<<<<<<<<<<<<<
 *     for attr, param in list_attr_param:
 *         set_fused_ops_const_param_pack_attribute(const_pack, attr, param)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyFusedOpsConstParamPack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":2439
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),             # <<<<<<<<<<<<<<
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 *     for attr, param in list_attr_param:
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_const_pack = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2441
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 *     for attr, param in list_attr_param:             # <<<<<<<<<<<<<<
 *         set_fused_ops_const_param_pack_attribute(const_pack, attr, param)
 *     return const_pack
 */
  if (likely(PyList_CheckExact(__pyx_v_list_attr_param)) || PyTuple_CheckExact(__pyx_v_list_attr_param)) {
    __pyx_t_4 = __pyx_v_list_attr_param; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_list_attr_param); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2441, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2441, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2441, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2441, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2441, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2441, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2441, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2441, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2441, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 2441, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2441, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_attr, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_param, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/cudnn.pyx":2442
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 *     for attr, param in list_attr_param:
 *         set_fused_ops_const_param_pack_attribute(const_pack, attr, param)             # <<<<<<<<<<<<<<
 *     return const_pack
 * 
 */
    __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_attr); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2442, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_set_fused_ops_const_param_pack_attribute(__pyx_v_const_pack, __pyx_t_1, __pyx_v_param, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cudnn.pyx":2441
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 *     for attr, param in list_attr_param:             # <<<<<<<<<<<<<<
 *         set_fused_ops_const_param_pack_attribute(const_pack, attr, param)
 *     return const_pack
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2443
 *     for attr, param in list_attr_param:
 *         set_fused_ops_const_param_pack_attribute(const_pack, attr, param)
 *     return const_pack             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_const_pack));
  __pyx_r = ((PyObject *)__pyx_v_const_pack);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2438
 * 
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn.create_fused_ops_const_param_pack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_const_pack);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_param);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2446
 * 
 * 
 * def make_fused_ops_plan(plan, const_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_137make_fused_ops_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_136make_fused_ops_plan[] = "make_fused_ops_plan(plan, const_pack)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_137make_fused_ops_plan = {"make_fused_ops_plan", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_137make_fused_ops_plan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_136make_fused_ops_plan};
static PyObject *__pyx_pw_4cupy_5cudnn_137make_fused_ops_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_plan = 0;
  PyObject *__pyx_v_const_pack = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("make_fused_ops_plan (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_const_pack,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_plan)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_const_pack)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("make_fused_ops_plan", 1, 2, 2, 1); __PYX_ERR(0, 2446, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_fused_ops_plan") < 0)) __PYX_ERR(0, 2446, __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_plan = values[0];
    __pyx_v_const_pack = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("make_fused_ops_plan", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2446, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.make_fused_ops_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_136make_fused_ops_plan(__pyx_self, __pyx_v_plan, __pyx_v_const_pack);

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

static PyObject *__pyx_pf_4cupy_5cudnn_136make_fused_ops_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_plan, PyObject *__pyx_v_const_pack) {
  size_t __pyx_v_handle;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("make_fused_ops_plan", 0);

  /* "cupy/cudnn.pyx":2447
 * 
 * def make_fused_ops_plan(plan, const_pack):
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2447, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_1;

  /* "cupy/cudnn.pyx":2448
 * def make_fused_ops_plan(plan, const_pack):
 *     handle = get_handle()
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plan, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2448, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_const_pack, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2448, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_makeFusedOpsPlan(__pyx_v_handle, __pyx_t_1, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2446
 * 
 * 
 * def make_fused_ops_plan(plan, const_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)
 */

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

/* "cupy/cudnn.pyx":2451
 * 
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_139create_fused_ops_variant_param_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_138create_fused_ops_variant_param_pack[] = "create_fused_ops_variant_param_pack(ops, list_attr_param)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_139create_fused_ops_variant_param_pack = {"create_fused_ops_variant_param_pack", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_139create_fused_ops_variant_param_pack, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_138create_fused_ops_variant_param_pack};
static PyObject *__pyx_pw_4cupy_5cudnn_139create_fused_ops_variant_param_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ops = 0;
  PyObject *__pyx_v_list_attr_param = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_fused_ops_variant_param_pack (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ops,&__pyx_n_s_list_attr_param,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ops)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_attr_param)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_fused_ops_variant_param_pack", 1, 2, 2, 1); __PYX_ERR(0, 2451, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_fused_ops_variant_param_pack") < 0)) __PYX_ERR(0, 2451, __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_ops = values[0];
    __pyx_v_list_attr_param = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_fused_ops_variant_param_pack", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2451, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.create_fused_ops_variant_param_pack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_138create_fused_ops_variant_param_pack(__pyx_self, __pyx_v_ops, __pyx_v_list_attr_param);

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

static PyObject *__pyx_pf_4cupy_5cudnn_138create_fused_ops_variant_param_pack(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ops, PyObject *__pyx_v_list_attr_param) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_var_pack = NULL;
  PyObject *__pyx_v_attr = NULL;
  PyObject *__pyx_v_param = 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)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_fused_ops_variant_param_pack", 0);

  /* "cupy/cudnn.pyx":2452
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),             # <<<<<<<<<<<<<<
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 *     for attr, param in list_attr_param:
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_ops); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2452, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_createFusedOpsVariantParamPack(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":2453
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)             # <<<<<<<<<<<<<<
 *     for attr, param in list_attr_param:
 *         set_fused_ops_variant_param_pack_attribute(var_pack, attr, param)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_py_cudnn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_destroyFusedOpsVariantParamPack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cudnn.pyx":2452
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),             # <<<<<<<<<<<<<<
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 *     for attr, param in list_attr_param:
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_var_pack = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2454
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 *     for attr, param in list_attr_param:             # <<<<<<<<<<<<<<
 *         set_fused_ops_variant_param_pack_attribute(var_pack, attr, param)
 *     return var_pack
 */
  if (likely(PyList_CheckExact(__pyx_v_list_attr_param)) || PyTuple_CheckExact(__pyx_v_list_attr_param)) {
    __pyx_t_4 = __pyx_v_list_attr_param; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_list_attr_param); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2454, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2454, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2454, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2454, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2454, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2454, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 2454, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2454, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 2454, __pyx_L1_error)
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2454, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_attr, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_param, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "cupy/cudnn.pyx":2455
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 *     for attr, param in list_attr_param:
 *         set_fused_ops_variant_param_pack_attribute(var_pack, attr, param)             # <<<<<<<<<<<<<<
 *     return var_pack
 * 
 */
    __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_attr); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2455, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_5cudnn_set_fused_ops_variant_param_pack_attribute(__pyx_v_var_pack, __pyx_t_1, __pyx_v_param, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cudnn.pyx":2454
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 *     for attr, param in list_attr_param:             # <<<<<<<<<<<<<<
 *         set_fused_ops_variant_param_pack_attribute(var_pack, attr, param)
 *     return var_pack
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2456
 *     for attr, param in list_attr_param:
 *         set_fused_ops_variant_param_pack_attribute(var_pack, attr, param)
 *     return var_pack             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_var_pack));
  __pyx_r = ((PyObject *)__pyx_v_var_pack);
  goto __pyx_L0;

  /* "cupy/cudnn.pyx":2451
 * 
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn.create_fused_ops_variant_param_pack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_var_pack);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_param);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cudnn.pyx":2459
 * 
 * 
 * def fused_ops_execute(plan, var_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_141fused_ops_execute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_140fused_ops_execute[] = "fused_ops_execute(plan, var_pack)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_141fused_ops_execute = {"fused_ops_execute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_141fused_ops_execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_140fused_ops_execute};
static PyObject *__pyx_pw_4cupy_5cudnn_141fused_ops_execute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_plan = 0;
  PyObject *__pyx_v_var_pack = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fused_ops_execute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_var_pack,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_plan)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_var_pack)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fused_ops_execute", 1, 2, 2, 1); __PYX_ERR(0, 2459, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fused_ops_execute") < 0)) __PYX_ERR(0, 2459, __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_plan = values[0];
    __pyx_v_var_pack = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fused_ops_execute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2459, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.fused_ops_execute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_140fused_ops_execute(__pyx_self, __pyx_v_plan, __pyx_v_var_pack);

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

static PyObject *__pyx_pf_4cupy_5cudnn_140fused_ops_execute(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_plan, PyObject *__pyx_v_var_pack) {
  size_t __pyx_v_handle;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("fused_ops_execute", 0);

  /* "cupy/cudnn.pyx":2460
 * 
 * def fused_ops_execute(plan, var_pack):
 *     handle = get_handle()             # <<<<<<<<<<<<<<
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_handle(0); if (unlikely(__pyx_t_1 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2460, __pyx_L1_error)
  __pyx_v_handle = __pyx_t_1;

  /* "cupy/cudnn.pyx":2461
 * def fused_ops_execute(plan, var_pack):
 *     handle = get_handle()
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plan, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_var_pack, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_fusedOpsExecute(__pyx_v_handle, __pyx_t_1, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2461, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":2459
 * 
 * 
 * def fused_ops_execute(plan, var_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)
 */

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

/* "cupy/cudnn.pyx":2464
 * 
 * 
 * cpdef set_fused_ops_const_param_pack_attribute(             # <<<<<<<<<<<<<<
 *         Descriptor const_pack, int param_label, desc_or_scalar):
 *     cdef int scaler
 */

static PyObject *__pyx_pw_4cupy_5cudnn_143set_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_fused_ops_const_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label, PyObject *__pyx_v_desc_or_scalar, CYTHON_UNUSED int __pyx_skip_dispatch) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_desc = 0;
  int __pyx_v_scalar;
  PyObject *__pyx_r = NULL;
  __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("set_fused_ops_const_param_pack_attribute", 0);

  /* "cupy/cudnn.pyx":2468
 *     cdef int scaler
 *     cdef Descriptor desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 */
  switch (__pyx_v_param_label) {
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_XDATA_PLACEHOLDER:
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_MODE:

    /* "cupy/cudnn.pyx":2469
 *     cdef Descriptor desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_MODE,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2470
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2471
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_WDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2472
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DWDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2473
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2474
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DYDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2475
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSUM_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2476
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSQSUM_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2477
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2478
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_BIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2479
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2480
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2481
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2482
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2483
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ZDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2484
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2485
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2486
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2487
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DXDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2488
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DZDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2489
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2490
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 *         scalar = <int>desc_or_scalar
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2492
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 *         scalar = <int>desc_or_scalar             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsConstParamPackAttribute(const_pack.value, param_label,
 *                                                  <size_t>&scalar)
 */
    __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_desc_or_scalar); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2492, __pyx_L1_error)
    __pyx_v_scalar = ((int)__pyx_t_1);

    /* "cupy/cudnn.pyx":2493
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 *         scalar = <int>desc_or_scalar
 *         cudnn.setFusedOpsConstParamPackAttribute(const_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                  <size_t>&scalar)
 *     else:
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsConstParamPackAttribute(__pyx_v_const_pack->value, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2468
 *     cdef int scaler
 *     cdef Descriptor desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 */
    break;
    default:

    /* "cupy/cudnn.pyx":2496
 *                                                  <size_t>&scalar)
 *     else:
 *         desc = <Descriptor>desc_or_scalar             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsConstParamPackAttribute(const_pack.value, param_label,
 *                                                  <size_t>desc.value)
 */
    __pyx_t_2 = __pyx_v_desc_or_scalar;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2497
 *     else:
 *         desc = <Descriptor>desc_or_scalar
 *         cudnn.setFusedOpsConstParamPackAttribute(const_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                  <size_t>desc.value)
 * 
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsConstParamPackAttribute(__pyx_v_const_pack->value, __pyx_v_param_label, ((size_t)__pyx_v_desc->value), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    break;
  }

  /* "cupy/cudnn.pyx":2464
 * 
 * 
 * cpdef set_fused_ops_const_param_pack_attribute(             # <<<<<<<<<<<<<<
 *         Descriptor const_pack, int param_label, desc_or_scalar):
 *     cdef int scaler
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cupy.cudnn.set_fused_ops_const_param_pack_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_desc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_143set_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_142set_fused_ops_const_param_pack_attribute[] = "set_fused_ops_const_param_pack_attribute(Descriptor const_pack, int param_label, desc_or_scalar)";
static PyObject *__pyx_pw_4cupy_5cudnn_143set_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack = 0;
  int __pyx_v_param_label;
  PyObject *__pyx_v_desc_or_scalar = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_fused_ops_const_param_pack_attribute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_const_pack,&__pyx_n_s_param_label,&__pyx_n_s_desc_or_scalar,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_const_pack)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_label)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_fused_ops_const_param_pack_attribute", 1, 3, 3, 1); __PYX_ERR(0, 2464, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desc_or_scalar)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_fused_ops_const_param_pack_attribute", 1, 3, 3, 2); __PYX_ERR(0, 2464, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_fused_ops_const_param_pack_attribute") < 0)) __PYX_ERR(0, 2464, __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_const_pack = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)values[0]);
    __pyx_v_param_label = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_param_label == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2465, __pyx_L3_error)
    __pyx_v_desc_or_scalar = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_fused_ops_const_param_pack_attribute", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2464, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.set_fused_ops_const_param_pack_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_const_pack), __pyx_ptype_4cupy_5cudnn_Descriptor, 1, "const_pack", 0))) __PYX_ERR(0, 2465, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_142set_fused_ops_const_param_pack_attribute(__pyx_self, __pyx_v_const_pack, __pyx_v_param_label, __pyx_v_desc_or_scalar);

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

static PyObject *__pyx_pf_4cupy_5cudnn_142set_fused_ops_const_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label, PyObject *__pyx_v_desc_or_scalar) {
  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("set_fused_ops_const_param_pack_attribute", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_set_fused_ops_const_param_pack_attribute(__pyx_v_const_pack, __pyx_v_param_label, __pyx_v_desc_or_scalar, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":2501
 * 
 * 
 * cpdef get_fused_ops_const_param_pack_attribute(Descriptor const_pack,             # <<<<<<<<<<<<<<
 *                                                int param_label):
 *     cdef int param_int
 */

static PyObject *__pyx_pw_4cupy_5cudnn_145get_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_get_fused_ops_const_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_param_int;
  size_t __pyx_v_param_desc;
  PyObject *__pyx_v_is_null = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_fused_ops_const_param_pack_attribute", 0);

  /* "cupy/cudnn.pyx":2505
 *     cdef int param_int
 *     cdef size_t param_desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 */
  switch (__pyx_v_param_label) {
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_XDATA_PLACEHOLDER:
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_MODE:

    /* "cupy/cudnn.pyx":2506
 *     cdef size_t param_desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_MODE,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2507
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2508
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_WDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2509
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DWDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2510
 *                        cudnn.CUDNN_PARAM_BN_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2511
 *                        cudnn.CUDNN_PARAM_WDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DYDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2512
 *                        cudnn.CUDNN_PARAM_DWDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSUM_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2513
 *                        cudnn.CUDNN_PARAM_YDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_YSQSUM_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2514
 *                        cudnn.CUDNN_PARAM_DYDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2515
 *                        cudnn.CUDNN_PARAM_YSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_BIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2516
 *                        cudnn.CUDNN_PARAM_YSQSUM_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2517
 *                        cudnn.CUDNN_PARAM_BN_SCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2518
 *                        cudnn.CUDNN_PARAM_BN_BIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2519
 *                        cudnn.CUDNN_PARAM_BN_SAVED_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2520
 *                        cudnn.CUDNN_PARAM_BN_SAVED_INVSTD_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ZDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2521
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_MEAN_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2522
 *                        cudnn.CUDNN_PARAM_BN_RUNNING_VAR_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2523
 *                        cudnn.CUDNN_PARAM_ZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2524
 *                        cudnn.CUDNN_PARAM_BN_Z_EQSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DXDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2525
 *                        cudnn.CUDNN_PARAM_BN_Z_EQBIAS_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DZDATA_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2526
 *                        cudnn.CUDNN_PARAM_ACTIVATION_BITMASK_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DSCALE_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2527
 *                        cudnn.CUDNN_PARAM_DXDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_DZDATA_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_BN_DBIAS_PLACEHOLDER:

    /* "cupy/cudnn.pyx":2529
 *                        cudnn.CUDNN_PARAM_BN_DSCALE_PLACEHOLDER,
 *                        cudnn.CUDNN_PARAM_BN_DBIAS_PLACEHOLDER):
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(             # <<<<<<<<<<<<<<
 *             const_pack.value, param_label, <size_t>&param_int)
 *         return <size_t>param_int, is_null
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsConstParamPackAttribute(__pyx_v_const_pack->value, __pyx_v_param_label, ((size_t)(&__pyx_v_param_int)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2529, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_is_null = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2531
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(
 *             const_pack.value, param_label, <size_t>&param_int)
 *         return <size_t>param_int, is_null             # <<<<<<<<<<<<<<
 *     else:
 *         if param_label == cudnn.CUDNN_PARAM_ACTIVATION_DESC:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_param_int)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2531, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2531, __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_is_null);
    __Pyx_GIVEREF(__pyx_v_is_null);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_is_null);
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2505
 *     cdef int param_int
 *     cdef size_t param_desc
 *     if param_label in (cudnn.CUDNN_PARAM_XDATA_PLACEHOLDER,             # <<<<<<<<<<<<<<
 *                        cudnn.CUDNN_PARAM_BN_MODE,
 *                        cudnn.CUDNN_PARAM_BN_EQSCALE_PLACEHOLDER,
 */
    break;
    default:

    /* "cupy/cudnn.pyx":2533
 *         return <size_t>param_int, is_null
 *     else:
 *         if param_label == cudnn.CUDNN_PARAM_ACTIVATION_DESC:             # <<<<<<<<<<<<<<
 *             param_desc = cudnn.createActivationDescriptor()
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 */
    switch (__pyx_v_param_label) {
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_ACTIVATION_DESC:

      /* "cupy/cudnn.pyx":2534
 *     else:
 *         if param_label == cudnn.CUDNN_PARAM_ACTIVATION_DESC:
 *             param_desc = cudnn.createActivationDescriptor()             # <<<<<<<<<<<<<<
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 *             param_desc = cudnn.createConvolutionDescriptor()
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2534, __pyx_L1_error)
      __pyx_v_param_desc = __pyx_t_3;

      /* "cupy/cudnn.pyx":2533
 *         return <size_t>param_int, is_null
 *     else:
 *         if param_label == cudnn.CUDNN_PARAM_ACTIVATION_DESC:             # <<<<<<<<<<<<<<
 *             param_desc = cudnn.createActivationDescriptor()
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 */
      break;
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_CONV_DESC:

      /* "cupy/cudnn.pyx":2536
 *             param_desc = cudnn.createActivationDescriptor()
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 *             param_desc = cudnn.createConvolutionDescriptor()             # <<<<<<<<<<<<<<
 *         elif param_label in (cudnn.CUDNN_PARAM_WDESC,
 *                              cudnn.CUDNN_PARAM_DWDESC,):
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2536, __pyx_L1_error)
      __pyx_v_param_desc = __pyx_t_3;

      /* "cupy/cudnn.pyx":2535
 *         if param_label == cudnn.CUDNN_PARAM_ACTIVATION_DESC:
 *             param_desc = cudnn.createActivationDescriptor()
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:             # <<<<<<<<<<<<<<
 *             param_desc = cudnn.createConvolutionDescriptor()
 *         elif param_label in (cudnn.CUDNN_PARAM_WDESC,
 */
      break;
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_WDESC:

      /* "cupy/cudnn.pyx":2537
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 *             param_desc = cudnn.createConvolutionDescriptor()
 *         elif param_label in (cudnn.CUDNN_PARAM_WDESC,             # <<<<<<<<<<<<<<
 *                              cudnn.CUDNN_PARAM_DWDESC,):
 *             param_desc = cudnn.createFilterDescriptor()
 */
      case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_PARAM_DWDESC:

      /* "cupy/cudnn.pyx":2539
 *         elif param_label in (cudnn.CUDNN_PARAM_WDESC,
 *                              cudnn.CUDNN_PARAM_DWDESC,):
 *             param_desc = cudnn.createFilterDescriptor()             # <<<<<<<<<<<<<<
 *         else:
 *             param_desc = cudnn.createTensorDescriptor()
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2539, __pyx_L1_error)
      __pyx_v_param_desc = __pyx_t_3;

      /* "cupy/cudnn.pyx":2537
 *         elif param_label == cudnn.CUDNN_PARAM_CONV_DESC:
 *             param_desc = cudnn.createConvolutionDescriptor()
 *         elif param_label in (cudnn.CUDNN_PARAM_WDESC,             # <<<<<<<<<<<<<<
 *                              cudnn.CUDNN_PARAM_DWDESC,):
 *             param_desc = cudnn.createFilterDescriptor()
 */
      break;
      default:

      /* "cupy/cudnn.pyx":2541
 *             param_desc = cudnn.createFilterDescriptor()
 *         else:
 *             param_desc = cudnn.createTensorDescriptor()             # <<<<<<<<<<<<<<
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(
 *             const_pack.value, param_label, param_desc)
 */
      __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 2541, __pyx_L1_error)
      __pyx_v_param_desc = __pyx_t_3;
      break;
    }

    /* "cupy/cudnn.pyx":2542
 *         else:
 *             param_desc = cudnn.createTensorDescriptor()
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(             # <<<<<<<<<<<<<<
 *             const_pack.value, param_label, param_desc)
 *         return param_desc, is_null
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsConstParamPackAttribute(__pyx_v_const_pack->value, __pyx_v_param_label, __pyx_v_param_desc, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_is_null = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2544
 *         is_null = cudnn.getFusedOpsConstParamPackAttribute(
 *             const_pack.value, param_label, param_desc)
 *         return param_desc, is_null             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_param_desc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_is_null);
    __Pyx_GIVEREF(__pyx_v_is_null);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_is_null);
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    break;
  }

  /* "cupy/cudnn.pyx":2501
 * 
 * 
 * cpdef get_fused_ops_const_param_pack_attribute(Descriptor const_pack,             # <<<<<<<<<<<<<<
 *                                                int param_label):
 *     cdef int param_int
 */

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

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_145get_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_144get_fused_ops_const_param_pack_attribute[] = "get_fused_ops_const_param_pack_attribute(Descriptor const_pack, int param_label)";
static PyObject *__pyx_pw_4cupy_5cudnn_145get_fused_ops_const_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack = 0;
  int __pyx_v_param_label;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_fused_ops_const_param_pack_attribute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_const_pack,&__pyx_n_s_param_label,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_const_pack)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_label)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_fused_ops_const_param_pack_attribute", 1, 2, 2, 1); __PYX_ERR(0, 2501, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_fused_ops_const_param_pack_attribute") < 0)) __PYX_ERR(0, 2501, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_const_pack = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)values[0]);
    __pyx_v_param_label = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_param_label == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2502, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_fused_ops_const_param_pack_attribute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2501, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.get_fused_ops_const_param_pack_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_const_pack), __pyx_ptype_4cupy_5cudnn_Descriptor, 1, "const_pack", 0))) __PYX_ERR(0, 2501, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_144get_fused_ops_const_param_pack_attribute(__pyx_self, __pyx_v_const_pack, __pyx_v_param_label);

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

static PyObject *__pyx_pf_4cupy_5cudnn_144get_fused_ops_const_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_const_pack, int __pyx_v_param_label) {
  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_fused_ops_const_param_pack_attribute", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_fused_ops_const_param_pack_attribute(__pyx_v_const_pack, __pyx_v_param_label, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":2547
 * 
 * 
 * cpdef set_fused_ops_variant_param_pack_attribute(             # <<<<<<<<<<<<<<
 *         Descriptor var_pack, int param_label, arr_or_scaler):
 *     cdef size_t scalar_size_t
 */

static PyObject *__pyx_pw_4cupy_5cudnn_147set_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_set_fused_ops_variant_param_pack_attribute(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_var_pack, int __pyx_v_param_label, PyObject *__pyx_v_arr_or_scaler, CYTHON_UNUSED int __pyx_skip_dispatch) {
  size_t __pyx_v_scalar_size_t;
  int64_t __pyx_v_scalar_int64_t;
  double __pyx_v_scalar_double;
  size_t __pyx_v_ptr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int64_t __pyx_t_3;
  double __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_fused_ops_variant_param_pack_attribute", 0);

  /* "cupy/cudnn.pyx":2553
 *     cdef double scalar_double
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:             # <<<<<<<<<<<<<<
 *         scalar_size_t = <size_t>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 */
  switch (__pyx_v_param_label) {
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:

    /* "cupy/cudnn.pyx":2554
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:
 *         scalar_size_t = <size_t>arr_or_scaler             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_size_t)
 */
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_arr_or_scaler); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2554, __pyx_L1_error)
    __pyx_v_scalar_size_t = ((size_t)__pyx_t_1);

    /* "cupy/cudnn.pyx":2555
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:
 *         scalar_size_t = <size_t>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_size_t)
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute(__pyx_v_var_pack->value, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_size_t)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2553
 *     cdef double scalar_double
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:             # <<<<<<<<<<<<<<
 *         scalar_size_t = <size_t>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:

    /* "cupy/cudnn.pyx":2558
 *                                                    <size_t>&scalar_size_t)
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:
 *         scalar_int64_t = <int64_t>arr_or_scaler             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_int64_t)
 */
    __pyx_t_3 = __Pyx_PyInt_As_int64_t(__pyx_v_arr_or_scaler); if (unlikely((__pyx_t_3 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2558, __pyx_L1_error)
    __pyx_v_scalar_int64_t = ((int64_t)__pyx_t_3);

    /* "cupy/cudnn.pyx":2559
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:
 *         scalar_int64_t = <int64_t>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_int64_t)
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute(__pyx_v_var_pack->value, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_int64_t)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2557
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_size_t)
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:             # <<<<<<<<<<<<<<
 *         scalar_int64_t = <int64_t>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EPSILON:

    /* "cupy/cudnn.pyx":2561
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_int64_t)
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,             # <<<<<<<<<<<<<<
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         scalar_double = <double>arr_or_scaler
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR:

    /* "cupy/cudnn.pyx":2563
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         scalar_double = <double>arr_or_scaler             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_double)
 */
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_arr_or_scaler); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 2563, __pyx_L1_error)
    __pyx_v_scalar_double = ((double)__pyx_t_4);

    /* "cupy/cudnn.pyx":2564
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         scalar_double = <double>arr_or_scaler
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_double)
 *     else:
 */
    __pyx_t_2 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute(__pyx_v_var_pack->value, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_double)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cudnn.pyx":2561
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    <size_t>&scalar_int64_t)
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,             # <<<<<<<<<<<<<<
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         scalar_double = <double>arr_or_scaler
 */
    break;
    default:

    /* "cupy/cudnn.pyx":2567
 *                                                    <size_t>&scalar_double)
 *     else:
 *         ptr = <size_t>arr_or_scaler.data.ptr             # <<<<<<<<<<<<<<
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,
 *                                                    ptr)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr_or_scaler, __pyx_n_s_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ptr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_t_5); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2567, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_ptr = ((size_t)__pyx_t_1);

    /* "cupy/cudnn.pyx":2568
 *     else:
 *         ptr = <size_t>arr_or_scaler.data.ptr
 *         cudnn.setFusedOpsVariantParamPackAttribute(var_pack.value, param_label,             # <<<<<<<<<<<<<<
 *                                                    ptr)
 * 
 */
    __pyx_t_5 = __pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute(__pyx_v_var_pack->value, __pyx_v_param_label, __pyx_v_ptr, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2568, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    break;
  }

  /* "cupy/cudnn.pyx":2547
 * 
 * 
 * cpdef set_fused_ops_variant_param_pack_attribute(             # <<<<<<<<<<<<<<
 *         Descriptor var_pack, int param_label, arr_or_scaler):
 *     cdef size_t scalar_size_t
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.set_fused_ops_variant_param_pack_attribute", __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_5cudnn_147set_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_146set_fused_ops_variant_param_pack_attribute[] = "set_fused_ops_variant_param_pack_attribute(Descriptor var_pack, int param_label, arr_or_scaler)";
static PyObject *__pyx_pw_4cupy_5cudnn_147set_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_var_pack = 0;
  int __pyx_v_param_label;
  PyObject *__pyx_v_arr_or_scaler = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_fused_ops_variant_param_pack_attribute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_var_pack,&__pyx_n_s_param_label,&__pyx_n_s_arr_or_scaler,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_var_pack)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_label)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_fused_ops_variant_param_pack_attribute", 1, 3, 3, 1); __PYX_ERR(0, 2547, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arr_or_scaler)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_fused_ops_variant_param_pack_attribute", 1, 3, 3, 2); __PYX_ERR(0, 2547, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_fused_ops_variant_param_pack_attribute") < 0)) __PYX_ERR(0, 2547, __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_var_pack = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)values[0]);
    __pyx_v_param_label = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_param_label == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2548, __pyx_L3_error)
    __pyx_v_arr_or_scaler = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_fused_ops_variant_param_pack_attribute", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2547, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.set_fused_ops_variant_param_pack_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_var_pack), __pyx_ptype_4cupy_5cudnn_Descriptor, 1, "var_pack", 0))) __PYX_ERR(0, 2548, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_5cudnn_146set_fused_ops_variant_param_pack_attribute(__pyx_self, __pyx_v_var_pack, __pyx_v_param_label, __pyx_v_arr_or_scaler);

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

static PyObject *__pyx_pf_4cupy_5cudnn_146set_fused_ops_variant_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v_var_pack, int __pyx_v_param_label, PyObject *__pyx_v_arr_or_scaler) {
  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("set_fused_ops_variant_param_pack_attribute", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_set_fused_ops_variant_param_pack_attribute(__pyx_v_var_pack, __pyx_v_param_label, __pyx_v_arr_or_scaler, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cudnn.pyx":2572
 * 
 * 
 * cpdef get_fused_ops_variant_param_pack_attribute(size_t var_pack,             # <<<<<<<<<<<<<<
 *                                                  int param_label):
 *     cdef size_t scalar_size_t
 */

static PyObject *__pyx_pw_4cupy_5cudnn_149get_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_5cudnn_get_fused_ops_variant_param_pack_attribute(size_t __pyx_v_var_pack, int __pyx_v_param_label, CYTHON_UNUSED int __pyx_skip_dispatch) {
  size_t __pyx_v_scalar_size_t;
  int64_t __pyx_v_scalar_int64_t;
  double __pyx_v_scalar_double;
  size_t __pyx_v_ptr;
  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_fused_ops_variant_param_pack_attribute", 0);

  /* "cupy/cudnn.pyx":2578
 *     cdef double scalar_double
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:             # <<<<<<<<<<<<<<
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_size_t)
 */
  switch (__pyx_v_param_label) {
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:

    /* "cupy/cudnn.pyx":2579
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_size_t)
 *         return <size_t>scalar_size_t
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute(__pyx_v_var_pack, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_size_t)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2579, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2581
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_size_t)
 *         return <size_t>scalar_size_t             # <<<<<<<<<<<<<<
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_scalar_size_t)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2581, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2578
 *     cdef double scalar_double
 *     cdef size_t ptr
 *     if param_label == cudnn.CUDNN_SCALAR_SIZE_T_WORKSPACE_SIZE_IN_BYTES:             # <<<<<<<<<<<<<<
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_size_t)
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:

    /* "cupy/cudnn.pyx":2583
 *         return <size_t>scalar_size_t
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_int64_t)
 *         return <size_t>scalar_int64_t
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute(__pyx_v_var_pack, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_int64_t)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2585
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_int64_t)
 *         return <size_t>scalar_int64_t             # <<<<<<<<<<<<<<
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_scalar_int64_t)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2585, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2582
 *                                                    <size_t>&scalar_size_t)
 *         return <size_t>scalar_size_t
 *     elif param_label == cudnn.CUDNN_SCALAR_INT64_T_BN_ACCUMULATION_COUNT:             # <<<<<<<<<<<<<<
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_int64_t)
 */
    break;
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EPSILON:

    /* "cupy/cudnn.pyx":2586
 *                                                    <size_t>&scalar_int64_t)
 *         return <size_t>scalar_int64_t
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,             # <<<<<<<<<<<<<<
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 */
    case __pyx_e_4cupy_4cuda_5cudnn_CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR:

    /* "cupy/cudnn.pyx":2588
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&scalar_double)
 *         return <size_t>scalar_double
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute(__pyx_v_var_pack, __pyx_v_param_label, ((size_t)(&__pyx_v_scalar_double)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2590
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&scalar_double)
 *         return <size_t>scalar_double             # <<<<<<<<<<<<<<
 *     else:
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_scalar_double)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "cupy/cudnn.pyx":2586
 *                                                    <size_t>&scalar_int64_t)
 *         return <size_t>scalar_int64_t
 *     elif param_label in (cudnn.CUDNN_SCALAR_DOUBLE_BN_EPSILON,             # <<<<<<<<<<<<<<
 *                          cudnn.CUDNN_SCALAR_DOUBLE_BN_EXP_AVG_FACTOR):
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 */
    break;
    default:

    /* "cupy/cudnn.pyx":2592
 *         return <size_t>scalar_double
 *     else:
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,             # <<<<<<<<<<<<<<
 *                                                    <size_t>&ptr)
 *         return <size_t>ptr
 */
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute(__pyx_v_var_pack, __pyx_v_param_label, ((size_t)(&__pyx_v_ptr)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2592, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cudnn.pyx":2594
 *         cudnn.getFusedOpsVariantParamPackAttribute(var_pack, param_label,
 *                                                    <size_t>&ptr)
 *         return <size_t>ptr             # <<<<<<<<<<<<<<
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    break;
  }

  /* "cupy/cudnn.pyx":2572
 * 
 * 
 * cpdef get_fused_ops_variant_param_pack_attribute(size_t var_pack,             # <<<<<<<<<<<<<<
 *                                                  int param_label):
 *     cdef size_t scalar_size_t
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cudnn.get_fused_ops_variant_param_pack_attribute", __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_5cudnn_149get_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_148get_fused_ops_variant_param_pack_attribute[] = "get_fused_ops_variant_param_pack_attribute(size_t var_pack, int param_label)";
static PyObject *__pyx_pw_4cupy_5cudnn_149get_fused_ops_variant_param_pack_attribute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  size_t __pyx_v_var_pack;
  int __pyx_v_param_label;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_fused_ops_variant_param_pack_attribute (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_var_pack,&__pyx_n_s_param_label,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_var_pack)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_param_label)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_fused_ops_variant_param_pack_attribute", 1, 2, 2, 1); __PYX_ERR(0, 2572, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_fused_ops_variant_param_pack_attribute") < 0)) __PYX_ERR(0, 2572, __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_var_pack = __Pyx_PyInt_As_size_t(values[0]); if (unlikely((__pyx_v_var_pack == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 2572, __pyx_L3_error)
    __pyx_v_param_label = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_param_label == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2573, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_fused_ops_variant_param_pack_attribute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2572, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.get_fused_ops_variant_param_pack_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_148get_fused_ops_variant_param_pack_attribute(__pyx_self, __pyx_v_var_pack, __pyx_v_param_label);

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

static PyObject *__pyx_pf_4cupy_5cudnn_148get_fused_ops_variant_param_pack_attribute(CYTHON_UNUSED PyObject *__pyx_self, size_t __pyx_v_var_pack, int __pyx_v_param_label) {
  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_fused_ops_variant_param_pack_attribute", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_5cudnn_get_fused_ops_variant_param_pack_attribute(__pyx_v_var_pack, __pyx_v_param_label, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "(tree fragment)":1
 * def __pyx_unpickle_Descriptor(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_151__pyx_unpickle_Descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_150__pyx_unpickle_Descriptor[] = "__pyx_unpickle_Descriptor(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_151__pyx_unpickle_Descriptor = {"__pyx_unpickle_Descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_151__pyx_unpickle_Descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_150__pyx_unpickle_Descriptor};
static PyObject *__pyx_pw_4cupy_5cudnn_151__pyx_unpickle_Descriptor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Descriptor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Descriptor", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Descriptor", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Descriptor") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Descriptor", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_Descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_150__pyx_unpickle_Descriptor(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4cupy_5cudnn_150__pyx_unpickle_Descriptor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Descriptor", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfeefb8e:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xfeefb8e) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfeefb8e:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 *     __pyx_result = Descriptor.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xfeefb8e:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Descriptor.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xfe, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfeefb8e:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 *     __pyx_result = Descriptor.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_5cudnn_Descriptor), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 *     __pyx_result = Descriptor.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Descriptor.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_5cudnn___pyx_unpickle_Descriptor__set_state(((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfeefb8e = (destroy, value))" % __pyx_checksum)
 *     __pyx_result = Descriptor.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Descriptor(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_Descriptor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle_Descriptor__set_state(struct __pyx_obj_4cupy_5cudnn_Descriptor *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Descriptor__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->destroy);
  __Pyx_DECREF(__pyx_v___pyx_result->destroy);
  __pyx_v___pyx_result->destroy = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_size_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->value = __pyx_t_2;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_Descriptor__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle__DescriptorArray(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_153__pyx_unpickle__DescriptorArray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_152__pyx_unpickle__DescriptorArray[] = "__pyx_unpickle__DescriptorArray(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_153__pyx_unpickle__DescriptorArray = {"__pyx_unpickle__DescriptorArray", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_153__pyx_unpickle__DescriptorArray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_152__pyx_unpickle__DescriptorArray};
static PyObject *__pyx_pw_4cupy_5cudnn_153__pyx_unpickle__DescriptorArray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle__DescriptorArray (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__DescriptorArray", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__DescriptorArray", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle__DescriptorArray") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle__DescriptorArray", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle__DescriptorArray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_152__pyx_unpickle__DescriptorArray(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4cupy_5cudnn_152__pyx_unpickle__DescriptorArray(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle__DescriptorArray", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfdc424d:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xfdc424d) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfdc424d:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xfdc424d:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xfd, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xfdc424d:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_5cudnn__DescriptorArray), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_5cudnn___pyx_unpickle__DescriptorArray__set_state(((struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xfdc424d = (_destroy, _value))" % __pyx_checksum)
 *     __pyx_result = _DescriptorArray.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle__DescriptorArray(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle__DescriptorArray", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle__DescriptorArray__set_state(struct __pyx_obj_4cupy_5cudnn__DescriptorArray *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  std::vector<size_t>  __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle__DescriptorArray__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_destroy);
  __Pyx_DECREF(__pyx_v___pyx_result->_destroy);
  __pyx_v___pyx_result->_destroy = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_convert_vector_from_py_size_t(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_value = __pyx_t_2;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle__DescriptorArray__set_state(<_DescriptorArray> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle__DescriptorArray__set_state(_DescriptorArray __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._destroy = __pyx_state[0]; __pyx_result._value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle__DescriptorArray__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_DropoutStates(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_5cudnn_155__pyx_unpickle_DropoutStates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_5cudnn_154__pyx_unpickle_DropoutStates[] = "__pyx_unpickle_DropoutStates(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4cupy_5cudnn_155__pyx_unpickle_DropoutStates = {"__pyx_unpickle_DropoutStates", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_155__pyx_unpickle_DropoutStates, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_154__pyx_unpickle_DropoutStates};
static PyObject *__pyx_pw_4cupy_5cudnn_155__pyx_unpickle_DropoutStates(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_DropoutStates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DropoutStates", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DropoutStates", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_DropoutStates") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_DropoutStates", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_DropoutStates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_5cudnn_154__pyx_unpickle_DropoutStates(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4cupy_5cudnn_154__pyx_unpickle_DropoutStates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_DropoutStates", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2ad9aa0:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x2ad9aa0) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2ad9aa0:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 *     __pyx_result = DropoutStates.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x2ad9aa0:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = DropoutStates.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x2a, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2ad9aa0:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 *     __pyx_result = DropoutStates.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4cupy_5cudnn_DropoutStates), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 *     __pyx_result = DropoutStates.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = DropoutStates.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_5cudnn___pyx_unpickle_DropoutStates__set_state(((struct __pyx_obj_4cupy_5cudnn_DropoutStates *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2ad9aa0 = (_desc, _states))" % __pyx_checksum)
 *     __pyx_result = DropoutStates.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_DropoutStates(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_DropoutStates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4cupy_5cudnn___pyx_unpickle_DropoutStates__set_state(struct __pyx_obj_4cupy_5cudnn_DropoutStates *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_DropoutStates__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_5cudnn_Descriptor))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_desc);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->_desc));
  __pyx_v___pyx_result->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_states);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->_states));
  __pyx_v___pyx_result->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_DropoutStates__set_state(<DropoutStates> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_DropoutStates__set_state(DropoutStates __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._desc = __pyx_state[0]; __pyx_result._states = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cupy.cudnn.__pyx_unpickle_DropoutStates__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

static PyObject *__pyx_convert_vector_to_py_size_t(const std::vector<size_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_size_t", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;
    __pyx_t_5 = __Pyx_PyInt_FromSize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_size_t")
 * cdef object __pyx_convert_vector_to_py_size_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_size_t")
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

static std::vector<size_t>  __pyx_convert_vector_from_py_size_t(PyObject *__pyx_v_o) {
  std::vector<size_t>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<size_t>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_size_t", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_As_size_t(__pyx_v_item); if (unlikely((__pyx_t_5 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((size_t)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_size_t")
 * cdef vector[X] __pyx_convert_vector_from_py_size_t(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_size_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

static PyObject *__pyx_convert_vector_to_py_Py_ssize_t(const std::vector<Py_ssize_t>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  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":61
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):
 *     return [v[i] for i in range(v.size())]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_v.size();
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;
    __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 61, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_Py_ssize_t")
 * cdef object __pyx_convert_vector_to_py_Py_ssize_t(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("vector.to_py.__pyx_convert_vector_to_py_Py_ssize_t", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_int")
 * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef vector[X] v
 *     for item in o:
 */

static std::vector<int>  __pyx_convert_vector_from_py_int(PyObject *__pyx_v_o) {
  std::vector<int>  __pyx_v_v;
  PyObject *__pyx_v_item = NULL;
  std::vector<int>  __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;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_int", 0);

  /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 47, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 47, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 47, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 47, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "vector.from_py":48
 *     cdef vector[X] v
 *     for item in o:
 *         v.push_back(<X>item)             # <<<<<<<<<<<<<<
 *     return v
 * 
 */
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 48, __pyx_L1_error)
    __pyx_v_v.push_back(((int)__pyx_t_5));

    /* "vector.from_py":47
 * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *:
 *     cdef vector[X] v
 *     for item in o:             # <<<<<<<<<<<<<<
 *         v.push_back(<X>item)
 *     return v
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "vector.from_py":49
 *     for item in o:
 *         v.push_back(<X>item)
 *     return v             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_v;
  goto __pyx_L0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_int")
 * cdef vector[X] __pyx_convert_vector_from_py_int(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_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_tp_new_4cupy_5cudnn_Descriptor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *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_5cudnn_Descriptor *)o);
  p->destroy = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_5cudnn_Descriptor(PyObject *o) {
  struct __pyx_obj_4cupy_5cudnn_Descriptor *p = (struct __pyx_obj_4cupy_5cudnn_Descriptor *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_4cupy_5cudnn_10Descriptor_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->destroy);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_5cudnn_Descriptor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *p = (struct __pyx_obj_4cupy_5cudnn_Descriptor *)o;
  if (p->destroy) {
    e = (*v)(p->destroy, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_5cudnn_Descriptor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_5cudnn_Descriptor *p = (struct __pyx_obj_4cupy_5cudnn_Descriptor *)o;
  tmp = ((PyObject*)p->destroy);
  p->destroy = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_5cudnn_10Descriptor_value(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_5cudnn_10Descriptor_5value_1__get__(o);
}

static int __pyx_setprop_4cupy_5cudnn_10Descriptor_value(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_5cudnn_10Descriptor_5value_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_4cupy_5cudnn_Descriptor[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_10Descriptor_5__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_5cudnn_10Descriptor_4__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_10Descriptor_7__setstate_cython__, METH_O, __pyx_doc_4cupy_5cudnn_10Descriptor_6__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_5cudnn_Descriptor[] = {
  {(char *)"value", __pyx_getprop_4cupy_5cudnn_10Descriptor_value, __pyx_setprop_4cupy_5cudnn_10Descriptor_value, (char *)"value: 'size_t'", 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_5cudnn_Descriptor = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.cudnn.Descriptor", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_5cudnn_Descriptor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_5cudnn_Descriptor, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  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*/
  "Descriptor(descriptor, destroyer)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_5cudnn_Descriptor, /*tp_traverse*/
  __pyx_tp_clear_4cupy_5cudnn_Descriptor, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_5cudnn_Descriptor, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_5cudnn_Descriptor, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_5cudnn_10Descriptor_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_5cudnn_Descriptor, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_5cudnn__DescriptorArray(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *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_5cudnn__DescriptorArray *)o);
  new((void*)&(p->_value)) std::vector<size_t> ();
  p->_destroy = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_5cudnn__DescriptorArray(PyObject *o) {
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *p = (struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
    __pyx_pw_4cupy_5cudnn_16_DescriptorArray_3__dealloc__(o);
    __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
    PyErr_Restore(etype, eval, etb);
  }
  __Pyx_call_destructor(p->_value);
  Py_CLEAR(p->_destroy);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_5cudnn__DescriptorArray(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *p = (struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)o;
  if (p->_destroy) {
    e = (*v)(p->_destroy, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_5cudnn__DescriptorArray(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_5cudnn__DescriptorArray *p = (struct __pyx_obj_4cupy_5cudnn__DescriptorArray *)o;
  tmp = ((PyObject*)p->_destroy);
  p->_destroy = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_5cudnn_16_DescriptorArray_data(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_5cudnn_16_DescriptorArray_4data_1__get__(o);
}

static PyMethodDef __pyx_methods_4cupy_5cudnn__DescriptorArray[] = {
  {"append", (PyCFunction)__pyx_pw_4cupy_5cudnn_16_DescriptorArray_5append, METH_O, __pyx_doc_4cupy_5cudnn_16_DescriptorArray_4append},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_16_DescriptorArray_7__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_5cudnn_16_DescriptorArray_6__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_16_DescriptorArray_9__setstate_cython__, METH_O, __pyx_doc_4cupy_5cudnn_16_DescriptorArray_8__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_5cudnn__DescriptorArray[] = {
  {(char *)"data", __pyx_getprop_4cupy_5cudnn_16_DescriptorArray_data, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_5cudnn__DescriptorArray = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.cudnn._DescriptorArray", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_5cudnn__DescriptorArray), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_5cudnn__DescriptorArray, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  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*/
  "_DescriptorArray(destroyer)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_5cudnn__DescriptorArray, /*tp_traverse*/
  __pyx_tp_clear_4cupy_5cudnn__DescriptorArray, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_5cudnn__DescriptorArray, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_5cudnn__DescriptorArray, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_5cudnn_16_DescriptorArray_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_5cudnn__DescriptorArray, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_5cudnn_DropoutStates(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *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_5cudnn_DropoutStates *)o);
  p->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  p->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4cupy_5cudnn_DropoutStates(PyObject *o) {
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *p = (struct __pyx_obj_4cupy_5cudnn_DropoutStates *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_states);
  Py_CLEAR(p->_desc);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4cupy_5cudnn_DropoutStates(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *p = (struct __pyx_obj_4cupy_5cudnn_DropoutStates *)o;
  if (p->_states) {
    e = (*v)(((PyObject *)p->_states), a); if (e) return e;
  }
  if (p->_desc) {
    e = (*v)(((PyObject *)p->_desc), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4cupy_5cudnn_DropoutStates(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4cupy_5cudnn_DropoutStates *p = (struct __pyx_obj_4cupy_5cudnn_DropoutStates *)o;
  tmp = ((PyObject*)p->_states);
  p->_states = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_desc);
  p->_desc = ((struct __pyx_obj_4cupy_5cudnn_Descriptor *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4cupy_5cudnn_13DropoutStates__states(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_1__get__(o);
}

static int __pyx_setprop_4cupy_5cudnn_13DropoutStates__states(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_3__set__(o, v);
  }
  else {
    return __pyx_pw_4cupy_5cudnn_13DropoutStates_7_states_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4cupy_5cudnn_13DropoutStates__desc(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_1__get__(o);
}

static int __pyx_setprop_4cupy_5cudnn_13DropoutStates__desc(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_3__set__(o, v);
  }
  else {
    return __pyx_pw_4cupy_5cudnn_13DropoutStates_5_desc_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4cupy_5cudnn_DropoutStates[] = {
  {"set_dropout_ratio", (PyCFunction)__pyx_pw_4cupy_5cudnn_13DropoutStates_3set_dropout_ratio, METH_O, __pyx_doc_4cupy_5cudnn_13DropoutStates_2set_dropout_ratio},
  {"forward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_13DropoutStates_5forward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_13DropoutStates_4forward},
  {"backward", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_13DropoutStates_7backward, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_13DropoutStates_6backward},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_13DropoutStates_9__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_5cudnn_13DropoutStates_8__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_13DropoutStates_11__setstate_cython__, METH_O, __pyx_doc_4cupy_5cudnn_13DropoutStates_10__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4cupy_5cudnn_DropoutStates[] = {
  {(char *)"_states", __pyx_getprop_4cupy_5cudnn_13DropoutStates__states, __pyx_setprop_4cupy_5cudnn_13DropoutStates__states, (char *)"_states: cupy.cuda.memory.MemoryPointer", 0},
  {(char *)"_desc", __pyx_getprop_4cupy_5cudnn_13DropoutStates__desc, __pyx_setprop_4cupy_5cudnn_13DropoutStates__desc, (char *)"_desc: cupy.cudnn.Descriptor", 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_5cudnn_DropoutStates = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.cudnn.DropoutStates", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_5cudnn_DropoutStates), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_5cudnn_DropoutStates, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  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*/
  "DropoutStates(handle, seed)", /*tp_doc*/
  __pyx_tp_traverse_4cupy_5cudnn_DropoutStates, /*tp_traverse*/
  __pyx_tp_clear_4cupy_5cudnn_DropoutStates, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4cupy_5cudnn_DropoutStates, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4cupy_5cudnn_DropoutStates, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4cupy_5cudnn_13DropoutStates_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4cupy_5cudnn_DropoutStates, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyObject *__pyx_tp_new_4cupy_5cudnn__Algorithm(PyTypeObject *t, PyObject *a, PyObject *k) {
  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;
  if (unlikely(__pyx_pw_4cupy_5cudnn_10_Algorithm_1__cinit__(o, a, k) < 0)) goto bad;
  return o;
  bad:
  Py_DECREF(o); o = 0;
  return NULL;
}

static void __pyx_tp_dealloc_4cupy_5cudnn__Algorithm(PyObject *o) {
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_4cupy_5cudnn__Algorithm[] = {
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_10_Algorithm_3__reduce_cython__, METH_NOARGS, __pyx_doc_4cupy_5cudnn_10_Algorithm_2__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4cupy_5cudnn_10_Algorithm_5__setstate_cython__, METH_O, __pyx_doc_4cupy_5cudnn_10_Algorithm_4__setstate_cython__},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4cupy_5cudnn__Algorithm = {
  PyVarObject_HEAD_INIT(0, 0)
  "cupy.cudnn._Algorithm", /*tp_name*/
  sizeof(struct __pyx_obj_4cupy_5cudnn__Algorithm), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4cupy_5cudnn__Algorithm, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  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_5cudnn__Algorithm, /*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_5cudnn__Algorithm, /*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
  #if PY_VERSION_HEX >= 0x030800b1
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {"get_handle", (PyCFunction)__pyx_pw_4cupy_5cudnn_1get_handle, METH_NOARGS, __pyx_doc_4cupy_5cudnn_get_handle},
  {"_get_nd_tensor_cache", (PyCFunction)__pyx_pw_4cupy_5cudnn_5_get_nd_tensor_cache, METH_NOARGS, __pyx_doc_4cupy_5cudnn_4_get_nd_tensor_cache},
  {"get_max_workspace_size", (PyCFunction)__pyx_pw_4cupy_5cudnn_7get_max_workspace_size, METH_NOARGS, __pyx_doc_4cupy_5cudnn_6get_max_workspace_size},
  {"set_max_workspace_size", (PyCFunction)__pyx_pw_4cupy_5cudnn_9set_max_workspace_size, METH_O, __pyx_doc_4cupy_5cudnn_8set_max_workspace_size},
  {"get_data_type", (PyCFunction)__pyx_pw_4cupy_5cudnn_11get_data_type, METH_O, __pyx_doc_4cupy_5cudnn_10get_data_type},
  {"_get_byte_size", (PyCFunction)__pyx_pw_4cupy_5cudnn_13_get_byte_size, METH_O, __pyx_doc_4cupy_5cudnn_12_get_byte_size},
  {"_create_tensor_nd_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_15_create_tensor_nd_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_14_create_tensor_nd_descriptor},
  {"_create_tensor_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_17_create_tensor_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_16_create_tensor_descriptor},
  {"_create_tensor_descriptor_as4darray", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_19_create_tensor_descriptor_as4darray, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_18_create_tensor_descriptor_as4darray},
  {"_create_filter_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_21_create_filter_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_20_create_filter_descriptor},
  {"_create_convolution_descriptor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_23_create_convolution_descriptor, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_22_create_convolution_descriptor},
  {"_ascontiguousarray_normalized_strides", (PyCFunction)__pyx_pw_4cupy_5cudnn_25_ascontiguousarray_normalized_strides, METH_O, __pyx_doc_4cupy_5cudnn_24_ascontiguousarray_normalized_strides},
  {"is_tensor_core_available", (PyCFunction)__pyx_pw_4cupy_5cudnn_89is_tensor_core_available, METH_O, __pyx_doc_4cupy_5cudnn_88is_tensor_core_available},
  {"_warn_algorithm_fwd", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_91_warn_algorithm_fwd, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_90_warn_algorithm_fwd},
  {"_find_algorithm_fwd", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_93_find_algorithm_fwd, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_92_find_algorithm_fwd},
  {"_get_algorithm_fwd", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_95_get_algorithm_fwd, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_94_get_algorithm_fwd},
  {"_warn_algorithm_bwd_filter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_97_warn_algorithm_bwd_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_96_warn_algorithm_bwd_filter},
  {"_find_algorithm_bwd_filter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_99_find_algorithm_bwd_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_98_find_algorithm_bwd_filter},
  {"_get_algorithm_bwd_filter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_101_get_algorithm_bwd_filter, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_100_get_algorithm_bwd_filter},
  {"_warn_algorithm_bwd_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_103_warn_algorithm_bwd_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_102_warn_algorithm_bwd_data},
  {"_find_algorithm_bwd_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_105_find_algorithm_bwd_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_104_find_algorithm_bwd_data},
  {"_get_algorithm_bwd_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_107_get_algorithm_bwd_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_106_get_algorithm_bwd_data},
  {"_should_use_tensor_core", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_109_should_use_tensor_core, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_108_should_use_tensor_core},
  {"set_fused_ops_const_param_pack_attribute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_143set_fused_ops_const_param_pack_attribute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_142set_fused_ops_const_param_pack_attribute},
  {"get_fused_ops_const_param_pack_attribute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_145get_fused_ops_const_param_pack_attribute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_144get_fused_ops_const_param_pack_attribute},
  {"set_fused_ops_variant_param_pack_attribute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_147set_fused_ops_variant_param_pack_attribute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_146set_fused_ops_variant_param_pack_attribute},
  {"get_fused_ops_variant_param_pack_attribute", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4cupy_5cudnn_149get_fused_ops_variant_param_pack_attribute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_5cudnn_148get_fused_ops_variant_param_pack_attribute},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_cudnn(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_cudnn},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "cudnn",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_A_numerical_overflow_might_have, __pyx_k_A_numerical_overflow_might_have, sizeof(__pyx_k_A_numerical_overflow_might_have), 0, 1, 0, 0},
  {&__pyx_n_s_Algorithm, __pyx_k_Algorithm, sizeof(__pyx_k_Algorithm), 0, 0, 1, 1},
  {&__pyx_kp_u_Both_mean_and_inv_std_must_be_No, __pyx_k_Both_mean_and_inv_std_must_be_No, sizeof(__pyx_k_Both_mean_and_inv_std_must_be_No), 0, 1, 0, 0},
  {&__pyx_kp_u_Could_be_faster_by_calling_batch, __pyx_k_Could_be_faster_by_calling_batch, sizeof(__pyx_k_Could_be_faster_by_calling_batch), 0, 1, 0, 0},
  {&__pyx_n_s_CuDNNError, __pyx_k_CuDNNError, sizeof(__pyx_k_CuDNNError), 0, 0, 1, 1},
  {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1},
  {&__pyx_n_s_Descriptor, __pyx_k_Descriptor, sizeof(__pyx_k_Descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_DescriptorArray, __pyx_k_DescriptorArray, sizeof(__pyx_k_DescriptorArray), 0, 0, 1, 1},
  {&__pyx_n_s_DropoutStates, __pyx_k_DropoutStates, sizeof(__pyx_k_DropoutStates), 0, 0, 1, 1},
  {&__pyx_kp_u_Dtype_is_not_supported_in_cuDNN, __pyx_k_Dtype_is_not_supported_in_cuDNN, sizeof(__pyx_k_Dtype_is_not_supported_in_cuDNN), 0, 1, 0, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x2a, __pyx_k_Incompatible_checksums_s_vs_0x2a, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x2a), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xfd, __pyx_k_Incompatible_checksums_s_vs_0xfd, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xfd), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xfe, __pyx_k_Incompatible_checksums_s_vs_0xfe, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xfe), 0, 0, 1, 0},
  {&__pyx_kp_u_Invalid_cuDNN_data_type, __pyx_k_Invalid_cuDNN_data_type, sizeof(__pyx_k_Invalid_cuDNN_data_type), 0, 1, 0, 0},
  {&__pyx_kp_u_No_available_algorithm_found, __pyx_k_No_available_algorithm_found, sizeof(__pyx_k_No_available_algorithm_found), 0, 1, 0, 0},
  {&__pyx_kp_u_No_conv_bwd_data_algo_available, __pyx_k_No_conv_bwd_data_algo_available, sizeof(__pyx_k_No_conv_bwd_data_algo_available), 0, 1, 0, 0},
  {&__pyx_kp_u_No_conv_bwd_filter_algo_availabl, __pyx_k_No_conv_bwd_filter_algo_availabl, sizeof(__pyx_k_No_conv_bwd_filter_algo_availabl), 0, 1, 0, 0},
  {&__pyx_kp_u_No_conv_fwd_algo_available_with, __pyx_k_No_conv_fwd_algo_available_with, sizeof(__pyx_k_No_conv_fwd_algo_available_with), 0, 1, 0, 0},
  {&__pyx_n_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 1},
  {&__pyx_n_s_PerformanceWarning, __pyx_k_PerformanceWarning, sizeof(__pyx_k_PerformanceWarning), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Tensor_Core_mode_is_set_but_the, __pyx_k_Tensor_Core_mode_is_set_but_the, sizeof(__pyx_k_Tensor_Core_mode_is_set_but_the), 0, 1, 0, 0},
  {&__pyx_kp_u_Tensor_Core_mode_is_set_but_the_2, __pyx_k_Tensor_Core_mode_is_set_but_the_2, sizeof(__pyx_k_Tensor_Core_mode_is_set_but_the_2), 0, 1, 0, 0},
  {&__pyx_kp_u_Tensor_Core_mode_is_set_but_the_3, __pyx_k_Tensor_Core_mode_is_set_but_the_3, sizeof(__pyx_k_Tensor_Core_mode_is_set_but_the_3), 0, 1, 0, 0},
  {&__pyx_kp_u_The_best_algo_of_conv_bwd_data_m, __pyx_k_The_best_algo_of_conv_bwd_data_m, sizeof(__pyx_k_The_best_algo_of_conv_bwd_data_m), 0, 1, 0, 0},
  {&__pyx_kp_u_The_best_algo_of_conv_bwd_filter, __pyx_k_The_best_algo_of_conv_bwd_filter, sizeof(__pyx_k_The_best_algo_of_conv_bwd_filter), 0, 1, 0, 0},
  {&__pyx_kp_u_The_best_algo_of_conv_fwd_might, __pyx_k_The_best_algo_of_conv_fwd_might, sizeof(__pyx_k_The_best_algo_of_conv_fwd_might), 0, 1, 0, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_u_Unknown_cudnn_data_type, __pyx_k_Unknown_cudnn_data_type, sizeof(__pyx_k_Unknown_cudnn_data_type), 0, 1, 0, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_W, __pyx_k_W, sizeof(__pyx_k_W), 0, 0, 1, 1},
  {&__pyx_kp_u_W_2, __pyx_k_W_2, sizeof(__pyx_k_W_2), 0, 1, 0, 0},
  {&__pyx_n_s__77, __pyx_k__77, sizeof(__pyx_k__77), 0, 0, 1, 1},
  {&__pyx_n_s_act_desc, __pyx_k_act_desc, sizeof(__pyx_k_act_desc), 0, 0, 1, 1},
  {&__pyx_n_s_activation_backward, __pyx_k_activation_backward, sizeof(__pyx_k_activation_backward), 0, 0, 1, 1},
  {&__pyx_n_s_activation_forward, __pyx_k_activation_forward, sizeof(__pyx_k_activation_forward), 0, 0, 1, 1},
  {&__pyx_n_s_add_infos, __pyx_k_add_infos, sizeof(__pyx_k_add_infos), 0, 0, 1, 1},
  {&__pyx_n_s_add_tensor, __pyx_k_add_tensor, sizeof(__pyx_k_add_tensor), 0, 0, 1, 1},
  {&__pyx_n_s_algo, __pyx_k_algo, sizeof(__pyx_k_algo), 0, 0, 1, 1},
  {&__pyx_n_s_algorithm, __pyx_k_algorithm, sizeof(__pyx_k_algorithm), 0, 0, 1, 1},
  {&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
  {&__pyx_n_u_always, __pyx_k_always, sizeof(__pyx_k_always), 0, 1, 0, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_arr, __pyx_k_arr, sizeof(__pyx_k_arr), 0, 0, 1, 1},
  {&__pyx_n_s_arr_or_scaler, __pyx_k_arr_or_scaler, sizeof(__pyx_k_arr_or_scaler), 0, 0, 1, 1},
  {&__pyx_n_s_atexit, __pyx_k_atexit, sizeof(__pyx_k_atexit), 0, 0, 1, 1},
  {&__pyx_n_s_attr, __pyx_k_attr, sizeof(__pyx_k_attr), 0, 0, 1, 1},
  {&__pyx_n_u_auto, __pyx_k_auto, sizeof(__pyx_k_auto), 0, 1, 0, 1},
  {&__pyx_n_s_auto_tune, __pyx_k_auto_tune, sizeof(__pyx_k_auto_tune), 0, 0, 1, 1},
  {&__pyx_kp_u_auto_tune_r_tensor_core_r, __pyx_k_auto_tune_r_tensor_core_r, sizeof(__pyx_k_auto_tune_r_tensor_core_r), 0, 1, 0, 0},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_u_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 1, 0, 1},
  {&__pyx_kp_u_b_2, __pyx_k_b_2, sizeof(__pyx_k_b_2), 0, 1, 0, 0},
  {&__pyx_n_s_b_desc, __pyx_k_b_desc, sizeof(__pyx_k_b_desc), 0, 0, 1, 1},
  {&__pyx_n_s_b_shape, __pyx_k_b_shape, sizeof(__pyx_k_b_shape), 0, 0, 1, 1},
  {&__pyx_n_s_batch_normalization_backward, __pyx_k_batch_normalization_backward, sizeof(__pyx_k_batch_normalization_backward), 0, 0, 1, 1},
  {&__pyx_n_s_batch_normalization_forward_infe, __pyx_k_batch_normalization_forward_infe, sizeof(__pyx_k_batch_normalization_forward_infe), 0, 0, 1, 1},
  {&__pyx_n_s_batch_normalization_forward_trai, __pyx_k_batch_normalization_forward_trai, sizeof(__pyx_k_batch_normalization_forward_trai), 0, 0, 1, 1},
  {&__pyx_n_s_batch_normalization_forward_trai_2, __pyx_k_batch_normalization_forward_trai_2, sizeof(__pyx_k_batch_normalization_forward_trai_2), 0, 0, 1, 1},
  {&__pyx_n_s_batch_size, __pyx_k_batch_size, sizeof(__pyx_k_batch_size), 0, 0, 1, 1},
  {&__pyx_n_s_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 0, 0, 1, 1},
  {&__pyx_n_s_bias, __pyx_k_bias, sizeof(__pyx_k_bias), 0, 0, 1, 1},
  {&__pyx_n_s_biasData, __pyx_k_biasData, sizeof(__pyx_k_biasData), 0, 0, 1, 1},
  {&__pyx_n_s_biasDesc, __pyx_k_biasDesc, sizeof(__pyx_k_biasDesc), 0, 0, 1, 1},
  {&__pyx_n_s_bias_desc, __pyx_k_bias_desc, sizeof(__pyx_k_bias_desc), 0, 0, 1, 1},
  {&__pyx_n_s_bn_ops, __pyx_k_bn_ops, sizeof(__pyx_k_bn_ops), 0, 0, 1, 1},
  {&__pyx_n_s_byte_size, __pyx_k_byte_size, sizeof(__pyx_k_byte_size), 0, 0, 1, 1},
  {&__pyx_n_s_c_contiguous, __pyx_k_c_contiguous, sizeof(__pyx_k_c_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_cache, __pyx_k_cache, sizeof(__pyx_k_cache), 0, 0, 1, 1},
  {&__pyx_n_s_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_coef, __pyx_k_coef, sizeof(__pyx_k_coef), 0, 0, 1, 1},
  {&__pyx_n_s_const_pack, __pyx_k_const_pack, sizeof(__pyx_k_const_pack), 0, 0, 1, 1},
  {&__pyx_n_s_conv_desc, __pyx_k_conv_desc, sizeof(__pyx_k_conv_desc), 0, 0, 1, 1},
  {&__pyx_n_s_conv_param, __pyx_k_conv_param, sizeof(__pyx_k_conv_param), 0, 0, 1, 1},
  {&__pyx_n_s_convolution_backward_data, __pyx_k_convolution_backward_data, sizeof(__pyx_k_convolution_backward_data), 0, 0, 1, 1},
  {&__pyx_n_s_convolution_backward_filter, __pyx_k_convolution_backward_filter, sizeof(__pyx_k_convolution_backward_filter), 0, 0, 1, 1},
  {&__pyx_n_s_convolution_forward, __pyx_k_convolution_forward, sizeof(__pyx_k_convolution_forward), 0, 0, 1, 1},
  {&__pyx_n_s_create_activation_descriptor, __pyx_k_create_activation_descriptor, sizeof(__pyx_k_create_activation_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_convolution_descriptor, __pyx_k_create_convolution_descriptor, sizeof(__pyx_k_create_convolution_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_ctc_loss_descriptor, __pyx_k_create_ctc_loss_descriptor, sizeof(__pyx_k_create_ctc_loss_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_dropout_descriptor, __pyx_k_create_dropout_descriptor, sizeof(__pyx_k_create_dropout_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_dropout_states, __pyx_k_create_dropout_states, sizeof(__pyx_k_create_dropout_states), 0, 0, 1, 1},
  {&__pyx_kp_u_create_dropout_states_is_depreca, __pyx_k_create_dropout_states_is_depreca, sizeof(__pyx_k_create_dropout_states_is_depreca), 0, 1, 0, 0},
  {&__pyx_n_s_create_filter_descriptor, __pyx_k_create_filter_descriptor, sizeof(__pyx_k_create_filter_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_fused_ops_const_param_pac, __pyx_k_create_fused_ops_const_param_pac, sizeof(__pyx_k_create_fused_ops_const_param_pac), 0, 0, 1, 1},
  {&__pyx_n_s_create_fused_ops_plan, __pyx_k_create_fused_ops_plan, sizeof(__pyx_k_create_fused_ops_plan), 0, 0, 1, 1},
  {&__pyx_n_s_create_fused_ops_variant_param_p, __pyx_k_create_fused_ops_variant_param_p, sizeof(__pyx_k_create_fused_ops_variant_param_p), 0, 0, 1, 1},
  {&__pyx_n_s_create_op_tensor_descriptor, __pyx_k_create_op_tensor_descriptor, sizeof(__pyx_k_create_op_tensor_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_pooling_descriptor, __pyx_k_create_pooling_descriptor, sizeof(__pyx_k_create_pooling_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_reduce_tensor_descriptor, __pyx_k_create_reduce_tensor_descriptor, sizeof(__pyx_k_create_reduce_tensor_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_rnn_descriptor, __pyx_k_create_rnn_descriptor, sizeof(__pyx_k_create_rnn_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_spatial_transformer_descr, __pyx_k_create_spatial_transformer_descr, sizeof(__pyx_k_create_spatial_transformer_descr), 0, 0, 1, 1},
  {&__pyx_n_s_create_tensor_descriptor, __pyx_k_create_tensor_descriptor, sizeof(__pyx_k_create_tensor_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_tensor_nd_descriptor, __pyx_k_create_tensor_nd_descriptor, sizeof(__pyx_k_create_tensor_nd_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_create_uninitialized_tensor_desc, __pyx_k_create_uninitialized_tensor_desc, sizeof(__pyx_k_create_uninitialized_tensor_desc), 0, 0, 1, 1},
  {&__pyx_n_s_ctc_desc, __pyx_k_ctc_desc, sizeof(__pyx_k_ctc_desc), 0, 0, 1, 1},
  {&__pyx_n_s_ctc_loss, __pyx_k_ctc_loss, sizeof(__pyx_k_ctc_loss), 0, 0, 1, 1},
  {&__pyx_n_s_ctypes, __pyx_k_ctypes, sizeof(__pyx_k_ctypes), 0, 0, 1, 1},
  {&__pyx_n_s_cudnn, __pyx_k_cudnn, sizeof(__pyx_k_cudnn), 0, 0, 1, 1},
  {&__pyx_n_s_cudnn_mode, __pyx_k_cudnn_mode, sizeof(__pyx_k_cudnn_mode), 0, 0, 1, 1},
  {&__pyx_n_s_cudnn_nd_tensor_cache, __pyx_k_cudnn_nd_tensor_cache, sizeof(__pyx_k_cudnn_nd_tensor_cache), 0, 0, 1, 1},
  {&__pyx_n_u_cudnn_nd_tensor_cache, __pyx_k_cudnn_nd_tensor_cache, sizeof(__pyx_k_cudnn_nd_tensor_cache), 0, 1, 0, 1},
  {&__pyx_n_s_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_core__ufuncs, __pyx_k_cupy_core__ufuncs, sizeof(__pyx_k_cupy_core__ufuncs), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_cuda, __pyx_k_cupy_cuda, sizeof(__pyx_k_cupy_cuda), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_cudnn, __pyx_k_cupy_cudnn, sizeof(__pyx_k_cupy_cudnn), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_cudnn_pyx, __pyx_k_cupy_cudnn_pyx, sizeof(__pyx_k_cupy_cudnn_pyx), 0, 0, 1, 0},
  {&__pyx_kp_u_cupy_cudnn_supports_c_contiguous, __pyx_k_cupy_cudnn_supports_c_contiguous, sizeof(__pyx_k_cupy_cudnn_supports_c_contiguous), 0, 1, 0, 0},
  {&__pyx_n_s_cx, __pyx_k_cx, sizeof(__pyx_k_cx), 0, 0, 1, 1},
  {&__pyx_n_s_cx_desc, __pyx_k_cx_desc, sizeof(__pyx_k_cx_desc), 0, 0, 1, 1},
  {&__pyx_n_s_cy, __pyx_k_cy, sizeof(__pyx_k_cy), 0, 0, 1, 1},
  {&__pyx_n_s_cy_desc, __pyx_k_cy_desc, sizeof(__pyx_k_cy_desc), 0, 0, 1, 1},
  {&__pyx_n_u_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 1, 0, 1},
  {&__pyx_n_s_dW, __pyx_k_dW, sizeof(__pyx_k_dW), 0, 0, 1, 1},
  {&__pyx_n_s_d_layout, __pyx_k_d_layout, sizeof(__pyx_k_d_layout), 0, 0, 1, 1},
  {&__pyx_kp_u_d_layout_r_w_layout_r, __pyx_k_d_layout_r_w_layout_r, sizeof(__pyx_k_d_layout_r_w_layout_r), 0, 1, 0, 0},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_n_s_data_type, __pyx_k_data_type, sizeof(__pyx_k_data_type), 0, 0, 1, 1},
  {&__pyx_n_s_dcx, __pyx_k_dcx, sizeof(__pyx_k_dcx), 0, 0, 1, 1},
  {&__pyx_n_s_dcx_desc, __pyx_k_dcx_desc, sizeof(__pyx_k_dcx_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dcy, __pyx_k_dcy, sizeof(__pyx_k_dcy), 0, 0, 1, 1},
  {&__pyx_n_s_dcy_desc, __pyx_k_dcy_desc, sizeof(__pyx_k_dcy_desc), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_decay, __pyx_k_decay, sizeof(__pyx_k_decay), 0, 0, 1, 1},
  {&__pyx_n_s_derivedBnDesc, __pyx_k_derivedBnDesc, sizeof(__pyx_k_derivedBnDesc), 0, 0, 1, 1},
  {&__pyx_n_s_desc, __pyx_k_desc, sizeof(__pyx_k_desc), 0, 0, 1, 1},
  {&__pyx_n_s_desc_or_scalar, __pyx_k_desc_or_scalar, sizeof(__pyx_k_desc_or_scalar), 0, 0, 1, 1},
  {&__pyx_n_s_descriptor, __pyx_k_descriptor, sizeof(__pyx_k_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyActivationDescriptor, __pyx_k_destroyActivationDescriptor, sizeof(__pyx_k_destroyActivationDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyCTCLossDescriptor, __pyx_k_destroyCTCLossDescriptor, sizeof(__pyx_k_destroyCTCLossDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyConvolutionDescriptor, __pyx_k_destroyConvolutionDescriptor, sizeof(__pyx_k_destroyConvolutionDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyDropoutDescriptor, __pyx_k_destroyDropoutDescriptor, sizeof(__pyx_k_destroyDropoutDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyFilterDescriptor, __pyx_k_destroyFilterDescriptor, sizeof(__pyx_k_destroyFilterDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyFusedOpsConstParamPack, __pyx_k_destroyFusedOpsConstParamPack, sizeof(__pyx_k_destroyFusedOpsConstParamPack), 0, 0, 1, 1},
  {&__pyx_n_s_destroyFusedOpsPlan, __pyx_k_destroyFusedOpsPlan, sizeof(__pyx_k_destroyFusedOpsPlan), 0, 0, 1, 1},
  {&__pyx_n_s_destroyFusedOpsVariantParamPack, __pyx_k_destroyFusedOpsVariantParamPack, sizeof(__pyx_k_destroyFusedOpsVariantParamPack), 0, 0, 1, 1},
  {&__pyx_n_s_destroyOpTensorDescriptor, __pyx_k_destroyOpTensorDescriptor, sizeof(__pyx_k_destroyOpTensorDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyPoolingDescriptor, __pyx_k_destroyPoolingDescriptor, sizeof(__pyx_k_destroyPoolingDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyRNNDataDescriptor, __pyx_k_destroyRNNDataDescriptor, sizeof(__pyx_k_destroyRNNDataDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyRNNDescriptor, __pyx_k_destroyRNNDescriptor, sizeof(__pyx_k_destroyRNNDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyReduceTensorDescriptor, __pyx_k_destroyReduceTensorDescriptor, sizeof(__pyx_k_destroyReduceTensorDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroySpatialTransformerDescrip, __pyx_k_destroySpatialTransformerDescrip, sizeof(__pyx_k_destroySpatialTransformerDescrip), 0, 0, 1, 1},
  {&__pyx_n_s_destroyTensorDescriptor, __pyx_k_destroyTensorDescriptor, sizeof(__pyx_k_destroyTensorDescriptor), 0, 0, 1, 1},
  {&__pyx_n_s_destroyer, __pyx_k_destroyer, sizeof(__pyx_k_destroyer), 0, 0, 1, 1},
  {&__pyx_n_s_deterministic, __pyx_k_deterministic, sizeof(__pyx_k_deterministic), 0, 0, 1, 1},
  {&__pyx_n_s_dev_id, __pyx_k_dev_id, sizeof(__pyx_k_dev_id), 0, 0, 1, 1},
  {&__pyx_n_s_device, __pyx_k_device, sizeof(__pyx_k_device), 0, 0, 1, 1},
  {&__pyx_n_s_dhx, __pyx_k_dhx, sizeof(__pyx_k_dhx), 0, 0, 1, 1},
  {&__pyx_n_s_dhx_desc, __pyx_k_dhx_desc, sizeof(__pyx_k_dhx_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dhy, __pyx_k_dhy, sizeof(__pyx_k_dhy), 0, 0, 1, 1},
  {&__pyx_n_s_dhy_desc, __pyx_k_dhy_desc, sizeof(__pyx_k_dhy_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dilation, __pyx_k_dilation, sizeof(__pyx_k_dilation), 0, 0, 1, 1},
  {&__pyx_kp_u_dilation_must_be_one_when_cuDNN, __pyx_k_dilation_must_be_one_when_cuDNN, sizeof(__pyx_k_dilation_must_be_one_when_cuDNN), 0, 1, 0, 0},
  {&__pyx_n_s_dim, __pyx_k_dim, sizeof(__pyx_k_dim), 0, 0, 1, 1},
  {&__pyx_n_s_dim_A, __pyx_k_dim_A, sizeof(__pyx_k_dim_A), 0, 0, 1, 1},
  {&__pyx_n_s_direction, __pyx_k_direction, sizeof(__pyx_k_direction), 0, 0, 1, 1},
  {&__pyx_n_s_direction_mode, __pyx_k_direction_mode, sizeof(__pyx_k_direction_mode), 0, 0, 1, 1},
  {&__pyx_n_s_double_one, __pyx_k_double_one, sizeof(__pyx_k_double_one), 0, 0, 1, 1},
  {&__pyx_n_s_double_zero, __pyx_k_double_zero, sizeof(__pyx_k_double_zero), 0, 0, 1, 1},
  {&__pyx_n_s_dropout, __pyx_k_dropout, sizeof(__pyx_k_dropout), 0, 0, 1, 1},
  {&__pyx_n_s_dropout_desc, __pyx_k_dropout_desc, sizeof(__pyx_k_dropout_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dropout_ratio, __pyx_k_dropout_ratio, sizeof(__pyx_k_dropout_ratio), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_param, __pyx_k_dtype_param, sizeof(__pyx_k_dtype_param), 0, 0, 1, 1},
  {&__pyx_n_s_dw, __pyx_k_dw, sizeof(__pyx_k_dw), 0, 0, 1, 1},
  {&__pyx_n_s_dw_desc, __pyx_k_dw_desc, sizeof(__pyx_k_dw_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dx_data_desc, __pyx_k_dx_data_desc, sizeof(__pyx_k_dx_data_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dxs, __pyx_k_dxs, sizeof(__pyx_k_dxs), 0, 0, 1, 1},
  {&__pyx_n_s_dxs_descs, __pyx_k_dxs_descs, sizeof(__pyx_k_dxs_descs), 0, 0, 1, 1},
  {&__pyx_n_s_dy, __pyx_k_dy, sizeof(__pyx_k_dy), 0, 0, 1, 1},
  {&__pyx_n_s_dy_data_desc, __pyx_k_dy_data_desc, sizeof(__pyx_k_dy_data_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dy_desc, __pyx_k_dy_desc, sizeof(__pyx_k_dy_desc), 0, 0, 1, 1},
  {&__pyx_n_s_dys, __pyx_k_dys, sizeof(__pyx_k_dys), 0, 0, 1, 1},
  {&__pyx_n_s_dys_descs, __pyx_k_dys_descs, sizeof(__pyx_k_dys_descs), 0, 0, 1, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_n_u_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 1, 0, 1},
  {&__pyx_n_s_elementwise_copy, __pyx_k_elementwise_copy, sizeof(__pyx_k_elementwise_copy), 0, 0, 1, 1},
  {&__pyx_n_s_eps, __pyx_k_eps, sizeof(__pyx_k_eps), 0, 0, 1, 1},
  {&__pyx_n_u_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 1, 0, 1},
  {&__pyx_n_s_filter_desc, __pyx_k_filter_desc, sizeof(__pyx_k_filter_desc), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 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_float_one, __pyx_k_float_one, sizeof(__pyx_k_float_one), 0, 0, 1, 1},
  {&__pyx_n_s_float_zero, __pyx_k_float_zero, sizeof(__pyx_k_float_zero), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_kp_u_func_cudnnConvolutionForward, __pyx_k_func_cudnnConvolutionForward, sizeof(__pyx_k_func_cudnnConvolutionForward), 0, 1, 0, 0},
  {&__pyx_n_s_fused_ops_execute, __pyx_k_fused_ops_execute, sizeof(__pyx_k_fused_ops_execute), 0, 0, 1, 1},
  {&__pyx_n_s_gW, __pyx_k_gW, sizeof(__pyx_k_gW), 0, 0, 1, 1},
  {&__pyx_n_s_gamma, __pyx_k_gamma, sizeof(__pyx_k_gamma), 0, 0, 1, 1},
  {&__pyx_n_s_gbeta, __pyx_k_gbeta, sizeof(__pyx_k_gbeta), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_array_info, __pyx_k_get_array_info, sizeof(__pyx_k_get_array_info), 0, 0, 1, 1},
  {&__pyx_n_s_get_rnn_lin_layer_bias_params, __pyx_k_get_rnn_lin_layer_bias_params, sizeof(__pyx_k_get_rnn_lin_layer_bias_params), 0, 0, 1, 1},
  {&__pyx_n_s_get_rnn_lin_layer_matrix_params, __pyx_k_get_rnn_lin_layer_matrix_params, sizeof(__pyx_k_get_rnn_lin_layer_matrix_params), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_ggamma, __pyx_k_ggamma, sizeof(__pyx_k_ggamma), 0, 0, 1, 1},
  {&__pyx_n_s_gradients, __pyx_k_gradients, sizeof(__pyx_k_gradients), 0, 0, 1, 1},
  {&__pyx_n_s_gradients_desc, __pyx_k_gradients_desc, sizeof(__pyx_k_gradients_desc), 0, 0, 1, 1},
  {&__pyx_n_s_groups, __pyx_k_groups, sizeof(__pyx_k_groups), 0, 0, 1, 1},
  {&__pyx_kp_u_groups_must_be_one_when_cuDNN_7, __pyx_k_groups_must_be_one_when_cuDNN_7, sizeof(__pyx_k_groups_must_be_one_when_cuDNN_7), 0, 1, 0, 0},
  {&__pyx_n_s_gx, __pyx_k_gx, sizeof(__pyx_k_gx), 0, 0, 1, 1},
  {&__pyx_n_s_gy, __pyx_k_gy, sizeof(__pyx_k_gy), 0, 0, 1, 1},
  {&__pyx_n_s_gy_desc, __pyx_k_gy_desc, sizeof(__pyx_k_gy_desc), 0, 0, 1, 1},
  {&__pyx_n_s_handle, __pyx_k_handle, sizeof(__pyx_k_handle), 0, 0, 1, 1},
  {&__pyx_n_s_handle_2, __pyx_k_handle_2, sizeof(__pyx_k_handle_2), 0, 0, 1, 1},
  {&__pyx_n_s_hidden_size, __pyx_k_hidden_size, sizeof(__pyx_k_hidden_size), 0, 0, 1, 1},
  {&__pyx_n_s_hx, __pyx_k_hx, sizeof(__pyx_k_hx), 0, 0, 1, 1},
  {&__pyx_n_s_hx_desc, __pyx_k_hx_desc, sizeof(__pyx_k_hx_desc), 0, 0, 1, 1},
  {&__pyx_n_s_hy, __pyx_k_hy, sizeof(__pyx_k_hy), 0, 0, 1, 1},
  {&__pyx_n_s_hy_desc, __pyx_k_hy_desc, sizeof(__pyx_k_hy_desc), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_indices, __pyx_k_indices, sizeof(__pyx_k_indices), 0, 0, 1, 1},
  {&__pyx_n_s_infos, __pyx_k_infos, sizeof(__pyx_k_infos), 0, 0, 1, 1},
  {&__pyx_n_s_input_length, __pyx_k_input_length, sizeof(__pyx_k_input_length), 0, 0, 1, 1},
  {&__pyx_n_s_input_length_ptr, __pyx_k_input_length_ptr, sizeof(__pyx_k_input_length_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_input_mode, __pyx_k_input_mode, sizeof(__pyx_k_input_mode), 0, 0, 1, 1},
  {&__pyx_n_s_inv_std, __pyx_k_inv_std, sizeof(__pyx_k_inv_std), 0, 0, 1, 1},
  {&__pyx_n_s_is_for_conv2d, __pyx_k_is_for_conv2d, sizeof(__pyx_k_is_for_conv2d), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  {&__pyx_n_s_ksize, __pyx_k_ksize, sizeof(__pyx_k_ksize), 0, 0, 1, 1},
  {&__pyx_kp_u_ksize_stride_and_pad_must_be_of, __pyx_k_ksize_stride_and_pad_must_be_of, sizeof(__pyx_k_ksize_stride_and_pad_must_be_of), 0, 1, 0, 0},
  {&__pyx_n_s_label_length, __pyx_k_label_length, sizeof(__pyx_k_label_length), 0, 0, 1, 1},
  {&__pyx_n_s_label_length_ptr, __pyx_k_label_length_ptr, sizeof(__pyx_k_label_length_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_labels, __pyx_k_labels, sizeof(__pyx_k_labels), 0, 0, 1, 1},
  {&__pyx_n_s_labels_ptr, __pyx_k_labels_ptr, sizeof(__pyx_k_labels_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_layer, __pyx_k_layer, sizeof(__pyx_k_layer), 0, 0, 1, 1},
  {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
  {&__pyx_n_s_lengths, __pyx_k_lengths, sizeof(__pyx_k_lengths), 0, 0, 1, 1},
  {&__pyx_n_s_lin_layer_id, __pyx_k_lin_layer_id, sizeof(__pyx_k_lin_layer_id), 0, 0, 1, 1},
  {&__pyx_n_s_list_attr_param, __pyx_k_list_attr_param, sizeof(__pyx_k_list_attr_param), 0, 0, 1, 1},
  {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1},
  {&__pyx_n_s_loss, __pyx_k_loss, sizeof(__pyx_k_loss), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_make_fused_ops_plan, __pyx_k_make_fused_ops_plan, sizeof(__pyx_k_make_fused_ops_plan), 0, 0, 1, 1},
  {&__pyx_n_s_mat, __pyx_k_mat, sizeof(__pyx_k_mat), 0, 0, 1, 1},
  {&__pyx_n_s_mat_desc, __pyx_k_mat_desc, sizeof(__pyx_k_mat_desc), 0, 0, 1, 1},
  {&__pyx_n_s_mathType, __pyx_k_mathType, sizeof(__pyx_k_mathType), 0, 0, 1, 1},
  {&__pyx_n_s_math_type, __pyx_k_math_type, sizeof(__pyx_k_math_type), 0, 0, 1, 1},
  {&__pyx_n_s_max_workspace_size, __pyx_k_max_workspace_size, sizeof(__pyx_k_max_workspace_size), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_memory, __pyx_k_memory, sizeof(__pyx_k_memory), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_n_layers, __pyx_k_n_layers, sizeof(__pyx_k_n_layers), 0, 0, 1, 1},
  {&__pyx_n_s_n_units, __pyx_k_n_units, sizeof(__pyx_k_n_units), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_nan_prop_mode, __pyx_k_nan_prop_mode, sizeof(__pyx_k_nan_prop_mode), 0, 0, 1, 1},
  {&__pyx_n_s_nb_dims, __pyx_k_nb_dims, sizeof(__pyx_k_nb_dims), 0, 0, 1, 1},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_need_cast, __pyx_k_need_cast, sizeof(__pyx_k_need_cast), 0, 0, 1, 1},
  {&__pyx_n_u_never, __pyx_k_never, sizeof(__pyx_k_never), 0, 1, 0, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  {&__pyx_n_s_num_layers, __pyx_k_num_layers, sizeof(__pyx_k_num_layers), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
  {&__pyx_n_s_one, __pyx_k_one, sizeof(__pyx_k_one), 0, 0, 1, 1},
  {&__pyx_n_s_op_type, __pyx_k_op_type, sizeof(__pyx_k_op_type), 0, 0, 1, 1},
  {&__pyx_n_s_ops, __pyx_k_ops, sizeof(__pyx_k_ops), 0, 0, 1, 1},
  {&__pyx_n_s_pad, __pyx_k_pad, sizeof(__pyx_k_pad), 0, 0, 1, 1},
  {&__pyx_kp_u_pad_and_stride_must_be_of_same_l, __pyx_k_pad_and_stride_must_be_of_same_l, sizeof(__pyx_k_pad_and_stride_must_be_of_same_l), 0, 1, 0, 0},
  {&__pyx_kp_u_pad_r_stride_r_dilation_r_groups, __pyx_k_pad_r_stride_r_dilation_r_groups, sizeof(__pyx_k_pad_r_stride_r_dilation_r_groups), 0, 1, 0, 0},
  {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1},
  {&__pyx_n_s_param_label, __pyx_k_param_label, sizeof(__pyx_k_param_label), 0, 0, 1, 1},
  {&__pyx_n_s_perf, __pyx_k_perf, sizeof(__pyx_k_perf), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_plan, __pyx_k_plan, sizeof(__pyx_k_plan), 0, 0, 1, 1},
  {&__pyx_n_s_pool_desc, __pyx_k_pool_desc, sizeof(__pyx_k_pool_desc), 0, 0, 1, 1},
  {&__pyx_n_s_pooling_backward, __pyx_k_pooling_backward, sizeof(__pyx_k_pooling_backward), 0, 0, 1, 1},
  {&__pyx_n_s_pooling_forward, __pyx_k_pooling_forward, sizeof(__pyx_k_pooling_forward), 0, 0, 1, 1},
  {&__pyx_kp_u_pooling_forward_supports_c_conti, __pyx_k_pooling_forward_supports_c_conti, sizeof(__pyx_k_pooling_forward_supports_c_conti), 0, 1, 0, 0},
  {&__pyx_n_s_probs, __pyx_k_probs, sizeof(__pyx_k_probs), 0, 0, 1, 1},
  {&__pyx_n_s_probs_desc, __pyx_k_probs_desc, sizeof(__pyx_k_probs_desc), 0, 0, 1, 1},
  {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_py_cudnn, __pyx_k_py_cudnn, sizeof(__pyx_k_py_cudnn), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Descriptor, __pyx_k_pyx_unpickle_Descriptor, sizeof(__pyx_k_pyx_unpickle_Descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_DropoutStates, __pyx_k_pyx_unpickle_DropoutStates, sizeof(__pyx_k_pyx_unpickle_DropoutStates), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle__DescriptorArray, __pyx_k_pyx_unpickle__DescriptorArray, sizeof(__pyx_k_pyx_unpickle__DescriptorArray), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_query_mode, __pyx_k_query_mode, sizeof(__pyx_k_query_mode), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 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_register, __pyx_k_register, sizeof(__pyx_k_register), 0, 0, 1, 1},
  {&__pyx_n_s_relu_nan_opt, __pyx_k_relu_nan_opt, sizeof(__pyx_k_relu_nan_opt), 0, 0, 1, 1},
  {&__pyx_n_s_reserve_space, __pyx_k_reserve_space, sizeof(__pyx_k_reserve_space), 0, 0, 1, 1},
  {&__pyx_kp_u_reserve_space_can_only_be_passed, __pyx_k_reserve_space_can_only_be_passed, sizeof(__pyx_k_reserve_space_can_only_be_passed), 0, 1, 0, 0},
  {&__pyx_n_s_reset_handles, __pyx_k_reset_handles, sizeof(__pyx_k_reset_handles), 0, 0, 1, 1},
  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_backward_data, __pyx_k_rnn_backward_data, sizeof(__pyx_k_rnn_backward_data), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_backward_data_ex, __pyx_k_rnn_backward_data_ex, sizeof(__pyx_k_rnn_backward_data_ex), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_backward_weights, __pyx_k_rnn_backward_weights, sizeof(__pyx_k_rnn_backward_weights), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_backward_weights_ex, __pyx_k_rnn_backward_weights_ex, sizeof(__pyx_k_rnn_backward_weights_ex), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_desc, __pyx_k_rnn_desc, sizeof(__pyx_k_rnn_desc), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_forward_inference, __pyx_k_rnn_forward_inference, sizeof(__pyx_k_rnn_forward_inference), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_forward_inference_ex, __pyx_k_rnn_forward_inference_ex, sizeof(__pyx_k_rnn_forward_inference_ex), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_forward_training, __pyx_k_rnn_forward_training, sizeof(__pyx_k_rnn_forward_training), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_forward_training_ex, __pyx_k_rnn_forward_training_ex, sizeof(__pyx_k_rnn_forward_training_ex), 0, 0, 1, 1},
  {&__pyx_n_s_rnn_mode, __pyx_k_rnn_mode, sizeof(__pyx_k_rnn_mode), 0, 0, 1, 1},
  {&__pyx_n_s_rstatus, __pyx_k_rstatus, sizeof(__pyx_k_rstatus), 0, 0, 1, 1},
  {&__pyx_n_s_running_mean, __pyx_k_running_mean, sizeof(__pyx_k_running_mean), 0, 0, 1, 1},
  {&__pyx_n_s_running_var, __pyx_k_running_var, sizeof(__pyx_k_running_var), 0, 0, 1, 1},
  {&__pyx_n_s_sampler_type, __pyx_k_sampler_type, sizeof(__pyx_k_sampler_type), 0, 0, 1, 1},
  {&__pyx_n_s_save_inv_std, __pyx_k_save_inv_std, sizeof(__pyx_k_save_inv_std), 0, 0, 1, 1},
  {&__pyx_n_s_save_mean, __pyx_k_save_mean, sizeof(__pyx_k_save_mean), 0, 0, 1, 1},
  {&__pyx_n_s_seed, __pyx_k_seed, sizeof(__pyx_k_seed), 0, 0, 1, 1},
  {&__pyx_n_s_set_dropout_descriptor, __pyx_k_set_dropout_descriptor, sizeof(__pyx_k_set_dropout_descriptor), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_shape_2, __pyx_k_shape_2, sizeof(__pyx_k_shape_2), 0, 0, 1, 1},
  {&__pyx_kp_u_shape_r_dtype_strides_r, __pyx_k_shape_r_dtype_strides_r, sizeof(__pyx_k_shape_r_dtype_strides_r), 0, 1, 0, 0},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_softmax_backward, __pyx_k_softmax_backward, sizeof(__pyx_k_softmax_backward), 0, 0, 1, 1},
  {&__pyx_n_s_softmax_forward, __pyx_k_softmax_forward, sizeof(__pyx_k_softmax_forward), 0, 0, 1, 1},
  {&__pyx_n_s_srcDestData, __pyx_k_srcDestData, sizeof(__pyx_k_srcDestData), 0, 0, 1, 1},
  {&__pyx_n_s_srcDestDesc, __pyx_k_srcDestDesc, sizeof(__pyx_k_srcDestDesc), 0, 0, 1, 1},
  {&__pyx_n_s_state_size, __pyx_k_state_size, sizeof(__pyx_k_state_size), 0, 0, 1, 1},
  {&__pyx_n_s_state_size_in_bytes, __pyx_k_state_size_in_bytes, sizeof(__pyx_k_state_size_in_bytes), 0, 0, 1, 1},
  {&__pyx_n_s_states, __pyx_k_states, sizeof(__pyx_k_states), 0, 0, 1, 1},
  {&__pyx_n_s_stride, __pyx_k_stride, sizeof(__pyx_k_stride), 0, 0, 1, 1},
  {&__pyx_n_s_strides, __pyx_k_strides, sizeof(__pyx_k_strides), 0, 0, 1, 1},
  {&__pyx_n_s_strides_2, __pyx_k_strides_2, sizeof(__pyx_k_strides_2), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_kp_u_tensor_code_mode_must_be_either, __pyx_k_tensor_code_mode_must_be_either, sizeof(__pyx_k_tensor_code_mode_must_be_either), 0, 1, 0, 0},
  {&__pyx_n_s_tensor_core, __pyx_k_tensor_core, sizeof(__pyx_k_tensor_core), 0, 0, 1, 1},
  {&__pyx_n_s_tensor_core_mode, __pyx_k_tensor_core_mode, sizeof(__pyx_k_tensor_core_mode), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  {&__pyx_kp_u_unknown_cudnnTensorFormat, __pyx_k_unknown_cudnnTensorFormat, sizeof(__pyx_k_unknown_cudnnTensorFormat), 0, 1, 0, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_use_tensor_core, __pyx_k_use_tensor_core, sizeof(__pyx_k_use_tensor_core), 0, 0, 1, 1},
  {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_var, __pyx_k_var, sizeof(__pyx_k_var), 0, 0, 1, 1},
  {&__pyx_n_s_var_pack, __pyx_k_var_pack, sizeof(__pyx_k_var_pack), 0, 0, 1, 1},
  {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_n_s_w_desc, __pyx_k_w_desc, sizeof(__pyx_k_w_desc), 0, 0, 1, 1},
  {&__pyx_n_s_w_layout, __pyx_k_w_layout, sizeof(__pyx_k_w_layout), 0, 0, 1, 1},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
  {&__pyx_n_s_work_size, __pyx_k_work_size, sizeof(__pyx_k_work_size), 0, 0, 1, 1},
  {&__pyx_n_s_workspace, __pyx_k_workspace, sizeof(__pyx_k_workspace), 0, 0, 1, 1},
  {&__pyx_n_s_workspace_size, __pyx_k_workspace_size, sizeof(__pyx_k_workspace_size), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_kp_u_x_2, __pyx_k_x_2, sizeof(__pyx_k_x_2), 0, 1, 0, 0},
  {&__pyx_n_s_x_data_desc, __pyx_k_x_data_desc, sizeof(__pyx_k_x_data_desc), 0, 0, 1, 1},
  {&__pyx_n_s_x_desc, __pyx_k_x_desc, sizeof(__pyx_k_x_desc), 0, 0, 1, 1},
  {&__pyx_n_s_xs, __pyx_k_xs, sizeof(__pyx_k_xs), 0, 0, 1, 1},
  {&__pyx_n_s_xs_descs, __pyx_k_xs_descs, sizeof(__pyx_k_xs_descs), 0, 0, 1, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_kp_u_y_2, __pyx_k_y_2, sizeof(__pyx_k_y_2), 0, 1, 0, 0},
  {&__pyx_n_s_y_data_desc, __pyx_k_y_data_desc, sizeof(__pyx_k_y_data_desc), 0, 0, 1, 1},
  {&__pyx_n_s_y_desc, __pyx_k_y_desc, sizeof(__pyx_k_y_desc), 0, 0, 1, 1},
  {&__pyx_n_s_ys, __pyx_k_ys, sizeof(__pyx_k_ys), 0, 0, 1, 1},
  {&__pyx_n_s_ys_descs, __pyx_k_ys_descs, sizeof(__pyx_k_ys_descs), 0, 0, 1, 1},
  {&__pyx_n_s_zero, __pyx_k_zero, sizeof(__pyx_k_zero), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 106, __pyx_L1_error)
  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 134, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 134, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 148, __pyx_L1_error)
  __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) __PYX_ERR(0, 1180, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 1364, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "cupy/cudnn.pyx":148
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')             # <<<<<<<<<<<<<<
 *     if arr._shape.size() == 4:
 *         data_type = get_data_type(arr.dtype)
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_cupy_cudnn_supports_c_contiguous); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/cudnn.pyx":203
 *     ndim = len(pad)
 *     if ndim != len(stride):
 *         raise ValueError('pad and stride must be of same length')             # <<<<<<<<<<<<<<
 * 
 *     compute_type = get_data_type(dtype)
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_pad_and_stride_must_be_of_same_l); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cupy/cudnn.pyx":221
 *                 for i in c_dilation:
 *                     if i != 1:
 *                         raise ValueError(             # <<<<<<<<<<<<<<
 *                             'dilation must be one when cuDNN < 6.0')
 *         cudnn.setConvolutionNdDescriptor_v3(
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_dilation_must_be_one_when_cuDNN); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/cudnn.pyx":244
 *             cudnn.setConvolutionGroupCount(desc, groups)
 *     elif groups > 1:
 *         raise ValueError('groups must be one when cuDNN < 7.0')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_groups_must_be_one_when_cuDNN_7); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "cupy/cudnn.pyx":279
 *     cdef dict cache
 *     if arr.size == 0:
 *         return Descriptor(0, None)             # <<<<<<<<<<<<<<
 *     if not arr.flags.c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 */
  __pyx_tuple__8 = PyTuple_Pack(2, __pyx_int_0, Py_None); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 279, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/cudnn.pyx":322
 *     cdef int ndim = len(ksize)
 *     if ndim != len(stride) or ndim != len(pad):
 *         raise ValueError('ksize, stride, and pad must be of same length')             # <<<<<<<<<<<<<<
 *     if ndim == 2:
 *         cudnn.setPooling2dDescriptor_v4(
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_ksize_stride_and_pad_must_be_of); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 322, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/cudnn.pyx":380
 *     cdef core.ndarray hy = core.ndarray(hx.shape, hx.dtype)
 *     if cx is None:
 *         cx = core.ndarray(0, dtype=xs.dtype)             # <<<<<<<<<<<<<<
 *     cdef core.ndarray cy = core.ndarray(cx.shape, cx.dtype)
 * 
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/cudnn.pyx":971
 *         output_units = n_units
 * 
 *     shape = xs.shape[:-1] + (output_units,)             # <<<<<<<<<<<<<<
 *     return core.ndarray(shape, dtype=xs.dtype)
 * 
 */
  __pyx_slice__14 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__14)) __PYX_ERR(0, 971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__14);
  __Pyx_GIVEREF(__pyx_slice__14);

  /* "cupy/cudnn.pyx":1178
 * 
 * def create_dropout_states(handle):
 *     warnings.warn('create_dropout_states is deprecated.'             # <<<<<<<<<<<<<<
 *                   'Please use DropoutStates class instead.',
 *                   DeprecationWarning)
 */
  __pyx_tuple__15 = PyTuple_Pack(2, __pyx_kp_u_create_dropout_states_is_depreca, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "(tree fragment)":2
 * def __reduce_cython__(self):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "(tree fragment)":4
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
 * def __setstate_cython__(self, __pyx_state):
 *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "cupy/cudnn.pyx":1364
 *             y_desc, y.data.ptr, 1, workspace.ptr, max_workspace_size)[0]
 *     if perf.status != cudnn.CUDNN_STATUS_SUCCESS:
 *         raise RuntimeError('No available algorithm found.')             # <<<<<<<<<<<<<<
 *     algo = _Algorithm(perf.algo, perf.memory, perf.mathType)
 *     _algorithm_fwd_cache[key] = algo
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_No_available_algorithm_found); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 1364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "cupy/cudnn.pyx":1634
 *         return False
 *     else:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             'tensor_code_mode must be either of "always", "auto", or "never".')
 * 
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_tensor_code_mode_must_be_either); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "cupy/cudnn.pyx":1969
 *     x = core._internal_ascontiguousarray(x)
 *     if not y._c_contiguous:
 *         raise ValueError('pooling_forward supports c-contiguous y only')             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     x_desc = cudnn.createTensorDescriptor()
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_u_pooling_forward_supports_c_conti); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 1969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cupy/cudnn.pyx":2121
 *     # compatibility. See cupy#2060 and cupy#2070.
 *     if (mean is None) != (inv_std is None):
 *         raise ValueError('Both mean and inv_std must be None if one is.')             # <<<<<<<<<<<<<<
 * 
 *     x = core._internal_ascontiguousarray(x)
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_Both_mean_and_inv_std_must_be_No); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 2121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cupy/cudnn.pyx":2394
 *             # cuDNN < 7401
 *             if reserve_space is not None:
 *                 raise ValueError(             # <<<<<<<<<<<<<<
 *                     'reserve_space can only be passed in cuDNN >= 7401')
 *             cudnn.batchNormalizationBackward(
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_reserve_space_can_only_be_passed); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 2394, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "cupy/cudnn.pyx":41
 * 
 * @atexit.register
 * def reset_handles():             # <<<<<<<<<<<<<<
 *     for handle in _handles:
 *         if handle:
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_n_s_handle); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_reset_handles, 41, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 41, __pyx_L1_error)

  /* "cupy/cudnn.pyx":259
 * 
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 */
  __pyx_tuple__38 = PyTuple_Pack(3, __pyx_n_s_arr, __pyx_n_s_format, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_tensor_descriptor, 259, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 259, __pyx_L1_error)

  /* "cupy/cudnn.pyx":266
 * 
 * 
 * def create_uninitialized_tensor_descriptor():             # <<<<<<<<<<<<<<
 *     """Create uninitialized tensor descriptor.
 * 
 */
  __pyx_codeobj__40 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_uninitialized_tensor_desc, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__40)) __PYX_ERR(0, 266, __pyx_L1_error)

  /* "cupy/cudnn.pyx":276
 * 
 * 
 * def create_tensor_nd_descriptor(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     cdef dict cache
 *     if arr.size == 0:
 */
  __pyx_tuple__41 = PyTuple_Pack(5, __pyx_n_s_arr, __pyx_n_s_cache, __pyx_n_s_data_type, __pyx_n_s_key, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  __pyx_codeobj__42 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__41, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_tensor_nd_descriptor, 276, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__42)) __PYX_ERR(0, 276, __pyx_L1_error)

  /* "cupy/cudnn.pyx":297
 * 
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)
 */
  __pyx_tuple__43 = PyTuple_Pack(3, __pyx_n_s_arr, __pyx_n_s_format, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
  __pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__43, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_filter_descriptor, 297, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 297, __pyx_L1_error)

  /* "cupy/cudnn.pyx":304
 * 
 * 
 * def create_convolution_descriptor(pad, stride, dtype,             # <<<<<<<<<<<<<<
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 */
  __pyx_tuple__45 = PyTuple_Pack(8, __pyx_n_s_pad, __pyx_n_s_stride, __pyx_n_s_dtype, __pyx_n_s_mode, __pyx_n_s_dilation, __pyx_n_s_use_tensor_core, __pyx_n_s_groups, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);
  __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(7, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_convolution_descriptor, 304, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 304, __pyx_L1_error)

  /* "cupy/cudnn.pyx":338
 * 
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)
 */
  __pyx_tuple__47 = PyTuple_Pack(5, __pyx_n_s_ksize, __pyx_n_s_stride, __pyx_n_s_pad, __pyx_n_s_mode, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_pooling_descriptor, 338, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 338, __pyx_L1_error)

  /* "cupy/cudnn.pyx":363
 * 
 * 
 * def rnn_forward_inference_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w,
 */
  __pyx_tuple__49 = PyTuple_Pack(25, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_ys, __pyx_n_s_hy, __pyx_n_s_cy, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_x_data_desc, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_w_desc, __pyx_n_s_y_data_desc, __pyx_n_s_hy_desc, __pyx_n_s_cy_desc, __pyx_n_s_xs_descs, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(8, 0, 25, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_forward_inference_ex, 363, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 363, __pyx_L1_error)

  /* "cupy/cudnn.pyx":422
 * 
 * 
 * def rnn_forward_training_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_tuple__51 = PyTuple_Pack(26, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_ys, __pyx_n_s_hy, __pyx_n_s_cy, __pyx_n_s_x_data_desc, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_w_desc, __pyx_n_s_y_data_desc, __pyx_n_s_hy_desc, __pyx_n_s_cy_desc, __pyx_n_s_xs_descs, __pyx_n_s_workspace, __pyx_n_s_reserve_space); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(8, 0, 26, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_forward_training_ex, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 422, __pyx_L1_error)

  /* "cupy/cudnn.pyx":484
 * 
 * 
 * def rnn_backward_data_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_tuple__53 = PyTuple_Pack(33, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_ys, __pyx_n_s_reserve_space, __pyx_n_s_dhy, __pyx_n_s_dcy, __pyx_n_s_dys, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_dxs, __pyx_n_s_dhx, __pyx_n_s_dcx, __pyx_n_s_y_data_desc, __pyx_n_s_dy_data_desc, __pyx_n_s_dhy_desc, __pyx_n_s_dcy_desc, __pyx_n_s_w_desc, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_dx_data_desc, __pyx_n_s_dhx_desc, __pyx_n_s_dcx_desc, __pyx_n_s_xs_descs, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(13, 0, 33, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_backward_data_ex, 484, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 484, __pyx_L1_error)

  /* "cupy/cudnn.pyx":558
 * 
 * 
 * def rnn_backward_weights_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */
  __pyx_tuple__55 = PyTuple_Pack(21, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_xs, __pyx_n_s_hx, __pyx_n_s_ys, __pyx_n_s_w, __pyx_n_s_reserve_space, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_x_data_desc, __pyx_n_s_hx_desc, __pyx_n_s_y_data_desc, __pyx_n_s_xs_descs, __pyx_n_s_workspace, __pyx_n_s_dw, __pyx_n_s_dw_desc); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(9, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_backward_weights_ex, 558, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 558, __pyx_L1_error)

  /* "cupy/cudnn.pyx":606
 * 
 * 
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */
  __pyx_tuple__57 = PyTuple_Pack(4, __pyx_n_s_mode, __pyx_n_s_nan_prop_mode, __pyx_n_s_coef, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_activation_descriptor, 606, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 606, __pyx_L1_error)

  /* "cupy/cudnn.pyx":614
 * 
 * 
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_tuple__59 = PyTuple_Pack(13, __pyx_n_s_x, __pyx_n_s_mode, __pyx_n_s_coef, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_y, __pyx_n_s_handle, __pyx_n_s_desc, __pyx_n_s_act_desc); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_activation_forward, 614, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 614, __pyx_L1_error)

  /* "cupy/cudnn.pyx":645
 * 
 * 
 * def activation_backward(core.ndarray x, core.ndarray y, core.ndarray gy,             # <<<<<<<<<<<<<<
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 */
  __pyx_tuple__61 = PyTuple_Pack(15, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_gy, __pyx_n_s_mode, __pyx_n_s_coef, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_gx, __pyx_n_s_handle, __pyx_n_s_desc, __pyx_n_s_act_desc); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(5, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_activation_backward, 645, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 645, __pyx_L1_error)

  /* "cupy/cudnn.pyx":702
 * 
 * 
 * def softmax_forward(core.ndarray x, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_tuple__63 = PyTuple_Pack(13, __pyx_n_s_x, __pyx_n_s_axis, __pyx_n_s_algorithm, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_y, __pyx_n_s_handle, __pyx_n_s_desc, __pyx_n_s_cudnn_mode); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
  __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_softmax_forward, 702, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 702, __pyx_L1_error)

  /* "cupy/cudnn.pyx":729
 * 
 * 
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_tuple__65 = PyTuple_Pack(14, __pyx_n_s_y, __pyx_n_s_gy, __pyx_n_s_axis, __pyx_n_s_algorithm, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_gx, __pyx_n_s_handle, __pyx_n_s_desc, __pyx_n_s_cudnn_mode); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);
  __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(4, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_softmax_backward, 729, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) __PYX_ERR(0, 729, __pyx_L1_error)

  /* "cupy/cudnn.pyx":757
 * 
 * 
 * def create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 */
  __pyx_tuple__67 = PyTuple_Pack(6, __pyx_n_s_handle, __pyx_n_s_dropout, __pyx_n_s_states, __pyx_n_s_state_size_in_bytes, __pyx_n_s_seed, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);
  __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_dropout_descriptor, 757, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 757, __pyx_L1_error)

  /* "cupy/cudnn.pyx":766
 * 
 * 
 * def set_dropout_descriptor(desc, handle, dropout):             # <<<<<<<<<<<<<<
 *     # When the fourth argument is NULL, random state is not updated.
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout, 0, 0, 0)
 */
  __pyx_tuple__69 = PyTuple_Pack(3, __pyx_n_s_desc, __pyx_n_s_handle, __pyx_n_s_dropout); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);
  __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_set_dropout_descriptor, 766, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 766, __pyx_L1_error)

  /* "cupy/cudnn.pyx":771
 * 
 * 
 * def _create_ctc_loss_descriptor(data_type):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)
 */
  __pyx_tuple__71 = PyTuple_Pack(2, __pyx_n_s_data_type, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);
  __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_ctc_loss_descriptor, 771, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 771, __pyx_L1_error)

  /* "cupy/cudnn.pyx":778
 * 
 * 
 * def ctc_loss(core.ndarray probs, labels,             # <<<<<<<<<<<<<<
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]
 */
  __pyx_tuple__73 = PyTuple_Pack(18, __pyx_n_s_probs, __pyx_n_s_labels, __pyx_n_s_label_length, __pyx_n_s_input_length, __pyx_n_s_algo, __pyx_n_s_batch_size, __pyx_n_s_labels_ptr, __pyx_n_s_label_length_ptr, __pyx_n_s_input_length_ptr, __pyx_n_s_handle, __pyx_n_s_data_type, __pyx_n_s_ctc_desc, __pyx_n_s_gradients, __pyx_n_s_loss, __pyx_n_s_probs_desc, __pyx_n_s_gradients_desc, __pyx_n_s_work_size, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);
  __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(5, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_ctc_loss, 778, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 778, __pyx_L1_error)

  /* "cupy/cudnn.pyx":809
 * 
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,             # <<<<<<<<<<<<<<
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 */
  __pyx_tuple__75 = PyTuple_Pack(10, __pyx_n_s_hidden_size, __pyx_n_s_num_layers, __pyx_n_s_dropout_desc, __pyx_n_s_input_mode, __pyx_n_s_direction, __pyx_n_s_mode, __pyx_n_s_data_type, __pyx_n_s_algo, __pyx_n_s_desc, __pyx_n_s_handle_2); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);
  __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(8, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_rnn_descriptor, 809, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 809, __pyx_L1_error)

  /* "cupy/cudnn.pyx":827
 * 
 * 
 * def get_rnn_lin_layer_matrix_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */
  __pyx_tuple__78 = PyTuple_Pack(16, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_layer, __pyx_n_s_x_desc, __pyx_n_s_w_desc, __pyx_n_s_w, __pyx_n_s_lin_layer_id, __pyx_n_s_ptr, __pyx_n_s_mat_desc, __pyx_n_s_data_type, __pyx_n_s__77, __pyx_n_s_dim, __pyx_n_s_byte_size, __pyx_n_s_offset, __pyx_n_s_size, __pyx_n_s_mat); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);
  __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__78, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_get_rnn_lin_layer_matrix_params, 827, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "cupy/cudnn.pyx":845
 * 
 * 
 * def get_rnn_lin_layer_bias_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */
  __pyx_tuple__80 = PyTuple_Pack(16, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_layer, __pyx_n_s_x_desc, __pyx_n_s_w_desc, __pyx_n_s_w, __pyx_n_s_lin_layer_id, __pyx_n_s_ptr, __pyx_n_s_bias_desc, __pyx_n_s_data_type, __pyx_n_s__77, __pyx_n_s_dim, __pyx_n_s_byte_size, __pyx_n_s_offset, __pyx_n_s_size, __pyx_n_s_bias); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);
  __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(7, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_get_rnn_lin_layer_bias_params, 845, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 845, __pyx_L1_error)

  /* "cupy/cudnn.pyx":975
 * 
 * 
 * def rnn_forward_inference(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_tuple__82 = PyTuple_Pack(24, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_ys, __pyx_n_s_hy, __pyx_n_s_cy, __pyx_n_s_xs_descs, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_w_desc, __pyx_n_s_ys_descs, __pyx_n_s_hy_desc, __pyx_n_s_cy_desc, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__82);
  __Pyx_GIVEREF(__pyx_tuple__82);
  __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(8, 0, 24, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__82, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_forward_inference, 975, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 975, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1023
 * 
 * 
 * def rnn_forward_training(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_tuple__84 = PyTuple_Pack(25, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_ys, __pyx_n_s_hy, __pyx_n_s_cy, __pyx_n_s_xs_descs, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_w_desc, __pyx_n_s_ys_descs, __pyx_n_s_hy_desc, __pyx_n_s_cy_desc, __pyx_n_s_workspace, __pyx_n_s_reserve_space); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);
  __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(8, 0, 25, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_forward_training, 1023, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(0, 1023, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1074
 * 
 * 
 * def rnn_backward_data(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_tuple__86 = PyTuple_Pack(33, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_hx, __pyx_n_s_cx, __pyx_n_s_w, __pyx_n_s_xs, __pyx_n_s_ys, __pyx_n_s_reserve_space, __pyx_n_s_dhy, __pyx_n_s_dcy, __pyx_n_s_dys, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_dxs, __pyx_n_s_dhx, __pyx_n_s_dcx, __pyx_n_s_ys_descs, __pyx_n_s_dys_descs, __pyx_n_s_dhy_desc, __pyx_n_s_dcy_desc, __pyx_n_s_w_desc, __pyx_n_s_hx_desc, __pyx_n_s_cx_desc, __pyx_n_s_dxs_descs, __pyx_n_s_dhx_desc, __pyx_n_s_dcx_desc, __pyx_n_s_xs_descs, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);
  __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(13, 0, 33, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__86, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_backward_data, 1074, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) __PYX_ERR(0, 1074, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1137
 * 
 * 
 * def rnn_backward_weights(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */
  __pyx_tuple__88 = PyTuple_Pack(20, __pyx_n_s_states, __pyx_n_s_direction_mode, __pyx_n_s_rnn_mode, __pyx_n_s_xs, __pyx_n_s_hx, __pyx_n_s_ys, __pyx_n_s_w, __pyx_n_s_reserve_space, __pyx_n_s_lengths, __pyx_n_s_length, __pyx_n_s_n_layers, __pyx_n_s_n_units, __pyx_n_s_handle, __pyx_n_s_rnn_desc, __pyx_n_s_xs_descs, __pyx_n_s_hx_desc, __pyx_n_s_ys_descs, __pyx_n_s_workspace, __pyx_n_s_dw, __pyx_n_s_dw_desc); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__88);
  __Pyx_GIVEREF(__pyx_tuple__88);
  __pyx_codeobj__89 = (PyObject*)__Pyx_PyCode_New(9, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__88, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_rnn_backward_weights, 1137, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__89)) __PYX_ERR(0, 1137, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1177
 * 
 * 
 * def create_dropout_states(handle):             # <<<<<<<<<<<<<<
 *     warnings.warn('create_dropout_states is deprecated.'
 *                   'Please use DropoutStates class instead.',
 */
  __pyx_tuple__90 = PyTuple_Pack(2, __pyx_n_s_handle, __pyx_n_s_state_size); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__90);
  __Pyx_GIVEREF(__pyx_tuple__90);
  __pyx_codeobj__91 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__90, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_dropout_states, 1177, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__91)) __PYX_ERR(0, 1177, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1185
 * 
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 */
  __pyx_tuple__92 = PyTuple_Pack(6, __pyx_n_s_sampler_type, __pyx_n_s_dtype, __pyx_n_s_nb_dims, __pyx_n_s_dim_A, __pyx_n_s_desc, __pyx_n_s_data_type); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__92);
  __Pyx_GIVEREF(__pyx_tuple__92);
  __pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(4, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__92, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_spatial_transformer_descr, 1185, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 1185, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1195
 * 
 * 
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,             # <<<<<<<<<<<<<<
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,
 */
  __pyx_tuple__94 = PyTuple_Pack(7, __pyx_n_s_handle, __pyx_n_s_alpha, __pyx_n_s_biasDesc, __pyx_n_s_biasData, __pyx_n_s_beta, __pyx_n_s_srcDestDesc, __pyx_n_s_srcDestData); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__94);
  __Pyx_GIVEREF(__pyx_tuple__94);
  __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__94, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_add_tensor, 1195, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 1195, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1201
 * 
 * 
 * def create_op_tensor_descriptor(op_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)
 */
  __pyx_tuple__96 = PyTuple_Pack(4, __pyx_n_s_op_type, __pyx_n_s_dtype, __pyx_n_s_desc, __pyx_n_s_data_type); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__96);
  __Pyx_GIVEREF(__pyx_tuple__96);
  __pyx_codeobj__97 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_op_tensor_descriptor, 1201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__97)) __PYX_ERR(0, 1201, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1211
 * 
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)
 */
  __pyx_tuple__98 = PyTuple_Pack(5, __pyx_n_s_reduce_type, __pyx_n_s_dtype, __pyx_n_s_desc, __pyx_n_s_data_type, __pyx_n_s_indices); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);
  __pyx_codeobj__99 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__98, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_reduce_tensor_descriptor, 1211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__99)) __PYX_ERR(0, 1211, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1638
 * 
 * 
 * def _get_array_info(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr is None:
 *         return 'None'
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_n_s_arr); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);
  __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__100, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_get_array_info, 1638, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 1638, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1645
 * 
 * 
 * def convolution_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_tuple__102 = PyTuple_Pack(34, __pyx_n_s_x, __pyx_n_s_W, __pyx_n_s_b, __pyx_n_s_y, __pyx_n_s_pad, __pyx_n_s_stride, __pyx_n_s_dilation, __pyx_n_s_groups, __pyx_n_s_auto_tune, __pyx_n_s_tensor_core, __pyx_n_s_d_layout, __pyx_n_s_w_layout, __pyx_n_s_dev_id, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_use_tensor_core, __pyx_n_s_conv_param, __pyx_n_s_i, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_y_desc, __pyx_n_s_b_desc, __pyx_n_s_filter_desc, __pyx_n_s_conv_desc, __pyx_n_s_max_workspace_size, __pyx_n_s_b_shape, __pyx_n_s_perf, __pyx_n_s_workspace, __pyx_n_s_e, __pyx_n_s_infos); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(0, 1645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__102);
  __Pyx_GIVEREF(__pyx_tuple__102);
  __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(8, 4, 34, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__102, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_convolution_forward, 1645, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(0, 1645, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1752
 * 
 * 
 * def convolution_backward_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gy, core.ndarray gW,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_tuple__104 = PyTuple_Pack(32, __pyx_n_s_x, __pyx_n_s_gy, __pyx_n_s_gW, __pyx_n_s_pad, __pyx_n_s_stride, __pyx_n_s_dilation, __pyx_n_s_groups, __pyx_n_s_deterministic, __pyx_n_s_auto_tune, __pyx_n_s_tensor_core, __pyx_n_s_d_layout, __pyx_n_s_w_layout, __pyx_n_s_dev_id, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_use_tensor_core, __pyx_n_s_conv_param, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_gy_desc, __pyx_n_s_filter_desc, __pyx_n_s_conv_desc, __pyx_n_s_perf, __pyx_n_s_algo, __pyx_n_s_max_workspace_size, __pyx_n_s_workspace_size, __pyx_n_s_math_type, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__104)) __PYX_ERR(0, 1752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(7, 5, 32, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__104, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_convolution_backward_filter, 1752, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) __PYX_ERR(0, 1752, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1842
 * 
 * 
 * def convolution_backward_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_tuple__106 = PyTuple_Pack(36, __pyx_n_s_W, __pyx_n_s_x, __pyx_n_s_b, __pyx_n_s_y, __pyx_n_s_pad, __pyx_n_s_stride, __pyx_n_s_dilation, __pyx_n_s_groups, __pyx_n_s_deterministic, __pyx_n_s_auto_tune, __pyx_n_s_tensor_core, __pyx_n_s_d_layout, __pyx_n_s_w_layout, __pyx_n_s_dev_id, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_use_tensor_core, __pyx_n_s_conv_param, __pyx_n_s_i, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_y_desc, __pyx_n_s_b_desc, __pyx_n_s_filter_desc, __pyx_n_s_conv_desc, __pyx_n_s_perf, __pyx_n_s_algo, __pyx_n_s_max_workspace_size, __pyx_n_s_workspace_size, __pyx_n_s_b_shape, __pyx_n_s_math_type, __pyx_n_s_workspace); if (unlikely(!__pyx_tuple__106)) __PYX_ERR(0, 1842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);
  __pyx_codeobj__107 = (PyObject*)__Pyx_PyCode_New(8, 5, 36, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__106, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_convolution_backward_data, 1842, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__107)) __PYX_ERR(0, 1842, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1955
 * 
 * 
 * def pooling_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */
  __pyx_tuple__108 = PyTuple_Pack(16, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_ksize, __pyx_n_s_stride, __pyx_n_s_pad, __pyx_n_s_mode, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_y_desc, __pyx_n_s_pool_desc); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 1955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__108);
  __Pyx_GIVEREF(__pyx_tuple__108);
  __pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(6, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__108, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_pooling_forward, 1955, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(0, 1955, __pyx_L1_error)

  /* "cupy/cudnn.pyx":1988
 * 
 * 
 * def pooling_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y, core.ndarray gy,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */
  __pyx_tuple__110 = PyTuple_Pack(18, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_gy, __pyx_n_s_ksize, __pyx_n_s_stride, __pyx_n_s_pad, __pyx_n_s_mode, __pyx_n_s_float_zero, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_gx, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_y_desc, __pyx_n_s_pool_desc); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 1988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__110);
  __Pyx_GIVEREF(__pyx_tuple__110);
  __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(7, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_pooling_backward, 1988, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 1988, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2056
 * 
 * 
 * def batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */
  __pyx_tuple__112 = PyTuple_Pack(17, __pyx_n_s_x, __pyx_n_s_gamma, __pyx_n_s_beta, __pyx_n_s_running_mean, __pyx_n_s_running_var, __pyx_n_s_mean, __pyx_n_s_inv_std, __pyx_n_s_eps, __pyx_n_s_decay, __pyx_n_s_is_for_conv2d, __pyx_n_s_cudnn_mode, __pyx_n_s_debug, __pyx_n_s_d_layout, __pyx_n_s_reserve_space, __pyx_n_s_y, __pyx_n_s_save_mean, __pyx_n_s_save_inv_std); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 2056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__112);
  __Pyx_GIVEREF(__pyx_tuple__112);
  __pyx_codeobj__113 = (PyObject*)__Pyx_PyCode_New(13, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__112, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_batch_normalization_forward_trai, 2056, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__113)) __PYX_ERR(0, 2056, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2085
 * 
 * 
 * def batch_normalization_forward_training_ex(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */
  __pyx_tuple__114 = PyTuple_Pack(17, __pyx_n_s_x, __pyx_n_s_gamma, __pyx_n_s_beta, __pyx_n_s_running_mean, __pyx_n_s_running_var, __pyx_n_s_mean, __pyx_n_s_inv_std, __pyx_n_s_eps, __pyx_n_s_decay, __pyx_n_s_is_for_conv2d, __pyx_n_s_cudnn_mode, __pyx_n_s_debug, __pyx_n_s_d_layout, __pyx_n_s_reserve_space, __pyx_n_s_y, __pyx_n_s_save_mean, __pyx_n_s_save_inv_std); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__114);
  __Pyx_GIVEREF(__pyx_tuple__114);
  __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(13, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__114, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_batch_normalization_forward_trai_2, 2085, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 2085, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2262
 * 
 * 
 * def batch_normalization_forward_inference(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray mean, core.ndarray var,
 */
  __pyx_tuple__116 = PyTuple_Pack(20, __pyx_n_s_x, __pyx_n_s_gamma, __pyx_n_s_beta, __pyx_n_s_mean, __pyx_n_s_var, __pyx_n_s_eps, __pyx_n_s_is_for_conv2d, __pyx_n_s_cudnn_mode, __pyx_n_s_d_layout, __pyx_n_s_dtype, __pyx_n_s_y, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_derivedBnDesc, __pyx_n_s_dtype_param); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 2262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__116);
  __Pyx_GIVEREF(__pyx_tuple__116);
  __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(9, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__116, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_batch_normalization_forward_infe, 2262, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) __PYX_ERR(0, 2262, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2307
 * 
 * 
 * def batch_normalization_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray gy,
 *         core.ndarray mean, core.ndarray inv_std,
 */
  __pyx_tuple__118 = PyTuple_Pack(30, __pyx_n_s_x, __pyx_n_s_gamma, __pyx_n_s_gy, __pyx_n_s_mean, __pyx_n_s_inv_std, __pyx_n_s_eps, __pyx_n_s_is_for_conv2d, __pyx_n_s_cudnn_mode, __pyx_n_s_debug, __pyx_n_s_d_layout, __pyx_n_s_reserve_space, __pyx_n_s_ggamma, __pyx_n_s_gbeta, __pyx_n_s_need_cast, __pyx_n_s_workspace, __pyx_n_s_dtype, __pyx_n_s_gx, __pyx_n_s_float_one, __pyx_n_s_double_zero, __pyx_n_s_double_one, __pyx_n_s_zero, __pyx_n_s_one, __pyx_n_s_handle, __pyx_n_s_x_desc, __pyx_n_s_derivedBnDesc, __pyx_n_s_dtype_param, __pyx_n_s_bn_ops, __pyx_n_s_workspace_size, __pyx_n_s_query_mode, __pyx_n_s_rstatus); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__118);
  __Pyx_GIVEREF(__pyx_tuple__118);
  __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(10, 1, 30, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_batch_normalization_backward, 2307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(0, 2307, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2424
 * 
 * 
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */
  __pyx_tuple__120 = PyTuple_Pack(4, __pyx_n_s_mode, __pyx_n_s_relu_nan_opt, __pyx_n_s_coef, __pyx_n_s_desc); if (unlikely(!__pyx_tuple__120)) __PYX_ERR(0, 2424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__120);
  __Pyx_GIVEREF(__pyx_tuple__120);
  __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__120, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_activation_descriptor, 2424, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) __PYX_ERR(0, 2424, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2432
 * 
 * 
 * def create_fused_ops_plan(ops):             # <<<<<<<<<<<<<<
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)
 */
  __pyx_tuple__122 = PyTuple_Pack(2, __pyx_n_s_ops, __pyx_n_s_plan); if (unlikely(!__pyx_tuple__122)) __PYX_ERR(0, 2432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__122);
  __Pyx_GIVEREF(__pyx_tuple__122);
  __pyx_codeobj__123 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__122, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_fused_ops_plan, 2432, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__123)) __PYX_ERR(0, 2432, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2438
 * 
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 */
  __pyx_tuple__124 = PyTuple_Pack(5, __pyx_n_s_ops, __pyx_n_s_list_attr_param, __pyx_n_s_const_pack, __pyx_n_s_attr, __pyx_n_s_param); if (unlikely(!__pyx_tuple__124)) __PYX_ERR(0, 2438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__124);
  __Pyx_GIVEREF(__pyx_tuple__124);
  __pyx_codeobj__125 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__124, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_fused_ops_const_param_pac, 2438, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__125)) __PYX_ERR(0, 2438, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2446
 * 
 * 
 * def make_fused_ops_plan(plan, const_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)
 */
  __pyx_tuple__126 = PyTuple_Pack(3, __pyx_n_s_plan, __pyx_n_s_const_pack, __pyx_n_s_handle); if (unlikely(!__pyx_tuple__126)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);
  __pyx_codeobj__127 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_make_fused_ops_plan, 2446, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__127)) __PYX_ERR(0, 2446, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2451
 * 
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 */
  __pyx_tuple__128 = PyTuple_Pack(5, __pyx_n_s_ops, __pyx_n_s_list_attr_param, __pyx_n_s_var_pack, __pyx_n_s_attr, __pyx_n_s_param); if (unlikely(!__pyx_tuple__128)) __PYX_ERR(0, 2451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);
  __pyx_codeobj__129 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__128, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_create_fused_ops_variant_param_p, 2451, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__129)) __PYX_ERR(0, 2451, __pyx_L1_error)

  /* "cupy/cudnn.pyx":2459
 * 
 * 
 * def fused_ops_execute(plan, var_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)
 */
  __pyx_tuple__130 = PyTuple_Pack(3, __pyx_n_s_plan, __pyx_n_s_var_pack, __pyx_n_s_handle); if (unlikely(!__pyx_tuple__130)) __PYX_ERR(0, 2459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);
  __pyx_codeobj__131 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__130, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cudnn_pyx, __pyx_n_s_fused_ops_execute, 2459, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__131)) __PYX_ERR(0, 2459, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_Descriptor(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__132 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__132)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Descriptor, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__134 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__134)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);
  __pyx_codeobj__135 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__134, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle__DescriptorArray, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__135)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__136 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);
  __pyx_codeobj__137 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_DropoutStates, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__137)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_ = PyFloat_FromDouble(0.); if (unlikely(!__pyx_float_0_)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_70 = PyInt_FromLong(70); if (unlikely(!__pyx_int_70)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_44931744 = PyInt_FromLong(44931744L); if (unlikely(!__pyx_int_44931744)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_266093133 = PyInt_FromLong(266093133L); if (unlikely(!__pyx_int_266093133)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_267320206 = PyInt_FromLong(267320206L); if (unlikely(!__pyx_int_267320206)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __pyx_v_4cupy_5cudnn__thread_local = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__algorithm_fwd_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_4cupy_5cudnn_Descriptor) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4cupy_5cudnn_Descriptor.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_5cudnn_Descriptor.tp_dictoffset && __pyx_type_4cupy_5cudnn_Descriptor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_5cudnn_Descriptor.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Descriptor, (PyObject *)&__pyx_type_4cupy_5cudnn_Descriptor) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_5cudnn_Descriptor) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
  __pyx_ptype_4cupy_5cudnn_Descriptor = &__pyx_type_4cupy_5cudnn_Descriptor;
  if (PyType_Ready(&__pyx_type_4cupy_5cudnn__DescriptorArray) < 0) __PYX_ERR(0, 863, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4cupy_5cudnn__DescriptorArray.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_5cudnn__DescriptorArray.tp_dictoffset && __pyx_type_4cupy_5cudnn__DescriptorArray.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_5cudnn__DescriptorArray.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_DescriptorArray, (PyObject *)&__pyx_type_4cupy_5cudnn__DescriptorArray) < 0) __PYX_ERR(0, 863, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_5cudnn__DescriptorArray) < 0) __PYX_ERR(0, 863, __pyx_L1_error)
  __pyx_ptype_4cupy_5cudnn__DescriptorArray = &__pyx_type_4cupy_5cudnn__DescriptorArray;
  if (PyType_Ready(&__pyx_type_4cupy_5cudnn_DropoutStates) < 0) __PYX_ERR(0, 1234, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4cupy_5cudnn_DropoutStates.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_5cudnn_DropoutStates.tp_dictoffset && __pyx_type_4cupy_5cudnn_DropoutStates.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_5cudnn_DropoutStates.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_DropoutStates, (PyObject *)&__pyx_type_4cupy_5cudnn_DropoutStates) < 0) __PYX_ERR(0, 1234, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_5cudnn_DropoutStates) < 0) __PYX_ERR(0, 1234, __pyx_L1_error)
  __pyx_ptype_4cupy_5cudnn_DropoutStates = &__pyx_type_4cupy_5cudnn_DropoutStates;
  if (PyType_Ready(&__pyx_type_4cupy_5cudnn__Algorithm) < 0) __PYX_ERR(0, 1311, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4cupy_5cudnn__Algorithm.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4cupy_5cudnn__Algorithm.tp_dictoffset && __pyx_type_4cupy_5cudnn__Algorithm.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4cupy_5cudnn__Algorithm.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Algorithm, (PyObject *)&__pyx_type_4cupy_5cudnn__Algorithm) < 0) __PYX_ERR(0, 1311, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4cupy_5cudnn__Algorithm) < 0) __PYX_ERR(0, 1311, __pyx_L1_error)
  __pyx_ptype_4cupy_5cudnn__Algorithm = &__pyx_type_4cupy_5cudnn__Algorithm;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.device"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4cuda_6device_Handle = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.device", "Handle", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Handle), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6device_Handle) __PYX_ERR(2, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6device_Device = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.device", "Device", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Device), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6device_Device) __PYX_ERR(2, 12, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6device_Device = (struct __pyx_vtabstruct_4cupy_4cuda_6device_Device*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6device_Device->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6device_Device)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.memory"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4cuda_6memory_BaseMemory = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.memory", "BaseMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6memory_BaseMemory) __PYX_ERR(3, 11, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.memory", "MemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer) __PYX_ERR(3, 20, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPointer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(3, 20, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPool = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.memory", "MemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6memory_MemoryPool) __PYX_ERR(3, 49, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(3, 49, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.memory", "CFunctionAllocatorMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory) __PYX_ERR(3, 66, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.memory", "CFunctionAllocator", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator) __PYX_ERR(3, 73, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator)) __PYX_ERR(3, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.function"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4cuda_8function_CPointer = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.function", "CPointer", sizeof(struct __pyx_obj_4cupy_4cuda_8function_CPointer), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_8function_CPointer) __PYX_ERR(4, 4, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Function = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.function", "Function", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Function), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_8function_Function) __PYX_ERR(4, 8, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Function = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Function*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Function->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Function)) __PYX_ERR(4, 8, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_Module = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.function", "Module", sizeof(struct __pyx_obj_4cupy_4cuda_8function_Module), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_8function_Module) __PYX_ERR(4, 18, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_Module = (struct __pyx_vtabstruct_4cupy_4cuda_8function_Module*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_Module->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_Module)) __PYX_ERR(4, 18, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_8function_LinkState = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.function", "LinkState", sizeof(struct __pyx_obj_4cupy_4cuda_8function_LinkState), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_8function_LinkState) __PYX_ERR(4, 30, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_8function_LinkState = (struct __pyx_vtabstruct_4cupy_4cuda_8function_LinkState*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_8function_LinkState->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_8function_LinkState)) __PYX_ERR(4, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.core.core"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4core_4core_ndarray = __Pyx_ImportType(__pyx_t_1, "cupy.core.core", "ndarray", sizeof(struct __pyx_obj_4cupy_4core_4core_ndarray), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4core_4core_ndarray) __PYX_ERR(5, 7, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_4core_ndarray = (struct __pyx_vtabstruct_4cupy_4core_4core_ndarray*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_4core_ndarray->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_4core_ndarray)) __PYX_ERR(5, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4core_4core_Indexer = __Pyx_ImportType(__pyx_t_1, "cupy.core.core", "Indexer", sizeof(struct __pyx_obj_4cupy_4core_4core_Indexer), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4core_4core_Indexer) __PYX_ERR(5, 90, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4core_4core_Indexer = (struct __pyx_vtabstruct_4cupy_4core_4core_Indexer*)__Pyx_GetVtable(__pyx_ptype_4cupy_4core_4core_Indexer->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4core_4core_Indexer)) __PYX_ERR(5, 90, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.core._routines_manipulation"); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast = __Pyx_ImportType(__pyx_t_1, "cupy.core._routines_manipulation", "broadcast", sizeof(struct __pyx_obj_4cupy_4core_22_routines_manipulation_broadcast), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4core_22_routines_manipulation_broadcast) __PYX_ERR(6, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.cudnn"); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf = __Pyx_ImportType(__pyx_t_1, "cupy.cuda.cudnn", "CuDNNAlgoPerf", sizeof(struct __pyx_obj_4cupy_4cuda_5cudnn_CuDNNAlgoPerf), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4cupy_4cuda_5cudnn_CuDNNAlgoPerf) __PYX_ERR(7, 250, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.device"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "get_device_id", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_device_id, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_compute_capability", (void (**)(void))&__pyx_f_4cupy_4cuda_6device_get_compute_capability, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.memory"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "alloc", (void (**)(void))&__pyx_f_4cupy_4cuda_6memory_alloc, "struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.core.core"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "_internal_ascontiguousarray", (void (**)(void))&__pyx_f_4cupy_4core_4core__internal_ascontiguousarray, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.core._routines_manipulation"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "_reshape", (void (**)(void))&__pyx_f_4cupy_4core_22_routines_manipulation__reshape, "struct __pyx_obj_4cupy_4core_4core_ndarray *(struct __pyx_obj_4cupy_4core_4core_ndarray *, std::vector<Py_ssize_t>  const &, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.cuda.cudnn"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "getVersion", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getVersion, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "queryRuntimeError", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_queryRuntimeError, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "create", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_create, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroy", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroy, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createTensorDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setTensor4dDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setTensor4dDescriptor, "PyObject *(size_t, int, int, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getTensor4dDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getTensor4dDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setTensorNdDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setTensorNdDescriptor, "PyObject *(size_t, int, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroyTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroyTensorDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "addTensor_v3", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_addTensor_v3, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createOpTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createOpTensorDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setOpTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setOpTensorDescriptor, "PyObject *(size_t, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createReduceTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createReduceTensorDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setReduceTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setReduceTensorDescriptor, "PyObject *(size_t, int, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createFilterDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createFilterDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setFilter4dDescriptor_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setFilter4dDescriptor_v4, "PyObject *(size_t, int, int, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setFilterNdDescriptor_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setFilterNdDescriptor_v4, "PyObject *(size_t, int, int, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getFilterNdDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getFilterNdDescriptor, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroyFilterDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroyFilterDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createConvolutionDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createConvolutionDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setConvolutionMathType", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setConvolutionMathType, "PyObject *(size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setConvolutionGroupCount", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setConvolutionGroupCount, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setConvolution2dDescriptor_v5", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setConvolution2dDescriptor_v5, "PyObject *(size_t, int, int, int, int, int, int, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setConvolutionNdDescriptor_v3", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setConvolutionNdDescriptor_v3, "PyObject *(size_t, int, size_t, size_t, size_t, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroyConvolutionDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroyConvolutionDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionForwardAlgorithmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionForwardAlgorithmEx_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionForwardAlgorithmEx_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionForwardAlgorithm_v6", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v6, "int (size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionForwardAlgorithm_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardAlgorithm_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionForwardWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionForwardWorkspaceSize, "Py_ssize_t (size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "convolutionForward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_convolutionForward, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionBackwardFilterAlgorithmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionBackwardFilterAlgorithmEx_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardFilterAlgorithmEx_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardFilterAlgorithm_v6", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v6, "int (size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardFilterAlgorithm_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterAlgorithm_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardFilterWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardFilterWorkspaceSize, "Py_ssize_t (size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "convolutionBackwardFilter_v3", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardFilter_v3, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionBackwardDataAlgorithmEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "findConvolutionBackwardDataAlgorithmEx_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_findConvolutionBackwardDataAlgorithmEx_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardDataAlgorithm_v6", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v6, "int (size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardDataAlgorithm_v7", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataAlgorithm_v7, "PyObject *(size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getConvolutionBackwardDataWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getConvolutionBackwardDataWorkspaceSize, "Py_ssize_t (size_t, size_t, size_t, size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "convolutionBackwardData_v3", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_convolutionBackwardData_v3, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createPoolingDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createPoolingDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setPooling2dDescriptor_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setPooling2dDescriptor_v4, "PyObject *(size_t, int, int, int, int, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setPoolingNdDescriptor_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setPoolingNdDescriptor_v4, "PyObject *(size_t, int, int, int, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroyPoolingDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroyPoolingDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "poolingForward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_poolingForward, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "poolingBackward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_poolingBackward, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "deriveBNTensorDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_deriveBNTensorDescriptor, "PyObject *(size_t, size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "batchNormalizationForwardTraining", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTraining, "PyObject *(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, double, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "batchNormalizationForwardInference", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardInference, "PyObject *(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "batchNormalizationBackward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackward, "PyObject *(size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "batchNormalizationForwardTrainingEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationForwardTrainingEx, "PyObject *(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, double, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getBatchNormalizationForwardTrainingExWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationForwardTrainingExWorkspaceSize, "size_t (size_t, int, int, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "batchNormalizationBackwardEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_batchNormalizationBackwardEx, "PyObject *(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, double, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getBatchNormalizationBackwardExWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationBackwardExWorkspaceSize, "size_t (size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getBatchNormalizationTrainingExReserveSpaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getBatchNormalizationTrainingExReserveSpaceSize, "size_t (size_t, int, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createActivationDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createActivationDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setActivationDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setActivationDescriptor, "PyObject *(size_t, int, int, double, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroyActivationDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_destroyActivationDescriptor, "PyObject *(size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "softmaxForward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_softmaxForward, "PyObject *(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "softmaxBackward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_softmaxBackward, "PyObject *(size_t, int, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "activationForward_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_activationForward_v4, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "activationBackward_v4", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_activationBackward_v4, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createDropoutDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createDropoutDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "dropoutGetStatesSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_dropoutGetStatesSize, "Py_ssize_t (size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setDropoutDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setDropoutDescriptor, "PyObject *(size_t, size_t, float, size_t, size_t, unsigned PY_LONG_LONG, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getDropoutReserveSpaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getDropoutReserveSpaceSize, "size_t (size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "dropoutForward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_dropoutForward, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "dropoutBackward", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_dropoutBackward, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createCTCLossDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createCTCLossDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setCTCLossDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setCTCLossDescriptor, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getCTCLossWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getCTCLossWorkspaceSize, "size_t (size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "CTCLoss", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_CTCLoss, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createRNNDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createRNNDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setRNNDescriptor_v5", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v5, "PyObject *(size_t, int, int, size_t, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setRNNDescriptor_v6", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setRNNDescriptor_v6, "PyObject *(size_t, size_t, int, int, size_t, int, int, int, int, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setRNNPaddingMode", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setRNNPaddingMode, "PyObject *(size_t, int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createRNNDataDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createRNNDataDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setRNNDataDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setRNNDataDescriptor, "PyObject *(size_t, int, size_t, int, int, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getRNNWorkspaceSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getRNNWorkspaceSize, "PyObject *(size_t, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getRNNTrainingReserveSize", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getRNNTrainingReserveSize, "PyObject *(size_t, size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getRNNLinLayerMatrixParams", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerMatrixParams, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getRNNLinLayerBiasParams", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getRNNLinLayerBiasParams, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, int, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNForwardInference", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNForwardInference, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNForwardTraining", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNForwardTraining, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNBackwardData", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardData, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNBackwardWeights", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeights, "PyObject *(size_t, size_t, int, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNForwardInferenceEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNForwardInferenceEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNForwardTrainingEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNForwardTrainingEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNBackwardDataEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardDataEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "RNNBackwardWeightsEx", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_RNNBackwardWeightsEx, "PyObject *(size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createSpatialTransformerDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createSpatialTransformerDescriptor, "size_t (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setSpatialTransformerDescriptor", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setSpatialTransformerDescriptor, "PyObject *(size_t, size_t, int, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createFusedOpsConstParamPack", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsConstParamPack, "PyObject *(int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setFusedOpsConstParamPackAttribute", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setFusedOpsConstParamPackAttribute, "PyObject *(size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getFusedOpsConstParamPackAttribute", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getFusedOpsConstParamPackAttribute, "PyObject *(size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createFusedOpsVariantParamPack", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsVariantParamPack, "PyObject *(int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "setFusedOpsVariantParamPackAttribute", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_setFusedOpsVariantParamPackAttribute, "PyObject *(size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "getFusedOpsVariantParamPackAttribute", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_getFusedOpsVariantParamPackAttribute, "PyObject *(size_t, int, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "createFusedOpsPlan", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_createFusedOpsPlan, "PyObject *(int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "makeFusedOpsPlan", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_makeFusedOpsPlan, "PyObject *(size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "fusedOpsExecute", (void (**)(void))&__pyx_f_4cupy_4cuda_5cudnn_fusedOpsExecute, "PyObject *(size_t, size_t, size_t, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("cupy.core.internal"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "prod_sequence", (void (**)(void))&__pyx_f_4cupy_4core_8internal_prod_sequence, "Py_ssize_t (PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initcudnn(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initcudnn(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_cudnn(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_cudnn(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_cudnn(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'cudnn' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cudnn(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("cudnn", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_cupy__cudnn) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "cupy.cudnn")) {
      if (unlikely(PyDict_SetItemString(modules, "cupy.cudnn", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "cupy/cudnn.pyx":4
 * from libc.stdint cimport int64_t
 * 
 * import atexit             # <<<<<<<<<<<<<<
 * import threading
 * import warnings
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_atexit, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_atexit, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":5
 * 
 * import atexit
 * import threading             # <<<<<<<<<<<<<<
 * import warnings
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":6
 * import atexit
 * import threading
 * import warnings             # <<<<<<<<<<<<<<
 * 
 * import numpy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":8
 * import warnings
 * 
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * from cupy.core cimport _routines_manipulation as _manipulation
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":17
 * from cupy.cuda cimport memory
 * 
 * from cupy.core._ufuncs import elementwise_copy             # <<<<<<<<<<<<<<
 * from cupy.cuda import cudnn as py_cudnn
 * from cupy import util
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_elementwise_copy);
  __Pyx_GIVEREF(__pyx_n_s_elementwise_copy);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_elementwise_copy);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_core__ufuncs, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_elementwise_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_elementwise_copy, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":18
 * 
 * from cupy.core._ufuncs import elementwise_copy
 * from cupy.cuda import cudnn as py_cudnn             # <<<<<<<<<<<<<<
 * from cupy import util
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_cudnn);
  __Pyx_GIVEREF(__pyx_n_s_cudnn);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_cudnn);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_cuda, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_cudnn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_cudnn, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cudnn.pyx":19
 * from cupy.core._ufuncs import elementwise_copy
 * from cupy.cuda import cudnn as py_cudnn
 * from cupy import util             # <<<<<<<<<<<<<<
 * 
 * cdef int _cudnn_version = cudnn.getVersion()
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_util);
  __Pyx_GIVEREF(__pyx_n_s_util);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_util);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_util); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_util, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":21
 * from cupy import util
 * 
 * cdef int _cudnn_version = cudnn.getVersion()             # <<<<<<<<<<<<<<
 * cdef _thread_local = threading.local()
 * 
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cudnn_getVersion(0); if (unlikely(__pyx_t_3 == ((size_t)0) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L1_error)
  __pyx_v_4cupy_5cudnn__cudnn_version = __pyx_t_3;

  /* "cupy/cudnn.pyx":22
 * 
 * cdef int _cudnn_version = cudnn.getVersion()
 * cdef _thread_local = threading.local()             # <<<<<<<<<<<<<<
 * 
 * cdef vector.vector[size_t] _handles
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_threading); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_local); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__thread_local);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__thread_local, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":40
 * 
 * 
 * @atexit.register             # <<<<<<<<<<<<<<
 * def reset_handles():
 *     for handle in _handles:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_atexit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_register); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cudnn.pyx":41
 * 
 * @atexit.register
 * def reset_handles():             # <<<<<<<<<<<<<<
 *     for handle in _handles:
 *         if handle:
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_3reset_handles, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cudnn.pyx":40
 * 
 * 
 * @atexit.register             # <<<<<<<<<<<<<<
 * def reset_handles():
 *     for handle in _handles:
 */
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __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;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_reset_handles, __pyx_t_4) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":54
 * 
 * 
 * cdef size_t _max_workspace_size = 8 * 1024 * 1024             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_4cupy_5cudnn__max_workspace_size = 0x800000;

  /* "cupy/cudnn.pyx":146
 * 
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     if not arr._c_contiguous:
 *         raise ValueError('cupy.cudnn supports c-contiguous arrays only')
 */
  __pyx_k_ = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":145
 * 
 * 
 * cpdef _create_tensor_descriptor(size_t desc, core.ndarray arr,             # <<<<<<<<<<<<<<
 *                                 int format=cudnn.CUDNN_TENSOR_NCHW):
 *     if not arr._c_contiguous:
 */
  __pyx_k_ = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":176
 * 
 * cpdef _create_filter_descriptor(
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     cdef vector.vector[int] c_shape
 *     cdef Py_ssize_t s, ndim = arr._shape.size()
 */
  __pyx_k__3 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":175
 * 
 * 
 * cpdef _create_filter_descriptor(             # <<<<<<<<<<<<<<
 *         size_t desc, core.ndarray arr, int format=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef vector.vector[int] c_shape
 */
  __pyx_k__3 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":259
 * 
 * 
 * def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createTensorDescriptor(),
 *                       py_cudnn.destroyTensorDescriptor)
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k__7 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_27create_tensor_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_tensor_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":266
 * 
 * 
 * def create_uninitialized_tensor_descriptor():             # <<<<<<<<<<<<<<
 *     """Create uninitialized tensor descriptor.
 * 
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_29create_uninitialized_tensor_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_uninitialized_tensor_desc, __pyx_t_4) < 0) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":276
 * 
 * 
 * def create_tensor_nd_descriptor(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     cdef dict cache
 *     if arr.size == 0:
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_31create_tensor_nd_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_tensor_nd_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":297
 * 
 * 
 * def create_filter_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createFilterDescriptor(),
 *                       py_cudnn.destroyFilterDescriptor)
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k__9 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_33create_filter_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_filter_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":305
 * 
 * def create_convolution_descriptor(pad, stride, dtype,
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,             # <<<<<<<<<<<<<<
 *                                   dilation=None,
 *                                   use_tensor_core=False,
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_CROSS_CORRELATION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k__10 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":304
 * 
 * 
 * def create_convolution_descriptor(pad, stride, dtype,             # <<<<<<<<<<<<<<
 *                                   mode=cudnn.CUDNN_CROSS_CORRELATION,
 *                                   dilation=None,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_35create_convolution_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_convolution_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":338
 * 
 * 
 * def create_pooling_descriptor(ksize, stride, pad, int mode):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createPoolingDescriptor(),
 *                       py_cudnn.destroyPoolingDescriptor)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_37create_pooling_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_pooling_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":363
 * 
 * 
 * def rnn_forward_inference_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_39rnn_forward_inference_ex, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_forward_inference_ex, __pyx_t_4) < 0) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":422
 * 
 * 
 * def rnn_forward_training_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_41rnn_forward_training_ex, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_forward_training_ex, __pyx_t_4) < 0) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":484
 * 
 * 
 * def rnn_backward_data_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_43rnn_backward_data_ex, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_backward_data_ex, __pyx_t_4) < 0) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":558
 * 
 * 
 * def rnn_backward_weights_ex(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_45rnn_backward_weights_ex, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_backward_weights_ex, __pyx_t_4) < 0) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":606
 * 
 * 
 * def create_activation_descriptor(mode, nan_prop_mode=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_PROPAGATE_NAN); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k__13 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_47create_activation_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_activation_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 606, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":614
 * 
 * 
 * def activation_forward(core.ndarray x, int mode, double coef=0.0):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_49activation_forward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_activation_forward, __pyx_t_4) < 0) __PYX_ERR(0, 614, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":645
 * 
 * 
 * def activation_backward(core.ndarray x, core.ndarray y, core.ndarray gy,             # <<<<<<<<<<<<<<
 *                         int mode, float coef=0.0):
 *     cdef float float_zero = 0, float_one = 1
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_51activation_backward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_activation_backward, __pyx_t_4) < 0) __PYX_ERR(0, 645, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":702
 * 
 * 
 * def softmax_forward(core.ndarray x, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_53softmax_forward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_softmax_forward, __pyx_t_4) < 0) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":729
 * 
 * 
 * def softmax_backward(core.ndarray y, core.ndarray gy, int axis, int algorithm):             # <<<<<<<<<<<<<<
 *     cdef float float_zero = 0, float_one = 1
 *     cdef double double_zero = 0, double_one = 1
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_55softmax_backward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_softmax_backward, __pyx_t_4) < 0) __PYX_ERR(0, 729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":757
 * 
 * 
 * def create_dropout_descriptor(             # <<<<<<<<<<<<<<
 *         handle, dropout, states, state_size_in_bytes, seed):
 *     desc = Descriptor(cudnn.createDropoutDescriptor(),
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_57create_dropout_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_dropout_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":766
 * 
 * 
 * def set_dropout_descriptor(desc, handle, dropout):             # <<<<<<<<<<<<<<
 *     # When the fourth argument is NULL, random state is not updated.
 *     cudnn.setDropoutDescriptor(desc.value, handle, dropout, 0, 0, 0)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_59set_dropout_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_dropout_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":771
 * 
 * 
 * def _create_ctc_loss_descriptor(data_type):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createCTCLossDescriptor(),
 *                       py_cudnn.destroyCTCLossDescriptor)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_61_create_ctc_loss_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_ctc_loss_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":778
 * 
 * 
 * def ctc_loss(core.ndarray probs, labels,             # <<<<<<<<<<<<<<
 *              label_length, input_length, int algo):
 *     batch_size = probs.shape[1]
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_63ctc_loss, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ctc_loss, __pyx_t_4) < 0) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":809
 * 
 * 
 * def create_rnn_descriptor(hidden_size, num_layers, dropout_desc,             # <<<<<<<<<<<<<<
 *                           input_mode, direction, mode, data_type, algo=None):
 *     desc = Descriptor(cudnn.createRNNDescriptor(),
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_65create_rnn_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_rnn_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":827
 * 
 * 
 * def get_rnn_lin_layer_matrix_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_67get_rnn_lin_layer_matrix_params, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_rnn_lin_layer_matrix_params, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":845
 * 
 * 
 * def get_rnn_lin_layer_bias_params(             # <<<<<<<<<<<<<<
 *         handle, rnn_desc, layer, x_desc, w_desc, core.ndarray w, lin_layer_id):
 *     cdef size_t ptr = 0
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_69get_rnn_lin_layer_bias_params, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_rnn_lin_layer_bias_params, __pyx_t_4) < 0) __PYX_ERR(0, 845, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":975
 * 
 * 
 * def rnn_forward_inference(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_71rnn_forward_inference, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_forward_inference, __pyx_t_4) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1023
 * 
 * 
 * def rnn_forward_training(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_73rnn_forward_training, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_forward_training, __pyx_t_4) < 0) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1074
 * 
 * 
 * def rnn_backward_data(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray hx, core.ndarray cx, core.ndarray w, core.ndarray xs,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_75rnn_backward_data, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_backward_data, __pyx_t_4) < 0) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1137
 * 
 * 
 * def rnn_backward_weights(             # <<<<<<<<<<<<<<
 *         DropoutStates states, int direction_mode, int rnn_mode,
 *         core.ndarray xs, core.ndarray hx, core.ndarray ys,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_77rnn_backward_weights, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rnn_backward_weights, __pyx_t_4) < 0) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1177
 * 
 * 
 * def create_dropout_states(handle):             # <<<<<<<<<<<<<<
 *     warnings.warn('create_dropout_states is deprecated.'
 *                   'Please use DropoutStates class instead.',
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_79create_dropout_states, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_dropout_states, __pyx_t_4) < 0) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1185
 * 
 * 
 * def create_spatial_transformer_descriptor(sampler_type, dtype, nb_dims, dim_A):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createSpatialTransformerDescriptor(),
 *                       py_cudnn.destroySpatialTransformerDescriptor)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_81create_spatial_transformer_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_spatial_transformer_descr, __pyx_t_4) < 0) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1195
 * 
 * 
 * def add_tensor(handle, alpha, biasDesc, biasData, beta, srcDestDesc,             # <<<<<<<<<<<<<<
 *                srcDestData):
 *     cudnn.addTensor_v3(handle, alpha, biasDesc,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_83add_tensor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_tensor, __pyx_t_4) < 0) __PYX_ERR(0, 1195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1201
 * 
 * 
 * def create_op_tensor_descriptor(op_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createOpTensorDescriptor(),
 *                       py_cudnn.destroyOpTensorDescriptor)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_85create_op_tensor_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_op_tensor_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1211
 * 
 * 
 * def create_reduce_tensor_descriptor(reduce_type, dtype):             # <<<<<<<<<<<<<<
 *     desc = Descriptor(cudnn.createReduceTensorDescriptor(),
 *                       py_cudnn.destroyReduceTensorDescriptor)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_87create_reduce_tensor_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_reduce_tensor_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1323
 * 
 * 
 * cdef dict _get_algorithm_fwd_cache = {}             # <<<<<<<<<<<<<<
 * cdef dict _get_algorithm_bwd_filter_cache = {}
 * cdef dict _get_algorithm_bwd_data_cache = {}
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1323, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__get_algorithm_fwd_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1324
 * 
 * cdef dict _get_algorithm_fwd_cache = {}
 * cdef dict _get_algorithm_bwd_filter_cache = {}             # <<<<<<<<<<<<<<
 * cdef dict _get_algorithm_bwd_data_cache = {}
 * cdef dict _algorithm_fwd_cache = {}
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1324, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_filter_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1325
 * cdef dict _get_algorithm_fwd_cache = {}
 * cdef dict _get_algorithm_bwd_filter_cache = {}
 * cdef dict _get_algorithm_bwd_data_cache = {}             # <<<<<<<<<<<<<<
 * cdef dict _algorithm_fwd_cache = {}
 * cdef dict _algorithm_bwd_filter_cache = {}
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__get_algorithm_bwd_data_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1326
 * cdef dict _get_algorithm_bwd_filter_cache = {}
 * cdef dict _get_algorithm_bwd_data_cache = {}
 * cdef dict _algorithm_fwd_cache = {}             # <<<<<<<<<<<<<<
 * cdef dict _algorithm_bwd_filter_cache = {}
 * cdef dict _algorithm_bwd_data_cache = {}
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__algorithm_fwd_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1327
 * cdef dict _get_algorithm_bwd_data_cache = {}
 * cdef dict _algorithm_fwd_cache = {}
 * cdef dict _algorithm_bwd_filter_cache = {}             # <<<<<<<<<<<<<<
 * cdef dict _algorithm_bwd_data_cache = {}
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__algorithm_bwd_filter_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1328
 * cdef dict _algorithm_fwd_cache = {}
 * cdef dict _algorithm_bwd_filter_cache = {}
 * cdef dict _algorithm_bwd_data_cache = {}             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_XGOTREF(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache);
  __Pyx_DECREF_SET(__pyx_v_4cupy_5cudnn__algorithm_bwd_data_cache, ((PyObject*)__pyx_t_4));
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1638
 * 
 * 
 * def _get_array_info(core.ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr is None:
 *         return 'None'
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_111_get_array_info, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_array_info, __pyx_t_4) < 0) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1649
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 *         bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,             # <<<<<<<<<<<<<<
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id
 */
  __pyx_k__20 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1650
 *         bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == W.data.device.id
 */
  __pyx_k__21 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1645
 * 
 * 
 * def convolution_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray W, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_113convolution_forward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_convolution_forward, __pyx_t_4) < 0) __PYX_ERR(0, 1645, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1756
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 *         bint deterministic, bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,             # <<<<<<<<<<<<<<
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = x.data.device.id
 */
  __pyx_k__22 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1757
 *         bint deterministic, bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     cdef int dev_id = x.data.device.id
 *     assert dev_id == gy.data.device.id
 */
  __pyx_k__23 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1752
 * 
 * 
 * def convolution_backward_filter(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gy, core.ndarray gW,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_115convolution_backward_filter, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_convolution_backward_filter, __pyx_t_4) < 0) __PYX_ERR(0, 1752, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1846
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 *         bint deterministic, bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,             # <<<<<<<<<<<<<<
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):
 *     cdef int dev_id = W.data.device.id
 */
  __pyx_k__24 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1847
 *         bint deterministic, bint auto_tune, tensor_core,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,
 *         int w_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     cdef int dev_id = W.data.device.id
 *     assert dev_id == x.data.device.id
 */
  __pyx_k__25 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":1842
 * 
 * 
 * def convolution_backward_data(             # <<<<<<<<<<<<<<
 *         core.ndarray W, core.ndarray x, core.ndarray b, core.ndarray y,
 *         tuple pad, tuple stride, tuple dilation, int groups, *,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_117convolution_backward_data, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_convolution_backward_data, __pyx_t_4) < 0) __PYX_ERR(0, 1842, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1955
 * 
 * 
 * def pooling_forward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_119pooling_forward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1955, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pooling_forward, __pyx_t_4) < 0) __PYX_ERR(0, 1955, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1988
 * 
 * 
 * def pooling_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray y, core.ndarray gy,
 *         tuple ksize, tuple stride, tuple pad, int mode):
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_121pooling_backward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1988, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pooling_backward, __pyx_t_4) < 0) __PYX_ERR(0, 1988, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2028
 * cdef _create_tensor_descriptor_for_bn(
 *         size_t desc, core.ndarray arr, bint is_for_conv2d,
 *         int format=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     assert arr._c_contiguous
 *     if is_for_conv2d:
 */
  __pyx_k__27 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2061
 *         mean, inv_std, double eps, double decay,
 *         bint is_for_conv2d, int cudnn_mode, bint debug,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 * 
 *     reserve_space, y, save_mean, save_inv_std = (
 */
  __pyx_k__28 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2056
 * 
 * 
 * def batch_normalization_forward_training(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_123batch_normalization_forward_training, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_batch_normalization_forward_trai, __pyx_t_4) < 0) __PYX_ERR(0, 2056, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2090
 *         mean, inv_std, double eps, double decay,
 *         bint is_for_conv2d, int cudnn_mode, bint debug,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 * 
 *     reserve_space, y, save_mean, save_inv_std = (
 */
  __pyx_k__29 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2085
 * 
 * 
 * def batch_normalization_forward_training_ex(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray running_mean, core.ndarray running_var,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_125batch_normalization_forward_training_ex, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_batch_normalization_forward_trai_2, __pyx_t_4) < 0) __PYX_ERR(0, 2085, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2113
 *         mean, inv_std, double eps, double decay,
 *         bint is_for_conv2d, int cudnn_mode, bint debug,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 * 
 *     cdef memory.MemoryPointer workspace = None
 */
  __pyx_k__30 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2266
 *         core.ndarray mean, core.ndarray var,
 *         double eps, bint is_for_conv2d, int cudnn_mode,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW):             # <<<<<<<<<<<<<<
 *     x = core._internal_ascontiguousarray(x)
 *     dtype = x.dtype
 */
  __pyx_k__32 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2262
 * 
 * 
 * def batch_normalization_forward_inference(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray beta,
 *         core.ndarray mean, core.ndarray var,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_127batch_normalization_forward_inference, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_batch_normalization_forward_infe, __pyx_t_4) < 0) __PYX_ERR(0, 2262, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2311
 *         core.ndarray mean, core.ndarray inv_std,
 *         double eps, bint is_for_conv2d, int cudnn_mode, bint debug,
 *         int d_layout=cudnn.CUDNN_TENSOR_NCHW,             # <<<<<<<<<<<<<<
 *         *,
 *         memory.MemoryPointer reserve_space=None,
 */
  __pyx_k__33 = __pyx_e_4cupy_4cuda_5cudnn_CUDNN_TENSOR_NCHW;

  /* "cupy/cudnn.pyx":2307
 * 
 * 
 * def batch_normalization_backward(             # <<<<<<<<<<<<<<
 *         core.ndarray x, core.ndarray gamma, core.ndarray gy,
 *         core.ndarray mean, core.ndarray inv_std,
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_129batch_normalization_backward, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_batch_normalization_backward, __pyx_t_4) < 0) __PYX_ERR(0, 2307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2424
 * 
 * 
 * def create_activation_descriptor(mode, relu_nan_opt=cudnn.CUDNN_PROPAGATE_NAN,             # <<<<<<<<<<<<<<
 *                                  coef=0.0):
 *     desc = Descriptor(cudnn.createActivationDescriptor(),
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cudnn_CUDNN_PROPAGATE_NAN); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k__35 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_131create_activation_descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_activation_descriptor, __pyx_t_4) < 0) __PYX_ERR(0, 2424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2432
 * 
 * 
 * def create_fused_ops_plan(ops):             # <<<<<<<<<<<<<<
 *     plan = Descriptor(cudnn.createFusedOpsPlan(ops),
 *                       py_cudnn.destroyFusedOpsPlan)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_133create_fused_ops_plan, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_fused_ops_plan, __pyx_t_4) < 0) __PYX_ERR(0, 2432, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2438
 * 
 * 
 * def create_fused_ops_const_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     const_pack = Descriptor(cudnn.createFusedOpsConstParamPack(ops),
 *                             py_cudnn.destroyFusedOpsConstParamPack)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_135create_fused_ops_const_param_pack, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_fused_ops_const_param_pac, __pyx_t_4) < 0) __PYX_ERR(0, 2438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2446
 * 
 * 
 * def make_fused_ops_plan(plan, const_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     return cudnn.makeFusedOpsPlan(handle, plan.value, const_pack.value)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_137make_fused_ops_plan, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_fused_ops_plan, __pyx_t_4) < 0) __PYX_ERR(0, 2446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2451
 * 
 * 
 * def create_fused_ops_variant_param_pack(ops, list_attr_param):             # <<<<<<<<<<<<<<
 *     var_pack = Descriptor(cudnn.createFusedOpsVariantParamPack(ops),
 *                           py_cudnn.destroyFusedOpsVariantParamPack)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_139create_fused_ops_variant_param_pack, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_fused_ops_variant_param_p, __pyx_t_4) < 0) __PYX_ERR(0, 2451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":2459
 * 
 * 
 * def fused_ops_execute(plan, var_pack):             # <<<<<<<<<<<<<<
 *     handle = get_handle()
 *     cudnn.fusedOpsExecute(handle, plan.value, var_pack.value)
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_141fused_ops_execute, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_fused_ops_execute, __pyx_t_4) < 0) __PYX_ERR(0, 2459, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Descriptor(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_151__pyx_unpickle_Descriptor, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Descriptor, __pyx_t_4) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Descriptor__set_state(<Descriptor> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Descriptor__set_state(Descriptor __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.destroy = __pyx_state[0]; __pyx_result.value = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_153__pyx_unpickle__DescriptorArray, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle__DescriptorArray, __pyx_t_4) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_DropoutStates(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4cupy_5cudnn_155__pyx_unpickle_DropoutStates, NULL, __pyx_n_s_cupy_cudnn); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_DropoutStates, __pyx_t_4) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cudnn.pyx":1
 * from libcpp cimport vector             # <<<<<<<<<<<<<<
 * from libc.stdint cimport int64_t
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "vector.from_py":45
 * 
 * @cname("__pyx_convert_vector_from_py_int")
 * cdef vector[X] __pyx_convert_vector_from_py_int(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_4);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cupy.cudnn", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cupy.cudnn");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_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
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(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
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(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;
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* UnicodeAsUCS4 */
static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
   Py_ssize_t length;
   #if CYTHON_PEP393_ENABLED
   length = PyUnicode_GET_LENGTH(x);
   if (likely(length == 1)) {
       return PyUnicode_READ_CHAR(x, 0);
   }
   #else
   length = PyUnicode_GET_SIZE(x);
   if (likely(length == 1)) {
       return PyUnicode_AS_UNICODE(x)[0];
   }
   #if Py_UNICODE_SIZE == 2
   else if (PyUnicode_GET_SIZE(x) == 2) {
       Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
       if (high_val >= 0xD800 && high_val <= 0xDBFF) {
           Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
           if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
               return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
           }
       }
   }
   #endif
   #endif
   PyErr_Format(PyExc_ValueError,
                "only single character unicode strings can be converted to Py_UCS4, "
                "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
   return (Py_UCS4)-1;
}

/* object_ord */
static long __Pyx__PyObject_Ord(PyObject* c) {
    Py_ssize_t size;
    if (PyBytes_Check(c)) {
        size = PyBytes_GET_SIZE(c);
        if (likely(size == 1)) {
            return (unsigned char) PyBytes_AS_STRING(c)[0];
        }
#if PY_MAJOR_VERSION < 3
    } else if (PyUnicode_Check(c)) {
        return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    } else if (PyByteArray_Check(c)) {
        size = PyByteArray_GET_SIZE(c);
        if (likely(size == 1)) {
            return (unsigned char) PyByteArray_AS_STRING(c)[0];
        }
#endif
    } else {
        PyErr_Format(PyExc_TypeError,
            "ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
        return (long)(Py_UCS4)-1;
    }
    PyErr_Format(PyExc_TypeError,
        "ord() expected a character, but string of length %zd found", size);
    return (long)(Py_UCS4)-1;
}

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* None */
static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
    Py_ssize_t q = a / b;
    Py_ssize_t r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* RaiseTooManyValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* GetItemInt */
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(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(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* BytesEquals */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        #if PY_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* SliceObject */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

/* PyIntCompare */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) 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));
}

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* dict_getitem_default */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
    if ((1));
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* RaiseKeywordRequired */
static void __Pyx_RaiseKeywordRequired(const char* func_name, PyObject* kw_name) {
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() needs keyword-only argument %U", func_name, kw_name);
        #else
        "%s() needs keyword-only argument %s", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_RemainderObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
            x = a % b;
            x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2);
            }
        }
                __Pyx_PyInt_RemainderObjC_ZeroDivisionError(b)
                x = a % b;
                x += ((x != 0) & ((x ^ b) < 0)) * b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla % llb;
                llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2);
}
#endif

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* PyObjectGetAttrStrNoError */
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    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 ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#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

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) ((size_t) 0 - (size_t) 1), const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (unsigned PY_LONG_LONG) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (unsigned PY_LONG_LONG) 0;
                case  1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
                case 2:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
                            return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
                            return (unsigned 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]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
                            return (unsigned 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]));
                        }
                    }
                    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 (unsigned PY_LONG_LONG) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (unsigned PY_LONG_LONG) 0;
                case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                            return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                            return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                            return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                            return (unsigned 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])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                            return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((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])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                            return (unsigned 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])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            unsigned PY_LONG_LONG val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (unsigned PY_LONG_LONG) -1;
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (unsigned PY_LONG_LONG) -1;
        val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to unsigned PY_LONG_LONG");
    return (unsigned PY_LONG_LONG) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to unsigned PY_LONG_LONG");
    return (unsigned PY_LONG_LONG) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
    const int64_t neg_one = (int64_t) ((int64_t) 0 - (int64_t) 1), const_zero = (int64_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int64_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 (int64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
                            return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
                            return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_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(int64_t) >= 4 * PyLong_SHIFT) {
                            return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_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 (int64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_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(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_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(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int64_t) -1;
        }
    } else {
        int64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int64_t) -1;
        val = __Pyx_PyInt_As_int64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int64_t");
    return (int64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int64_t");
    return (int64_t) -1;
}

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
