/* Generated by Cython 0.28.3 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "define_macros": [
            [
                "_FORCE_INLINES",
                "1"
            ]
        ],
        "depends": [
            "cupy/cuda/cupy_cufft.h"
        ],
        "extra_link_args": [
            "-Wl,--disable-new-dtags,-rpath,/usr/local/cuda/lib64"
        ],
        "include_dirs": [
            "cupy/cuda",
            "/usr/local/cuda/include"
        ],
        "language": "c++",
        "libraries": [
            "cublas",
            "cuda",
            "cudart",
            "cufft",
            "curand",
            "cusparse",
            "nvrtc"
        ],
        "library_dirs": [
            "/usr/local/cuda/lib64"
        ],
        "name": "cupy.cuda.cufft",
        "sources": [
            "cupy/cuda/cufft.pyx"
        ]
    },
    "module_name": "cupy.cuda.cufft"
}
END: Cython Metadata */

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

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

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

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


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

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

#define __PYX_HAVE__cupy__cuda__cufft
#define __PYX_HAVE_API__cupy__cuda__cufft
/* Early includes */
#include <stdint.h>
#include <string.h>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <vector>
#include <utility>
#include <map>
#include "../cuda/cupy_cuda.h"
#include "cupy_cufft.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

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

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

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


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

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


static const char *__pyx_f[] = {
  "cupy/cuda/cufft.pyx",
  "stringsource",
  "cupy/cuda/device.pxd",
  "cupy/cuda/memory.pxd",
  "cupy/cuda/runtime.pxd",
  "cupy/cuda/cufft.pxd",
};
/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()

/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif


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

/* "driver.pxd":39
 * 
 * 
 * cpdef enum:             # <<<<<<<<<<<<<<
 *     CU_JIT_INPUT_CUBIN = 0
 *     CU_JIT_INPUT_PTX = 1
 */
enum  {
  __pyx_e_4cupy_4cuda_6driver_CU_JIT_INPUT_CUBIN = 0,
  __pyx_e_4cupy_4cuda_6driver_CU_JIT_INPUT_PTX = 1,
  __pyx_e_4cupy_4cuda_6driver_CU_JIT_INPUT_FATBINARY = 2,
  __pyx_e_4cupy_4cuda_6driver_CU_JIT_INPUT_OBJECT = 3,
  __pyx_e_4cupy_4cuda_6driver_CU_JIT_INPUT_LIBRARY = 4,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES = 1,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES = 2,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES = 3,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_NUM_REGS = 4,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_PTX_VERSION = 5,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_BINARY_VERSION = 6,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_CACHE_MODE_CA = 7,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES = 8,
  __pyx_e_4cupy_4cuda_6driver_CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT = 9,
  __pyx_e_4cupy_4cuda_6driver_CUDA_ERROR_INVALID_VALUE = 1,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_UNSIGNED_INT8 = 0x01,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_UNSIGNED_INT16 = 0x02,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_UNSIGNED_INT32 = 0x03,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_SIGNED_INT8 = 0x08,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_SIGNED_INT16 = 0x09,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_SIGNED_INT32 = 0x0a,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_HALF = 0x10,
  __pyx_e_4cupy_4cuda_6driver_CU_AD_FORMAT_FLOAT = 0x20,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_ADDRESS_MODE_WRAP = 0,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_ADDRESS_MODE_CLAMP = 1,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_ADDRESS_MODE_MIRROR = 2,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_ADDRESS_MODE_BORDER = 3,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_FILTER_MODE_POINT = 0,
  __pyx_e_4cupy_4cuda_6driver_CU_TR_FILTER_MODE_LINEAR = 1,
  __pyx_e_4cupy_4cuda_6driver_CU_TRSA_OVERRIDE_FORMAT = 0x01,
  __pyx_e_4cupy_4cuda_6driver_CU_TRSF_READ_AS_INTEGER = 0x01,
  __pyx_e_4cupy_4cuda_6driver_CU_TRSF_NORMALIZED_COORDINATES = 0x02,
  __pyx_e_4cupy_4cuda_6driver_CU_TRSF_SRGB = 0x10
};
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_device_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_from_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_copy_to_host_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_13MemoryPointer_memset_async;
struct __pyx_opt_args_4cupy_4cuda_6memory_set_allocator;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_free_all_blocks;
struct __pyx_opt_args_4cupy_4cuda_6memory_10MemoryPool_set_limit;

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

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

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

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

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

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

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

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

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

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

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

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

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

/* "runtime.pxd":384
 *                         unsigned int flags=*)
 * cpdef streamQuery(intptr_t stream)
 * cpdef streamWaitEvent(intptr_t stream, intptr_t event, unsigned int flags=*)             # <<<<<<<<<<<<<<
 * cpdef intptr_t eventCreate() except? 0
 * cpdef intptr_t eventCreateWithFlags(unsigned int flags) except? 0
 */
struct __pyx_opt_args_4cupy_4cuda_7runtime_streamWaitEvent {
  int __pyx_n;
  unsigned int flags;
};

/* "cupy/cuda/cufft.pxd":9
 * 
 * 
 * cpdef enum:             # <<<<<<<<<<<<<<
 *     CUFFT_C2C = 0x29
 *     CUFFT_R2C = 0x2a
 */
enum  {
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C = 0x29,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C = 0x2a,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R = 0x2c,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z = 0x69,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z = 0x6a,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2D = 0x6c,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_FORWARD = -1L,
  __pyx_e_4cupy_4cuda_5cufft_CUFFT_INVERSE = 1
};

/* "cupy/cuda/cufft.pyx":32
 * 
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     # Actually, this is 64, but it's undocumented. For the sake
 *     # of safety, let us use 16, which agrees with the cuFFT doc.
 */
enum  {
  __pyx_e_4cupy_4cuda_5cufft_MAX_CUDA_DESCRIPTOR_GPUS = 16
};

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


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


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


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


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


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


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


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



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

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


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

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


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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

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

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

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

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

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

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

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

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

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

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

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

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

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

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

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

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

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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_cufftHandle(cufftHandle 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 int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE cufftHandle __Pyx_PyInt_As_cufftHandle(PyObject *);

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

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

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

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

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

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

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

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

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

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

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


/* Module declarations from 'cython' */

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

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

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

/* Module declarations from 'libcpp' */

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

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

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

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

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

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

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

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

/* Module declarations from 'cupy.cuda.stream' */
static intptr_t (*__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr)(void); /*proto*/
static PyObject *(*__pyx_f_4cupy_4cuda_6stream_get_current_stream)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'cupy.cuda.cufft' */
static PyObject *__pyx_v_4cupy_4cuda_5cufft__thread_local = 0;
static PyObject *__pyx_v_4cupy_4cuda_5cufft_RESULT = 0;
static PyObject *__pyx_f_4cupy_4cuda_5cufft_get_current_plan(int __pyx_skip_dispatch); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4cuda_5cufft_check_result(int, int __pyx_skip_dispatch); /*proto*/
static size_t __pyx_f_4cupy_4cuda_5cufft_getVersion(int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft__reorder_buffers(cufftHandle, intptr_t, PyObject *); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft__XtMalloc(PyObject *, PyObject *, cufftXtSubFormat); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft__XtFree(intptr_t); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execC2C(cufftHandle, intptr_t, intptr_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execR2C(cufftHandle, intptr_t, intptr_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execC2R(cufftHandle, intptr_t, intptr_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execZ2Z(cufftHandle, intptr_t, intptr_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execD2Z(cufftHandle, intptr_t, intptr_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execZ2D(cufftHandle, intptr_t, intptr_t, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_multi_gpu_execC2C(cufftHandle, intptr_t, intptr_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_multi_gpu_execZ2Z(cufftHandle, intptr_t, intptr_t, int, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_convert_vector_to_py_int(const std::vector<int>  &); /*proto*/
static std::vector<int>  __pyx_convert_vector_from_py_int(PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "cupy.cuda.cufft"
extern int __pyx_module_is_main_cupy__cuda__cufft;
int __pyx_module_is_main_cupy__cuda__cufft = 0;

/* Implementation of 'cupy.cuda.cufft' */
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_NotImplementedError;
static const char __pyx_k_C[] = "C";
static const char __pyx_k_a[] = "a";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_s[] = "%s";
static const char __pyx_k_nx[] = "nx";
static const char __pyx_k_arr[] = "arr";
static const char __pyx_k_buf[] = "buf";
static const char __pyx_k_del[] = "__del__";
static const char __pyx_k_dev[] = "dev";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_fft[] = "fft";
static const char __pyx_k_fmt[] = "fmt";
static const char __pyx_k_out[] = "out";
static const char __pyx_k_ptr[] = "ptr";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_char[] = "char";
static const char __pyx_k_cupy[] = "cupy";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_dype[] = "dype";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_gpus[] = "gpus";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_ndim[] = "ndim";
static const char __pyx_k_plan[] = "plan";
static const char __pyx_k_ptr2[] = "ptr2";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_size[] = "size";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_Event[] = "Event";
static const char __pyx_k_batch[] = "batch";
static const char __pyx_k_count[] = "count";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_enter[] = "__enter__";
static const char __pyx_k_event[] = "event";
static const char __pyx_k_flags[] = "flags";
static const char __pyx_k_idata[] = "idata";
static const char __pyx_k_idist[] = "idist";
static const char __pyx_k_local[] = "local";
static const char __pyx_k_lower[] = "lower";
static const char __pyx_k_nGPUs[] = "nGPUs";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_odata[] = "odata";
static const char __pyx_k_odist[] = "odist";
static const char __pyx_k_order[] = "order";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_ravel[] = "ravel";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_share[] = "share";
static const char __pyx_k_sizes[] = "sizes";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_upper[] = "upper";
static const char __pyx_k_xtArr[] = "xtArr";
static const char __pyx_k_Device[] = "Device";
static const char __pyx_k_Plan1d[] = "Plan1d";
static const char __pyx_k_PlanNd[] = "PlanNd";
static const char __pyx_k_Stream[] = "Stream";
static const char __pyx_k_action[] = "action";
static const char __pyx_k_events[] = "events";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_gather[] = "gather";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_record[] = "record";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_result[] = "result";
static const char __pyx_k_stream[] = "stream";
static const char __pyx_k_OWNDATA[] = "OWNDATA";
static const char __pyx_k_devices[] = "devices";
static const char __pyx_k_float32[] = "float32";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_inembed[] = "inembed";
static const char __pyx_k_istride[] = "istride";
static const char __pyx_k_min_len[] = "min_len";
static const char __pyx_k_ndarray[] = "ndarray";
static const char __pyx_k_onembed[] = "onembed";
static const char __pyx_k_ostride[] = "ostride";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_scatter[] = "scatter";
static const char __pyx_k_streams[] = "streams";
static const char __pyx_k_exc_type[] = "exc_type";
static const char __pyx_k_fft_type[] = "fft_type";
static const char __pyx_k_itemsize[] = "itemsize";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_complex64[] = "complex64";
static const char __pyx_k_direction[] = "direction";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_exc_value[] = "exc_value";
static const char __pyx_k_last_axis[] = "last_axis";
static const char __pyx_k_last_size[] = "last_size";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_shape_arr[] = "shape_arr";
static const char __pyx_k_shape_ptr[] = "shape_ptr";
static const char __pyx_k_threading[] = "threading";
static const char __pyx_k_traceback[] = "traceback";
static const char __pyx_k_work_area[] = "work_area";
static const char __pyx_k_work_size[] = "work_size";
static const char __pyx_k_CuFFTError[] = "CuFFTError";
static const char __pyx_k_Plan1d_fft[] = "Plan1d.fft";
static const char __pyx_k_PlanNd_fft[] = "PlanNd.fft";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_complex128[] = "complex128";
static const char __pyx_k_curr_event[] = "curr_event";
static const char __pyx_k_prev_event[] = "prev_event";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_wait_event[] = "wait_event";
static const char __pyx_k_xtArr_desc[] = "xtArr_desc";
static const char __pyx_k_batch_share[] = "batch_share";
static const char __pyx_k_curr_stream[] = "curr_stream";
static const char __pyx_k_inembed_arr[] = "inembed_arr";
static const char __pyx_k_inembed_ptr[] = "inembed_ptr";
static const char __pyx_k_onembed_arr[] = "onembed_arr";
static const char __pyx_k_onembed_ptr[] = "onembed_ptr";
static const char __pyx_k_synchronize[] = "synchronize";
static const char __pyx_k_Plan1d___del[] = "Plan1d.__del__";
static const char __pyx_k_PlanNd___del[] = "PlanNd.__del__";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_c_contiguous[] = "c_contiguous";
static const char __pyx_k_current_plan[] = "_current_plan";
static const char __pyx_k_f_contiguous[] = "f_contiguous";
static const char __pyx_k_outer_stream[] = "outer_stream";
static const char __pyx_k_xtArr_buffer[] = "xtArr_buffer";
static const char __pyx_k_CUFFT_SUCCESS[] = "CUFFT_SUCCESS";
static const char __pyx_k_Plan1d___exit[] = "Plan1d.__exit__";
static const char __pyx_k_Plan1d___init[] = "Plan1d.__init__";
static const char __pyx_k_PlanNd___exit[] = "PlanNd.__exit__";
static const char __pyx_k_PlanNd___init[] = "PlanNd.__init__";
static const char __pyx_k_multi_gpu_fft[] = "_multi_gpu_fft";
static const char __pyx_k_work_area_ptr[] = "work_area_ptr";
static const char __pyx_k_Plan1d___enter[] = "Plan1d.__enter__";
static const char __pyx_k_PlanNd___enter[] = "PlanNd.__enter__";
static const char __pyx_k_single_gpu_fft[] = "_single_gpu_fft";
static const char __pyx_k_use_multi_gpus[] = "_use_multi_gpus";
static const char __pyx_k_cupy_cuda_cufft[] = "cupy.cuda.cufft";
static const char __pyx_k_free_all_blocks[] = "free_all_blocks";
static const char __pyx_k_cupy_cuda_device[] = "cupy.cuda.device";
static const char __pyx_k_cupy_cuda_stream[] = "cupy.cuda.stream";
static const char __pyx_k_get_output_array[] = "get_output_array";
static const char __pyx_k_multi_gpu_memcpy[] = "_multi_gpu_memcpy";
static const char __pyx_k_use_multi_gpus_2[] = "use_multi_gpus";
static const char __pyx_k_CUFFT_EXEC_FAILED[] = "CUFFT_EXEC_FAILED";
static const char __pyx_k_CUFFT_PARSE_ERROR[] = "CUFFT_PARSE_ERROR";
static const char __pyx_k_CuFFTError___init[] = "CuFFTError.__init__";
static const char __pyx_k_CUFFT_ALLOC_FAILED[] = "CUFFT_ALLOC_FAILED";
static const char __pyx_k_CUFFT_INVALID_PLAN[] = "CUFFT_INVALID_PLAN";
static const char __pyx_k_CUFFT_INVALID_SIZE[] = "CUFFT_INVALID_SIZE";
static const char __pyx_k_CUFFT_INVALID_TYPE[] = "CUFFT_INVALID_TYPE";
static const char __pyx_k_CUFFT_NO_WORKSPACE[] = "CUFFT_NO_WORKSPACE";
static const char __pyx_k_CUFFT_SETUP_FAILED[] = "CUFFT_SETUP_FAILED";
static const char __pyx_k_check_output_array[] = "check_output_array";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_multi_gpu_get_plan[] = "_multi_gpu_get_plan";
static const char __pyx_k_CUFFT_INVALID_VALUE[] = "CUFFT_INVALID_VALUE";
static const char __pyx_k_CUFFT_LICENSE_ERROR[] = "CUFFT_LICENSE_ERROR";
static const char __pyx_k_CUFFT_NOT_SUPPORTED[] = "CUFFT_NOT_SUPPORTED";
static const char __pyx_k_CuFFTError___reduce[] = "CuFFTError.__reduce__";
static const char __pyx_k_Impossible_to_reach[] = "Impossible to reach.";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_cupy_cuda_cufft_pyx[] = "cupy/cuda/cufft.pyx";
static const char __pyx_k_out_must_have_shape[] = "out must have shape {}.";
static const char __pyx_k_single_gpu_get_plan[] = "_single_gpu_get_plan";
static const char __pyx_k_CUFFT_INTERNAL_ERROR[] = "CUFFT_INTERNAL_ERROR";
static const char __pyx_k_CUFFT_INVALID_DEVICE[] = "CUFFT_INVALID_DEVICE";
static const char __pyx_k_CUFFT_UNALIGNED_DATA[] = "CUFFT_UNALIGNED_DATA";
static const char __pyx_k_CUFFT_NOT_IMPLEMENTED[] = "CUFFT_NOT_IMPLEMENTED";
static const char __pyx_k_Plan1d__multi_gpu_fft[] = "Plan1d._multi_gpu_fft";
static const char __pyx_k_output_dtype_mismatch[] = "output dtype mismatch";
static const char __pyx_k_output_shape_mismatch[] = "output shape mismatch";
static const char __pyx_k_Plan1d__single_gpu_fft[] = "Plan1d._single_gpu_fft";
static const char __pyx_k_copy_from_device_async[] = "copy_from_device_async";
static const char __pyx_k_multi_gpu_setup_buffer[] = "_multi_gpu_setup_buffer";
static const char __pyx_k_output_dtype_and_shape[] = "_output_dtype_and_shape";
static const char __pyx_k_Plan1d_get_output_array[] = "Plan1d.get_output_array";
static const char __pyx_k_PlanNd_get_output_array[] = "PlanNd.get_output_array";
static const char __pyx_k_get_default_memory_pool[] = "get_default_memory_pool";
static const char __pyx_k_Plan1d__multi_gpu_memcpy[] = "Plan1d._multi_gpu_memcpy";
static const char __pyx_k_Plan1d_check_output_array[] = "Plan1d.check_output_array";
static const char __pyx_k_PlanNd_check_output_array[] = "PlanNd.check_output_array";
static const char __pyx_k_output_dimension_mismatch[] = "output dimension mismatch";
static const char __pyx_k_Plan1d__multi_gpu_get_plan[] = "Plan1d._multi_gpu_get_plan";
static const char __pyx_k_output_contiguity_mismatch[] = "output contiguity mismatch";
static const char __pyx_k_output_dtype_is_unexpected[] = "output dtype is unexpected";
static const char __pyx_k_output_shape_is_incorrecct[] = "output shape is incorrecct";
static const char __pyx_k_Plan1d__single_gpu_get_plan[] = "Plan1d._single_gpu_get_plan";
static const char __pyx_k_Plan1d__multi_gpu_setup_buffer[] = "Plan1d._multi_gpu_setup_buffer";
static const char __pyx_k_Plan1d__output_dtype_and_shape[] = "Plan1d._output_dtype_and_shape";
static const char __pyx_k_PlanNd__output_dtype_and_shape[] = "PlanNd._output_dtype_and_shape";
static const char __pyx_k_CUFFT_INCOMPLETE_PARAMETER_LIST[] = "CUFFT_INCOMPLETE_PARAMETER_LIST";
static const char __pyx_k_User_managed_buffer_area_is_not[] = "User-managed buffer area is not yet supported.";
static const char __pyx_k_devices_should_be_an_int_or_a_l[] = "\"devices\" should be an int or a list of int.";
static const char __pyx_k_Currently_for_multiple_GPUs_only[] = "Currently for multiple GPUs only C2C and Z2Z are supported.";
static const char __pyx_k_For_GPUs_the_array_length_must_b[] = "For {} GPUs, the array length must be at least {} (you have {}).";
static const char __pyx_k_For_multi_GPU_FFT_with_batch_1_t[] = "For multi-GPU FFT with batch = 1, the array size must be a power of 2.";
static const char __pyx_k_out_dtype_mismatch_found_expecte[] = "out dtype mismatch: found {}, expected {}";
static const char __pyx_k_For_multi_GPU_FFT_with_batch_1_t_2[] = "For multi-GPU FFT with batch = 1, the number of devices must be 2, 4, 8, or 16.";
static PyObject *__pyx_n_u_C;
static PyObject *__pyx_n_u_CUFFT_ALLOC_FAILED;
static PyObject *__pyx_n_u_CUFFT_EXEC_FAILED;
static PyObject *__pyx_n_u_CUFFT_INCOMPLETE_PARAMETER_LIST;
static PyObject *__pyx_n_u_CUFFT_INTERNAL_ERROR;
static PyObject *__pyx_n_u_CUFFT_INVALID_DEVICE;
static PyObject *__pyx_n_u_CUFFT_INVALID_PLAN;
static PyObject *__pyx_n_u_CUFFT_INVALID_SIZE;
static PyObject *__pyx_n_u_CUFFT_INVALID_TYPE;
static PyObject *__pyx_n_u_CUFFT_INVALID_VALUE;
static PyObject *__pyx_n_u_CUFFT_LICENSE_ERROR;
static PyObject *__pyx_n_u_CUFFT_NOT_IMPLEMENTED;
static PyObject *__pyx_n_u_CUFFT_NOT_SUPPORTED;
static PyObject *__pyx_n_u_CUFFT_NO_WORKSPACE;
static PyObject *__pyx_n_u_CUFFT_PARSE_ERROR;
static PyObject *__pyx_n_u_CUFFT_SETUP_FAILED;
static PyObject *__pyx_n_u_CUFFT_SUCCESS;
static PyObject *__pyx_n_u_CUFFT_UNALIGNED_DATA;
static PyObject *__pyx_n_s_CuFFTError;
static PyObject *__pyx_n_s_CuFFTError___init;
static PyObject *__pyx_n_s_CuFFTError___reduce;
static PyObject *__pyx_kp_u_Currently_for_multiple_GPUs_only;
static PyObject *__pyx_n_s_Device;
static PyObject *__pyx_n_s_Event;
static PyObject *__pyx_kp_u_For_GPUs_the_array_length_must_b;
static PyObject *__pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t;
static PyObject *__pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t_2;
static PyObject *__pyx_kp_u_Impossible_to_reach;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_n_u_OWNDATA;
static PyObject *__pyx_n_s_Plan1d;
static PyObject *__pyx_n_s_Plan1d___del;
static PyObject *__pyx_n_s_Plan1d___enter;
static PyObject *__pyx_n_s_Plan1d___exit;
static PyObject *__pyx_n_s_Plan1d___init;
static PyObject *__pyx_n_s_Plan1d__multi_gpu_fft;
static PyObject *__pyx_n_s_Plan1d__multi_gpu_get_plan;
static PyObject *__pyx_n_s_Plan1d__multi_gpu_memcpy;
static PyObject *__pyx_n_s_Plan1d__multi_gpu_setup_buffer;
static PyObject *__pyx_n_s_Plan1d__output_dtype_and_shape;
static PyObject *__pyx_n_s_Plan1d__single_gpu_fft;
static PyObject *__pyx_n_s_Plan1d__single_gpu_get_plan;
static PyObject *__pyx_n_s_Plan1d_check_output_array;
static PyObject *__pyx_n_s_Plan1d_fft;
static PyObject *__pyx_n_s_Plan1d_get_output_array;
static PyObject *__pyx_n_s_PlanNd;
static PyObject *__pyx_n_s_PlanNd___del;
static PyObject *__pyx_n_s_PlanNd___enter;
static PyObject *__pyx_n_s_PlanNd___exit;
static PyObject *__pyx_n_s_PlanNd___init;
static PyObject *__pyx_n_s_PlanNd__output_dtype_and_shape;
static PyObject *__pyx_n_s_PlanNd_check_output_array;
static PyObject *__pyx_n_s_PlanNd_fft;
static PyObject *__pyx_n_s_PlanNd_get_output_array;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_Stream;
static PyObject *__pyx_kp_u_User_managed_buffer_area_is_not;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_action;
static PyObject *__pyx_n_s_arr;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_s_batch;
static PyObject *__pyx_n_s_batch_share;
static PyObject *__pyx_n_s_buf;
static PyObject *__pyx_n_s_c_contiguous;
static PyObject *__pyx_n_s_char;
static PyObject *__pyx_n_s_check_output_array;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_complex128;
static PyObject *__pyx_n_s_complex64;
static PyObject *__pyx_n_s_copy_from_device_async;
static PyObject *__pyx_n_s_count;
static PyObject *__pyx_n_s_cupy;
static PyObject *__pyx_n_s_cupy_cuda_cufft;
static PyObject *__pyx_kp_s_cupy_cuda_cufft_pyx;
static PyObject *__pyx_n_s_cupy_cuda_device;
static PyObject *__pyx_n_s_cupy_cuda_stream;
static PyObject *__pyx_n_s_curr_event;
static PyObject *__pyx_n_s_curr_stream;
static PyObject *__pyx_n_s_current_plan;
static PyObject *__pyx_n_u_current_plan;
static PyObject *__pyx_n_s_data;
static PyObject *__pyx_n_s_del;
static PyObject *__pyx_n_s_dev;
static PyObject *__pyx_n_s_devices;
static PyObject *__pyx_kp_u_devices_should_be_an_int_or_a_l;
static PyObject *__pyx_n_s_direction;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dype;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_event;
static PyObject *__pyx_n_s_events;
static PyObject *__pyx_n_s_exc_type;
static PyObject *__pyx_n_s_exc_value;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_n_s_f_contiguous;
static PyObject *__pyx_n_s_fft;
static PyObject *__pyx_n_s_fft_type;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_fmt;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_free_all_blocks;
static PyObject *__pyx_n_u_gather;
static PyObject *__pyx_n_s_get_default_memory_pool;
static PyObject *__pyx_n_s_get_output_array;
static PyObject *__pyx_n_s_gpus;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_idata;
static PyObject *__pyx_n_s_idist;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_inembed;
static PyObject *__pyx_n_s_inembed_arr;
static PyObject *__pyx_n_s_inembed_ptr;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_istride;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_n_s_last_axis;
static PyObject *__pyx_n_s_last_size;
static PyObject *__pyx_n_s_local;
static PyObject *__pyx_n_s_lower;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_min_len;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_multi_gpu_fft;
static PyObject *__pyx_n_s_multi_gpu_get_plan;
static PyObject *__pyx_n_s_multi_gpu_memcpy;
static PyObject *__pyx_n_s_multi_gpu_setup_buffer;
static PyObject *__pyx_n_s_nGPUs;
static PyObject *__pyx_n_s_ndarray;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_nx;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_odata;
static PyObject *__pyx_n_s_odist;
static PyObject *__pyx_n_s_onembed;
static PyObject *__pyx_n_s_onembed_arr;
static PyObject *__pyx_n_s_onembed_ptr;
static PyObject *__pyx_n_s_order;
static PyObject *__pyx_n_s_ostride;
static PyObject *__pyx_n_s_out;
static PyObject *__pyx_kp_u_out_dtype_mismatch_found_expecte;
static PyObject *__pyx_kp_u_out_must_have_shape;
static PyObject *__pyx_n_s_outer_stream;
static PyObject *__pyx_kp_u_output_contiguity_mismatch;
static PyObject *__pyx_kp_u_output_dimension_mismatch;
static PyObject *__pyx_n_s_output_dtype_and_shape;
static PyObject *__pyx_kp_u_output_dtype_is_unexpected;
static PyObject *__pyx_kp_u_output_dtype_mismatch;
static PyObject *__pyx_kp_u_output_shape_is_incorrecct;
static PyObject *__pyx_kp_u_output_shape_mismatch;
static PyObject *__pyx_n_s_plan;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_prev_event;
static PyObject *__pyx_n_s_ptr;
static PyObject *__pyx_n_s_ptr2;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_ravel;
static PyObject *__pyx_n_s_record;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_kp_u_s;
static PyObject *__pyx_n_u_scatter;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_shape_arr;
static PyObject *__pyx_n_s_shape_ptr;
static PyObject *__pyx_n_s_share;
static PyObject *__pyx_n_s_single_gpu_fft;
static PyObject *__pyx_n_s_single_gpu_get_plan;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_sizes;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_stream;
static PyObject *__pyx_n_s_streams;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_s_synchronize;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_threading;
static PyObject *__pyx_n_s_traceback;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_n_s_use_multi_gpus;
static PyObject *__pyx_n_s_use_multi_gpus_2;
static PyObject *__pyx_n_s_wait_event;
static PyObject *__pyx_n_s_work_area;
static PyObject *__pyx_n_s_work_area_ptr;
static PyObject *__pyx_n_s_work_size;
static PyObject *__pyx_n_s_xtArr;
static PyObject *__pyx_n_s_xtArr_buffer;
static PyObject *__pyx_n_s_xtArr_desc;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_get_current_plan(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10CuFFTError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_result); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10CuFFTError_2__reduce__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_2check_result(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_result); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_4getVersion(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_devices, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_2_single_gpu_get_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, cufftHandle __pyx_v_plan, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_4_multi_gpu_get_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, cufftHandle __pyx_v_plan, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_devices, CYTHON_UNUSED PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_6__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_8__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_10__exit__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_value, CYTHON_UNUSED PyObject *__pyx_v_traceback); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_12fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_14_single_gpu_fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_16_multi_gpu_setup_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_18_multi_gpu_memcpy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_action); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_20_multi_gpu_fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_22_output_dtype_and_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_24get_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_26check_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_inembed, int __pyx_v_istride, int __pyx_v_idist, PyObject *__pyx_v_onembed, int __pyx_v_ostride, int __pyx_v_odist, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_order, int __pyx_v_last_axis, PyObject *__pyx_v_last_size); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_2__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_4__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_6__exit__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_value, CYTHON_UNUSED PyObject *__pyx_v_traceback); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_8fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_10_output_dtype_and_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_12get_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_order); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_14check_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6execC2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_8execR2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10execC2R(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_12execZ2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_14execD2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_16execZ2D(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_18multi_gpu_execC2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction); /* proto */
static PyObject *__pyx_pf_4cupy_4cuda_5cufft_20multi_gpu_execZ2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction); /* proto */
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_9;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_11;
static PyObject *__pyx_int_12;
static PyObject *__pyx_int_13;
static PyObject *__pyx_int_14;
static PyObject *__pyx_int_15;
static PyObject *__pyx_int_16;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__50;
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__66;
static PyObject *__pyx_codeobj__18;
static PyObject *__pyx_codeobj__20;
static PyObject *__pyx_codeobj__23;
static PyObject *__pyx_codeobj__25;
static PyObject *__pyx_codeobj__27;
static PyObject *__pyx_codeobj__29;
static PyObject *__pyx_codeobj__31;
static PyObject *__pyx_codeobj__33;
static PyObject *__pyx_codeobj__35;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__39;
static PyObject *__pyx_codeobj__41;
static PyObject *__pyx_codeobj__43;
static PyObject *__pyx_codeobj__45;
static PyObject *__pyx_codeobj__47;
static PyObject *__pyx_codeobj__49;
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__67;
/* Late includes */

/* "cupy/cuda/cufft.pyx":21
 * 
 * 
 * cpdef get_current_plan():             # <<<<<<<<<<<<<<
 *     """Get current cuFFT plan.
 * 
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_1get_current_plan(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_get_current_plan(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;
  __Pyx_RefNannySetupContext("get_current_plan", 0);

  /* "cupy/cuda/cufft.pyx":27
 *         None or cupy.cuda.cufft.Plan1d or cupy.cuda.cufft.PlanNd
 *     """
 *     if not hasattr(_thread_local, '_current_plan'):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 *     return _thread_local._current_plan
 */
  __pyx_t_1 = __pyx_v_4cupy_4cuda_5cufft__thread_local;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_u_current_plan); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 27, __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/cuda/cufft.pyx":28
 *     """
 *     if not hasattr(_thread_local, '_current_plan'):
 *         _thread_local._current_plan = None             # <<<<<<<<<<<<<<
 *     return _thread_local._current_plan
 * 
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan, Py_None) < 0) __PYX_ERR(0, 28, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":27
 *         None or cupy.cuda.cufft.Plan1d or cupy.cuda.cufft.PlanNd
 *     """
 *     if not hasattr(_thread_local, '_current_plan'):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 *     return _thread_local._current_plan
 */
  }

  /* "cupy/cuda/cufft.pyx":29
 *     if not hasattr(_thread_local, '_current_plan'):
 *         _thread_local._current_plan = None
 *     return _thread_local._current_plan             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":21
 * 
 * 
 * cpdef get_current_plan():             # <<<<<<<<<<<<<<
 *     """Get current cuFFT plan.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cuda.cufft.get_current_plan", __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_4cuda_5cufft_1get_current_plan(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_get_current_plan[] = "get_current_plan()\nGet current cuFFT plan.\n\n    Returns:\n        None or cupy.cuda.cufft.Plan1d or cupy.cuda.cufft.PlanNd\n    ";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_1get_current_plan(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_current_plan (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_get_current_plan(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_get_current_plan(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_current_plan", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_get_current_plan(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":136
 * class CuFFTError(RuntimeError):
 * 
 *     def __init__(self, int result):             # <<<<<<<<<<<<<<
 *         self.result = result
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_10CuFFTError___init__[] = "CuFFTError.__init__(self, int result)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_10CuFFTError_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_10CuFFTError___init__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  int __pyx_v_result;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_result,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_self)) != 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_result)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 136, __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, 136, __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_self = values[0];
    __pyx_v_result = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_result == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 136, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 136, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.CuFFTError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_10CuFFTError___init__(__pyx_self, __pyx_v_self, __pyx_v_result);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10CuFFTError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_result) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cuda/cufft.pyx":137
 * 
 *     def __init__(self, int result):
 *         self.result = result             # <<<<<<<<<<<<<<
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_result, __pyx_t_1) < 0) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":138
 *     def __init__(self, int result):
 *         self.result = result
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_CuFFTError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__pyx_v_4cupy_4cuda_5cufft_RESULT == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 138, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_4cupy_4cuda_5cufft_RESULT, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyUnicode_Format(__pyx_kp_u_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __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;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __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;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":136
 * class CuFFTError(RuntimeError):
 * 
 *     def __init__(self, int result):             # <<<<<<<<<<<<<<
 *         self.result = result
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 */

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

/* "cupy/cuda/cufft.pyx":140
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (type(self), (self.result,))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_3__reduce__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_10CuFFTError_2__reduce__[] = "CuFFTError.__reduce__(self)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_10CuFFTError_3__reduce__ = {"__reduce__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_3__reduce__, METH_O, __pyx_doc_4cupy_4cuda_5cufft_10CuFFTError_2__reduce__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_10CuFFTError_3__reduce__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_10CuFFTError_2__reduce__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10CuFFTError_2__reduce__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__reduce__", 0);

  /* "cupy/cuda/cufft.pyx":141
 * 
 *     def __reduce__(self):
 *         return (type(self), (self.result,))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __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, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_self)));
  __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_self)));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(__pyx_v_self)));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":140
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (type(self), (self.result,))
 * 
 */

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

/* "cupy/cuda/cufft.pyx":145
 * 
 * @cython.profile(False)
 * cpdef inline check_result(int result):             # <<<<<<<<<<<<<<
 *     if result != 0:
 *         raise CuFFTError(result)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_3check_result(PyObject *__pyx_self, PyObject *__pyx_arg_result); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4cupy_4cuda_5cufft_check_result(int __pyx_v_result, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("check_result", 0);

  /* "cupy/cuda/cufft.pyx":146
 * @cython.profile(False)
 * cpdef inline check_result(int result):
 *     if result != 0:             # <<<<<<<<<<<<<<
 *         raise CuFFTError(result)
 * 
 */
  __pyx_t_1 = ((__pyx_v_result != 0) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/cuda/cufft.pyx":147
 * cpdef inline check_result(int result):
 *     if result != 0:
 *         raise CuFFTError(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_CuFFTError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __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[2] = {__pyx_t_5, __pyx_t_4};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __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_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 147, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":146
 * @cython.profile(False)
 * cpdef inline check_result(int result):
 *     if result != 0:             # <<<<<<<<<<<<<<
 *         raise CuFFTError(result)
 * 
 */
  }

  /* "cupy/cuda/cufft.pyx":145
 * 
 * @cython.profile(False)
 * cpdef inline check_result(int result):             # <<<<<<<<<<<<<<
 *     if result != 0:
 *         raise CuFFTError(result)
 */

  /* 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_6);
  __Pyx_AddTraceback("cupy.cuda.cufft.check_result", __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_4cuda_5cufft_3check_result(PyObject *__pyx_self, PyObject *__pyx_arg_result); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_2check_result[] = "check_result(int result)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_3check_result(PyObject *__pyx_self, PyObject *__pyx_arg_result) {
  int __pyx_v_result;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_result (wrapper)", 0);
  assert(__pyx_arg_result); {
    __pyx_v_result = __Pyx_PyInt_As_int(__pyx_arg_result); if (unlikely((__pyx_v_result == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.check_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_2check_result(__pyx_self, ((int)__pyx_v_result));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_2check_result(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_result) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("check_result", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); 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.cuda.cufft.check_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":150
 * 
 * 
 * cpdef size_t getVersion() except? -1:             # <<<<<<<<<<<<<<
 *     cdef int version
 *     result = cufftGetVersion(&version)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_5getVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static size_t __pyx_f_4cupy_4cuda_5cufft_getVersion(CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_version;
  cufftResult_t __pyx_v_result;
  size_t __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("getVersion", 0);

  /* "cupy/cuda/cufft.pyx":152
 * cpdef size_t getVersion() except? -1:
 *     cdef int version
 *     result = cufftGetVersion(&version)             # <<<<<<<<<<<<<<
 *     check_result(result)
 *     return version
 */
  __pyx_v_result = cufftGetVersion((&__pyx_v_version));

  /* "cupy/cuda/cufft.pyx":153
 *     cdef int version
 *     result = cufftGetVersion(&version)
 *     check_result(result)             # <<<<<<<<<<<<<<
 *     return version
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":154
 *     result = cufftGetVersion(&version)
 *     check_result(result)
 *     return version             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_version;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":150
 * 
 * 
 * cpdef size_t getVersion() except? -1:             # <<<<<<<<<<<<<<
 *     cdef int version
 *     result = cufftGetVersion(&version)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cupy.cuda.cufft.getVersion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1L;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_5getVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_4getVersion[] = "getVersion() -> size_t";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_5getVersion(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getVersion (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_4getVersion(__pyx_self);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_4getVersion(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  size_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("getVersion", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_getVersion(0); if (unlikely(__pyx_t_1 == ((size_t)-1L) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __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.cuda.cufft.getVersion", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":160
 * # left in the GPU memory in a permutation of the natural output", see
 * # https://docs.nvidia.com/cuda/cufft/index.html#multiple-GPU-cufft-intermediate-helper  # NOQA
 * cdef _reorder_buffers(Handle plan, intptr_t xtArr, list xtArr_buffer):             # <<<<<<<<<<<<<<
 *     cdef int i, result, nGPUs
 *     cdef intptr_t temp_xtArr
 */

static PyObject *__pyx_f_4cupy_4cuda_5cufft__reorder_buffers(cufftHandle __pyx_v_plan, intptr_t __pyx_v_xtArr, PyObject *__pyx_v_xtArr_buffer) {
  int __pyx_v_i;
  int __pyx_v_result;
  int __pyx_v_nGPUs;
  intptr_t __pyx_v_temp_xtArr;
  cudaLibXtDesc *__pyx_v_temp_arr;
  cudaLibXtDesc *__pyx_v_arr;
  PyObject *__pyx_v_gpus = 0;
  PyObject *__pyx_v_sizes = 0;
  PyObject *__pyx_v_temp_xtArr_buffer = 0;
  PyObject *__pyx_v_temp = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  intptr_t __pyx_t_11;
  __Pyx_RefNannySetupContext("_reorder_buffers", 0);

  /* "cupy/cuda/cufft.pyx":165
 *     cdef XtArray* temp_arr
 *     cdef XtArray* arr
 *     cdef list gpus = []             # <<<<<<<<<<<<<<
 *     cdef list sizes = []
 *     cdef list temp_xtArr_buffer
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_gpus = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":166
 *     cdef XtArray* arr
 *     cdef list gpus = []
 *     cdef list sizes = []             # <<<<<<<<<<<<<<
 *     cdef list temp_xtArr_buffer
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_sizes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":169
 *     cdef list temp_xtArr_buffer
 * 
 *     arr = <XtArray*>xtArr             # <<<<<<<<<<<<<<
 *     nGPUs = len(xtArr_buffer)
 *     assert nGPUs == arr.descriptor.nGPUs
 */
  __pyx_v_arr = ((cudaLibXtDesc *)__pyx_v_xtArr);

  /* "cupy/cuda/cufft.pyx":170
 * 
 *     arr = <XtArray*>xtArr
 *     nGPUs = len(xtArr_buffer)             # <<<<<<<<<<<<<<
 *     assert nGPUs == arr.descriptor.nGPUs
 * 
 */
  if (unlikely(__pyx_v_xtArr_buffer == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 170, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_xtArr_buffer); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 170, __pyx_L1_error)
  __pyx_v_nGPUs = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":171
 *     arr = <XtArray*>xtArr
 *     nGPUs = len(xtArr_buffer)
 *     assert nGPUs == arr.descriptor.nGPUs             # <<<<<<<<<<<<<<
 * 
 *     # allocate another buffer to prepare for order conversion
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_nGPUs == __pyx_v_arr->descriptor->nGPUs) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 171, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cuda/cufft.pyx":174
 * 
 *     # allocate another buffer to prepare for order conversion
 *     for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *         gpus.append(arr.descriptor.GPUs[i])
 *         sizes.append(arr.descriptor.size[i])
 */
  __pyx_t_3 = __pyx_v_nGPUs;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/cuda/cufft.pyx":175
 *     # allocate another buffer to prepare for order conversion
 *     for i in range(nGPUs):
 *         gpus.append(arr.descriptor.GPUs[i])             # <<<<<<<<<<<<<<
 *         sizes.append(arr.descriptor.size[i])
 *     temp_xtArr, temp_xtArr_buffer = _XtMalloc(gpus, sizes,
 */
    __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_arr->descriptor->GPUs[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_gpus, __pyx_t_1); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 175, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":176
 *     for i in range(nGPUs):
 *         gpus.append(arr.descriptor.GPUs[i])
 *         sizes.append(arr.descriptor.size[i])             # <<<<<<<<<<<<<<
 *     temp_xtArr, temp_xtArr_buffer = _XtMalloc(gpus, sizes,
 *                                               CUFFT_XT_FORMAT_INPLACE)
 */
    __pyx_t_1 = __Pyx_PyInt_FromSize_t((__pyx_v_arr->descriptor->size[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyList_Append(__pyx_v_sizes, __pyx_t_1); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 176, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "cupy/cuda/cufft.pyx":177
 *         gpus.append(arr.descriptor.GPUs[i])
 *         sizes.append(arr.descriptor.size[i])
 *     temp_xtArr, temp_xtArr_buffer = _XtMalloc(gpus, sizes,             # <<<<<<<<<<<<<<
 *                                               CUFFT_XT_FORMAT_INPLACE)
 *     temp_arr = <XtArray*>temp_xtArr
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft__XtMalloc(__pyx_v_gpus, __pyx_v_sizes, CUFFT_XT_FORMAT_INPLACE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __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 != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 177, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_8);
    #else
    __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 177, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
    index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_7);
    index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 177, __pyx_L1_error)
    __pyx_t_10 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 177, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_t_11 = PyInt_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_11 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_8)->tp_name), 0))) __PYX_ERR(0, 177, __pyx_L1_error)
  __pyx_v_temp_xtArr = __pyx_t_11;
  __pyx_v_temp_xtArr_buffer = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":179
 *     temp_xtArr, temp_xtArr_buffer = _XtMalloc(gpus, sizes,
 *                                               CUFFT_XT_FORMAT_INPLACE)
 *     temp_arr = <XtArray*>temp_xtArr             # <<<<<<<<<<<<<<
 * 
 *     # Make a device copy to bring the data from the permuted order back to
 */
  __pyx_v_temp_arr = ((cudaLibXtDesc *)__pyx_v_temp_xtArr);

  /* "cupy/cuda/cufft.pyx":184
 *     # the natural order. Note that this works because after FFT
 *     # arr.subFormat is silently changed to CUFFT_XT_FORMAT_INPLACE_SHUFFLED
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtMemcpy(plan, <void*>temp_arr, <void*>arr,
 *                                CUFFT_COPY_DEVICE_TO_DEVICE)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":185
 *     # arr.subFormat is silently changed to CUFFT_XT_FORMAT_INPLACE_SHUFFLED
 *     with nogil:
 *         result = cufftXtMemcpy(plan, <void*>temp_arr, <void*>arr,             # <<<<<<<<<<<<<<
 *                                CUFFT_COPY_DEVICE_TO_DEVICE)
 *     check_result(result)
 */
        __pyx_v_result = cufftXtMemcpy(__pyx_v_plan, ((void *)__pyx_v_temp_arr), ((void *)__pyx_v_arr), CUFFT_COPY_DEVICE_TO_DEVICE);
      }

      /* "cupy/cuda/cufft.pyx":184
 *     # the natural order. Note that this works because after FFT
 *     # arr.subFormat is silently changed to CUFFT_XT_FORMAT_INPLACE_SHUFFLED
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtMemcpy(plan, <void*>temp_arr, <void*>arr,
 *                                CUFFT_COPY_DEVICE_TO_DEVICE)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
  }

  /* "cupy/cuda/cufft.pyx":187
 *         result = cufftXtMemcpy(plan, <void*>temp_arr, <void*>arr,
 *                                CUFFT_COPY_DEVICE_TO_DEVICE)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(nGPUs):
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":189
 *     check_result(result)
 * 
 *     for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *         # swap MemoryPointer in xtArr_buffer
 *         temp = temp_xtArr_buffer[i]
 */
  __pyx_t_3 = __pyx_v_nGPUs;
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "cupy/cuda/cufft.pyx":191
 *     for i in range(nGPUs):
 *         # swap MemoryPointer in xtArr_buffer
 *         temp = temp_xtArr_buffer[i]             # <<<<<<<<<<<<<<
 *         temp_xtArr_buffer[i] = xtArr_buffer[i]
 *         xtArr_buffer[i] = temp
 */
    if (unlikely(__pyx_v_temp_xtArr_buffer == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 191, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_temp_xtArr_buffer, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_temp, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":192
 *         # swap MemoryPointer in xtArr_buffer
 *         temp = temp_xtArr_buffer[i]
 *         temp_xtArr_buffer[i] = xtArr_buffer[i]             # <<<<<<<<<<<<<<
 *         xtArr_buffer[i] = temp
 * 
 */
    if (unlikely(__pyx_v_xtArr_buffer == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 192, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_xtArr_buffer, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_temp_xtArr_buffer == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 192, __pyx_L1_error)
    }
    if (unlikely(__Pyx_SetItemInt(__pyx_v_temp_xtArr_buffer, __pyx_v_i, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 192, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":193
 *         temp = temp_xtArr_buffer[i]
 *         temp_xtArr_buffer[i] = xtArr_buffer[i]
 *         xtArr_buffer[i] = temp             # <<<<<<<<<<<<<<
 * 
 *         # swap pointer in xtArr
 */
    if (unlikely(__pyx_v_xtArr_buffer == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 193, __pyx_L1_error)
    }
    if (unlikely(__Pyx_SetItemInt(__pyx_v_xtArr_buffer, __pyx_v_i, __pyx_v_temp, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 193, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":196
 * 
 *         # swap pointer in xtArr
 *         arr.descriptor.data[i] = temp_arr.descriptor.data[i]             # <<<<<<<<<<<<<<
 *         assert arr.descriptor.size[i] == temp_arr.descriptor.size[i]
 *         temp_arr.descriptor.data[i] = NULL
 */
    (__pyx_v_arr->descriptor->data[__pyx_v_i]) = (__pyx_v_temp_arr->descriptor->data[__pyx_v_i]);

    /* "cupy/cuda/cufft.pyx":197
 *         # swap pointer in xtArr
 *         arr.descriptor.data[i] = temp_arr.descriptor.data[i]
 *         assert arr.descriptor.size[i] == temp_arr.descriptor.size[i]             # <<<<<<<<<<<<<<
 *         temp_arr.descriptor.data[i] = NULL
 *         temp_arr.descriptor.size[i] = 0
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!(((__pyx_v_arr->descriptor->size[__pyx_v_i]) == (__pyx_v_temp_arr->descriptor->size[__pyx_v_i])) != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 197, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/cuda/cufft.pyx":198
 *         arr.descriptor.data[i] = temp_arr.descriptor.data[i]
 *         assert arr.descriptor.size[i] == temp_arr.descriptor.size[i]
 *         temp_arr.descriptor.data[i] = NULL             # <<<<<<<<<<<<<<
 *         temp_arr.descriptor.size[i] = 0
 * 
 */
    (__pyx_v_temp_arr->descriptor->data[__pyx_v_i]) = NULL;

    /* "cupy/cuda/cufft.pyx":199
 *         assert arr.descriptor.size[i] == temp_arr.descriptor.size[i]
 *         temp_arr.descriptor.data[i] = NULL
 *         temp_arr.descriptor.size[i] = 0             # <<<<<<<<<<<<<<
 * 
 *     # temp_xtArr now points to the old data, which is now in temp_xtArr_buffer
 */
    (__pyx_v_temp_arr->descriptor->size[__pyx_v_i]) = 0;
  }

  /* "cupy/cuda/cufft.pyx":203
 *     # temp_xtArr now points to the old data, which is now in temp_xtArr_buffer
 *     # and will be deallocated after this line (out of scope)
 *     _XtFree(temp_xtArr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft__XtFree(__pyx_v_temp_xtArr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":160
 * # left in the GPU memory in a permutation of the natural output", see
 * # https://docs.nvidia.com/cuda/cufft/index.html#multiple-GPU-cufft-intermediate-helper  # NOQA
 * cdef _reorder_buffers(Handle plan, intptr_t xtArr, list xtArr_buffer):             # <<<<<<<<<<<<<<
 *     cdef int i, result, nGPUs
 *     cdef intptr_t temp_xtArr
 */

  /* 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.cuda.cufft._reorder_buffers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gpus);
  __Pyx_XDECREF(__pyx_v_sizes);
  __Pyx_XDECREF(__pyx_v_temp_xtArr_buffer);
  __Pyx_XDECREF(__pyx_v_temp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":209
 * # uncessary memory usage, and 2. use CuPy's memory pool.
 * # This is meant to replace cufftXtMalloc().
 * cdef _XtMalloc(list gpus, list sizes, XtSubFormat fmt):             # <<<<<<<<<<<<<<
 *     cdef XtArrayDesc* xtArr_desc
 *     cdef XtArray* xtArr
 */

static PyObject *__pyx_f_4cupy_4cuda_5cufft__XtMalloc(PyObject *__pyx_v_gpus, PyObject *__pyx_v_sizes, cufftXtSubFormat __pyx_v_fmt) {
  cudaXtDesc *__pyx_v_xtArr_desc;
  cudaLibXtDesc *__pyx_v_xtArr;
  PyObject *__pyx_v_xtArr_buffer = 0;
  int __pyx_v_i;
  int __pyx_v_nGPUs;
  size_t __pyx_v_size;
  PyObject *__pyx_v_gpu = NULL;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_buf = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  size_t __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;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  __Pyx_RefNannySetupContext("_XtMalloc", 0);

  /* "cupy/cuda/cufft.pyx":212
 *     cdef XtArrayDesc* xtArr_desc
 *     cdef XtArray* xtArr
 *     cdef list xtArr_buffer = []             # <<<<<<<<<<<<<<
 *     cdef int i, nGPUs
 *     cdef size_t size
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_xtArr_buffer = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":216
 *     cdef size_t size
 * 
 *     assert len(gpus) == len(sizes)             # <<<<<<<<<<<<<<
 *     nGPUs = len(gpus)
 *     xtArr_desc = <XtArrayDesc*>PyMem_Malloc(sizeof(XtArrayDesc))
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(__pyx_v_gpus == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 216, __pyx_L1_error)
    }
    __pyx_t_2 = PyList_GET_SIZE(__pyx_v_gpus); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 216, __pyx_L1_error)
    if (unlikely(__pyx_v_sizes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      __PYX_ERR(0, 216, __pyx_L1_error)
    }
    __pyx_t_3 = PyList_GET_SIZE(__pyx_v_sizes); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 216, __pyx_L1_error)
    if (unlikely(!((__pyx_t_2 == __pyx_t_3) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 216, __pyx_L1_error)
    }
  }
  #endif

  /* "cupy/cuda/cufft.pyx":217
 * 
 *     assert len(gpus) == len(sizes)
 *     nGPUs = len(gpus)             # <<<<<<<<<<<<<<
 *     xtArr_desc = <XtArrayDesc*>PyMem_Malloc(sizeof(XtArrayDesc))
 *     xtArr = <XtArray*>PyMem_Malloc(sizeof(XtArray))
 */
  if (unlikely(__pyx_v_gpus == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(0, 217, __pyx_L1_error)
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_v_gpus); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 217, __pyx_L1_error)
  __pyx_v_nGPUs = __pyx_t_3;

  /* "cupy/cuda/cufft.pyx":218
 *     assert len(gpus) == len(sizes)
 *     nGPUs = len(gpus)
 *     xtArr_desc = <XtArrayDesc*>PyMem_Malloc(sizeof(XtArrayDesc))             # <<<<<<<<<<<<<<
 *     xtArr = <XtArray*>PyMem_Malloc(sizeof(XtArray))
 *     c_memset(xtArr_desc, 0, sizeof(XtArrayDesc))
 */
  __pyx_v_xtArr_desc = ((cudaXtDesc *)PyMem_Malloc((sizeof(cudaXtDesc))));

  /* "cupy/cuda/cufft.pyx":219
 *     nGPUs = len(gpus)
 *     xtArr_desc = <XtArrayDesc*>PyMem_Malloc(sizeof(XtArrayDesc))
 *     xtArr = <XtArray*>PyMem_Malloc(sizeof(XtArray))             # <<<<<<<<<<<<<<
 *     c_memset(xtArr_desc, 0, sizeof(XtArrayDesc))
 *     c_memset(xtArr, 0, sizeof(XtArray))
 */
  __pyx_v_xtArr = ((cudaLibXtDesc *)PyMem_Malloc((sizeof(cudaLibXtDesc))));

  /* "cupy/cuda/cufft.pyx":220
 *     xtArr_desc = <XtArrayDesc*>PyMem_Malloc(sizeof(XtArrayDesc))
 *     xtArr = <XtArray*>PyMem_Malloc(sizeof(XtArray))
 *     c_memset(xtArr_desc, 0, sizeof(XtArrayDesc))             # <<<<<<<<<<<<<<
 *     c_memset(xtArr, 0, sizeof(XtArray))
 * 
 */
  (void)(memset(__pyx_v_xtArr_desc, 0, (sizeof(cudaXtDesc))));

  /* "cupy/cuda/cufft.pyx":221
 *     xtArr = <XtArray*>PyMem_Malloc(sizeof(XtArray))
 *     c_memset(xtArr_desc, 0, sizeof(XtArrayDesc))
 *     c_memset(xtArr, 0, sizeof(XtArray))             # <<<<<<<<<<<<<<
 * 
 *     xtArr_desc.nGPUs = nGPUs
 */
  (void)(memset(__pyx_v_xtArr, 0, (sizeof(cudaLibXtDesc))));

  /* "cupy/cuda/cufft.pyx":223
 *     c_memset(xtArr, 0, sizeof(XtArray))
 * 
 *     xtArr_desc.nGPUs = nGPUs             # <<<<<<<<<<<<<<
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):
 *         with Device(gpu):
 */
  __pyx_v_xtArr_desc->nGPUs = __pyx_v_nGPUs;

  /* "cupy/cuda/cufft.pyx":224
 * 
 *     xtArr_desc.nGPUs = nGPUs
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):             # <<<<<<<<<<<<<<
 *         with Device(gpu):
 *             buf = memory.alloc(size)
 */
  __pyx_t_4 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_gpus);
  __Pyx_GIVEREF(__pyx_v_gpus);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_gpus);
  __Pyx_INCREF(__pyx_v_sizes);
  __Pyx_GIVEREF(__pyx_v_sizes);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_sizes);
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 224, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 224, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 224, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      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, 224, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 224, __pyx_L1_error)
      __pyx_t_10 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 224, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __pyx_t_11 = __Pyx_PyInt_As_size_t(__pyx_t_8); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_gpu, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_v_size = __pyx_t_11;
    __pyx_v_i = __pyx_t_4;
    __pyx_t_4 = (__pyx_t_4 + 1);

    /* "cupy/cuda/cufft.pyx":225
 *     xtArr_desc.nGPUs = nGPUs
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):
 *         with Device(gpu):             # <<<<<<<<<<<<<<
 *             buf = memory.alloc(size)
 *         assert gpu == buf.device_id
 */
    /*with:*/ {
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_Device); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_gpu); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 225, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_gpu};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 225, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_v_gpu};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 225, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_5);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 225, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
          __Pyx_INCREF(__pyx_v_gpu);
          __Pyx_GIVEREF(__pyx_v_gpu);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_gpu);
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 225, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 225, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 225, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 225, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 225, __pyx_L7_error)
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          /*try:*/ {

            /* "cupy/cuda/cufft.pyx":226
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):
 *         with Device(gpu):
 *             buf = memory.alloc(size)             # <<<<<<<<<<<<<<
 *         assert gpu == buf.device_id
 *         xtArr_buffer.append(buf)
 */
            __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 226, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 226, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF_SET(__pyx_v_buf, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_8));
            __pyx_t_8 = 0;

            /* "cupy/cuda/cufft.pyx":225
 *     xtArr_desc.nGPUs = nGPUs
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):
 *         with Device(gpu):             # <<<<<<<<<<<<<<
 *             buf = memory.alloc(size)
 *         assert gpu == buf.device_id
 */
          }
          __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;
          goto __pyx_L20_try_end;
          __pyx_L13_error:;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.cuda.cufft._XtMalloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_5, &__pyx_t_9) < 0) __PYX_ERR(0, 225, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_7 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 225, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_7, NULL);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 225, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            if (__pyx_t_17 < 0) __PYX_ERR(0, 225, __pyx_L15_except_error)
            __pyx_t_18 = ((!(__pyx_t_17 != 0)) != 0);
            if (__pyx_t_18) {
              __Pyx_GIVEREF(__pyx_t_8);
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_XGIVEREF(__pyx_t_9);
              __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_5, __pyx_t_9);
              __pyx_t_8 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; 
              __PYX_ERR(0, 225, __pyx_L15_except_error)
            }
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L14_exception_handled;
          }
          __pyx_L15_except_error:;
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          goto __pyx_L1_error;
          __pyx_L14_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          __pyx_L20_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_12) {
            __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple_, NULL);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 225, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
      goto __pyx_L24;
      __pyx_L7_error:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L1_error;
      __pyx_L24:;
    }

    /* "cupy/cuda/cufft.pyx":227
 *         with Device(gpu):
 *             buf = memory.alloc(size)
 *         assert gpu == buf.device_id             # <<<<<<<<<<<<<<
 *         xtArr_buffer.append(buf)
 *         xtArr_desc.GPUs[i] = gpu
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      if (unlikely(!__pyx_v_buf)) { __Pyx_RaiseUnboundLocalError("buf"); __PYX_ERR(0, 227, __pyx_L1_error) }
      __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_buf->device_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_gpu, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 227, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_18)) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 227, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/cuda/cufft.pyx":228
 *             buf = memory.alloc(size)
 *         assert gpu == buf.device_id
 *         xtArr_buffer.append(buf)             # <<<<<<<<<<<<<<
 *         xtArr_desc.GPUs[i] = gpu
 *         xtArr_desc.data[i] = <void*>buf.ptr
 */
    if (unlikely(!__pyx_v_buf)) { __Pyx_RaiseUnboundLocalError("buf"); __PYX_ERR(0, 228, __pyx_L1_error) }
    __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_xtArr_buffer, ((PyObject *)__pyx_v_buf)); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 228, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":229
 *         assert gpu == buf.device_id
 *         xtArr_buffer.append(buf)
 *         xtArr_desc.GPUs[i] = gpu             # <<<<<<<<<<<<<<
 *         xtArr_desc.data[i] = <void*>buf.ptr
 *         xtArr_desc.size[i] = size
 */
    __pyx_t_20 = __Pyx_PyInt_As_int(__pyx_v_gpu); if (unlikely((__pyx_t_20 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 229, __pyx_L1_error)
    (__pyx_v_xtArr_desc->GPUs[__pyx_v_i]) = __pyx_t_20;

    /* "cupy/cuda/cufft.pyx":230
 *         xtArr_buffer.append(buf)
 *         xtArr_desc.GPUs[i] = gpu
 *         xtArr_desc.data[i] = <void*>buf.ptr             # <<<<<<<<<<<<<<
 *         xtArr_desc.size[i] = size
 * 
 */
    if (unlikely(!__pyx_v_buf)) { __Pyx_RaiseUnboundLocalError("buf"); __PYX_ERR(0, 230, __pyx_L1_error) }
    (__pyx_v_xtArr_desc->data[__pyx_v_i]) = ((void *)__pyx_v_buf->ptr);

    /* "cupy/cuda/cufft.pyx":231
 *         xtArr_desc.GPUs[i] = gpu
 *         xtArr_desc.data[i] = <void*>buf.ptr
 *         xtArr_desc.size[i] = size             # <<<<<<<<<<<<<<
 * 
 *     xtArr.descriptor = xtArr_desc
 */
    (__pyx_v_xtArr_desc->size[__pyx_v_i]) = __pyx_v_size;

    /* "cupy/cuda/cufft.pyx":224
 * 
 *     xtArr_desc.nGPUs = nGPUs
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):             # <<<<<<<<<<<<<<
 *         with Device(gpu):
 *             buf = memory.alloc(size)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":233
 *         xtArr_desc.size[i] = size
 * 
 *     xtArr.descriptor = xtArr_desc             # <<<<<<<<<<<<<<
 *     xtArr.subFormat = fmt
 * 
 */
  __pyx_v_xtArr->descriptor = __pyx_v_xtArr_desc;

  /* "cupy/cuda/cufft.pyx":234
 * 
 *     xtArr.descriptor = xtArr_desc
 *     xtArr.subFormat = fmt             # <<<<<<<<<<<<<<
 * 
 *     return <intptr_t>xtArr, xtArr_buffer
 */
  __pyx_v_xtArr->subFormat = __pyx_v_fmt;

  /* "cupy/cuda/cufft.pyx":236
 *     xtArr.subFormat = fmt
 * 
 *     return <intptr_t>xtArr, xtArr_buffer             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(((intptr_t)__pyx_v_xtArr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 236, __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_xtArr_buffer);
  __Pyx_GIVEREF(__pyx_v_xtArr_buffer);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_xtArr_buffer);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":209
 * # uncessary memory usage, and 2. use CuPy's memory pool.
 * # This is meant to replace cufftXtMalloc().
 * cdef _XtMalloc(list gpus, list sizes, XtSubFormat fmt):             # <<<<<<<<<<<<<<
 *     cdef XtArrayDesc* xtArr_desc
 *     cdef XtArray* xtArr
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cuda.cufft._XtMalloc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_xtArr_buffer);
  __Pyx_XDECREF(__pyx_v_gpu);
  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":242
 * # We only free the C structs. The underlying GPU buffers are deallocated when
 * # going out of scope.
 * cdef _XtFree(intptr_t ptr):             # <<<<<<<<<<<<<<
 *     cdef XtArray* xtArr = <XtArray*>ptr
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor
 */

static PyObject *__pyx_f_4cupy_4cuda_5cufft__XtFree(intptr_t __pyx_v_ptr) {
  cudaLibXtDesc *__pyx_v_xtArr;
  cudaXtDesc *__pyx_v_xtArr_desc;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  cudaXtDesc *__pyx_t_1;
  __Pyx_RefNannySetupContext("_XtFree", 0);

  /* "cupy/cuda/cufft.pyx":243
 * # going out of scope.
 * cdef _XtFree(intptr_t ptr):
 *     cdef XtArray* xtArr = <XtArray*>ptr             # <<<<<<<<<<<<<<
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor
 *     PyMem_Free(xtArr_desc)
 */
  __pyx_v_xtArr = ((cudaLibXtDesc *)__pyx_v_ptr);

  /* "cupy/cuda/cufft.pyx":244
 * cdef _XtFree(intptr_t ptr):
 *     cdef XtArray* xtArr = <XtArray*>ptr
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor             # <<<<<<<<<<<<<<
 *     PyMem_Free(xtArr_desc)
 *     PyMem_Free(xtArr)
 */
  __pyx_t_1 = __pyx_v_xtArr->descriptor;
  __pyx_v_xtArr_desc = __pyx_t_1;

  /* "cupy/cuda/cufft.pyx":245
 *     cdef XtArray* xtArr = <XtArray*>ptr
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor
 *     PyMem_Free(xtArr_desc)             # <<<<<<<<<<<<<<
 *     PyMem_Free(xtArr)
 * 
 */
  PyMem_Free(__pyx_v_xtArr_desc);

  /* "cupy/cuda/cufft.pyx":246
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor
 *     PyMem_Free(xtArr_desc)
 *     PyMem_Free(xtArr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  PyMem_Free(__pyx_v_xtArr);

  /* "cupy/cuda/cufft.pyx":242
 * # We only free the C structs. The underlying GPU buffers are deallocated when
 * # going out of scope.
 * cdef _XtFree(intptr_t ptr):             # <<<<<<<<<<<<<<
 *     cdef XtArray* xtArr = <XtArray*>ptr
 *     cdef XtArrayDesc* xtArr_desc = xtArr.descriptor
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":250
 * 
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,             # <<<<<<<<<<<<<<
 *                  devices=None, out=None):
 *         cdef Handle plan
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d___init__[] = "Plan1d.__init__(self, int nx, int fft_type, int batch, *, devices=None, out=None)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d___init__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  int __pyx_v_nx;
  int __pyx_v_fft_type;
  int __pyx_v_batch;
  PyObject *__pyx_v_devices = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_nx,&__pyx_n_s_fft_type,&__pyx_n_s_batch,&__pyx_n_s_devices,&__pyx_n_s_out,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "cupy/cuda/cufft.pyx":251
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,
 *                  devices=None, out=None):             # <<<<<<<<<<<<<<
 *         cdef Handle plan
 *         cdef bint use_multi_gpus = 0 if devices is None else 1
 */
    values[4] = ((PyObject *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  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_self)) != 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_nx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); __PYX_ERR(0, 250, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fft_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); __PYX_ERR(0, 250, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_batch)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); __PYX_ERR(0, 250, __pyx_L3_error)
        }
      }
      if (kw_args > 0 && likely(kw_args <= 2)) {
        Py_ssize_t index;
        for (index = 4; index < 6 && 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, "__init__") < 0)) __PYX_ERR(0, 250, __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_self = values[0];
    __pyx_v_nx = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 250, __pyx_L3_error)
    __pyx_v_fft_type = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_fft_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 250, __pyx_L3_error)
    __pyx_v_batch = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_batch == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 250, __pyx_L3_error)
    __pyx_v_devices = values[4];
    __pyx_v_out = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 250, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d___init__(__pyx_self, __pyx_v_self, __pyx_v_nx, __pyx_v_fft_type, __pyx_v_batch, __pyx_v_devices, __pyx_v_out);

  /* "cupy/cuda/cufft.pyx":250
 * 
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,             # <<<<<<<<<<<<<<
 *                  devices=None, out=None):
 *         cdef Handle plan
 */

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_devices, PyObject *__pyx_v_out) {
  cufftHandle __pyx_v_plan;
  int __pyx_v_use_multi_gpus;
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cuda/cufft.pyx":253
 *                  devices=None, out=None):
 *         cdef Handle plan
 *         cdef bint use_multi_gpus = 0 if devices is None else 1             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_2 = (__pyx_v_devices == Py_None);
  if ((__pyx_t_2 != 0)) {
    __pyx_t_1 = 0;
  } else {
    __pyx_t_1 = 1;
  }
  __pyx_v_use_multi_gpus = __pyx_t_1;

  /* "cupy/cuda/cufft.pyx":255
 *         cdef bint use_multi_gpus = 0 if devices is None else 1
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftCreate(&plan)
 *             if result == 0:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":256
 * 
 *         with nogil:
 *             result = cufftCreate(&plan)             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)
 */
        __pyx_v_result = cufftCreate((&__pyx_v_plan));

        /* "cupy/cuda/cufft.pyx":257
 *         with nogil:
 *             result = cufftCreate(&plan)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftSetAutoAllocation(plan, 0)
 *         check_result(result)
 */
        __pyx_t_1 = ((__pyx_v_result == 0) != 0);
        if (__pyx_t_1) {

          /* "cupy/cuda/cufft.pyx":258
 *             result = cufftCreate(&plan)
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
          __pyx_v_result = cufftSetAutoAllocation(__pyx_v_plan, 0);

          /* "cupy/cuda/cufft.pyx":257
 *         with nogil:
 *             result = cufftCreate(&plan)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftSetAutoAllocation(plan, 0)
 *         check_result(result)
 */
        }
      }

      /* "cupy/cuda/cufft.pyx":255
 *         cdef bint use_multi_gpus = 0 if devices is None else 1
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftCreate(&plan)
 *             if result == 0:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":259
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         # set plan, work_area, gpus, streams, and events
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":262
 * 
 *         # set plan, work_area, gpus, streams, and events
 *         if not use_multi_gpus:             # <<<<<<<<<<<<<<
 *             self._single_gpu_get_plan(plan, nx, fft_type, batch)
 *         else:
 */
  __pyx_t_1 = ((!(__pyx_v_use_multi_gpus != 0)) != 0);
  if (__pyx_t_1) {

    /* "cupy/cuda/cufft.pyx":263
 *         # set plan, work_area, gpus, streams, and events
 *         if not use_multi_gpus:
 *             self._single_gpu_get_plan(plan, nx, fft_type, batch)             # <<<<<<<<<<<<<<
 *         else:
 *             self._multi_gpu_get_plan(plan, nx, fft_type, batch, devices, out)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_single_gpu_get_plan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyInt_From_cufftHandle(__pyx_v_plan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_fft_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_batch); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __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;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 4+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __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;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(4+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_8);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":262
 * 
 *         # set plan, work_area, gpus, streams, and events
 *         if not use_multi_gpus:             # <<<<<<<<<<<<<<
 *             self._single_gpu_get_plan(plan, nx, fft_type, batch)
 *         else:
 */
    goto __pyx_L7;
  }

  /* "cupy/cuda/cufft.pyx":265
 *             self._single_gpu_get_plan(plan, nx, fft_type, batch)
 *         else:
 *             self._multi_gpu_get_plan(plan, nx, fft_type, batch, devices, out)             # <<<<<<<<<<<<<<
 * 
 *         self.nx = nx
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_multi_gpu_get_plan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = __Pyx_PyInt_From_cufftHandle(__pyx_v_plan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_fft_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_batch); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 265, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    __pyx_t_10 = 0;
    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_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[7] = {__pyx_t_5, __pyx_t_11, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_devices, __pyx_v_out};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[7] = {__pyx_t_5, __pyx_t_11, __pyx_t_8, __pyx_t_7, __pyx_t_6, __pyx_v_devices, __pyx_v_out};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 6+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 265, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_10, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_devices);
      __Pyx_GIVEREF(__pyx_v_devices);
      PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_10, __pyx_v_devices);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_9, 5+__pyx_t_10, __pyx_v_out);
      __pyx_t_11 = 0;
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L7:;

  /* "cupy/cuda/cufft.pyx":267
 *             self._multi_gpu_get_plan(plan, nx, fft_type, batch, devices, out)
 * 
 *         self.nx = nx             # <<<<<<<<<<<<<<
 *         self.fft_type = fft_type
 *         self.batch = batch
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_nx, __pyx_t_3) < 0) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":268
 * 
 *         self.nx = nx
 *         self.fft_type = fft_type             # <<<<<<<<<<<<<<
 *         self.batch = batch
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_fft_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_fft_type, __pyx_t_3) < 0) __PYX_ERR(0, 268, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":269
 *         self.nx = nx
 *         self.fft_type = fft_type
 *         self.batch = batch             # <<<<<<<<<<<<<<
 * 
 *         self._use_multi_gpus = use_multi_gpus
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_batch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_batch, __pyx_t_3) < 0) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":271
 *         self.batch = batch
 * 
 *         self._use_multi_gpus = use_multi_gpus             # <<<<<<<<<<<<<<
 *         self.batch_share = None
 *         self.xtArr = <intptr_t>0  # pointer to metadata for multi-GPU buffer
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_use_multi_gpus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_use_multi_gpus, __pyx_t_3) < 0) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":272
 * 
 *         self._use_multi_gpus = use_multi_gpus
 *         self.batch_share = None             # <<<<<<<<<<<<<<
 *         self.xtArr = <intptr_t>0  # pointer to metadata for multi-GPU buffer
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_batch_share, Py_None) < 0) __PYX_ERR(0, 272, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":273
 *         self._use_multi_gpus = use_multi_gpus
 *         self.batch_share = None
 *         self.xtArr = <intptr_t>0  # pointer to metadata for multi-GPU buffer             # <<<<<<<<<<<<<<
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 * 
 */
  __pyx_t_3 = PyInt_FromSsize_t(((intptr_t)0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_xtArr, __pyx_t_3) < 0) __PYX_ERR(0, 273, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":274
 *         self.batch_share = None
 *         self.xtArr = <intptr_t>0  # pointer to metadata for multi-GPU buffer
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer             # <<<<<<<<<<<<<<
 * 
 *     def _single_gpu_get_plan(self, Handle plan, int nx, int fft_type,
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_xtArr_buffer, Py_None) < 0) __PYX_ERR(0, 274, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":250
 * 
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,             # <<<<<<<<<<<<<<
 *                  devices=None, out=None):
 *         cdef Handle plan
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":276
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 * 
 *     def _single_gpu_get_plan(self, Handle plan, int nx, int fft_type,             # <<<<<<<<<<<<<<
 *                              int batch):
 *         cdef int result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_3_single_gpu_get_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_2_single_gpu_get_plan[] = "Plan1d._single_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_3_single_gpu_get_plan = {"_single_gpu_get_plan", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_3_single_gpu_get_plan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_2_single_gpu_get_plan};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_3_single_gpu_get_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  cufftHandle __pyx_v_plan;
  int __pyx_v_nx;
  int __pyx_v_fft_type;
  int __pyx_v_batch;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_single_gpu_get_plan (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_plan,&__pyx_n_s_nx,&__pyx_n_s_fft_type,&__pyx_n_s_batch,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_self)) != 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_plan)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_get_plan", 1, 5, 5, 1); __PYX_ERR(0, 276, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_get_plan", 1, 5, 5, 2); __PYX_ERR(0, 276, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fft_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_get_plan", 1, 5, 5, 3); __PYX_ERR(0, 276, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_batch)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_get_plan", 1, 5, 5, 4); __PYX_ERR(0, 276, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_single_gpu_get_plan") < 0)) __PYX_ERR(0, 276, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_self = values[0];
    __pyx_v_plan = __Pyx_PyInt_As_cufftHandle(values[1]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
    __pyx_v_nx = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
    __pyx_v_fft_type = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_fft_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L3_error)
    __pyx_v_batch = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_batch == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 277, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_single_gpu_get_plan", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 276, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._single_gpu_get_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_2_single_gpu_get_plan(__pyx_self, __pyx_v_self, __pyx_v_plan, __pyx_v_nx, __pyx_v_fft_type, __pyx_v_batch);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_2_single_gpu_get_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, cufftHandle __pyx_v_plan, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch) {
  int __pyx_v_result;
  size_t __pyx_v_work_size;
  intptr_t __pyx_v_ptr;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_work_area = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  intptr_t __pyx_t_6;
  __Pyx_RefNannySetupContext("_single_gpu_get_plan", 0);

  /* "cupy/cuda/cufft.pyx":282
 *         cdef intptr_t ptr
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                      &work_size)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":283
 * 
 *         with nogil:
 *             result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,             # <<<<<<<<<<<<<<
 *                                      &work_size)
 * 
 */
        __pyx_v_result = cufftMakePlan1d(__pyx_v_plan, __pyx_v_nx, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, (&__pyx_v_work_size));
      }

      /* "cupy/cuda/cufft.pyx":282
 *         cdef intptr_t ptr
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                      &work_size)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":288
 *         # cufftMakePlan1d uses large memory when nx has large divisor.
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  __pyx_t_1 = ((__pyx_v_result == 2) != 0);
  if (__pyx_t_1) {

    /* "cupy/cuda/cufft.pyx":289
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_get_default_memory_pool); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_free_all_blocks); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 289, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":290
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          &work_size)
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "cupy/cuda/cufft.pyx":291
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,             # <<<<<<<<<<<<<<
 *                                          &work_size)
 * 
 */
          __pyx_v_result = cufftMakePlan1d(__pyx_v_plan, __pyx_v_nx, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, (&__pyx_v_work_size));
        }

        /* "cupy/cuda/cufft.pyx":290
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          &work_size)
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L9;
          }
          __pyx_L9:;
        }
    }

    /* "cupy/cuda/cufft.pyx":288
 *         # cufftMakePlan1d uses large memory when nx has large divisor.
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  }

  /* "cupy/cuda/cufft.pyx":294
 *                                          &work_size)
 * 
 *         check_result(result)             # <<<<<<<<<<<<<<
 *         work_area = memory.alloc(work_size)
 *         ptr = work_area.ptr
 */
  __pyx_t_2 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cuda/cufft.pyx":295
 * 
 *         check_result(result)
 *         work_area = memory.alloc(work_size)             # <<<<<<<<<<<<<<
 *         ptr = work_area.ptr
 *         with nogil:
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_work_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_2, 0)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_work_area = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "cupy/cuda/cufft.pyx":296
 *         check_result(result)
 *         work_area = memory.alloc(work_size)
 *         ptr = work_area.ptr             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void*>(ptr))
 */
  __pyx_t_6 = __pyx_v_work_area->ptr;
  __pyx_v_ptr = __pyx_t_6;

  /* "cupy/cuda/cufft.pyx":297
 *         work_area = memory.alloc(work_size)
 *         ptr = work_area.ptr
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetWorkArea(plan, <void*>(ptr))
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":298
 *         ptr = work_area.ptr
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void*>(ptr))             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftSetWorkArea(__pyx_v_plan, ((void *)__pyx_v_ptr));
      }

      /* "cupy/cuda/cufft.pyx":297
 *         work_area = memory.alloc(work_size)
 *         ptr = work_area.ptr
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetWorkArea(plan, <void*>(ptr))
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
  }

  /* "cupy/cuda/cufft.pyx":299
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void*>(ptr))
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         self.plan = plan
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cuda/cufft.pyx":301
 *         check_result(result)
 * 
 *         self.plan = plan             # <<<<<<<<<<<<<<
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = None
 */
  __pyx_t_5 = __Pyx_PyInt_From_cufftHandle(__pyx_v_plan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_plan, __pyx_t_5) < 0) __PYX_ERR(0, 301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cuda/cufft.pyx":302
 * 
 *         self.plan = plan
 *         self.work_area = work_area  # this is for cuFFT plan             # <<<<<<<<<<<<<<
 *         self.gpus = None
 *         self.streams = None
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_work_area, ((PyObject *)__pyx_v_work_area)) < 0) __PYX_ERR(0, 302, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":303
 *         self.plan = plan
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = None             # <<<<<<<<<<<<<<
 *         self.streams = None
 *         self.events = None
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_gpus, Py_None) < 0) __PYX_ERR(0, 303, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":304
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = None
 *         self.streams = None             # <<<<<<<<<<<<<<
 *         self.events = None
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_streams, Py_None) < 0) __PYX_ERR(0, 304, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":305
 *         self.gpus = None
 *         self.streams = None
 *         self.events = None             # <<<<<<<<<<<<<<
 * 
 *     def _multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch,
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_events, Py_None) < 0) __PYX_ERR(0, 305, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":276
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 * 
 *     def _single_gpu_get_plan(self, Handle plan, int nx, int fft_type,             # <<<<<<<<<<<<<<
 *                              int batch):
 *         cdef int result
 */

  /* 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_AddTraceback("cupy.cuda.cufft.Plan1d._single_gpu_get_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_work_area);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":307
 *         self.events = None
 * 
 *     def _multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch,             # <<<<<<<<<<<<<<
 *                             devices, out):
 *         cdef int nGPUs, min_len, result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_5_multi_gpu_get_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_4_multi_gpu_get_plan[] = "Plan1d._multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch, devices, out)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_5_multi_gpu_get_plan = {"_multi_gpu_get_plan", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_5_multi_gpu_get_plan, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_4_multi_gpu_get_plan};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_5_multi_gpu_get_plan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  cufftHandle __pyx_v_plan;
  int __pyx_v_nx;
  int __pyx_v_fft_type;
  int __pyx_v_batch;
  PyObject *__pyx_v_devices = 0;
  CYTHON_UNUSED PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_multi_gpu_get_plan (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_plan,&__pyx_n_s_nx,&__pyx_n_s_fft_type,&__pyx_n_s_batch,&__pyx_n_s_devices,&__pyx_n_s_out,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_self)) != 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_plan)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 1); __PYX_ERR(0, 307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nx)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 2); __PYX_ERR(0, 307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fft_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 3); __PYX_ERR(0, 307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_batch)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 4); __PYX_ERR(0, 307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_devices)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 5); __PYX_ERR(0, 307, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, 6); __PYX_ERR(0, 307, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_multi_gpu_get_plan") < 0)) __PYX_ERR(0, 307, __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_self = values[0];
    __pyx_v_plan = __Pyx_PyInt_As_cufftHandle(values[1]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L3_error)
    __pyx_v_nx = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_nx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L3_error)
    __pyx_v_fft_type = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_fft_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L3_error)
    __pyx_v_batch = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_batch == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 307, __pyx_L3_error)
    __pyx_v_devices = values[5];
    __pyx_v_out = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_multi_gpu_get_plan", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_get_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_4_multi_gpu_get_plan(__pyx_self, __pyx_v_self, __pyx_v_plan, __pyx_v_nx, __pyx_v_fft_type, __pyx_v_batch, __pyx_v_devices, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_4_multi_gpu_get_plan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, cufftHandle __pyx_v_plan, int __pyx_v_nx, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_devices, CYTHON_UNUSED PyObject *__pyx_v_out) {
  int __pyx_v_nGPUs;
  int __pyx_v_min_len;
  int __pyx_v_result;
  std::vector<int>  __pyx_v_gpus;
  std::vector<size_t>  __pyx_v_work_size;
  PyObject *__pyx_v_work_area = 0;
  PyObject *__pyx_v_streams = 0;
  PyObject *__pyx_v_events = 0;
  std::vector<void *>  __pyx_v_work_area_ptr;
  int __pyx_v_i;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_buf = NULL;
  PyObject *__pyx_v_stream = NULL;
  PyObject *__pyx_v_event = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  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;
  int __pyx_t_20;
  __Pyx_RefNannySetupContext("_multi_gpu_get_plan", 0);

  /* "cupy/cuda/cufft.pyx":312
 *         cdef vector.vector[int] gpus
 *         cdef vector.vector[size_t] work_size
 *         cdef list work_area = []             # <<<<<<<<<<<<<<
 *         cdef list streams = []
 *         cdef list events = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_work_area = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":313
 *         cdef vector.vector[size_t] work_size
 *         cdef list work_area = []
 *         cdef list streams = []             # <<<<<<<<<<<<<<
 *         cdef list events = []
 *         cdef vector.vector[void*] work_area_ptr
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_streams = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":314
 *         cdef list work_area = []
 *         cdef list streams = []
 *         cdef list events = []             # <<<<<<<<<<<<<<
 *         cdef vector.vector[void*] work_area_ptr
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_events = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":318
 * 
 *         # some sanity checks
 *         if fft_type != CUFFT_C2C and fft_type != CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'
 *                              ' supported.')
 */
  switch (__pyx_v_fft_type) {
    case __pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C:
    case __pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z:
    __pyx_t_2 = 0;
    break;
    default:
    __pyx_t_2 = 1;
    break;
  }
  if (unlikely(__pyx_t_2)) {

    /* "cupy/cuda/cufft.pyx":319
 *         # some sanity checks
 *         if fft_type != CUFFT_C2C and fft_type != CUFFT_Z2Z:
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'             # <<<<<<<<<<<<<<
 *                              ' supported.')
 *         if isinstance(devices, list):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 319, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":318
 * 
 *         # some sanity checks
 *         if fft_type != CUFFT_C2C and fft_type != CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'
 *                              ' supported.')
 */
  }

  /* "cupy/cuda/cufft.pyx":321
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'
 *                              ' supported.')
 *         if isinstance(devices, list):             # <<<<<<<<<<<<<<
 *             nGPUs = len(devices)
 *             for i in range(nGPUs):
 */
  __pyx_t_2 = PyList_Check(__pyx_v_devices); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cupy/cuda/cufft.pyx":322
 *                              ' supported.')
 *         if isinstance(devices, list):
 *             nGPUs = len(devices)             # <<<<<<<<<<<<<<
 *             for i in range(nGPUs):
 *                 gpus.push_back(devices[i])
 */
    __pyx_t_4 = PyObject_Length(__pyx_v_devices); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 322, __pyx_L1_error)
    __pyx_v_nGPUs = __pyx_t_4;

    /* "cupy/cuda/cufft.pyx":323
 *         if isinstance(devices, list):
 *             nGPUs = len(devices)
 *             for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *                 gpus.push_back(devices[i])
 *         elif isinstance(devices, int):
 */
    __pyx_t_5 = __pyx_v_nGPUs;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "cupy/cuda/cufft.pyx":324
 *             nGPUs = len(devices)
 *             for i in range(nGPUs):
 *                 gpus.push_back(devices[i])             # <<<<<<<<<<<<<<
 *         elif isinstance(devices, int):
 *             nGPUs = devices
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_devices, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 324, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      try {
        __pyx_v_gpus.push_back(__pyx_t_8);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 324, __pyx_L1_error)
      }
    }

    /* "cupy/cuda/cufft.pyx":321
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'
 *                              ' supported.')
 *         if isinstance(devices, list):             # <<<<<<<<<<<<<<
 *             nGPUs = len(devices)
 *             for i in range(nGPUs):
 */
    goto __pyx_L4;
  }

  /* "cupy/cuda/cufft.pyx":325
 *             for i in range(nGPUs):
 *                 gpus.push_back(devices[i])
 *         elif isinstance(devices, int):             # <<<<<<<<<<<<<<
 *             nGPUs = devices
 *             for i in range(nGPUs):
 */
  __pyx_t_3 = PyInt_Check(__pyx_v_devices); 
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (likely(__pyx_t_2)) {

    /* "cupy/cuda/cufft.pyx":326
 *                 gpus.push_back(devices[i])
 *         elif isinstance(devices, int):
 *             nGPUs = devices             # <<<<<<<<<<<<<<
 *             for i in range(nGPUs):
 *                 gpus.push_back(i)
 */
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_devices); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 326, __pyx_L1_error)
    __pyx_v_nGPUs = __pyx_t_5;

    /* "cupy/cuda/cufft.pyx":327
 *         elif isinstance(devices, int):
 *             nGPUs = devices
 *             for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *                 gpus.push_back(i)
 *         else:
 */
    __pyx_t_5 = __pyx_v_nGPUs;
    __pyx_t_6 = __pyx_t_5;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "cupy/cuda/cufft.pyx":328
 *             nGPUs = devices
 *             for i in range(nGPUs):
 *                 gpus.push_back(i)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError('\"devices\" should be an int or a list of int.')
 */
      try {
        __pyx_v_gpus.push_back(__pyx_v_i);
      } catch(...) {
        __Pyx_CppExn2PyErr();
        __PYX_ERR(0, 328, __pyx_L1_error)
      }
    }

    /* "cupy/cuda/cufft.pyx":325
 *             for i in range(nGPUs):
 *                 gpus.push_back(devices[i])
 *         elif isinstance(devices, int):             # <<<<<<<<<<<<<<
 *             nGPUs = devices
 *             for i in range(nGPUs):
 */
    goto __pyx_L4;
  }

  /* "cupy/cuda/cufft.pyx":330
 *                 gpus.push_back(i)
 *         else:
 *             raise ValueError('\"devices\" should be an int or a list of int.')             # <<<<<<<<<<<<<<
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 330, __pyx_L1_error)
  }
  __pyx_L4:;

  /* "cupy/cuda/cufft.pyx":331
 *         else:
 *             raise ValueError('\"devices\" should be an int or a list of int.')
 *         if batch == 1:             # <<<<<<<<<<<<<<
 *             if (nx & (nx - 1)) != 0:
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 */
  __pyx_t_2 = ((__pyx_v_batch == 1) != 0);
  if (__pyx_t_2) {

    /* "cupy/cuda/cufft.pyx":332
 *             raise ValueError('\"devices\" should be an int or a list of int.')
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 *                                  'size must be a power of 2.')
 */
    __pyx_t_2 = (((__pyx_v_nx & (__pyx_v_nx - 1)) != 0) != 0);
    if (unlikely(__pyx_t_2)) {

      /* "cupy/cuda/cufft.pyx":333
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '             # <<<<<<<<<<<<<<
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 333, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":332
 *             raise ValueError('\"devices\" should be an int or a list of int.')
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 *                                  'size must be a power of 2.')
 */
    }

    /* "cupy/cuda/cufft.pyx":335
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):             # <<<<<<<<<<<<<<
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'
 *                                  ' of devices must be 2, 4, 8, or 16.')
 */
    switch (__pyx_v_nGPUs) {
      case 2:
      case 4:
      case 8:
      case 16:
      __pyx_t_2 = 0;
      break;
      default:
      __pyx_t_2 = 1;
      break;
    }
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/cuda/cufft.pyx":336
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'             # <<<<<<<<<<<<<<
 *                                  ' of devices must be 2, 4, 8, or 16.')
 *             if nGPUs in (2, 4):
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 336, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":335
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):             # <<<<<<<<<<<<<<
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'
 *                                  ' of devices must be 2, 4, 8, or 16.')
 */
    }

    /* "cupy/cuda/cufft.pyx":338
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'
 *                                  ' of devices must be 2, 4, 8, or 16.')
 *             if nGPUs in (2, 4):             # <<<<<<<<<<<<<<
 *                 min_len = 64
 *             elif nGPUs == 8:
 */
    switch (__pyx_v_nGPUs) {
      case 2:
      case 4:

      /* "cupy/cuda/cufft.pyx":339
 *                                  ' of devices must be 2, 4, 8, or 16.')
 *             if nGPUs in (2, 4):
 *                 min_len = 64             # <<<<<<<<<<<<<<
 *             elif nGPUs == 8:
 *                 min_len = 128
 */
      __pyx_v_min_len = 64;

      /* "cupy/cuda/cufft.pyx":338
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'
 *                                  ' of devices must be 2, 4, 8, or 16.')
 *             if nGPUs in (2, 4):             # <<<<<<<<<<<<<<
 *                 min_len = 64
 *             elif nGPUs == 8:
 */
      break;

      /* "cupy/cuda/cufft.pyx":340
 *             if nGPUs in (2, 4):
 *                 min_len = 64
 *             elif nGPUs == 8:             # <<<<<<<<<<<<<<
 *                 min_len = 128
 *             else:  # nGPU = 16
 */
      case 8:

      /* "cupy/cuda/cufft.pyx":341
 *                 min_len = 64
 *             elif nGPUs == 8:
 *                 min_len = 128             # <<<<<<<<<<<<<<
 *             else:  # nGPU = 16
 *                 min_len = 1024
 */
      __pyx_v_min_len = 0x80;

      /* "cupy/cuda/cufft.pyx":340
 *             if nGPUs in (2, 4):
 *                 min_len = 64
 *             elif nGPUs == 8:             # <<<<<<<<<<<<<<
 *                 min_len = 128
 *             else:  # nGPU = 16
 */
      break;
      default:

      /* "cupy/cuda/cufft.pyx":343
 *                 min_len = 128
 *             else:  # nGPU = 16
 *                 min_len = 1024             # <<<<<<<<<<<<<<
 *             if nx < min_len:
 *                 raise ValueError('For {} GPUs, the array length must be at '
 */
      __pyx_v_min_len = 0x400;
      break;
    }

    /* "cupy/cuda/cufft.pyx":344
 *             else:  # nGPU = 16
 *                 min_len = 1024
 *             if nx < min_len:             # <<<<<<<<<<<<<<
 *                 raise ValueError('For {} GPUs, the array length must be at '
 *                                  'least {} (you have {}).'
 */
    __pyx_t_3 = ((__pyx_v_nx < __pyx_v_min_len) != 0);
    if (unlikely(__pyx_t_3)) {

      /* "cupy/cuda/cufft.pyx":347
 *                 raise ValueError('For {} GPUs, the array length must be at '
 *                                  'least {} (you have {}).'
 *                                  .format(nGPUs, min_len, nx))             # <<<<<<<<<<<<<<
 *         work_size.resize(nGPUs)
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_For_GPUs_the_array_length_must_b, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_nGPUs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_min_len); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_nx); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 347, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_10, __pyx_t_11, __pyx_t_12};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_10, __pyx_t_11, __pyx_t_12};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_14 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 347, __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_10);
        PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_5, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_5, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_5, __pyx_t_12);
        __pyx_t_10 = 0;
        __pyx_t_11 = 0;
        __pyx_t_12 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cupy/cuda/cufft.pyx":345
 *                 min_len = 1024
 *             if nx < min_len:
 *                 raise ValueError('For {} GPUs, the array length must be at '             # <<<<<<<<<<<<<<
 *                                  'least {} (you have {}).'
 *                                  .format(nGPUs, min_len, nx))
 */
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 345, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 345, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":344
 *             else:  # nGPU = 16
 *                 min_len = 1024
 *             if nx < min_len:             # <<<<<<<<<<<<<<
 *                 raise ValueError('For {} GPUs, the array length must be at '
 *                                  'least {} (you have {}).'
 */
    }

    /* "cupy/cuda/cufft.pyx":331
 *         else:
 *             raise ValueError('\"devices\" should be an int or a list of int.')
 *         if batch == 1:             # <<<<<<<<<<<<<<
 *             if (nx & (nx - 1)) != 0:
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '
 */
  }

  /* "cupy/cuda/cufft.pyx":348
 *                                  'least {} (you have {}).'
 *                                  .format(nGPUs, min_len, nx))
 *         work_size.resize(nGPUs)             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  try {
    __pyx_v_work_size.resize(__pyx_v_nGPUs);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 348, __pyx_L1_error)
  }

  /* "cupy/cuda/cufft.pyx":350
 *         work_size.resize(nGPUs)
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())
 *             if result == 0:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":351
 * 
 *         with nogil:
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 */
        __pyx_v_result = cufftXtSetGPUs(__pyx_v_plan, __pyx_v_nGPUs, __pyx_v_gpus.data());

        /* "cupy/cuda/cufft.pyx":352
 *         with nogil:
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          work_size.data())
 */
        __pyx_t_3 = ((__pyx_v_result == 0) != 0);
        if (__pyx_t_3) {

          /* "cupy/cuda/cufft.pyx":353
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())
 *             if result == 0:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,             # <<<<<<<<<<<<<<
 *                                          work_size.data())
 * 
 */
          __pyx_v_result = cufftMakePlan1d(__pyx_v_plan, __pyx_v_nx, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, __pyx_v_work_size.data());

          /* "cupy/cuda/cufft.pyx":352
 *         with nogil:
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          work_size.data())
 */
        }
      }

      /* "cupy/cuda/cufft.pyx":350
 *         work_size.resize(nGPUs)
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftXtSetGPUs(plan, nGPUs, gpus.data())
 *             if result == 0:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L15;
        }
        __pyx_L15:;
      }
  }

  /* "cupy/cuda/cufft.pyx":358
 *         # cufftMakePlan1d uses large memory when nx has large divisor.
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  __pyx_t_3 = ((__pyx_v_result == 2) != 0);
  if (__pyx_t_3) {

    /* "cupy/cuda/cufft.pyx":359
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 */
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_get_default_memory_pool); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (__pyx_t_14) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 359, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_free_all_blocks); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 359, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 359, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 359, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cupy/cuda/cufft.pyx":360
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          work_size.data())
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "cupy/cuda/cufft.pyx":361
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,             # <<<<<<<<<<<<<<
 *                                          work_size.data())
 *         check_result(result)
 */
          __pyx_v_result = cufftMakePlan1d(__pyx_v_plan, __pyx_v_nx, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, __pyx_v_work_size.data());
        }

        /* "cupy/cuda/cufft.pyx":360
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          work_size.data())
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L20;
          }
          __pyx_L20:;
        }
    }

    /* "cupy/cuda/cufft.pyx":358
 *         # cufftMakePlan1d uses large memory when nx has large divisor.
 *         # See https://github.com/cupy/cupy/issues/1063
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  }

  /* "cupy/cuda/cufft.pyx":363
 *                 result = cufftMakePlan1d(plan, nx, <Type>fft_type, batch,
 *                                          work_size.data())
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(nGPUs):
 */
  __pyx_t_9 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/cuda/cufft.pyx":365
 *         check_result(result)
 * 
 *         for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *             with Device(gpus[i]):
 *                 buf = memory.alloc(work_size[i])
 */
  __pyx_t_5 = __pyx_v_nGPUs;
  __pyx_t_6 = __pyx_t_5;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "cupy/cuda/cufft.pyx":366
 * 
 *         for i in range(nGPUs):
 *             with Device(gpus[i]):             # <<<<<<<<<<<<<<
 *                 buf = memory.alloc(work_size[i])
 *                 stream = Stream()
 */
    /*with:*/ {
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_Device); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_gpus[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_14 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_14) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_1};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_1};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 366, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_14); __pyx_t_14 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_exit); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_enter); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 366, __pyx_L23_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (__pyx_t_1) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 366, __pyx_L23_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 366, __pyx_L23_error)
      }
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      /*try:*/ {
        {
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          /*try:*/ {

            /* "cupy/cuda/cufft.pyx":367
 *         for i in range(nGPUs):
 *             with Device(gpus[i]):
 *                 buf = memory.alloc(work_size[i])             # <<<<<<<<<<<<<<
 *                 stream = Stream()
 *                 event = Event()
 */
            __pyx_t_9 = __Pyx_PyInt_FromSize_t((__pyx_v_work_size[__pyx_v_i])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 367, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_12 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_9, 0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 367, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF_SET(__pyx_v_buf, ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_12));
            __pyx_t_12 = 0;

            /* "cupy/cuda/cufft.pyx":368
 *             with Device(gpus[i]):
 *                 buf = memory.alloc(work_size[i])
 *                 stream = Stream()             # <<<<<<<<<<<<<<
 *                 event = Event()
 *             work_area.append(buf)
 */
            __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_Stream); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 368, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_11 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
              }
            }
            if (__pyx_t_11) {
              __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 368, __pyx_L29_error)
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            } else {
              __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 368, __pyx_L29_error)
            }
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF_SET(__pyx_v_stream, __pyx_t_12);
            __pyx_t_12 = 0;

            /* "cupy/cuda/cufft.pyx":369
 *                 buf = memory.alloc(work_size[i])
 *                 stream = Stream()
 *                 event = Event()             # <<<<<<<<<<<<<<
 *             work_area.append(buf)
 *             streams.append(stream)
 */
            __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_Event); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 369, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_11 = NULL;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
              }
            }
            if (__pyx_t_11) {
              __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 369, __pyx_L29_error)
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            } else {
              __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 369, __pyx_L29_error)
            }
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF_SET(__pyx_v_event, __pyx_t_12);
            __pyx_t_12 = 0;

            /* "cupy/cuda/cufft.pyx":366
 * 
 *         for i in range(nGPUs):
 *             with Device(gpus[i]):             # <<<<<<<<<<<<<<
 *                 buf = memory.alloc(work_size[i])
 *                 stream = Stream()
 */
          }
          __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;
          goto __pyx_L36_try_end;
          __pyx_L29_error:;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          /*except:*/ {
            __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_get_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_9, &__pyx_t_11) < 0) __PYX_ERR(0, 366, __pyx_L31_except_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_1 = PyTuple_Pack(3, __pyx_t_12, __pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L31_except_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_1, NULL);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 366, __pyx_L31_except_error)
            __Pyx_GOTREF(__pyx_t_19);
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (__pyx_t_3 < 0) __PYX_ERR(0, 366, __pyx_L31_except_error)
            __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
            if (__pyx_t_2) {
              __Pyx_GIVEREF(__pyx_t_12);
              __Pyx_GIVEREF(__pyx_t_9);
              __Pyx_XGIVEREF(__pyx_t_11);
              __Pyx_ErrRestoreWithState(__pyx_t_12, __pyx_t_9, __pyx_t_11);
              __pyx_t_12 = 0; __pyx_t_9 = 0; __pyx_t_11 = 0; 
              __PYX_ERR(0, 366, __pyx_L31_except_error)
            }
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            goto __pyx_L30_exception_handled;
          }
          __pyx_L31_except_error:;
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          goto __pyx_L1_error;
          __pyx_L30_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          __pyx_L36_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_15) {
            __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_tuple__6, NULL);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 366, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          }
          goto __pyx_L28;
        }
        __pyx_L28:;
      }
      goto __pyx_L40;
      __pyx_L23_error:;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      goto __pyx_L1_error;
      __pyx_L40:;
    }

    /* "cupy/cuda/cufft.pyx":370
 *                 stream = Stream()
 *                 event = Event()
 *             work_area.append(buf)             # <<<<<<<<<<<<<<
 *             streams.append(stream)
 *             events.append(event)
 */
    if (unlikely(!__pyx_v_buf)) { __Pyx_RaiseUnboundLocalError("buf"); __PYX_ERR(0, 370, __pyx_L1_error) }
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_work_area, ((PyObject *)__pyx_v_buf)); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 370, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":371
 *                 event = Event()
 *             work_area.append(buf)
 *             streams.append(stream)             # <<<<<<<<<<<<<<
 *             events.append(event)
 *             work_area_ptr.push_back(<void*>buf.ptr)
 */
    if (unlikely(!__pyx_v_stream)) { __Pyx_RaiseUnboundLocalError("stream"); __PYX_ERR(0, 371, __pyx_L1_error) }
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_streams, __pyx_v_stream); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 371, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":372
 *             work_area.append(buf)
 *             streams.append(stream)
 *             events.append(event)             # <<<<<<<<<<<<<<
 *             work_area_ptr.push_back(<void*>buf.ptr)
 *         with nogil:
 */
    if (unlikely(!__pyx_v_event)) { __Pyx_RaiseUnboundLocalError("event"); __PYX_ERR(0, 372, __pyx_L1_error) }
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_events, __pyx_v_event); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 372, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":373
 *             streams.append(stream)
 *             events.append(event)
 *             work_area_ptr.push_back(<void*>buf.ptr)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = cufftXtSetWorkArea(plan, work_area_ptr.data())
 */
    if (unlikely(!__pyx_v_buf)) { __Pyx_RaiseUnboundLocalError("buf"); __PYX_ERR(0, 373, __pyx_L1_error) }
    try {
      __pyx_v_work_area_ptr.push_back(((void *)__pyx_v_buf->ptr));
    } catch(...) {
      __Pyx_CppExn2PyErr();
      __PYX_ERR(0, 373, __pyx_L1_error)
    }
  }

  /* "cupy/cuda/cufft.pyx":374
 *             events.append(event)
 *             work_area_ptr.push_back(<void*>buf.ptr)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftXtSetWorkArea(plan, work_area_ptr.data())
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":375
 *             work_area_ptr.push_back(<void*>buf.ptr)
 *         with nogil:
 *             result = cufftXtSetWorkArea(plan, work_area_ptr.data())             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftXtSetWorkArea(__pyx_v_plan, __pyx_v_work_area_ptr.data());
      }

      /* "cupy/cuda/cufft.pyx":374
 *             events.append(event)
 *             work_area_ptr.push_back(<void*>buf.ptr)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftXtSetWorkArea(plan, work_area_ptr.data())
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L43;
        }
        __pyx_L43:;
      }
  }

  /* "cupy/cuda/cufft.pyx":376
 *         with nogil:
 *             result = cufftXtSetWorkArea(plan, work_area_ptr.data())
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         self.plan = plan
 */
  __pyx_t_11 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/cuda/cufft.pyx":378
 *         check_result(result)
 * 
 *         self.plan = plan             # <<<<<<<<<<<<<<
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = list(gpus)
 */
  __pyx_t_11 = __Pyx_PyInt_From_cufftHandle(__pyx_v_plan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_plan, __pyx_t_11) < 0) __PYX_ERR(0, 378, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cupy/cuda/cufft.pyx":379
 * 
 *         self.plan = plan
 *         self.work_area = work_area  # this is for cuFFT plan             # <<<<<<<<<<<<<<
 *         self.gpus = list(gpus)
 *         self.streams = streams      # for async, overlapped copies
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_work_area, __pyx_v_work_area) < 0) __PYX_ERR(0, 379, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":380
 *         self.plan = plan
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = list(gpus)             # <<<<<<<<<<<<<<
 *         self.streams = streams      # for async, overlapped copies
 *         self.events = events        # for async, overlapped copies
 */
  __pyx_t_11 = __pyx_convert_vector_to_py_int(__pyx_v_gpus); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = PySequence_List(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_gpus, __pyx_t_9) < 0) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cupy/cuda/cufft.pyx":381
 *         self.work_area = work_area  # this is for cuFFT plan
 *         self.gpus = list(gpus)
 *         self.streams = streams      # for async, overlapped copies             # <<<<<<<<<<<<<<
 *         self.events = events        # for async, overlapped copies
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_streams, __pyx_v_streams) < 0) __PYX_ERR(0, 381, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":382
 *         self.gpus = list(gpus)
 *         self.streams = streams      # for async, overlapped copies
 *         self.events = events        # for async, overlapped copies             # <<<<<<<<<<<<<<
 * 
 *     def __del__(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_events, __pyx_v_events) < 0) __PYX_ERR(0, 382, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":307
 *         self.events = None
 * 
 *     def _multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch,             # <<<<<<<<<<<<<<
 *                             devices, out):
 *         cdef int nGPUs, min_len, result
 */

  /* 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_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_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_get_plan", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_work_area);
  __Pyx_XDECREF(__pyx_v_streams);
  __Pyx_XDECREF(__pyx_v_events);
  __Pyx_XDECREF((PyObject *)__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_event);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":384
 *         self.events = events        # for async, overlapped copies
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef int dev = runtime.getDevice()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_7__del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_6__del__[] = "Plan1d.__del__(self)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_7__del__ = {"__del__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_7__del__, METH_O, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_6__del__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_7__del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_6__del__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_6__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  cufftHandle __pyx_v_plan;
  int __pyx_v_dev;
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cufftHandle __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  intptr_t __pyx_t_6;
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "cupy/cuda/cufft.pyx":385
 * 
 *     def __del__(self):
 *         cdef Handle plan = self.plan             # <<<<<<<<<<<<<<
 *         cdef int dev = runtime.getDevice()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_2 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plan = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":386
 *     def __del__(self):
 *         cdef Handle plan = self.plan
 *         cdef int dev = runtime.getDevice()             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_3 = __pyx_f_4cupy_4cuda_7runtime_getDevice(0); if (unlikely(__pyx_t_3 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 386, __pyx_L1_error)
  __pyx_v_dev = __pyx_t_3;

  /* "cupy/cuda/cufft.pyx":388
 *         cdef int dev = runtime.getDevice()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftDestroy(plan)
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":389
 * 
 *         with nogil:
 *             result = cufftDestroy(plan)             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftDestroy(__pyx_v_plan);
      }

      /* "cupy/cuda/cufft.pyx":388
 *         cdef int dev = runtime.getDevice()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftDestroy(plan)
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":390
 *         with nogil:
 *             result = cufftDestroy(plan)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         # cuFFT bug: after cufftDestroy(), the current device is mistakenly
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":396
 *         # https://github.com/cupy/cupy/pull/2644#discussion_r347567899 and
 *         # NVIDIA internal ticket 2761341.
 *         runtime.setDevice(dev)             # <<<<<<<<<<<<<<
 * 
 *         if self.xtArr != 0:
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_7runtime_setDevice(__pyx_v_dev, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":398
 *         runtime.setDevice(dev)
 * 
 *         if self.xtArr != 0:             # <<<<<<<<<<<<<<
 *             _XtFree(self.xtArr)
 *             self.xtArr = 0
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":399
 * 
 *         if self.xtArr != 0:
 *             _XtFree(self.xtArr)             # <<<<<<<<<<<<<<
 *             self.xtArr = 0
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft__XtFree(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":400
 *         if self.xtArr != 0:
 *             _XtFree(self.xtArr)
 *             self.xtArr = 0             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_xtArr, __pyx_int_0) < 0) __PYX_ERR(0, 400, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":398
 *         runtime.setDevice(dev)
 * 
 *         if self.xtArr != 0:             # <<<<<<<<<<<<<<
 *             _XtFree(self.xtArr)
 *             self.xtArr = 0
 */
  }

  /* "cupy/cuda/cufft.pyx":384
 *         self.events = events        # for async, overlapped copies
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef int dev = runtime.getDevice()
 */

  /* 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_AddTraceback("cupy.cuda.cufft.Plan1d.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":402
 *             self.xtArr = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_9__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_8__enter__[] = "Plan1d.__enter__(self)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_9__enter__ = {"__enter__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_9__enter__, METH_O, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_8__enter__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_9__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_8__enter__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_8__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "cupy/cuda/cufft.pyx":403
 * 
 *     def __enter__(self):
 *         _thread_local._current_plan = self             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan, __pyx_v_self) < 0) __PYX_ERR(0, 403, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":404
 *     def __enter__(self):
 *         _thread_local._current_plan = self
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":402
 *             self.xtArr = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":406
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_11__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_10__exit__[] = "Plan1d.__exit__(self, exc_type, exc_value, traceback)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_11__exit__ = {"__exit__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_11__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_10__exit__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_11__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_type = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_value = 0;
  CYTHON_UNUSED PyObject *__pyx_v_traceback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_exc_type,&__pyx_n_s_exc_value,&__pyx_n_s_traceback,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_self)) != 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_exc_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 1); __PYX_ERR(0, 406, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exc_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 2); __PYX_ERR(0, 406, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_traceback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 3); __PYX_ERR(0, 406, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 406, __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_self = values[0];
    __pyx_v_exc_type = values[1];
    __pyx_v_exc_value = values[2];
    __pyx_v_traceback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 406, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_10__exit__(__pyx_self, __pyx_v_self, __pyx_v_exc_type, __pyx_v_exc_value, __pyx_v_traceback);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_10__exit__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_value, CYTHON_UNUSED PyObject *__pyx_v_traceback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "cupy/cuda/cufft.pyx":407
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):
 *         _thread_local._current_plan = None             # <<<<<<<<<<<<<<
 * 
 *     def fft(self, a, out, direction):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan, Py_None) < 0) __PYX_ERR(0, 407, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":406
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":409
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         if self._use_multi_gpus:
 *             # Note: mult-GPU plans cannot set stream
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_13fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_12fft[] = "Plan1d.fft(self, a, out, direction)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_13fft = {"fft", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_13fft, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_12fft};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_13fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_direction = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fft (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,&__pyx_n_s_direction,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 1); __PYX_ERR(0, 409, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 2); __PYX_ERR(0, 409, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 3); __PYX_ERR(0, 409, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fft") < 0)) __PYX_ERR(0, 409, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
    __pyx_v_direction = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 409, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_12fft(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_12fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("fft", 0);

  /* "cupy/cuda/cufft.pyx":410
 * 
 *     def fft(self, a, out, direction):
 *         if self._use_multi_gpus:             # <<<<<<<<<<<<<<
 *             # Note: mult-GPU plans cannot set stream
 *             self._multi_gpu_fft(a, out, direction)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_use_multi_gpus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cupy/cuda/cufft.pyx":412
 *         if self._use_multi_gpus:
 *             # Note: mult-GPU plans cannot set stream
 *             self._multi_gpu_fft(a, out, direction)             # <<<<<<<<<<<<<<
 *         else:
 *             self._single_gpu_fft(a, out, direction)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_multi_gpu_fft); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_a, __pyx_v_out, __pyx_v_direction};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_a, __pyx_v_out, __pyx_v_direction};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_a);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_direction);
      __Pyx_GIVEREF(__pyx_v_direction);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_direction);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":410
 * 
 *     def fft(self, a, out, direction):
 *         if self._use_multi_gpus:             # <<<<<<<<<<<<<<
 *             # Note: mult-GPU plans cannot set stream
 *             self._multi_gpu_fft(a, out, direction)
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":414
 *             self._multi_gpu_fft(a, out, direction)
 *         else:
 *             self._single_gpu_fft(a, out, direction)             # <<<<<<<<<<<<<<
 * 
 *     def _single_gpu_fft(self, a, out, direction):
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_single_gpu_fft); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_a, __pyx_v_out, __pyx_v_direction};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_a, __pyx_v_out, __pyx_v_direction};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_a);
      __Pyx_INCREF(__pyx_v_out);
      __Pyx_GIVEREF(__pyx_v_out);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_out);
      __Pyx_INCREF(__pyx_v_direction);
      __Pyx_GIVEREF(__pyx_v_direction);
      PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_v_direction);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":409
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         if self._use_multi_gpus:
 *             # Note: mult-GPU plans cannot set stream
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":416
 *             self._single_gpu_fft(a, out, direction)
 * 
 *     def _single_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_15_single_gpu_fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_14_single_gpu_fft[] = "Plan1d._single_gpu_fft(self, a, out, direction)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_15_single_gpu_fft = {"_single_gpu_fft", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_15_single_gpu_fft, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_14_single_gpu_fft};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_15_single_gpu_fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_direction = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_single_gpu_fft (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,&__pyx_n_s_direction,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_fft", 1, 4, 4, 1); __PYX_ERR(0, 416, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_fft", 1, 4, 4, 2); __PYX_ERR(0, 416, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_single_gpu_fft", 1, 4, 4, 3); __PYX_ERR(0, 416, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_single_gpu_fft") < 0)) __PYX_ERR(0, 416, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
    __pyx_v_direction = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_single_gpu_fft", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 416, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._single_gpu_fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_14_single_gpu_fft(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_14_single_gpu_fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_stream;
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cufftHandle __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  intptr_t __pyx_t_6;
  intptr_t __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("_single_gpu_fft", 0);

  /* "cupy/cuda/cufft.pyx":417
 * 
 *     def _single_gpu_fft(self, a, out, direction):
 *         cdef Handle plan = self.plan             # <<<<<<<<<<<<<<
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_2 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plan = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":418
 *     def _single_gpu_fft(self, a, out, direction):
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_v_stream = __pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr();

  /* "cupy/cuda/cufft.pyx":420
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":421
 * 
 *         with nogil:
 *             result = cufftSetStream(plan, <driver.Stream>stream)             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftSetStream(__pyx_v_plan, ((cudaStream_t)__pyx_v_stream));
      }

      /* "cupy/cuda/cufft.pyx":420
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":422
 *         with nogil:
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":424
 *         check_result(result)
 * 
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 424, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":425
 * 
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 425, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execC2C(__pyx_v_plan, __pyx_t_6, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":424
 *         check_result(result)
 * 
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":426
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":427
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execR2C(__pyx_v_plan, __pyx_t_7, __pyx_t_6, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":426
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":428
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":429
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execC2R(__pyx_v_plan, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 429, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":428
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":430
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 430, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":431
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execZ2Z(__pyx_v_plan, __pyx_t_7, __pyx_t_6, __pyx_t_8, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":430
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":432
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":433
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         else:
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execD2Z(__pyx_v_plan, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":432
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":435
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         else:
 *             execZ2D(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 * 
 *     def _multi_gpu_setup_buffer(self, a):
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execZ2D(__pyx_v_plan, __pyx_t_7, __pyx_t_6, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L6:;

  /* "cupy/cuda/cufft.pyx":416
 *             self._single_gpu_fft(a, out, direction)
 * 
 *     def _single_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._single_gpu_fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":437
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 * 
 *     def _multi_gpu_setup_buffer(self, a):             # <<<<<<<<<<<<<<
 *         cdef XtArrayDesc* xtArr_desc
 *         cdef XtArray* xtArr
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_17_multi_gpu_setup_buffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_16_multi_gpu_setup_buffer[] = "Plan1d._multi_gpu_setup_buffer(self, a)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_17_multi_gpu_setup_buffer = {"_multi_gpu_setup_buffer", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_17_multi_gpu_setup_buffer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_16_multi_gpu_setup_buffer};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_17_multi_gpu_setup_buffer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_multi_gpu_setup_buffer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_setup_buffer", 1, 2, 2, 1); __PYX_ERR(0, 437, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_multi_gpu_setup_buffer") < 0)) __PYX_ERR(0, 437, __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_self = values[0];
    __pyx_v_a = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_multi_gpu_setup_buffer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 437, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_setup_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_16_multi_gpu_setup_buffer(__pyx_self, __pyx_v_self, __pyx_v_a);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_16_multi_gpu_setup_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  cudaXtDesc *__pyx_v_xtArr_desc;
  cudaLibXtDesc *__pyx_v_xtArr;
  intptr_t __pyx_v_ptr;
  PyObject *__pyx_v_xtArr_buffer = 0;
  PyObject *__pyx_v_share = 0;
  PyObject *__pyx_v_sizes = 0;
  int __pyx_v_i;
  int __pyx_v_nGPUs;
  cufftXtSubFormat __pyx_v_fmt;
  int __pyx_7genexpr__pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  intptr_t __pyx_t_15;
  cudaXtDesc *__pyx_t_16;
  __Pyx_RefNannySetupContext("_multi_gpu_setup_buffer", 0);

  /* "cupy/cuda/cufft.pyx":452
 *         # TODO(leofang): revisit this when NumPy support is added
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *             if self.xtArr == 0 and self.xtArr_buffer is None:
 *                 nGPUs = len(self.gpus)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_a, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":453
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):
 *             if self.xtArr == 0 and self.xtArr_buffer is None:             # <<<<<<<<<<<<<<
 *                 nGPUs = len(self.gpus)
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (__pyx_t_1 == Py_None);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (__pyx_t_3 != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "cupy/cuda/cufft.pyx":454
 *         if isinstance(a, cupy.ndarray):
 *             if self.xtArr == 0 and self.xtArr_buffer is None:
 *                 nGPUs = len(self.gpus)             # <<<<<<<<<<<<<<
 * 
 *                 # this is the rule for distributing the workload
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_gpus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __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, 454, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_nGPUs = __pyx_t_6;

      /* "cupy/cuda/cufft.pyx":457
 * 
 *                 # this is the rule for distributing the workload
 *                 if self.batch > 1:             # <<<<<<<<<<<<<<
 *                     share = [self.batch // nGPUs] * nGPUs
 *                     for i in range(self.batch % nGPUs):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 457, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_4) {

        /* "cupy/cuda/cufft.pyx":458
 *                 # this is the rule for distributing the workload
 *                 if self.batch > 1:
 *                     share = [self.batch // nGPUs] * nGPUs             # <<<<<<<<<<<<<<
 *                     for i in range(self.batch % nGPUs):
 *                         share[i] += 1
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 458, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nGPUs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = PyNumber_FloorDivide(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 458, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyList_New(1 * ((__pyx_v_nGPUs<0) ? 0:__pyx_v_nGPUs)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < __pyx_v_nGPUs; __pyx_temp++) {
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_7);
            PyList_SET_ITEM(__pyx_t_1, __pyx_temp, __pyx_t_7);
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_share = ((PyObject*)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "cupy/cuda/cufft.pyx":459
 *                 if self.batch > 1:
 *                     share = [self.batch // nGPUs] * nGPUs
 *                     for i in range(self.batch % nGPUs):             # <<<<<<<<<<<<<<
 *                         share[i] += 1
 *                 else:
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_nGPUs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 459, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_2 = PyNumber_Remainder(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 459, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = __pyx_t_8;
        for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
          __pyx_v_i = __pyx_t_10;

          /* "cupy/cuda/cufft.pyx":460
 *                     share = [self.batch // nGPUs] * nGPUs
 *                     for i in range(self.batch % nGPUs):
 *                         share[i] += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     share = [1.0 / nGPUs] * nGPUs
 */
          __pyx_t_11 = __pyx_v_i;
          __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_share, __pyx_t_11, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 460, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 460, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(__Pyx_SetItemInt(__pyx_v_share, __pyx_t_11, __pyx_t_7, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 460, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }

        /* "cupy/cuda/cufft.pyx":457
 * 
 *                 # this is the rule for distributing the workload
 *                 if self.batch > 1:             # <<<<<<<<<<<<<<
 *                     share = [self.batch // nGPUs] * nGPUs
 *                     for i in range(self.batch % nGPUs):
 */
        goto __pyx_L7;
      }

      /* "cupy/cuda/cufft.pyx":462
 *                         share[i] += 1
 *                 else:
 *                     share = [1.0 / nGPUs] * nGPUs             # <<<<<<<<<<<<<<
 *                 sizes = [int(share[i] * self.nx * a.dtype.itemsize)
 *                          for i in range(nGPUs)]
 */
      /*else*/ {
        if (unlikely(__pyx_v_nGPUs == 0)) {
          PyErr_SetString(PyExc_ZeroDivisionError, "float division");
          __PYX_ERR(0, 462, __pyx_L1_error)
        }
        __pyx_t_7 = PyFloat_FromDouble((1.0 / ((double)__pyx_v_nGPUs))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_2 = PyList_New(1 * ((__pyx_v_nGPUs<0) ? 0:__pyx_v_nGPUs)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < __pyx_v_nGPUs; __pyx_temp++) {
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_7);
            PyList_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_t_7);
          }
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_share = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L7:;

      /* "cupy/cuda/cufft.pyx":463
 *                 else:
 *                     share = [1.0 / nGPUs] * nGPUs
 *                 sizes = [int(share[i] * self.nx * a.dtype.itemsize)             # <<<<<<<<<<<<<<
 *                          for i in range(nGPUs)]
 * 
 */
      { /* enter inner scope */
        __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);

        /* "cupy/cuda/cufft.pyx":464
 *                     share = [1.0 / nGPUs] * nGPUs
 *                 sizes = [int(share[i] * self.nx * a.dtype.itemsize)
 *                          for i in range(nGPUs)]             # <<<<<<<<<<<<<<
 * 
 *                 # get buffer
 */
        __pyx_t_10 = __pyx_v_nGPUs;
        __pyx_t_11 = __pyx_t_10;
        for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
          __pyx_7genexpr__pyx_v_i = __pyx_t_12;

          /* "cupy/cuda/cufft.pyx":463
 *                 else:
 *                     share = [1.0 / nGPUs] * nGPUs
 *                 sizes = [int(share[i] * self.nx * a.dtype.itemsize)             # <<<<<<<<<<<<<<
 *                          for i in range(nGPUs)]
 * 
 */
          __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_share, __pyx_7genexpr__pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = PyNumber_Multiply(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyNumber_Multiply(__pyx_t_13, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 463, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
      } /* exit inner scope */
      __pyx_v_sizes = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "cupy/cuda/cufft.pyx":467
 * 
 *                 # get buffer
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     fmt = CUFFT_XT_FORMAT_INPLACE
 *                 # TODO(leofang): revisit this when NumPy support is added
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = PyObject_IsInstance(__pyx_v_a, __pyx_t_7); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "cupy/cuda/cufft.pyx":468
 *                 # get buffer
 *                 if isinstance(a, cupy.ndarray):
 *                     fmt = CUFFT_XT_FORMAT_INPLACE             # <<<<<<<<<<<<<<
 *                 # TODO(leofang): revisit this when NumPy support is added
 *                 # else:  # from numpy
 */
        __pyx_v_fmt = CUFFT_XT_FORMAT_INPLACE;

        /* "cupy/cuda/cufft.pyx":467
 * 
 *                 # get buffer
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     fmt = CUFFT_XT_FORMAT_INPLACE
 *                 # TODO(leofang): revisit this when NumPy support is added
 */
      }

      /* "cupy/cuda/cufft.pyx":472
 *                 # else:  # from numpy
 *                 #     fmt = CUFFT_XT_FORMAT_1D_INPUT_SHUFFLED
 *                 ptr, xtArr_buffer = _XtMalloc(self.gpus, sizes, fmt)             # <<<<<<<<<<<<<<
 * 
 *                 xtArr = <XtArray*>ptr
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_gpus); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 472, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (!(likely(PyList_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 472, __pyx_L1_error)
      __pyx_t_2 = __pyx_f_4cupy_4cuda_5cufft__XtMalloc(((PyObject*)__pyx_t_7), __pyx_v_sizes, __pyx_v_fmt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 472, __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_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 472, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 472, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_7)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_1 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_1)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 2) < 0) __PYX_ERR(0, 472, __pyx_L1_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 472, __pyx_L1_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_t_15 = PyInt_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_15 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 472, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 472, __pyx_L1_error)
      __pyx_v_ptr = __pyx_t_15;
      __pyx_v_xtArr_buffer = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "cupy/cuda/cufft.pyx":474
 *                 ptr, xtArr_buffer = _XtMalloc(self.gpus, sizes, fmt)
 * 
 *                 xtArr = <XtArray*>ptr             # <<<<<<<<<<<<<<
 *                 xtArr_desc = xtArr.descriptor
 *                 assert xtArr_desc.nGPUs == nGPUs
 */
      __pyx_v_xtArr = ((cudaLibXtDesc *)__pyx_v_ptr);

      /* "cupy/cuda/cufft.pyx":475
 * 
 *                 xtArr = <XtArray*>ptr
 *                 xtArr_desc = xtArr.descriptor             # <<<<<<<<<<<<<<
 *                 assert xtArr_desc.nGPUs == nGPUs
 * 
 */
      __pyx_t_16 = __pyx_v_xtArr->descriptor;
      __pyx_v_xtArr_desc = __pyx_t_16;

      /* "cupy/cuda/cufft.pyx":476
 *                 xtArr = <XtArray*>ptr
 *                 xtArr_desc = xtArr.descriptor
 *                 assert xtArr_desc.nGPUs == nGPUs             # <<<<<<<<<<<<<<
 * 
 *                 self.batch_share = share
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_xtArr_desc->nGPUs == __pyx_v_nGPUs) != 0))) {
          PyErr_SetNone(PyExc_AssertionError);
          __PYX_ERR(0, 476, __pyx_L1_error)
        }
      }
      #endif

      /* "cupy/cuda/cufft.pyx":478
 *                 assert xtArr_desc.nGPUs == nGPUs
 * 
 *                 self.batch_share = share             # <<<<<<<<<<<<<<
 *                 self.xtArr = ptr
 *                 self.xtArr_buffer = xtArr_buffer  # kept to ensure lifetime
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_batch_share, __pyx_v_share) < 0) __PYX_ERR(0, 478, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":479
 * 
 *                 self.batch_share = share
 *                 self.xtArr = ptr             # <<<<<<<<<<<<<<
 *                 self.xtArr_buffer = xtArr_buffer  # kept to ensure lifetime
 *             else:
 */
      __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_xtArr, __pyx_t_2) < 0) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cupy/cuda/cufft.pyx":480
 *                 self.batch_share = share
 *                 self.xtArr = ptr
 *                 self.xtArr_buffer = xtArr_buffer  # kept to ensure lifetime             # <<<<<<<<<<<<<<
 *             else:
 *                 # After FFT the subFormat flag is silently changed to
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_xtArr_buffer, __pyx_v_xtArr_buffer) < 0) __PYX_ERR(0, 480, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":453
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):
 *             if self.xtArr == 0 and self.xtArr_buffer is None:             # <<<<<<<<<<<<<<
 *                 nGPUs = len(self.gpus)
 * 
 */
      goto __pyx_L4;
    }

    /* "cupy/cuda/cufft.pyx":486
 *                 # it, otherwise in the next run we would encounter
 *                 # CUFFT_INVALID_TYPE!
 *                 ptr = self.xtArr             # <<<<<<<<<<<<<<
 *                 xtArr = <XtArray*>ptr
 *                 if self.batch == 1:
 */
    /*else*/ {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_15 = PyInt_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_15 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_ptr = __pyx_t_15;

      /* "cupy/cuda/cufft.pyx":487
 *                 # CUFFT_INVALID_TYPE!
 *                 ptr = self.xtArr
 *                 xtArr = <XtArray*>ptr             # <<<<<<<<<<<<<<
 *                 if self.batch == 1:
 *                     if isinstance(a, cupy.ndarray):
 */
      __pyx_v_xtArr = ((cudaLibXtDesc *)__pyx_v_ptr);

      /* "cupy/cuda/cufft.pyx":488
 *                 ptr = self.xtArr
 *                 xtArr = <XtArray*>ptr
 *                 if self.batch == 1:             # <<<<<<<<<<<<<<
 *                     if isinstance(a, cupy.ndarray):
 *                         fmt = CUFFT_XT_FORMAT_INPLACE
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 488, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_5) {

        /* "cupy/cuda/cufft.pyx":489
 *                 xtArr = <XtArray*>ptr
 *                 if self.batch == 1:
 *                     if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                         fmt = CUFFT_XT_FORMAT_INPLACE
 *                     # TODO(leofang): revisit this when NumPy support is added
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 489, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 489, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = PyObject_IsInstance(__pyx_v_a, __pyx_t_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 489, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_4 = (__pyx_t_5 != 0);
        if (__pyx_t_4) {

          /* "cupy/cuda/cufft.pyx":490
 *                 if self.batch == 1:
 *                     if isinstance(a, cupy.ndarray):
 *                         fmt = CUFFT_XT_FORMAT_INPLACE             # <<<<<<<<<<<<<<
 *                     # TODO(leofang): revisit this when NumPy support is added
 *                     # else:  # from numpy
 */
          __pyx_v_fmt = CUFFT_XT_FORMAT_INPLACE;

          /* "cupy/cuda/cufft.pyx":489
 *                 xtArr = <XtArray*>ptr
 *                 if self.batch == 1:
 *                     if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                         fmt = CUFFT_XT_FORMAT_INPLACE
 *                     # TODO(leofang): revisit this when NumPy support is added
 */
        }

        /* "cupy/cuda/cufft.pyx":494
 *                     # else:  # from numpy
 *                     #     fmt = CUFFT_XT_FORMAT_1D_INPUT_SHUFFLED
 *                     xtArr.subFormat = fmt             # <<<<<<<<<<<<<<
 *         elif isinstance(a, list):
 *             # TODO(leofang): For users running Plan1d.fft() (bypassing all
 */
        __pyx_v_xtArr->subFormat = __pyx_v_fmt;

        /* "cupy/cuda/cufft.pyx":488
 *                 ptr = self.xtArr
 *                 xtArr = <XtArray*>ptr
 *                 if self.batch == 1:             # <<<<<<<<<<<<<<
 *                     if isinstance(a, cupy.ndarray):
 *                         fmt = CUFFT_XT_FORMAT_INPLACE
 */
      }
    }
    __pyx_L4:;

    /* "cupy/cuda/cufft.pyx":452
 *         # TODO(leofang): revisit this when NumPy support is added
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *             if self.xtArr == 0 and self.xtArr_buffer is None:
 *                 nGPUs = len(self.gpus)
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":495
 *                     #     fmt = CUFFT_XT_FORMAT_1D_INPUT_SHUFFLED
 *                     xtArr.subFormat = fmt
 *         elif isinstance(a, list):             # <<<<<<<<<<<<<<
 *             # TODO(leofang): For users running Plan1d.fft() (bypassing all
 *             # checks in cupy.fft.fft), they are allowed to send in a list of
 */
  __pyx_t_4 = PyList_Check(__pyx_v_a); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (unlikely(__pyx_t_5)) {

    /* "cupy/cuda/cufft.pyx":500
 *             # ndarrays, each of which is on a different GPU. Then, no data
 *             # copy is needed, just replace the pointers in the descriptor.
 *             raise NotImplementedError('User-managed buffer area is not yet '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 *         else:
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __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, 500, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":495
 *                     #     fmt = CUFFT_XT_FORMAT_1D_INPUT_SHUFFLED
 *                     xtArr.subFormat = fmt
 *         elif isinstance(a, list):             # <<<<<<<<<<<<<<
 *             # TODO(leofang): For users running Plan1d.fft() (bypassing all
 *             # checks in cupy.fft.fft), they are allowed to send in a list of
 */
  }

  /* "cupy/cuda/cufft.pyx":503
 *                                       'supported.')
 *         else:
 *             raise ValueError('Impossible to reach.')             # <<<<<<<<<<<<<<
 * 
 *     def _multi_gpu_memcpy(self, a, str action):
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __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, 503, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":437
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 * 
 *     def _multi_gpu_setup_buffer(self, a):             # <<<<<<<<<<<<<<
 *         cdef XtArrayDesc* xtArr_desc
 *         cdef XtArray* xtArr
 */

  /* 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_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_setup_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_xtArr_buffer);
  __Pyx_XDECREF(__pyx_v_share);
  __Pyx_XDECREF(__pyx_v_sizes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":505
 *             raise ValueError('Impossible to reach.')
 * 
 *     def _multi_gpu_memcpy(self, a, str action):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef list xtArr_buffer, share
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_19_multi_gpu_memcpy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_18_multi_gpu_memcpy[] = "Plan1d._multi_gpu_memcpy(self, a, unicode action)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_19_multi_gpu_memcpy = {"_multi_gpu_memcpy", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_19_multi_gpu_memcpy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_18_multi_gpu_memcpy};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_19_multi_gpu_memcpy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_action = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_multi_gpu_memcpy (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_action,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_memcpy", 1, 3, 3, 1); __PYX_ERR(0, 505, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_action)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_memcpy", 1, 3, 3, 2); __PYX_ERR(0, 505, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_multi_gpu_memcpy") < 0)) __PYX_ERR(0, 505, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_action = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_multi_gpu_memcpy", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 505, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_memcpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_action), (&PyUnicode_Type), 1, "action", 1))) __PYX_ERR(0, 505, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_18_multi_gpu_memcpy(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_action);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_18_multi_gpu_memcpy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_action) {
  cufftHandle __pyx_v_plan;
  PyObject *__pyx_v_xtArr_buffer = 0;
  PyObject *__pyx_v_share = 0;
  int __pyx_v_start;
  int __pyx_v_nGPUs;
  int __pyx_v_i;
  int __pyx_v_count;
  CYTHON_UNUSED cudaLibXtDesc *__pyx_v_arr;
  intptr_t __pyx_v_ptr;
  size_t __pyx_v_size;
  PyObject *__pyx_v_b = NULL;
  PyObject *__pyx_v_curr_stream = NULL;
  PyObject *__pyx_v_outer_stream = NULL;
  PyObject *__pyx_v_prev_event = NULL;
  PyObject *__pyx_v_curr_event = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cufftHandle __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  intptr_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  size_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  long __pyx_t_17;
  __Pyx_RefNannySetupContext("_multi_gpu_memcpy", 0);

  /* "cupy/cuda/cufft.pyx":506
 * 
 *     def _multi_gpu_memcpy(self, a, str action):
 *         cdef Handle plan = self.plan             # <<<<<<<<<<<<<<
 *         cdef list xtArr_buffer, share
 *         cdef int start, nGPUs, i, count, result
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_2 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 506, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plan = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":515
 *         # TODO(leofang): revisit this when NumPy support is added
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *             start = 0
 *             b = a.ravel()
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = PyObject_IsInstance(__pyx_v_a, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":516
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):
 *             start = 0             # <<<<<<<<<<<<<<
 *             b = a.ravel()
 *             assert b.flags['OWNDATA'] is False
 */
    __pyx_v_start = 0;

    /* "cupy/cuda/cufft.pyx":517
 *         if isinstance(a, cupy.ndarray):
 *             start = 0
 *             b = a.ravel()             # <<<<<<<<<<<<<<
 *             assert b.flags['OWNDATA'] is False
 *             assert self.xtArr_buffer is not None
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ravel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_b = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":518
 *             start = 0
 *             b = a.ravel()
 *             assert b.flags['OWNDATA'] is False             # <<<<<<<<<<<<<<
 *             assert self.xtArr_buffer is not None
 *             ptr = self.xtArr
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_n_u_OWNDATA); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = (__pyx_t_1 == Py_False);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!(__pyx_t_5 != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 518, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/cuda/cufft.pyx":519
 *             b = a.ravel()
 *             assert b.flags['OWNDATA'] is False
 *             assert self.xtArr_buffer is not None             # <<<<<<<<<<<<<<
 *             ptr = self.xtArr
 *             arr = <XtArray*>ptr
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = (__pyx_t_1 != Py_None);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!(__pyx_t_5 != 0))) {
        PyErr_SetNone(PyExc_AssertionError);
        __PYX_ERR(0, 519, __pyx_L1_error)
      }
    }
    #endif

    /* "cupy/cuda/cufft.pyx":520
 *             assert b.flags['OWNDATA'] is False
 *             assert self.xtArr_buffer is not None
 *             ptr = self.xtArr             # <<<<<<<<<<<<<<
 *             arr = <XtArray*>ptr
 *             xtArr_buffer = self.xtArr_buffer
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ptr = __pyx_t_7;

    /* "cupy/cuda/cufft.pyx":521
 *             assert self.xtArr_buffer is not None
 *             ptr = self.xtArr
 *             arr = <XtArray*>ptr             # <<<<<<<<<<<<<<
 *             xtArr_buffer = self.xtArr_buffer
 *             nGPUs = len(self.gpus)
 */
    __pyx_v_arr = ((cudaLibXtDesc *)__pyx_v_ptr);

    /* "cupy/cuda/cufft.pyx":522
 *             ptr = self.xtArr
 *             arr = <XtArray*>ptr
 *             xtArr_buffer = self.xtArr_buffer             # <<<<<<<<<<<<<<
 *             nGPUs = len(self.gpus)
 *             share = self.batch_share
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 522, __pyx_L1_error)
    __pyx_v_xtArr_buffer = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":523
 *             arr = <XtArray*>ptr
 *             xtArr_buffer = self.xtArr_buffer
 *             nGPUs = len(self.gpus)             # <<<<<<<<<<<<<<
 *             share = self.batch_share
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_gpus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_nGPUs = __pyx_t_8;

    /* "cupy/cuda/cufft.pyx":524
 *             xtArr_buffer = self.xtArr_buffer
 *             nGPUs = len(self.gpus)
 *             share = self.batch_share             # <<<<<<<<<<<<<<
 * 
 *             if action == 'scatter':
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch_share); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 524, __pyx_L1_error)
    __pyx_v_share = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":526
 *             share = self.batch_share
 * 
 *             if action == 'scatter':             # <<<<<<<<<<<<<<
 *                 if isinstance(a, cupy.ndarray):
 *                     for i in range(nGPUs):
 */
    __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_action, __pyx_n_u_scatter, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 526, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (__pyx_t_4) {

      /* "cupy/cuda/cufft.pyx":527
 * 
 *             if action == 'scatter':
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = PyObject_IsInstance(__pyx_v_a, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "cupy/cuda/cufft.pyx":528
 *             if action == 'scatter':
 *                 if isinstance(a, cupy.ndarray):
 *                     for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize
 */
        __pyx_t_9 = __pyx_v_nGPUs;
        __pyx_t_10 = __pyx_t_9;
        for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
          __pyx_v_i = __pyx_t_11;

          /* "cupy/cuda/cufft.pyx":529
 *                 if isinstance(a, cupy.ndarray):
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)             # <<<<<<<<<<<<<<
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 */
          if (unlikely(__pyx_v_share == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 529, __pyx_L1_error)
          }
          __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_share, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_count = __pyx_t_12;

          /* "cupy/cuda/cufft.pyx":530
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize             # <<<<<<<<<<<<<<
 *                         curr_stream = self.streams[i]
 *                         if i == 0:
 */
          __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_6); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 530, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_v_size = __pyx_t_13;

          /* "cupy/cuda/cufft.pyx":531
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]             # <<<<<<<<<<<<<<
 *                         if i == 0:
 *                             # When we come here, another stream could still be
 */
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_streams); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 531, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 531, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF_SET(__pyx_v_curr_stream, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "cupy/cuda/cufft.pyx":532
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 *                         if i == 0:             # <<<<<<<<<<<<<<
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 */
          __pyx_t_5 = ((__pyx_v_i == 0) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":535
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 *                             outer_stream = stream_module.get_current_stream()             # <<<<<<<<<<<<<<
 *                             outer_stream.synchronize()
 *                         xtArr_buffer[i].copy_from_device_async(
 */
            __pyx_t_3 = __pyx_f_4cupy_4cuda_6stream_get_current_stream(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_XDECREF_SET(__pyx_v_outer_stream, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "cupy/cuda/cufft.pyx":536
 *                             # copying data for us, so we wait patiently...
 *                             outer_stream = stream_module.get_current_stream()
 *                             outer_stream.synchronize()             # <<<<<<<<<<<<<<
 *                         xtArr_buffer[i].copy_from_device_async(
 *                             b[start:start+count].data, size, curr_stream)
 */
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_outer_stream, __pyx_n_s_synchronize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 536, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_1 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
              if (likely(__pyx_t_1)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_6, function);
              }
            }
            if (__pyx_t_1) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 536, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            } else {
              __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 536, __pyx_L1_error)
            }
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cupy/cuda/cufft.pyx":532
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 *                         if i == 0:             # <<<<<<<<<<<<<<
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 */
          }

          /* "cupy/cuda/cufft.pyx":537
 *                             outer_stream = stream_module.get_current_stream()
 *                             outer_stream.synchronize()
 *                         xtArr_buffer[i].copy_from_device_async(             # <<<<<<<<<<<<<<
 *                             b[start:start+count].data, size, curr_stream)
 *                         if i != 0:
 */
          if (unlikely(__pyx_v_xtArr_buffer == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 537, __pyx_L1_error)
          }
          __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_xtArr_buffer, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 537, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy_from_device_async); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "cupy/cuda/cufft.pyx":538
 *                             outer_stream.synchronize()
 *                         xtArr_buffer[i].copy_from_device_async(
 *                             b[start:start+count].data, size, curr_stream)             # <<<<<<<<<<<<<<
 *                         if i != 0:
 *                             prev_event = self.events[i-1]
 */
          __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_b, __pyx_v_start, (__pyx_v_start + __pyx_v_count), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 538, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_data); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 538, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 538, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_15 = NULL;
          __pyx_t_12 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_15)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_15);
              __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[4] = {__pyx_t_15, __pyx_t_14, __pyx_t_6, __pyx_v_curr_stream};
            __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 537, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
            PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_14, __pyx_t_6, __pyx_v_curr_stream};
            __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 537, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          {
            __pyx_t_16 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 537, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            if (__pyx_t_15) {
              __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_14);
            PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_12, __pyx_t_14);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_12, __pyx_t_6);
            __Pyx_INCREF(__pyx_v_curr_stream);
            __Pyx_GIVEREF(__pyx_v_curr_stream);
            PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_12, __pyx_v_curr_stream);
            __pyx_t_14 = 0;
            __pyx_t_6 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 537, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "cupy/cuda/cufft.pyx":539
 *                         xtArr_buffer[i].copy_from_device_async(
 *                             b[start:start+count].data, size, curr_stream)
 *                         if i != 0:             # <<<<<<<<<<<<<<
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 */
          __pyx_t_5 = ((__pyx_v_i != 0) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":540
 *                             b[start:start+count].data, size, curr_stream)
 *                         if i != 0:
 *                             prev_event = self.events[i-1]             # <<<<<<<<<<<<<<
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 540, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_17 = (__pyx_v_i - 1);
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, __pyx_t_17, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_prev_event, __pyx_t_1);
            __pyx_t_1 = 0;

            /* "cupy/cuda/cufft.pyx":541
 *                         if i != 0:
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)             # <<<<<<<<<<<<<<
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_stream, __pyx_n_s_wait_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 541, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_16 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_16)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            if (!__pyx_t_16) {
              __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_prev_event); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
            } else {
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_3)) {
                PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_prev_event};
                __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_GOTREF(__pyx_t_1);
              } else
              #endif
              #if CYTHON_FAST_PYCCALL
              if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
                PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_prev_event};
                __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_GOTREF(__pyx_t_1);
              } else
              #endif
              {
                __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 541, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_16); __pyx_t_16 = NULL;
                __Pyx_INCREF(__pyx_v_prev_event);
                __Pyx_GIVEREF(__pyx_v_prev_event);
                PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_prev_event);
                __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 541, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "cupy/cuda/cufft.pyx":539
 *                         xtArr_buffer[i].copy_from_device_async(
 *                             b[start:start+count].data, size, curr_stream)
 *                         if i != 0:             # <<<<<<<<<<<<<<
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 */
          }

          /* "cupy/cuda/cufft.pyx":542
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]             # <<<<<<<<<<<<<<
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_events); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF_SET(__pyx_v_curr_event, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "cupy/cuda/cufft.pyx":543
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)             # <<<<<<<<<<<<<<
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_event, __pyx_n_s_record); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_6)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          if (!__pyx_t_6) {
            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_curr_stream); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_1)) {
              PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_curr_stream};
              __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
              PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_curr_stream};
              __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            {
              __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 543, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_6); __pyx_t_6 = NULL;
              __Pyx_INCREF(__pyx_v_curr_stream);
              __Pyx_GIVEREF(__pyx_v_curr_stream);
              PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_v_curr_stream);
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "cupy/cuda/cufft.pyx":544
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:             # <<<<<<<<<<<<<<
 *                             curr_event.synchronize()
 *                         start += count
 */
          __pyx_t_5 = ((__pyx_v_i == (__pyx_v_nGPUs - 1)) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":545
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()             # <<<<<<<<<<<<<<
 *                         start += count
 *                     assert start == b.size
 */
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_event, __pyx_n_s_synchronize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_16 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_1);
              if (likely(__pyx_t_16)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_1, function);
              }
            }
            if (__pyx_t_16) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 545, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            } else {
              __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 545, __pyx_L1_error)
            }
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cupy/cuda/cufft.pyx":544
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:             # <<<<<<<<<<<<<<
 *                             curr_event.synchronize()
 *                         start += count
 */
          }

          /* "cupy/cuda/cufft.pyx":546
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()
 *                         start += count             # <<<<<<<<<<<<<<
 *                     assert start == b.size
 *                 # TODO(leofang): revisit this when NumPy support is added
 */
          __pyx_v_start = (__pyx_v_start + __pyx_v_count);
        }

        /* "cupy/cuda/cufft.pyx":547
 *                             curr_event.synchronize()
 *                         start += count
 *                     assert start == b.size             # <<<<<<<<<<<<<<
 *                 # TODO(leofang): revisit this when NumPy support is added
 *                 # else:  # numpy
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 547, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_16 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_16); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 547, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_16); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_5)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 547, __pyx_L1_error)
          }
        }
        #endif

        /* "cupy/cuda/cufft.pyx":527
 * 
 *             if action == 'scatter':
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)
 */
      }

      /* "cupy/cuda/cufft.pyx":526
 *             share = self.batch_share
 * 
 *             if action == 'scatter':             # <<<<<<<<<<<<<<
 *                 if isinstance(a, cupy.ndarray):
 *                     for i in range(nGPUs):
 */
      goto __pyx_L4;
    }

    /* "cupy/cuda/cufft.pyx":556
 *                 #             CUFFT_COPY_HOST_TO_DEVICE)
 *                 #     check_result(result)
 *             elif action == 'gather':             # <<<<<<<<<<<<<<
 *                 if isinstance(a, cupy.ndarray):
 *                     if self.batch == 1:
 */
    __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_action, __pyx_n_u_gather, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 556, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (likely(__pyx_t_4)) {

      /* "cupy/cuda/cufft.pyx":557
 *                 #     check_result(result)
 *             elif action == 'gather':
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     if self.batch == 1:
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)
 */
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 557, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_4 = PyObject_IsInstance(__pyx_v_a, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 557, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "cupy/cuda/cufft.pyx":558
 *             elif action == 'gather':
 *                 if isinstance(a, cupy.ndarray):
 *                     if self.batch == 1:             # <<<<<<<<<<<<<<
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)
 * 
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_batch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_16 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_16); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        if (__pyx_t_5) {

          /* "cupy/cuda/cufft.pyx":559
 *                 if isinstance(a, cupy.ndarray):
 *                     if self.batch == 1:
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)             # <<<<<<<<<<<<<<
 * 
 *                     for i in range(nGPUs):
 */
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_16); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 559, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_16 = __pyx_f_4cupy_4cuda_5cufft__reorder_buffers(__pyx_v_plan, __pyx_t_7, __pyx_v_xtArr_buffer); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "cupy/cuda/cufft.pyx":558
 *             elif action == 'gather':
 *                 if isinstance(a, cupy.ndarray):
 *                     if self.batch == 1:             # <<<<<<<<<<<<<<
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)
 * 
 */
        }

        /* "cupy/cuda/cufft.pyx":561
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)
 * 
 *                     for i in range(nGPUs):             # <<<<<<<<<<<<<<
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize
 */
        __pyx_t_9 = __pyx_v_nGPUs;
        __pyx_t_10 = __pyx_t_9;
        for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
          __pyx_v_i = __pyx_t_11;

          /* "cupy/cuda/cufft.pyx":562
 * 
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)             # <<<<<<<<<<<<<<
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 */
          if (unlikely(__pyx_v_share == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 562, __pyx_L1_error)
          }
          __pyx_t_16 = __Pyx_GetItemInt_List(__pyx_v_share, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = PyNumber_Multiply(__pyx_t_16, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 562, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_count = __pyx_t_12;

          /* "cupy/cuda/cufft.pyx":563
 *                     for i in range(nGPUs):
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize             # <<<<<<<<<<<<<<
 *                         curr_stream = self.streams[i]
 *                         if i == 0:
 */
          __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_13 = __Pyx_PyInt_As_size_t(__pyx_t_3); if (unlikely((__pyx_t_13 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 563, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_size = __pyx_t_13;

          /* "cupy/cuda/cufft.pyx":564
 *                         count = int(share[i] * self.nx)
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]             # <<<<<<<<<<<<<<
 *                         if i == 0:
 *                             # When we come here, another stream could still be
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_streams); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 564, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF_SET(__pyx_v_curr_stream, __pyx_t_16);
          __pyx_t_16 = 0;

          /* "cupy/cuda/cufft.pyx":565
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 *                         if i == 0:             # <<<<<<<<<<<<<<
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 */
          __pyx_t_5 = ((__pyx_v_i == 0) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":568
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 *                             outer_stream = stream_module.get_current_stream()             # <<<<<<<<<<<<<<
 *                             outer_stream.synchronize()
 *                         b[start:start+count].data.copy_from_device_async(
 */
            __pyx_t_16 = __pyx_f_4cupy_4cuda_6stream_get_current_stream(0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 568, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_XDECREF_SET(__pyx_v_outer_stream, __pyx_t_16);
            __pyx_t_16 = 0;

            /* "cupy/cuda/cufft.pyx":569
 *                             # copying data for us, so we wait patiently...
 *                             outer_stream = stream_module.get_current_stream()
 *                             outer_stream.synchronize()             # <<<<<<<<<<<<<<
 *                         b[start:start+count].data.copy_from_device_async(
 *                             xtArr_buffer[i], size, curr_stream)
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_outer_stream, __pyx_n_s_synchronize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_1 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_1)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            if (__pyx_t_1) {
              __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 569, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            } else {
              __pyx_t_16 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 569, __pyx_L1_error)
            }
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

            /* "cupy/cuda/cufft.pyx":565
 *                         size = count * b.dtype.itemsize
 *                         curr_stream = self.streams[i]
 *                         if i == 0:             # <<<<<<<<<<<<<<
 *                             # When we come here, another stream could still be
 *                             # copying data for us, so we wait patiently...
 */
          }

          /* "cupy/cuda/cufft.pyx":570
 *                             outer_stream = stream_module.get_current_stream()
 *                             outer_stream.synchronize()
 *                         b[start:start+count].data.copy_from_device_async(             # <<<<<<<<<<<<<<
 *                             xtArr_buffer[i], size, curr_stream)
 *                         if i != 0:
 */
          __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_b, __pyx_v_start, (__pyx_v_start + __pyx_v_count), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy_from_device_async); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "cupy/cuda/cufft.pyx":571
 *                             outer_stream.synchronize()
 *                         b[start:start+count].data.copy_from_device_async(
 *                             xtArr_buffer[i], size, curr_stream)             # <<<<<<<<<<<<<<
 *                         if i != 0:
 *                             prev_event = self.events[i-1]
 */
          if (unlikely(__pyx_v_xtArr_buffer == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 571, __pyx_L1_error)
          }
          __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_xtArr_buffer, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 571, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = __Pyx_PyInt_FromSize_t(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_14 = NULL;
          __pyx_t_12 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_14)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
              __pyx_t_12 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_t_1, __pyx_t_6, __pyx_v_curr_stream};
            __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 570, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_t_1, __pyx_t_6, __pyx_v_curr_stream};
            __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_12, 3+__pyx_t_12); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 570, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          } else
          #endif
          {
            __pyx_t_15 = PyTuple_New(3+__pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 570, __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_1);
            PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_12, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_6);
            PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_12, __pyx_t_6);
            __Pyx_INCREF(__pyx_v_curr_stream);
            __Pyx_GIVEREF(__pyx_v_curr_stream);
            PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_12, __pyx_v_curr_stream);
            __pyx_t_1 = 0;
            __pyx_t_6 = 0;
            __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 570, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "cupy/cuda/cufft.pyx":572
 *                         b[start:start+count].data.copy_from_device_async(
 *                             xtArr_buffer[i], size, curr_stream)
 *                         if i != 0:             # <<<<<<<<<<<<<<
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 */
          __pyx_t_5 = ((__pyx_v_i != 0) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":573
 *                             xtArr_buffer[i], size, curr_stream)
 *                         if i != 0:
 *                             prev_event = self.events[i-1]             # <<<<<<<<<<<<<<
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]
 */
            __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_events); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 573, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_17 = (__pyx_v_i - 1);
            __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_16, __pyx_t_17, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 573, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF_SET(__pyx_v_prev_event, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "cupy/cuda/cufft.pyx":574
 *                         if i != 0:
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)             # <<<<<<<<<<<<<<
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 */
            __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_stream, __pyx_n_s_wait_event); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 574, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_15 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16);
              if (likely(__pyx_t_15)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_16, function);
              }
            }
            if (!__pyx_t_15) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_v_prev_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
            } else {
              #if CYTHON_FAST_PYCALL
              if (PyFunction_Check(__pyx_t_16)) {
                PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_prev_event};
                __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_GOTREF(__pyx_t_3);
              } else
              #endif
              #if CYTHON_FAST_PYCCALL
              if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
                PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_v_prev_event};
                __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_GOTREF(__pyx_t_3);
              } else
              #endif
              {
                __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 574, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = NULL;
                __Pyx_INCREF(__pyx_v_prev_event);
                __Pyx_GIVEREF(__pyx_v_prev_event);
                PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_prev_event);
                __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cupy/cuda/cufft.pyx":572
 *                         b[start:start+count].data.copy_from_device_async(
 *                             xtArr_buffer[i], size, curr_stream)
 *                         if i != 0:             # <<<<<<<<<<<<<<
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 */
          }

          /* "cupy/cuda/cufft.pyx":575
 *                             prev_event = self.events[i-1]
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]             # <<<<<<<<<<<<<<
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 575, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 575, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF_SET(__pyx_v_curr_event, __pyx_t_16);
          __pyx_t_16 = 0;

          /* "cupy/cuda/cufft.pyx":576
 *                             curr_stream.wait_event(prev_event)
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)             # <<<<<<<<<<<<<<
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_event, __pyx_n_s_record); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 576, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_6 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_6)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (!__pyx_t_6) {
            __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_curr_stream); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 576, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_16);
          } else {
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_3)) {
              PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_curr_stream};
              __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 576, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_GOTREF(__pyx_t_16);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
              PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_curr_stream};
              __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 576, __pyx_L1_error)
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_GOTREF(__pyx_t_16);
            } else
            #endif
            {
              __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 576, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_6); __pyx_t_6 = NULL;
              __Pyx_INCREF(__pyx_v_curr_stream);
              __Pyx_GIVEREF(__pyx_v_curr_stream);
              PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_curr_stream);
              __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 576, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "cupy/cuda/cufft.pyx":577
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:             # <<<<<<<<<<<<<<
 *                             curr_event.synchronize()
 *                         start += count
 */
          __pyx_t_5 = ((__pyx_v_i == (__pyx_v_nGPUs - 1)) != 0);
          if (__pyx_t_5) {

            /* "cupy/cuda/cufft.pyx":578
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()             # <<<<<<<<<<<<<<
 *                         start += count
 *                     assert start == b.size
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr_event, __pyx_n_s_synchronize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 578, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_15 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_15)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            if (__pyx_t_15) {
              __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 578, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            } else {
              __pyx_t_16 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 578, __pyx_L1_error)
            }
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

            /* "cupy/cuda/cufft.pyx":577
 *                         curr_event = self.events[i]
 *                         curr_event.record(curr_stream)
 *                         if i == nGPUs - 1:             # <<<<<<<<<<<<<<
 *                             curr_event.synchronize()
 *                         start += count
 */
          }

          /* "cupy/cuda/cufft.pyx":579
 *                         if i == nGPUs - 1:
 *                             curr_event.synchronize()
 *                         start += count             # <<<<<<<<<<<<<<
 *                     assert start == b.size
 *                 # TODO(leofang): revisit this when NumPy support is added
 */
          __pyx_v_start = (__pyx_v_start + __pyx_v_count);
        }

        /* "cupy/cuda/cufft.pyx":580
 *                             curr_event.synchronize()
 *                         start += count
 *                     assert start == b.size             # <<<<<<<<<<<<<<
 *                 # TODO(leofang): revisit this when NumPy support is added
 *                 # else:  # numpy
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_b, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_15 = PyObject_RichCompare(__pyx_t_16, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_5)) {
            PyErr_SetNone(PyExc_AssertionError);
            __PYX_ERR(0, 580, __pyx_L1_error)
          }
        }
        #endif

        /* "cupy/cuda/cufft.pyx":557
 *                 #     check_result(result)
 *             elif action == 'gather':
 *                 if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *                     if self.batch == 1:
 *                         _reorder_buffers(plan, self.xtArr, xtArr_buffer)
 */
      }

      /* "cupy/cuda/cufft.pyx":556
 *                 #             CUFFT_COPY_HOST_TO_DEVICE)
 *                 #     check_result(result)
 *             elif action == 'gather':             # <<<<<<<<<<<<<<
 *                 if isinstance(a, cupy.ndarray):
 *                     if self.batch == 1:
 */
      goto __pyx_L4;
    }

    /* "cupy/cuda/cufft.pyx":590
 *                 #     check_result(result)
 *             else:
 *                 raise ValueError             # <<<<<<<<<<<<<<
 * 
 *     def _multi_gpu_fft(self, a, out, direction):
 */
    /*else*/ {
      __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
      __PYX_ERR(0, 590, __pyx_L1_error)
    }
    __pyx_L4:;

    /* "cupy/cuda/cufft.pyx":515
 *         # TODO(leofang): revisit this when NumPy support is added
 *         # if isinstance(a, cupy.ndarray) or isinstance(a, numpy.ndarray):
 *         if isinstance(a, cupy.ndarray):             # <<<<<<<<<<<<<<
 *             start = 0
 *             b = a.ravel()
 */
  }

  /* "cupy/cuda/cufft.pyx":505
 *             raise ValueError('Impossible to reach.')
 * 
 *     def _multi_gpu_memcpy(self, a, str action):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef list xtArr_buffer, share
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_memcpy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_xtArr_buffer);
  __Pyx_XDECREF(__pyx_v_share);
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XDECREF(__pyx_v_curr_stream);
  __Pyx_XDECREF(__pyx_v_outer_stream);
  __Pyx_XDECREF(__pyx_v_prev_event);
  __Pyx_XDECREF(__pyx_v_curr_event);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":592
 *                 raise ValueError
 * 
 *     def _multi_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         # When we arrive here, the normal CuPy call path ensures a and out
 *         # reside on the same GPU -> must distribute a to all of the GPUs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_21_multi_gpu_fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_20_multi_gpu_fft[] = "Plan1d._multi_gpu_fft(self, a, out, direction)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_21_multi_gpu_fft = {"_multi_gpu_fft", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_21_multi_gpu_fft, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_20_multi_gpu_fft};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_21_multi_gpu_fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_direction = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_multi_gpu_fft (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,&__pyx_n_s_direction,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_fft", 1, 4, 4, 1); __PYX_ERR(0, 592, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_fft", 1, 4, 4, 2); __PYX_ERR(0, 592, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_multi_gpu_fft", 1, 4, 4, 3); __PYX_ERR(0, 592, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_multi_gpu_fft") < 0)) __PYX_ERR(0, 592, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
    __pyx_v_direction = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_multi_gpu_fft", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 592, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_20_multi_gpu_fft(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_20_multi_gpu_fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  cufftHandle __pyx_t_7;
  intptr_t __pyx_t_8;
  intptr_t __pyx_t_9;
  __Pyx_RefNannySetupContext("_multi_gpu_fft", 0);

  /* "cupy/cuda/cufft.pyx":595
 *         # When we arrive here, the normal CuPy call path ensures a and out
 *         # reside on the same GPU -> must distribute a to all of the GPUs
 *         self._multi_gpu_setup_buffer(a)             # <<<<<<<<<<<<<<
 * 
 *         # Next, copy data to buffer
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_multi_gpu_setup_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_a);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":598
 * 
 *         # Next, copy data to buffer
 *         self._multi_gpu_memcpy(a, 'scatter')             # <<<<<<<<<<<<<<
 * 
 *         # Actual workhorses
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_multi_gpu_memcpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_a, __pyx_n_u_scatter};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_a, __pyx_n_u_scatter};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_a);
    __Pyx_GIVEREF(__pyx_v_a);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_a);
    __Pyx_INCREF(__pyx_n_u_scatter);
    __Pyx_GIVEREF(__pyx_n_u_scatter);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_n_u_scatter);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":601
 * 
 *         # Actual workhorses
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_6) {

    /* "cupy/cuda/cufft.pyx":602
 *         # Actual workhorses
 *         if self.fft_type == CUFFT_C2C:
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2Z:
 *             multi_gpu_execZ2Z(self.plan, self.xtArr, self.xtArr, direction)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_PyInt_As_cufftHandle(__pyx_t_3); if (unlikely((__pyx_t_7 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 602, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4cupy_4cuda_5cufft_multi_gpu_execC2C(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_5, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 602, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":601
 * 
 *         # Actual workhorses
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":603
 *         if self.fft_type == CUFFT_C2C:
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             multi_gpu_execZ2Z(self.plan, self.xtArr, self.xtArr, direction)
 *         else:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6)) {

    /* "cupy/cuda/cufft.pyx":604
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)
 *         elif self.fft_type == CUFFT_Z2Z:
 *             multi_gpu_execZ2Z(self.plan, self.xtArr, self.xtArr, direction)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_7 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_xtArr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 604, __pyx_L1_error)
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_multi_gpu_execZ2Z(__pyx_t_7, __pyx_t_9, __pyx_t_8, __pyx_t_5, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":603
 *         if self.fft_type == CUFFT_C2C:
 *             multi_gpu_execC2C(self.plan, self.xtArr, self.xtArr, direction)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             multi_gpu_execZ2Z(self.plan, self.xtArr, self.xtArr, direction)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":606
 *             multi_gpu_execZ2Z(self.plan, self.xtArr, self.xtArr, direction)
 *         else:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *         # Gather the distributed outputs
 */
  /*else*/ {
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 606, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":609
 * 
 *         # Gather the distributed outputs
 *         self._multi_gpu_memcpy(out, 'gather')             # <<<<<<<<<<<<<<
 * 
 *     def _output_dtype_and_shape(self, a):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_multi_gpu_memcpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_out, __pyx_n_u_gather};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_out, __pyx_n_u_gather};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_out);
    __Pyx_GIVEREF(__pyx_v_out);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_out);
    __Pyx_INCREF(__pyx_n_u_gather);
    __Pyx_GIVEREF(__pyx_n_u_gather);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_n_u_gather);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":592
 *                 raise ValueError
 * 
 *     def _multi_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         # When we arrive here, the normal CuPy call path ensures a and out
 *         # reside on the same GPU -> must distribute a to all of the GPUs
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._multi_gpu_fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":611
 *         self._multi_gpu_memcpy(out, 'gather')
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_23_output_dtype_and_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_22_output_dtype_and_shape[] = "Plan1d._output_dtype_and_shape(self, a)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_23_output_dtype_and_shape = {"_output_dtype_and_shape", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_23_output_dtype_and_shape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_22_output_dtype_and_shape};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_23_output_dtype_and_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_output_dtype_and_shape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_output_dtype_and_shape", 1, 2, 2, 1); __PYX_ERR(0, 611, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_output_dtype_and_shape") < 0)) __PYX_ERR(0, 611, __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_self = values[0];
    __pyx_v_a = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_output_dtype_and_shape", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 611, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._output_dtype_and_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_22_output_dtype_and_shape(__pyx_self, __pyx_v_self, __pyx_v_a);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_22_output_dtype_and_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_output_dtype_and_shape", 0);

  /* "cupy/cuda/cufft.pyx":612
 * 
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)             # <<<<<<<<<<<<<<
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_shape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cuda/cufft.pyx":613
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":614
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[-1] = shape[-1] // 2 + 1
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 614, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_complex64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":613
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":615
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex64
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":616
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[-1] = shape[-1] // 2 + 1             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_shape, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_shape, -1L, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":617
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex64             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[-1] = self.nx
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_complex64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":615
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex64
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":618
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             shape[-1] = self.nx
 *             dtype = numpy.float32
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 618, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 618, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":619
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[-1] = self.nx             # <<<<<<<<<<<<<<
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_SetItemInt(__pyx_v_shape, -1L, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":620
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[-1] = self.nx
 *             dtype = numpy.float32             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_dtype = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":618
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             shape[-1] = self.nx
 *             dtype = numpy.float32
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":621
 *             shape[-1] = self.nx
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 621, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":622
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[-1] = shape[-1] // 2 + 1
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_complex128); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":621
 *             shape[-1] = self.nx
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":623
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex128
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":624
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[-1] = shape[-1] // 2 + 1             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         else:
 */
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_shape, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_shape, -1L, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":625
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex128             # <<<<<<<<<<<<<<
 *         else:
 *             shape[-1] = self.nx
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_complex128); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":623
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             shape[-1] = shape[-1] // 2 + 1
 *             dtype = numpy.complex128
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":627
 *             dtype = numpy.complex128
 *         else:
 *             shape[-1] = self.nx             # <<<<<<<<<<<<<<
 *             dtype = numpy.float64
 *         return tuple(shape), dtype
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_nx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__Pyx_SetItemInt(__pyx_v_shape, -1L, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) __PYX_ERR(0, 627, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":628
 *         else:
 *             shape[-1] = self.nx
 *             dtype = numpy.float64             # <<<<<<<<<<<<<<
 *         return tuple(shape), dtype
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":629
 *             shape[-1] = self.nx
 *             dtype = numpy.float64
 *         return tuple(shape), dtype             # <<<<<<<<<<<<<<
 * 
 *     def get_output_array(self, a):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_AsTuple(__pyx_v_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dtype);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":611
 *         self._multi_gpu_memcpy(out, 'gather')
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d._output_dtype_and_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":631
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_25get_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_24get_output_array[] = "Plan1d.get_output_array(self, a)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_25get_output_array = {"get_output_array", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_25get_output_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_24get_output_array};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_25get_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_output_array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_output_array", 1, 2, 2, 1); __PYX_ERR(0, 631, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_output_array") < 0)) __PYX_ERR(0, 631, __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_self = values[0];
    __pyx_v_a = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_output_array", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 631, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.get_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_24get_output_array(__pyx_self, __pyx_v_self, __pyx_v_a);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_24get_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_dtype = 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)(PyObject *);
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("get_output_array", 0);

  /* "cupy/cuda/cufft.pyx":632
 * 
 *     def get_output_array(self, a):
 *         shape, dtype = self._output_dtype_and_shape(a)             # <<<<<<<<<<<<<<
 *         return cupy.empty(shape, dtype)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_output_dtype_and_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_a);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(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 != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 632, __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_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 632, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 632, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_shape = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":633
 *     def get_output_array(self, a):
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype)             # <<<<<<<<<<<<<<
 * 
 *     def check_output_array(self, a, out):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_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_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_shape, __pyx_v_dtype};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_shape, __pyx_v_dtype};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_v_shape);
    __Pyx_INCREF(__pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_v_dtype);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":631
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype)
 */

  /* 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.cuda.cufft.Plan1d.get_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":635
 *         return cupy.empty(shape, dtype)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         """Verify shape and dtype of the output array.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_27check_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_26check_output_array[] = "Plan1d.check_output_array(self, a, out)\nVerify shape and dtype of the output array.\n\n        Parameters\n        ----------\n        a : cupy.array\n            The input to the transform\n        out : cupy.array\n            The array where the output of the transform will be stored.\n        ";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_27check_output_array = {"check_output_array", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_27check_output_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6Plan1d_26check_output_array};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6Plan1d_27check_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_output_array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, 1); __PYX_ERR(0, 635, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, 2); __PYX_ERR(0, 635, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check_output_array") < 0)) __PYX_ERR(0, 635, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 635, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.check_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6Plan1d_26check_output_array(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6Plan1d_26check_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out) {
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_dtype = 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)(PyObject *);
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("check_output_array", 0);

  /* "cupy/cuda/cufft.pyx":645
 *             The array where the output of the transform will be stored.
 *         """
 *         shape, dtype = self._output_dtype_and_shape(a)             # <<<<<<<<<<<<<<
 *         if out.shape != shape:
 *             raise ValueError(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_output_dtype_and_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_a);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(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 != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 645, __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_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 645, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 645, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_shape = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":646
 *         """
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         if out.shape != shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 ('out must have shape {}.').format(shape))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_v_shape, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_t_6)) {

    /* "cupy/cuda/cufft.pyx":648
 *         if out.shape != shape:
 *             raise ValueError(
 *                 ('out must have shape {}.').format(shape))             # <<<<<<<<<<<<<<
 *         if out.dtype != dtype:
 *             raise ValueError(
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_out_must_have_shape, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_shape};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_v_shape};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_shape);
        __Pyx_GIVEREF(__pyx_v_shape);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_shape);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":647
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         if out.shape != shape:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 ('out must have shape {}.').format(shape))
 *         if out.dtype != dtype:
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 647, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":646
 *         """
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         if out.shape != shape:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 ('out must have shape {}.').format(shape))
 */
  }

  /* "cupy/cuda/cufft.pyx":649
 *             raise ValueError(
 *                 ('out must have shape {}.').format(shape))
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'out dtype mismatch: found {}, expected {}'.format(
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dtype, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_t_6)) {

    /* "cupy/cuda/cufft.pyx":651
 *         if out.dtype != dtype:
 *             raise ValueError(
 *                 'out dtype mismatch: found {}, expected {}'.format(             # <<<<<<<<<<<<<<
 *                     out.dtype, a.dtype))
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_out_dtype_mismatch_found_expecte, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "cupy/cuda/cufft.pyx":652
 *             raise ValueError(
 *                 'out dtype mismatch: found {}, expected {}'.format(
 *                     out.dtype, a.dtype))             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_t_2};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_3, __pyx_t_2};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":650
 *                 ('out must have shape {}.').format(shape))
 *         if out.dtype != dtype:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 'out dtype mismatch: found {}, expected {}'.format(
 *                     out.dtype, a.dtype))
 */
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 650, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":649
 *             raise ValueError(
 *                 ('out must have shape {}.').format(shape))
 *         if out.dtype != dtype:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 'out dtype mismatch: found {}, expected {}'.format(
 */
  }

  /* "cupy/cuda/cufft.pyx":635
 *         return cupy.empty(shape, dtype)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         """Verify shape and dtype of the output array.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cupy.cuda.cufft.Plan1d.check_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":656
 * 
 * class PlanNd(object):
 *     def __init__(self, object shape, object inembed, int istride,             # <<<<<<<<<<<<<<
 *                  int idist, object onembed, int ostride, int odist,
 *                  int fft_type, int batch, str order, int last_axis, last_size):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd___init__[] = "PlanNd.__init__(self, shape, inembed, int istride, int idist, onembed, int ostride, int odist, int fft_type, int batch, unicode order, int last_axis, last_size)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_1__init__ = {"__init__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd___init__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_shape = 0;
  PyObject *__pyx_v_inembed = 0;
  int __pyx_v_istride;
  int __pyx_v_idist;
  PyObject *__pyx_v_onembed = 0;
  int __pyx_v_ostride;
  int __pyx_v_odist;
  int __pyx_v_fft_type;
  int __pyx_v_batch;
  PyObject *__pyx_v_order = 0;
  int __pyx_v_last_axis;
  PyObject *__pyx_v_last_size = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_shape,&__pyx_n_s_inembed,&__pyx_n_s_istride,&__pyx_n_s_idist,&__pyx_n_s_onembed,&__pyx_n_s_ostride,&__pyx_n_s_odist,&__pyx_n_s_fft_type,&__pyx_n_s_batch,&__pyx_n_s_order,&__pyx_n_s_last_axis,&__pyx_n_s_last_size,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_self)) != 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_shape)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 1); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inembed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 2); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_istride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 3); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_idist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 4); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_onembed)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 5); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ostride)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 6); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 7); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fft_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 8); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_batch)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 9); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 10); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_last_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 11); __PYX_ERR(0, 656, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_last_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 12); __PYX_ERR(0, 656, __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, 656, __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_self = values[0];
    __pyx_v_shape = values[1];
    __pyx_v_inembed = values[2];
    __pyx_v_istride = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_istride == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 656, __pyx_L3_error)
    __pyx_v_idist = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_idist == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 657, __pyx_L3_error)
    __pyx_v_onembed = values[5];
    __pyx_v_ostride = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_ostride == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 657, __pyx_L3_error)
    __pyx_v_odist = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_odist == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 657, __pyx_L3_error)
    __pyx_v_fft_type = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_fft_type == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 658, __pyx_L3_error)
    __pyx_v_batch = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_batch == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 658, __pyx_L3_error)
    __pyx_v_order = ((PyObject*)values[10]);
    __pyx_v_last_axis = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_last_axis == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 658, __pyx_L3_error)
    __pyx_v_last_size = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 656, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_order), (&PyUnicode_Type), 1, "order", 1))) __PYX_ERR(0, 658, __pyx_L1_error)
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd___init__(__pyx_self, __pyx_v_self, __pyx_v_shape, __pyx_v_inembed, __pyx_v_istride, __pyx_v_idist, __pyx_v_onembed, __pyx_v_ostride, __pyx_v_odist, __pyx_v_fft_type, __pyx_v_batch, __pyx_v_order, __pyx_v_last_axis, __pyx_v_last_size);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_shape, PyObject *__pyx_v_inembed, int __pyx_v_istride, int __pyx_v_idist, PyObject *__pyx_v_onembed, int __pyx_v_ostride, int __pyx_v_odist, int __pyx_v_fft_type, int __pyx_v_batch, PyObject *__pyx_v_order, int __pyx_v_last_axis, PyObject *__pyx_v_last_size) {
  cufftHandle __pyx_v_plan;
  size_t __pyx_v_work_size;
  int __pyx_v_ndim;
  std::vector<int>  __pyx_v_shape_arr;
  std::vector<int>  __pyx_v_inembed_arr;
  std::vector<int>  __pyx_v_onembed_arr;
  int *__pyx_v_shape_ptr;
  int *__pyx_v_inembed_ptr;
  int *__pyx_v_onembed_ptr;
  cufftResult_t __pyx_v_result;
  struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *__pyx_v_work_area = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::vector<int>  __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cupy/cuda/cufft.pyx":662
 *         cdef size_t work_size
 *         cdef int ndim, i
 *         cdef vector.vector[int] shape_arr = shape             # <<<<<<<<<<<<<<
 *         cdef vector.vector[int] inembed_arr
 *         cdef vector.vector[int] onembed_arr
 */
  __pyx_t_1 = __pyx_convert_vector_from_py_int(__pyx_v_shape); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 662, __pyx_L1_error)
  __pyx_v_shape_arr = __pyx_t_1;

  /* "cupy/cuda/cufft.pyx":665
 *         cdef vector.vector[int] inembed_arr
 *         cdef vector.vector[int] onembed_arr
 *         cdef int* shape_ptr = shape_arr.data()             # <<<<<<<<<<<<<<
 *         cdef int* inembed_ptr
 *         cdef int* onembed_ptr
 */
  __pyx_v_shape_ptr = __pyx_v_shape_arr.data();

  /* "cupy/cuda/cufft.pyx":668
 *         cdef int* inembed_ptr
 *         cdef int* onembed_ptr
 *         ndim = len(shape)             # <<<<<<<<<<<<<<
 * 
 *         if inembed is None:
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_shape); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 668, __pyx_L1_error)
  __pyx_v_ndim = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":670
 *         ndim = len(shape)
 * 
 *         if inembed is None:             # <<<<<<<<<<<<<<
 *             inembed_ptr = NULL  # ignore istride and use default strides
 *         else:
 */
  __pyx_t_3 = (__pyx_v_inembed == Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":671
 * 
 *         if inembed is None:
 *             inembed_ptr = NULL  # ignore istride and use default strides             # <<<<<<<<<<<<<<
 *         else:
 *             inembed_arr = inembed
 */
    __pyx_v_inembed_ptr = NULL;

    /* "cupy/cuda/cufft.pyx":670
 *         ndim = len(shape)
 * 
 *         if inembed is None:             # <<<<<<<<<<<<<<
 *             inembed_ptr = NULL  # ignore istride and use default strides
 *         else:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":673
 *             inembed_ptr = NULL  # ignore istride and use default strides
 *         else:
 *             inembed_arr = inembed             # <<<<<<<<<<<<<<
 *             inembed_ptr = inembed_arr.data()
 * 
 */
  /*else*/ {
    __pyx_t_1 = __pyx_convert_vector_from_py_int(__pyx_v_inembed); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 673, __pyx_L1_error)
    __pyx_v_inembed_arr = __pyx_t_1;

    /* "cupy/cuda/cufft.pyx":674
 *         else:
 *             inembed_arr = inembed
 *             inembed_ptr = inembed_arr.data()             # <<<<<<<<<<<<<<
 * 
 *         if onembed is None:
 */
    __pyx_v_inembed_ptr = __pyx_v_inembed_arr.data();
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":676
 *             inembed_ptr = inembed_arr.data()
 * 
 *         if onembed is None:             # <<<<<<<<<<<<<<
 *             onembed_ptr = NULL  # ignore ostride and use default strides
 *         else:
 */
  __pyx_t_4 = (__pyx_v_onembed == Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "cupy/cuda/cufft.pyx":677
 * 
 *         if onembed is None:
 *             onembed_ptr = NULL  # ignore ostride and use default strides             # <<<<<<<<<<<<<<
 *         else:
 *             onembed_arr = onembed
 */
    __pyx_v_onembed_ptr = NULL;

    /* "cupy/cuda/cufft.pyx":676
 *             inembed_ptr = inembed_arr.data()
 * 
 *         if onembed is None:             # <<<<<<<<<<<<<<
 *             onembed_ptr = NULL  # ignore ostride and use default strides
 *         else:
 */
    goto __pyx_L4;
  }

  /* "cupy/cuda/cufft.pyx":679
 *             onembed_ptr = NULL  # ignore ostride and use default strides
 *         else:
 *             onembed_arr = onembed             # <<<<<<<<<<<<<<
 *             onembed_ptr = onembed_arr.data()
 * 
 */
  /*else*/ {
    __pyx_t_1 = __pyx_convert_vector_from_py_int(__pyx_v_onembed); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 679, __pyx_L1_error)
    __pyx_v_onembed_arr = __pyx_t_1;

    /* "cupy/cuda/cufft.pyx":680
 *         else:
 *             onembed_arr = onembed
 *             onembed_ptr = onembed_arr.data()             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
    __pyx_v_onembed_ptr = __pyx_v_onembed_arr.data();
  }
  __pyx_L4:;

  /* "cupy/cuda/cufft.pyx":682
 *             onembed_ptr = onembed_arr.data()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftCreate(&plan)
 *             if result == 0:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":683
 * 
 *         with nogil:
 *             result = cufftCreate(&plan)             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)
 */
        __pyx_v_result = cufftCreate((&__pyx_v_plan));

        /* "cupy/cuda/cufft.pyx":684
 *         with nogil:
 *             result = cufftCreate(&plan)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftSetAutoAllocation(plan, 0)
 *             if result == 0:
 */
        __pyx_t_3 = ((__pyx_v_result == 0) != 0);
        if (__pyx_t_3) {

          /* "cupy/cuda/cufft.pyx":685
 *             result = cufftCreate(&plan)
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)             # <<<<<<<<<<<<<<
 *             if result == 0:
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 */
          __pyx_v_result = cufftSetAutoAllocation(__pyx_v_plan, 0);

          /* "cupy/cuda/cufft.pyx":684
 *         with nogil:
 *             result = cufftCreate(&plan)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftSetAutoAllocation(plan, 0)
 *             if result == 0:
 */
        }

        /* "cupy/cuda/cufft.pyx":686
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 *                                            inembed_ptr, istride, idist,
 */
        __pyx_t_3 = ((__pyx_v_result == 0) != 0);
        if (__pyx_t_3) {

          /* "cupy/cuda/cufft.pyx":687
 *                 result = cufftSetAutoAllocation(plan, 0)
 *             if result == 0:
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,             # <<<<<<<<<<<<<<
 *                                            inembed_ptr, istride, idist,
 *                                            onembed_ptr, ostride, odist,
 */
          __pyx_v_result = cufftMakePlanMany(__pyx_v_plan, __pyx_v_ndim, __pyx_v_shape_ptr, __pyx_v_inembed_ptr, __pyx_v_istride, __pyx_v_idist, __pyx_v_onembed_ptr, __pyx_v_ostride, __pyx_v_odist, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, (&__pyx_v_work_size));

          /* "cupy/cuda/cufft.pyx":686
 *             if result == 0:
 *                 result = cufftSetAutoAllocation(plan, 0)
 *             if result == 0:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 *                                            inembed_ptr, istride, idist,
 */
        }
      }

      /* "cupy/cuda/cufft.pyx":682
 *             onembed_ptr = onembed_arr.data()
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftCreate(&plan)
 *             if result == 0:
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L7;
        }
        __pyx_L7:;
      }
  }

  /* "cupy/cuda/cufft.pyx":694
 * 
 *         # cufftMakePlanMany could use a large amount of memory
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  __pyx_t_3 = ((__pyx_v_result == 2) != 0);
  if (__pyx_t_3) {

    /* "cupy/cuda/cufft.pyx":695
 *         # cufftMakePlanMany could use a large amount of memory
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 695, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_get_default_memory_pool); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 695, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 695, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_free_all_blocks); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 695, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 695, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/cuda/cufft.pyx":696
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 *                                            inembed_ptr, istride, idist,
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        Py_UNBLOCK_THREADS
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {

          /* "cupy/cuda/cufft.pyx":697
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,             # <<<<<<<<<<<<<<
 *                                            inembed_ptr, istride, idist,
 *                                            onembed_ptr, ostride, odist,
 */
          __pyx_v_result = cufftMakePlanMany(__pyx_v_plan, __pyx_v_ndim, __pyx_v_shape_ptr, __pyx_v_inembed_ptr, __pyx_v_istride, __pyx_v_idist, __pyx_v_onembed_ptr, __pyx_v_ostride, __pyx_v_odist, ((cufftType_t)__pyx_v_fft_type), __pyx_v_batch, (&__pyx_v_work_size));
        }

        /* "cupy/cuda/cufft.pyx":696
 *         if result == 2:
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 result = cufftMakePlanMany(plan, ndim, shape_ptr,
 *                                            inembed_ptr, istride, idist,
 */
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            Py_BLOCK_THREADS
            #endif
            goto __pyx_L13;
          }
          __pyx_L13:;
        }
    }

    /* "cupy/cuda/cufft.pyx":694
 * 
 *         # cufftMakePlanMany could use a large amount of memory
 *         if result == 2:             # <<<<<<<<<<<<<<
 *             cupy.get_default_memory_pool().free_all_blocks()
 *             with nogil:
 */
  }

  /* "cupy/cuda/cufft.pyx":702
 *                                            <Type>fft_type, batch,
 *                                            &work_size)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         # TODO: for CUDA>=9.2 could also allow setting a work area policy
 */
  __pyx_t_5 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cupy/cuda/cufft.pyx":707
 *         # result = cufftXtSetWorkAreaPolicy(plan, policy, &work_size)
 * 
 *         work_area = memory.alloc(work_size)             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void *>(work_area.ptr))
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_work_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 707, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = ((PyObject *)__pyx_f_4cupy_4cuda_6memory_alloc(__pyx_t_5, 0)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 707, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_work_area = ((struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":708
 * 
 *         work_area = memory.alloc(work_size)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetWorkArea(plan, <void *>(work_area.ptr))
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":709
 *         work_area = memory.alloc(work_size)
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void *>(work_area.ptr))             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftSetWorkArea(__pyx_v_plan, ((void *)__pyx_v_work_area->ptr));
      }

      /* "cupy/cuda/cufft.pyx":708
 * 
 *         work_area = memory.alloc(work_size)
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetWorkArea(plan, <void *>(work_area.ptr))
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L16;
        }
        __pyx_L16:;
      }
  }

  /* "cupy/cuda/cufft.pyx":710
 *         with nogil:
 *             result = cufftSetWorkArea(plan, <void *>(work_area.ptr))
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         self.shape = tuple(shape)
 */
  __pyx_t_8 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":712
 *         check_result(result)
 * 
 *         self.shape = tuple(shape)             # <<<<<<<<<<<<<<
 *         self.fft_type = fft_type
 *         self.plan = plan
 */
  __pyx_t_8 = __Pyx_PySequence_Tuple(__pyx_v_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_shape, __pyx_t_8) < 0) __PYX_ERR(0, 712, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":713
 * 
 *         self.shape = tuple(shape)
 *         self.fft_type = fft_type             # <<<<<<<<<<<<<<
 *         self.plan = plan
 *         self.work_area = work_area
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_fft_type); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_fft_type, __pyx_t_8) < 0) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":714
 *         self.shape = tuple(shape)
 *         self.fft_type = fft_type
 *         self.plan = plan             # <<<<<<<<<<<<<<
 *         self.work_area = work_area
 *         self.order = order  # either 'C' or 'F'
 */
  __pyx_t_8 = __Pyx_PyInt_From_cufftHandle(__pyx_v_plan); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_plan, __pyx_t_8) < 0) __PYX_ERR(0, 714, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":715
 *         self.fft_type = fft_type
 *         self.plan = plan
 *         self.work_area = work_area             # <<<<<<<<<<<<<<
 *         self.order = order  # either 'C' or 'F'
 *         self.last_axis = last_axis  # ignored for C2C
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_work_area, ((PyObject *)__pyx_v_work_area)) < 0) __PYX_ERR(0, 715, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":716
 *         self.plan = plan
 *         self.work_area = work_area
 *         self.order = order  # either 'C' or 'F'             # <<<<<<<<<<<<<<
 *         self.last_axis = last_axis  # ignored for C2C
 *         self.last_size = last_size  # = None (and ignored) for C2C
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 716, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":717
 *         self.work_area = work_area
 *         self.order = order  # either 'C' or 'F'
 *         self.last_axis = last_axis  # ignored for C2C             # <<<<<<<<<<<<<<
 *         self.last_size = last_size  # = None (and ignored) for C2C
 * 
 */
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_last_axis); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 717, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_last_axis, __pyx_t_8) < 0) __PYX_ERR(0, 717, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cupy/cuda/cufft.pyx":718
 *         self.order = order  # either 'C' or 'F'
 *         self.last_axis = last_axis  # ignored for C2C
 *         self.last_size = last_size  # = None (and ignored) for C2C             # <<<<<<<<<<<<<<
 * 
 *     def __del__(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_last_size, __pyx_v_last_size) < 0) __PYX_ERR(0, 718, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":656
 * 
 * class PlanNd(object):
 *     def __init__(self, object shape, object inembed, int istride,             # <<<<<<<<<<<<<<
 *                  int idist, object onembed, int ostride, int odist,
 *                  int fft_type, int batch, str order, int last_axis, last_size):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  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_AddTraceback("cupy.cuda.cufft.PlanNd.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_work_area);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":720
 *         self.last_size = last_size  # = None (and ignored) for C2C
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         with nogil:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_3__del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_2__del__[] = "PlanNd.__del__(self)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_3__del__ = {"__del__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_3__del__, METH_O, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_2__del__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_3__del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_2__del__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_2__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  cufftHandle __pyx_v_plan;
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cufftHandle __pyx_t_2;
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "cupy/cuda/cufft.pyx":721
 * 
 *     def __del__(self):
 *         cdef Handle plan = self.plan             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = cufftDestroy(plan)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_2 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plan = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":722
 *     def __del__(self):
 *         cdef Handle plan = self.plan
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftDestroy(plan)
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":723
 *         cdef Handle plan = self.plan
 *         with nogil:
 *             result = cufftDestroy(plan)             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftDestroy(__pyx_v_plan);
      }

      /* "cupy/cuda/cufft.pyx":722
 *     def __del__(self):
 *         cdef Handle plan = self.plan
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftDestroy(plan)
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":724
 *         with nogil:
 *             result = cufftDestroy(plan)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":720
 *         self.last_size = last_size  # = None (and ignored) for C2C
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         with nogil:
 */

  /* 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.cuda.cufft.PlanNd.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":726
 *         check_result(result)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_5__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_4__enter__[] = "PlanNd.__enter__(self)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_5__enter__ = {"__enter__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_5__enter__, METH_O, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_4__enter__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_5__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_4__enter__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_4__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "cupy/cuda/cufft.pyx":727
 * 
 *     def __enter__(self):
 *         _thread_local._current_plan = self             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan, __pyx_v_self) < 0) __PYX_ERR(0, 727, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":728
 *     def __enter__(self):
 *         _thread_local._current_plan = self
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":726
 *         check_result(result)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":730
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_7__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_6__exit__[] = "PlanNd.__exit__(self, exc_type, exc_value, traceback)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_7__exit__ = {"__exit__", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_7__exit__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_6__exit__};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_7__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_type = 0;
  CYTHON_UNUSED PyObject *__pyx_v_exc_value = 0;
  CYTHON_UNUSED PyObject *__pyx_v_traceback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_exc_type,&__pyx_n_s_exc_value,&__pyx_n_s_traceback,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_self)) != 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_exc_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 1); __PYX_ERR(0, 730, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_exc_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 2); __PYX_ERR(0, 730, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_traceback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, 3); __PYX_ERR(0, 730, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 730, __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_self = values[0];
    __pyx_v_exc_type = values[1];
    __pyx_v_exc_value = values[2];
    __pyx_v_traceback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 730, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_6__exit__(__pyx_self, __pyx_v_self, __pyx_v_exc_type, __pyx_v_exc_value, __pyx_v_traceback);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_6__exit__(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v_exc_value, CYTHON_UNUSED PyObject *__pyx_v_traceback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "cupy/cuda/cufft.pyx":731
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):
 *         _thread_local._current_plan = None             # <<<<<<<<<<<<<<
 * 
 *     def fft(self, a, out, direction):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_n_s_current_plan, Py_None) < 0) __PYX_ERR(0, 731, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":730
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":733
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_9fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_8fft[] = "PlanNd.fft(self, a, out, direction)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_9fft = {"fft", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_9fft, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_8fft};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_9fft(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_direction = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fft (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,&__pyx_n_s_direction,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 1); __PYX_ERR(0, 733, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 2); __PYX_ERR(0, 733, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, 3); __PYX_ERR(0, 733, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fft") < 0)) __PYX_ERR(0, 733, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
    __pyx_v_direction = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fft", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 733, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_8fft(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_8fft(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out, PyObject *__pyx_v_direction) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_stream;
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  cufftHandle __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  intptr_t __pyx_t_6;
  intptr_t __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("fft", 0);

  /* "cupy/cuda/cufft.pyx":734
 * 
 *     def fft(self, a, out, direction):
 *         cdef Handle plan = self.plan             # <<<<<<<<<<<<<<
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 *         with nogil:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_plan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_cufftHandle(__pyx_t_1); if (unlikely((__pyx_t_2 == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_plan = __pyx_t_2;

  /* "cupy/cuda/cufft.pyx":735
 *     def fft(self, a, out, direction):
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()             # <<<<<<<<<<<<<<
 *         with nogil:
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 */
  __pyx_v_stream = __pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr();

  /* "cupy/cuda/cufft.pyx":736
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":737
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 *         with nogil:
 *             result = cufftSetStream(plan, <driver.Stream>stream)             # <<<<<<<<<<<<<<
 *         check_result(result)
 * 
 */
        __pyx_v_result = cufftSetStream(__pyx_v_plan, ((cudaStream_t)__pyx_v_stream));
      }

      /* "cupy/cuda/cufft.pyx":736
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 *         with nogil:             # <<<<<<<<<<<<<<
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":738
 *         with nogil:
 *             result = cufftSetStream(plan, <driver.Stream>stream)
 *         check_result(result)             # <<<<<<<<<<<<<<
 * 
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":740
 *         check_result(result)
 * 
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":741
 * 
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 741, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execC2C(__pyx_v_plan, __pyx_t_6, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":740
 *         check_result(result)
 * 
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":742
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":743
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execR2C(__pyx_v_plan, __pyx_t_7, __pyx_t_6, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":742
 *         if self.fft_type == CUFFT_C2C:
 *             execC2C(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":744
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":745
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execC2R(__pyx_v_plan, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":744
 *         elif self.fft_type == CUFFT_R2C:
 *             execR2C(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":746
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":747
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_direction); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execZ2Z(__pyx_v_plan, __pyx_t_7, __pyx_t_6, __pyx_t_8, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":746
 *         elif self.fft_type == CUFFT_C2R:
 *             execC2R(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":748
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2D:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 748, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "cupy/cuda/cufft.pyx":749
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2D:
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __pyx_f_4cupy_4cuda_5cufft_execD2Z(__pyx_v_plan, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cupy/cuda/cufft.pyx":748
 *         elif self.fft_type == CUFFT_Z2Z:
 *             execZ2Z(plan, a.data.ptr, out.data.ptr, direction)
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2D:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":750
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2D:             # <<<<<<<<<<<<<<
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 *         else:
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2D); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_5)) {

    /* "cupy/cuda/cufft.pyx":751
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2D:
 *             execZ2D(plan, a.data.ptr, out.data.ptr)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ptr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = PyInt_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ptr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = PyInt_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_6 == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execZ2D(__pyx_v_plan, __pyx_t_7, __pyx_t_6, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":750
 *         elif self.fft_type == CUFFT_D2Z:
 *             execD2Z(plan, a.data.ptr, out.data.ptr)
 *         elif self.fft_type == CUFFT_Z2D:             # <<<<<<<<<<<<<<
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 *         else:
 */
    goto __pyx_L6;
  }

  /* "cupy/cuda/cufft.pyx":753
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 *         else:
 *             raise ValueError             # <<<<<<<<<<<<<<
 * 
 *     def _output_dtype_and_shape(self, a):
 */
  /*else*/ {
    __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0);
    __PYX_ERR(0, 753, __pyx_L1_error)
  }
  __pyx_L6:;

  /* "cupy/cuda/cufft.pyx":733
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.fft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":755
 *             raise ValueError
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_11_output_dtype_and_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_10_output_dtype_and_shape[] = "PlanNd._output_dtype_and_shape(self, a)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_11_output_dtype_and_shape = {"_output_dtype_and_shape", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_11_output_dtype_and_shape, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_10_output_dtype_and_shape};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_11_output_dtype_and_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_output_dtype_and_shape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_output_dtype_and_shape", 1, 2, 2, 1); __PYX_ERR(0, 755, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_output_dtype_and_shape") < 0)) __PYX_ERR(0, 755, __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_self = values[0];
    __pyx_v_a = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_output_dtype_and_shape", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 755, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd._output_dtype_and_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_10_output_dtype_and_shape(__pyx_self, __pyx_v_self, __pyx_v_a);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_10_output_dtype_and_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a) {
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("_output_dtype_and_shape", 0);

  /* "cupy/cuda/cufft.pyx":756
 * 
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)             # <<<<<<<<<<<<<<
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_shape = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "cupy/cuda/cufft.pyx":757
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 757, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":758
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[self.last_axis] = self.last_size
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 758, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_complex64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 758, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":757
 *     def _output_dtype_and_shape(self, a):
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":759
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex64
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":760
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[self.last_axis] = self.last_size             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyObject_SetItem(__pyx_v_shape, __pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":761
 *         elif self.fft_type == CUFFT_R2C:
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex64             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[self.last_axis] = self.last_size
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_complex64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":759
 *         if self.fft_type == CUFFT_C2C:
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_R2C:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex64
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":762
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float32
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":763
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[self.last_axis] = self.last_size             # <<<<<<<<<<<<<<
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyObject_SetItem(__pyx_v_shape, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":764
 *         elif self.fft_type == CUFFT_C2R:
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float32             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_dtype = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":762
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex64
 *         elif self.fft_type == CUFFT_C2R:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float32
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":765
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":766
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128             # <<<<<<<<<<<<<<
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[self.last_axis] = self.last_size
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_complex128); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cupy/cuda/cufft.pyx":765
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float32
 *         elif self.fft_type == CUFFT_Z2Z:             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":767
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex128
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "cupy/cuda/cufft.pyx":768
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[self.last_axis] = self.last_size             # <<<<<<<<<<<<<<
 *             dtype = numpy.complex128
 *         else:  # CUFFT_Z2D
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyObject_SetItem(__pyx_v_shape, __pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 768, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cupy/cuda/cufft.pyx":769
 *         elif self.fft_type == CUFFT_D2Z:
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex128             # <<<<<<<<<<<<<<
 *         else:  # CUFFT_Z2D
 *             shape[self.last_axis] = self.last_size
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_complex128); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dtype = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":767
 *         elif self.fft_type == CUFFT_Z2Z:
 *             dtype = numpy.complex128
 *         elif self.fft_type == CUFFT_D2Z:             # <<<<<<<<<<<<<<
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.complex128
 */
    goto __pyx_L3;
  }

  /* "cupy/cuda/cufft.pyx":771
 *             dtype = numpy.complex128
 *         else:  # CUFFT_Z2D
 *             shape[self.last_axis] = self.last_size             # <<<<<<<<<<<<<<
 *             dtype = numpy.float64
 *         return tuple(shape), dtype
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyObject_SetItem(__pyx_v_shape, __pyx_t_2, __pyx_t_3) < 0)) __PYX_ERR(0, 771, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cupy/cuda/cufft.pyx":772
 *         else:  # CUFFT_Z2D
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float64             # <<<<<<<<<<<<<<
 *         return tuple(shape), dtype
 * 
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dtype = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "cupy/cuda/cufft.pyx":773
 *             shape[self.last_axis] = self.last_size
 *             dtype = numpy.float64
 *         return tuple(shape), dtype             # <<<<<<<<<<<<<<
 * 
 *     def get_output_array(self, a, order='C'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_AsTuple(__pyx_v_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 773, __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_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_dtype);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":755
 *             raise ValueError
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd._output_dtype_and_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":775
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a, order='C'):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype, order=order)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_13get_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_12get_output_array[] = "PlanNd.get_output_array(self, a, order=u'C')";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_13get_output_array = {"get_output_array", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_13get_output_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_12get_output_array};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_13get_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_output_array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_order,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject*)__pyx_n_u_C));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_output_array", 0, 2, 3, 1); __PYX_ERR(0, 775, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_order);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_output_array") < 0)) __PYX_ERR(0, 775, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_order = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_output_array", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 775, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.get_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_12get_output_array(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_order);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_12get_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_order) {
  PyObject *__pyx_v_shape = NULL;
  PyObject *__pyx_v_dtype = 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)(PyObject *);
  __Pyx_RefNannySetupContext("get_output_array", 0);

  /* "cupy/cuda/cufft.pyx":776
 * 
 *     def get_output_array(self, a, order='C'):
 *         shape, dtype = self._output_dtype_and_shape(a)             # <<<<<<<<<<<<<<
 *         return cupy.empty(shape, dtype, order=order)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_output_dtype_and_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_a};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_a);
      __Pyx_GIVEREF(__pyx_v_a);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_a);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(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 != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 776, __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_4 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 2) < 0) __PYX_ERR(0, 776, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 776, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_shape = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":777
 *     def get_output_array(self, a, order='C'):
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype, order=order)             # <<<<<<<<<<<<<<
 * 
 *     def check_output_array(self, a, out):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_shape);
  __Pyx_GIVEREF(__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_shape);
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_dtype);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 777, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cupy/cuda/cufft.pyx":775
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a, order='C'):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype, order=order)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.get_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shape);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":779
 *         return cupy.empty(shape, dtype, order=order)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         if out is a:
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 */

/* Python wrapper */
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_15check_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_14check_output_array[] = "PlanNd.check_output_array(self, a, out)";
static PyMethodDef __pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_15check_output_array = {"check_output_array", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_15check_output_array, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6PlanNd_14check_output_array};
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_6PlanNd_15check_output_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_output_array (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_a,&__pyx_n_s_out,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_self)) != 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_a)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, 1); __PYX_ERR(0, 779, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, 2); __PYX_ERR(0, 779, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check_output_array") < 0)) __PYX_ERR(0, 779, __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_self = values[0];
    __pyx_v_a = values[1];
    __pyx_v_out = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_output_array", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 779, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.check_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6PlanNd_14check_output_array(__pyx_self, __pyx_v_self, __pyx_v_a, __pyx_v_out);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6PlanNd_14check_output_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_a, PyObject *__pyx_v_out) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_size = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_RefNannySetupContext("check_output_array", 0);

  /* "cupy/cuda/cufft.pyx":780
 * 
 *     def check_output_array(self, a, out):
 *         if out is a:             # <<<<<<<<<<<<<<
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 *             return
 */
  __pyx_t_1 = (__pyx_v_out == __pyx_v_a);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "cupy/cuda/cufft.pyx":782
 *         if out is a:
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 *             return             # <<<<<<<<<<<<<<
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):
 *             if out.shape != a.shape:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "cupy/cuda/cufft.pyx":780
 * 
 *     def check_output_array(self, a, out):
 *         if out is a:             # <<<<<<<<<<<<<<
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 *             return
 */
  }

  /* "cupy/cuda/cufft.pyx":783
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 *             return
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L5_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "cupy/cuda/cufft.pyx":784
 *             return
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):
 *             if out.shape != a.shape:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/cuda/cufft.pyx":785
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')             # <<<<<<<<<<<<<<
 *             if out.dtype != a.dtype:
 *                 raise ValueError('output dtype mismatch')
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __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, 785, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":784
 *             return
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):
 *             if out.shape != a.shape:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:
 */
    }

    /* "cupy/cuda/cufft.pyx":786
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output dtype mismatch')
 *         else:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/cuda/cufft.pyx":787
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:
 *                 raise ValueError('output dtype mismatch')             # <<<<<<<<<<<<<<
 *         else:
 *             if out.ndim != a.ndim:
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 787, __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, 787, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":786
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output dtype mismatch')
 *         else:
 */
    }

    /* "cupy/cuda/cufft.pyx":783
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 *             return
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):             # <<<<<<<<<<<<<<
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')
 */
    goto __pyx_L4;
  }

  /* "cupy/cuda/cufft.pyx":789
 *                 raise ValueError('output dtype mismatch')
 *         else:
 *             if out.ndim != a.ndim:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__pyx_t_1)) {

      /* "cupy/cuda/cufft.pyx":790
 *         else:
 *             if out.ndim != a.ndim:
 *                 raise ValueError('output dimension mismatch')             # <<<<<<<<<<<<<<
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 790, __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, 790, __pyx_L1_error)

      /* "cupy/cuda/cufft.pyx":789
 *                 raise ValueError('output dtype mismatch')
 *         else:
 *             if out.ndim != a.ndim:             # <<<<<<<<<<<<<<
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):
 */
    }

    /* "cupy/cuda/cufft.pyx":791
 *             if out.ndim != a.ndim:
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):             # <<<<<<<<<<<<<<
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 *                    (i == self.last_axis and size != self.last_size):
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_5 = __pyx_int_0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 791, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 791, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 791, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 791, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 791, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_7(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 791, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_size, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5);
      __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 791, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5);
      __pyx_t_5 = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "cupy/cuda/cufft.pyx":792
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \             # <<<<<<<<<<<<<<
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_i, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (!__pyx_t_2) {
        goto __pyx_L14_next_or;
      } else {
      }
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_size, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 792, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (!__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_L14_next_or:;

      /* "cupy/cuda/cufft.pyx":793
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 *                    (i == self.last_axis and size != self.last_size):             # <<<<<<<<<<<<<<
 *                     raise ValueError('output shape is incorrecct')
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_axis); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_i, __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_size, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_1 = __pyx_t_2;
      __pyx_L13_bool_binop_done:;

      /* "cupy/cuda/cufft.pyx":792
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \             # <<<<<<<<<<<<<<
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')
 */
      if (unlikely(__pyx_t_1)) {

        /* "cupy/cuda/cufft.pyx":794
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')             # <<<<<<<<<<<<<<
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 */
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __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, 794, __pyx_L1_error)

        /* "cupy/cuda/cufft.pyx":792
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \             # <<<<<<<<<<<<<<
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')
 */
      }

      /* "cupy/cuda/cufft.pyx":791
 *             if out.ndim != a.ndim:
 *                 raise ValueError('output dimension mismatch')
 *             for i, size in enumerate(out.shape):             # <<<<<<<<<<<<<<
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 *                    (i == self.last_axis and size != self.last_size):
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cupy/cuda/cufft.pyx":795
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):             # <<<<<<<<<<<<<<
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 *                     raise ValueError('output dtype is unexpected')
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fft_type); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L18_bool_binop_done;
    }
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L18_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "cupy/cuda/cufft.pyx":796
 *                     raise ValueError('output shape is incorrecct')
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):             # <<<<<<<<<<<<<<
 *                     raise ValueError('output dtype is unexpected')
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_char); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_upper); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (__pyx_t_10) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 796, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 796, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 796, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 796, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_8};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 796, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 796, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
          __pyx_t_8 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 796, __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_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 796, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__pyx_t_2)) {

        /* "cupy/cuda/cufft.pyx":797
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 *                     raise ValueError('output dtype is unexpected')             # <<<<<<<<<<<<<<
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 797, __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, 797, __pyx_L1_error)

        /* "cupy/cuda/cufft.pyx":796
 *                     raise ValueError('output shape is incorrecct')
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):             # <<<<<<<<<<<<<<
 *                     raise ValueError('output dtype is unexpected')
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 */
      }

      /* "cupy/cuda/cufft.pyx":795
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):             # <<<<<<<<<<<<<<
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 *                     raise ValueError('output dtype is unexpected')
 */
      goto __pyx_L17;
    }

    /* "cupy/cuda/cufft.pyx":799
 *                     raise ValueError('output dtype is unexpected')
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):             # <<<<<<<<<<<<<<
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 */
    /*else*/ {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_cupy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_dype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_char); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_lower); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 799, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 799, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 799, __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;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 799, __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;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 799, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 799, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 799, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(__pyx_t_2)) {

        /* "cupy/cuda/cufft.pyx":800
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 *                     raise ValueError('output dtype is unexpected')             # <<<<<<<<<<<<<<
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 */
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 800, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_Raise(__pyx_t_10, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __PYX_ERR(0, 800, __pyx_L1_error)

        /* "cupy/cuda/cufft.pyx":799
 *                     raise ValueError('output dtype is unexpected')
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):             # <<<<<<<<<<<<<<
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 */
      }
    }
    __pyx_L17:;
  }
  __pyx_L4:;

  /* "cupy/cuda/cufft.pyx":801
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and             # <<<<<<<<<<<<<<
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 *             raise ValueError('output contiguity mismatch')
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_flags); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_f_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L23_bool_binop_done;
  }

  /* "cupy/cuda/cufft.pyx":802
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):             # <<<<<<<<<<<<<<
 *             raise ValueError('output contiguity mismatch')
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_flags); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s_flags); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_c_contiguous); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_2 = __pyx_t_1;
  __pyx_L23_bool_binop_done:;

  /* "cupy/cuda/cufft.pyx":801
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and             # <<<<<<<<<<<<<<
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 *             raise ValueError('output contiguity mismatch')
 */
  __pyx_t_1 = ((!__pyx_t_2) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "cupy/cuda/cufft.pyx":803
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 *             raise ValueError('output contiguity mismatch')             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_Raise(__pyx_t_10, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __PYX_ERR(0, 803, __pyx_L1_error)

    /* "cupy/cuda/cufft.pyx":801
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 *                     raise ValueError('output dtype is unexpected')
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and             # <<<<<<<<<<<<<<
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 *             raise ValueError('output contiguity mismatch')
 */
  }

  /* "cupy/cuda/cufft.pyx":779
 *         return cupy.empty(shape, dtype, order=order)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         if out is a:
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cupy.cuda.cufft.PlanNd.check_output_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cupy/cuda/cufft.pyx":806
 * 
 * 
 * cpdef execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_7execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execC2C(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execC2C", 0);

  /* "cupy/cuda/cufft.pyx":807
 * 
 * cpdef execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,
 *                               direction)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":808
 * cpdef execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,             # <<<<<<<<<<<<<<
 *                               direction)
 *     check_result(result)
 */
        __pyx_v_result = cufftExecC2C(__pyx_v_plan, ((cufftComplex *)__pyx_v_idata), ((cufftComplex *)__pyx_v_odata), __pyx_v_direction);
      }

      /* "cupy/cuda/cufft.pyx":807
 * 
 * cpdef execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,
 *                               direction)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":810
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,
 *                               direction)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":806
 * 
 * 
 * cpdef execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecC2C(plan, <Complex*>idata, <Complex*>odata,
 */

  /* 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.cuda.cufft.execC2C", __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_4cuda_5cufft_7execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_6execC2C[] = "execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_7execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  int __pyx_v_direction;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execC2C (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,&__pyx_n_s_direction,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execC2C", 1, 4, 4, 1); __PYX_ERR(0, 806, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execC2C", 1, 4, 4, 2); __PYX_ERR(0, 806, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execC2C", 1, 4, 4, 3); __PYX_ERR(0, 806, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execC2C") < 0)) __PYX_ERR(0, 806, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L3_error)
    __pyx_v_direction = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execC2C", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 806, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execC2C", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_6execC2C(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_6execC2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execC2C", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execC2C(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":813
 * 
 * 
 * cpdef execR2C(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_9execR2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execR2C(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execR2C", 0);

  /* "cupy/cuda/cufft.pyx":814
 * 
 * cpdef execR2C(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)
 *     check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":815
 * cpdef execR2C(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)             # <<<<<<<<<<<<<<
 *     check_result(result)
 * 
 */
        __pyx_v_result = cufftExecR2C(__pyx_v_plan, ((cufftReal *)__pyx_v_idata), ((cufftComplex *)__pyx_v_odata));
      }

      /* "cupy/cuda/cufft.pyx":814
 * 
 * cpdef execR2C(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)
 *     check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":816
 *     with nogil:
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":813
 * 
 * 
 * cpdef execR2C(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecR2C(plan, <Float*>idata, <Complex*>odata)
 */

  /* 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.cuda.cufft.execR2C", __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_4cuda_5cufft_9execR2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_8execR2C[] = "execR2C(Handle plan, intptr_t idata, intptr_t odata)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_9execR2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execR2C (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execR2C", 1, 3, 3, 1); __PYX_ERR(0, 813, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execR2C", 1, 3, 3, 2); __PYX_ERR(0, 813, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execR2C") < 0)) __PYX_ERR(0, 813, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 813, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 813, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 813, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execR2C", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 813, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execR2C", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_8execR2C(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_8execR2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execR2C", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execR2C(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":819
 * 
 * 
 * cpdef execC2R(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_11execC2R(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execC2R(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execC2R", 0);

  /* "cupy/cuda/cufft.pyx":820
 * 
 * cpdef execC2R(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)
 *     check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":821
 * cpdef execC2R(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)             # <<<<<<<<<<<<<<
 *     check_result(result)
 * 
 */
        __pyx_v_result = cufftExecC2R(__pyx_v_plan, ((cufftComplex *)__pyx_v_idata), ((cufftReal *)__pyx_v_odata));
      }

      /* "cupy/cuda/cufft.pyx":820
 * 
 * cpdef execC2R(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)
 *     check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":822
 *     with nogil:
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":819
 * 
 * 
 * cpdef execC2R(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecC2R(plan, <Complex*>idata, <Float*>odata)
 */

  /* 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.cuda.cufft.execC2R", __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_4cuda_5cufft_11execC2R(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_10execC2R[] = "execC2R(Handle plan, intptr_t idata, intptr_t odata)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_11execC2R(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execC2R (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execC2R", 1, 3, 3, 1); __PYX_ERR(0, 819, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execC2R", 1, 3, 3, 2); __PYX_ERR(0, 819, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execC2R") < 0)) __PYX_ERR(0, 819, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execC2R", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 819, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execC2R", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_10execC2R(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_10execC2R(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execC2R", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execC2R(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 819, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":825
 * 
 * 
 * cpdef execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_13execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execZ2Z(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execZ2Z", 0);

  /* "cupy/cuda/cufft.pyx":826
 * 
 * cpdef execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,
 *                               <DoubleComplex*>odata, direction)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":827
 * cpdef execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,             # <<<<<<<<<<<<<<
 *                               <DoubleComplex*>odata, direction)
 *     check_result(result)
 */
        __pyx_v_result = cufftExecZ2Z(__pyx_v_plan, ((cufftDoubleComplex *)__pyx_v_idata), ((cufftDoubleComplex *)__pyx_v_odata), __pyx_v_direction);
      }

      /* "cupy/cuda/cufft.pyx":826
 * 
 * cpdef execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,
 *                               <DoubleComplex*>odata, direction)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":829
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,
 *                               <DoubleComplex*>odata, direction)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":825
 * 
 * 
 * cpdef execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecZ2Z(plan, <DoubleComplex*>idata,
 */

  /* 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.cuda.cufft.execZ2Z", __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_4cuda_5cufft_13execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_12execZ2Z[] = "execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_13execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  int __pyx_v_direction;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execZ2Z (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,&__pyx_n_s_direction,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execZ2Z", 1, 4, 4, 1); __PYX_ERR(0, 825, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execZ2Z", 1, 4, 4, 2); __PYX_ERR(0, 825, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execZ2Z", 1, 4, 4, 3); __PYX_ERR(0, 825, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execZ2Z") < 0)) __PYX_ERR(0, 825, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L3_error)
    __pyx_v_direction = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execZ2Z", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 825, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execZ2Z", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_12execZ2Z(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_12execZ2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execZ2Z", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execZ2Z(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":832
 * 
 * 
 * cpdef execD2Z(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_15execD2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execD2Z(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execD2Z", 0);

  /* "cupy/cuda/cufft.pyx":833
 * 
 * cpdef execD2Z(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)
 *     check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":834
 * cpdef execD2Z(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)             # <<<<<<<<<<<<<<
 *     check_result(result)
 * 
 */
        __pyx_v_result = cufftExecD2Z(__pyx_v_plan, ((cufftDoubleReal *)__pyx_v_idata), ((cufftDoubleComplex *)__pyx_v_odata));
      }

      /* "cupy/cuda/cufft.pyx":833
 * 
 * cpdef execD2Z(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)
 *     check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":835
 *     with nogil:
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":832
 * 
 * 
 * cpdef execD2Z(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecD2Z(plan, <Double*>idata, <DoubleComplex*>odata)
 */

  /* 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.cuda.cufft.execD2Z", __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_4cuda_5cufft_15execD2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_14execD2Z[] = "execD2Z(Handle plan, intptr_t idata, intptr_t odata)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_15execD2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execD2Z (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execD2Z", 1, 3, 3, 1); __PYX_ERR(0, 832, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execD2Z", 1, 3, 3, 2); __PYX_ERR(0, 832, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execD2Z") < 0)) __PYX_ERR(0, 832, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execD2Z", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 832, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execD2Z", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_14execD2Z(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_14execD2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execD2Z", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execD2Z(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":838
 * 
 * 
 * cpdef execZ2D(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_17execZ2D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_execZ2D(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execZ2D", 0);

  /* "cupy/cuda/cufft.pyx":839
 * 
 * cpdef execZ2D(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)
 *     check_result(result)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":840
 * cpdef execZ2D(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)             # <<<<<<<<<<<<<<
 *     check_result(result)
 * 
 */
        __pyx_v_result = cufftExecZ2D(__pyx_v_plan, ((cufftDoubleComplex *)__pyx_v_idata), ((cufftDoubleReal *)__pyx_v_odata));
      }

      /* "cupy/cuda/cufft.pyx":839
 * 
 * cpdef execZ2D(Handle plan, intptr_t idata, intptr_t odata):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)
 *     check_result(result)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":841
 *     with nogil:
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 841, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":838
 * 
 * 
 * cpdef execZ2D(Handle plan, intptr_t idata, intptr_t odata):             # <<<<<<<<<<<<<<
 *     with nogil:
 *         result = cufftExecZ2D(plan, <DoubleComplex*>idata, <Double*>odata)
 */

  /* 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.cuda.cufft.execZ2D", __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_4cuda_5cufft_17execZ2D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_16execZ2D[] = "execZ2D(Handle plan, intptr_t idata, intptr_t odata)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_17execZ2D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execZ2D (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execZ2D", 1, 3, 3, 1); __PYX_ERR(0, 838, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("execZ2D", 1, 3, 3, 2); __PYX_ERR(0, 838, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execZ2D") < 0)) __PYX_ERR(0, 838, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execZ2D", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 838, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.execZ2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_16execZ2D(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_16execZ2D(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("execZ2D", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_execZ2D(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":844
 * 
 * 
 * cpdef multi_gpu_execC2C(Handle plan, intptr_t idata, intptr_t odata,             # <<<<<<<<<<<<<<
 *                         int direction):
 *     with nogil:
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_19multi_gpu_execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_multi_gpu_execC2C(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("multi_gpu_execC2C", 0);

  /* "cupy/cuda/cufft.pyx":846
 * cpdef multi_gpu_execC2C(Handle plan, intptr_t idata, intptr_t odata,
 *                         int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtExecDescriptorC2C(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":847
 *                         int direction):
 *     with nogil:
 *         result = cufftXtExecDescriptorC2C(plan, <XtArray*>idata,             # <<<<<<<<<<<<<<
 *                                           <XtArray*>odata, direction)
 *     check_result(result)
 */
        __pyx_v_result = cufftXtExecDescriptorC2C(__pyx_v_plan, ((cudaLibXtDesc *)__pyx_v_idata), ((cudaLibXtDesc *)__pyx_v_odata), __pyx_v_direction);
      }

      /* "cupy/cuda/cufft.pyx":846
 * cpdef multi_gpu_execC2C(Handle plan, intptr_t idata, intptr_t odata,
 *                         int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtExecDescriptorC2C(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":849
 *         result = cufftXtExecDescriptorC2C(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 *     check_result(result)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":844
 * 
 * 
 * cpdef multi_gpu_execC2C(Handle plan, intptr_t idata, intptr_t odata,             # <<<<<<<<<<<<<<
 *                         int direction):
 *     with nogil:
 */

  /* 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.cuda.cufft.multi_gpu_execC2C", __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_4cuda_5cufft_19multi_gpu_execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_18multi_gpu_execC2C[] = "multi_gpu_execC2C(Handle plan, intptr_t idata, intptr_t odata, int direction)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_19multi_gpu_execC2C(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  int __pyx_v_direction;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("multi_gpu_execC2C (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,&__pyx_n_s_direction,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execC2C", 1, 4, 4, 1); __PYX_ERR(0, 844, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execC2C", 1, 4, 4, 2); __PYX_ERR(0, 844, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execC2C", 1, 4, 4, 3); __PYX_ERR(0, 844, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "multi_gpu_execC2C") < 0)) __PYX_ERR(0, 844, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 844, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 844, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 844, __pyx_L3_error)
    __pyx_v_direction = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 845, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("multi_gpu_execC2C", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 844, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.multi_gpu_execC2C", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_18multi_gpu_execC2C(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_18multi_gpu_execC2C(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("multi_gpu_execC2C", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_multi_gpu_execC2C(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "cupy/cuda/cufft.pyx":852
 * 
 * 
 * cpdef multi_gpu_execZ2Z(Handle plan, intptr_t idata, intptr_t odata,             # <<<<<<<<<<<<<<
 *                         int direction):
 *     with nogil:
 */

static PyObject *__pyx_pw_4cupy_4cuda_5cufft_21multi_gpu_execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4cupy_4cuda_5cufft_multi_gpu_execZ2Z(cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction, CYTHON_UNUSED int __pyx_skip_dispatch) {
  cufftResult_t __pyx_v_result;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("multi_gpu_execZ2Z", 0);

  /* "cupy/cuda/cufft.pyx":854
 * cpdef multi_gpu_execZ2Z(Handle plan, intptr_t idata, intptr_t odata,
 *                         int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtExecDescriptorZ2Z(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "cupy/cuda/cufft.pyx":855
 *                         int direction):
 *     with nogil:
 *         result = cufftXtExecDescriptorZ2Z(plan, <XtArray*>idata,             # <<<<<<<<<<<<<<
 *                                           <XtArray*>odata, direction)
 *     check_result(result)
 */
        __pyx_v_result = cufftXtExecDescriptorZ2Z(__pyx_v_plan, ((cudaLibXtDesc *)__pyx_v_idata), ((cudaLibXtDesc *)__pyx_v_odata), __pyx_v_direction);
      }

      /* "cupy/cuda/cufft.pyx":854
 * cpdef multi_gpu_execZ2Z(Handle plan, intptr_t idata, intptr_t odata,
 *                         int direction):
 *     with nogil:             # <<<<<<<<<<<<<<
 *         result = cufftXtExecDescriptorZ2Z(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }

  /* "cupy/cuda/cufft.pyx":857
 *         result = cufftXtExecDescriptorZ2Z(plan, <XtArray*>idata,
 *                                           <XtArray*>odata, direction)
 *     check_result(result)             # <<<<<<<<<<<<<<
 */
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_check_result(__pyx_v_result, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 857, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":852
 * 
 * 
 * cpdef multi_gpu_execZ2Z(Handle plan, intptr_t idata, intptr_t odata,             # <<<<<<<<<<<<<<
 *                         int direction):
 *     with nogil:
 */

  /* 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.cuda.cufft.multi_gpu_execZ2Z", __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_4cuda_5cufft_21multi_gpu_execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4cupy_4cuda_5cufft_20multi_gpu_execZ2Z[] = "multi_gpu_execZ2Z(Handle plan, intptr_t idata, intptr_t odata, int direction)";
static PyObject *__pyx_pw_4cupy_4cuda_5cufft_21multi_gpu_execZ2Z(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  cufftHandle __pyx_v_plan;
  intptr_t __pyx_v_idata;
  intptr_t __pyx_v_odata;
  int __pyx_v_direction;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("multi_gpu_execZ2Z (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_plan,&__pyx_n_s_idata,&__pyx_n_s_odata,&__pyx_n_s_direction,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_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_idata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execZ2Z", 1, 4, 4, 1); __PYX_ERR(0, 852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_odata)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execZ2Z", 1, 4, 4, 2); __PYX_ERR(0, 852, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_direction)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("multi_gpu_execZ2Z", 1, 4, 4, 3); __PYX_ERR(0, 852, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "multi_gpu_execZ2Z") < 0)) __PYX_ERR(0, 852, __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_plan = __Pyx_PyInt_As_cufftHandle(values[0]); if (unlikely((__pyx_v_plan == ((cufftHandle)-1)) && PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error)
    __pyx_v_idata = PyInt_AsSsize_t(values[1]); if (unlikely((__pyx_v_idata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error)
    __pyx_v_odata = PyInt_AsSsize_t(values[2]); if (unlikely((__pyx_v_odata == ((intptr_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error)
    __pyx_v_direction = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 853, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("multi_gpu_execZ2Z", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 852, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("cupy.cuda.cufft.multi_gpu_execZ2Z", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4cupy_4cuda_5cufft_20multi_gpu_execZ2Z(__pyx_self, __pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction);

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

static PyObject *__pyx_pf_4cupy_4cuda_5cufft_20multi_gpu_execZ2Z(CYTHON_UNUSED PyObject *__pyx_self, cufftHandle __pyx_v_plan, intptr_t __pyx_v_idata, intptr_t __pyx_v_odata, int __pyx_v_direction) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("multi_gpu_execZ2Z", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4cupy_4cuda_5cufft_multi_gpu_execZ2Z(__pyx_v_plan, __pyx_v_idata, __pyx_v_odata, __pyx_v_direction, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "vector.to_py":60
 * 
 * @cname("__pyx_convert_vector_to_py_int")
 * cdef object __pyx_convert_vector_to_py_int(vector[X]& v):             # <<<<<<<<<<<<<<
 *     return [v[i] for i in range(v.size())]
 * 
 */

static PyObject *__pyx_convert_vector_to_py_int(const std::vector<int>  &__pyx_v_v) {
  size_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__pyx_convert_vector_to_py_int", 0);

  /* "vector.to_py":61
 * @cname("__pyx_convert_vector_to_py_int")
 * cdef object __pyx_convert_vector_to_py_int(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_From_int((__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_int")
 * cdef object __pyx_convert_vector_to_py_int(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_int", __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;
  __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 PyMethodDef __pyx_methods[] = {
  {"get_current_plan", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_1get_current_plan, METH_NOARGS, __pyx_doc_4cupy_4cuda_5cufft_get_current_plan},
  {"check_result", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_3check_result, METH_O, __pyx_doc_4cupy_4cuda_5cufft_2check_result},
  {"getVersion", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_5getVersion, METH_NOARGS, __pyx_doc_4cupy_4cuda_5cufft_4getVersion},
  {"execC2C", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_7execC2C, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_6execC2C},
  {"execR2C", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_9execR2C, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_8execR2C},
  {"execC2R", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_11execC2R, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_10execC2R},
  {"execZ2Z", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_13execZ2Z, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_12execZ2Z},
  {"execD2Z", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_15execD2Z, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_14execD2Z},
  {"execZ2D", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_17execZ2D, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_16execZ2D},
  {"multi_gpu_execC2C", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_19multi_gpu_execC2C, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_18multi_gpu_execC2C},
  {"multi_gpu_execZ2Z", (PyCFunction)__pyx_pw_4cupy_4cuda_5cufft_21multi_gpu_execZ2Z, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4cupy_4cuda_5cufft_20multi_gpu_execZ2Z},
  {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_cufft(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_cufft},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "cufft",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_u_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_ALLOC_FAILED, __pyx_k_CUFFT_ALLOC_FAILED, sizeof(__pyx_k_CUFFT_ALLOC_FAILED), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_EXEC_FAILED, __pyx_k_CUFFT_EXEC_FAILED, sizeof(__pyx_k_CUFFT_EXEC_FAILED), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INCOMPLETE_PARAMETER_LIST, __pyx_k_CUFFT_INCOMPLETE_PARAMETER_LIST, sizeof(__pyx_k_CUFFT_INCOMPLETE_PARAMETER_LIST), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INTERNAL_ERROR, __pyx_k_CUFFT_INTERNAL_ERROR, sizeof(__pyx_k_CUFFT_INTERNAL_ERROR), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INVALID_DEVICE, __pyx_k_CUFFT_INVALID_DEVICE, sizeof(__pyx_k_CUFFT_INVALID_DEVICE), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INVALID_PLAN, __pyx_k_CUFFT_INVALID_PLAN, sizeof(__pyx_k_CUFFT_INVALID_PLAN), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INVALID_SIZE, __pyx_k_CUFFT_INVALID_SIZE, sizeof(__pyx_k_CUFFT_INVALID_SIZE), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INVALID_TYPE, __pyx_k_CUFFT_INVALID_TYPE, sizeof(__pyx_k_CUFFT_INVALID_TYPE), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_INVALID_VALUE, __pyx_k_CUFFT_INVALID_VALUE, sizeof(__pyx_k_CUFFT_INVALID_VALUE), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_LICENSE_ERROR, __pyx_k_CUFFT_LICENSE_ERROR, sizeof(__pyx_k_CUFFT_LICENSE_ERROR), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_NOT_IMPLEMENTED, __pyx_k_CUFFT_NOT_IMPLEMENTED, sizeof(__pyx_k_CUFFT_NOT_IMPLEMENTED), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_NOT_SUPPORTED, __pyx_k_CUFFT_NOT_SUPPORTED, sizeof(__pyx_k_CUFFT_NOT_SUPPORTED), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_NO_WORKSPACE, __pyx_k_CUFFT_NO_WORKSPACE, sizeof(__pyx_k_CUFFT_NO_WORKSPACE), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_PARSE_ERROR, __pyx_k_CUFFT_PARSE_ERROR, sizeof(__pyx_k_CUFFT_PARSE_ERROR), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_SETUP_FAILED, __pyx_k_CUFFT_SETUP_FAILED, sizeof(__pyx_k_CUFFT_SETUP_FAILED), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_SUCCESS, __pyx_k_CUFFT_SUCCESS, sizeof(__pyx_k_CUFFT_SUCCESS), 0, 1, 0, 1},
  {&__pyx_n_u_CUFFT_UNALIGNED_DATA, __pyx_k_CUFFT_UNALIGNED_DATA, sizeof(__pyx_k_CUFFT_UNALIGNED_DATA), 0, 1, 0, 1},
  {&__pyx_n_s_CuFFTError, __pyx_k_CuFFTError, sizeof(__pyx_k_CuFFTError), 0, 0, 1, 1},
  {&__pyx_n_s_CuFFTError___init, __pyx_k_CuFFTError___init, sizeof(__pyx_k_CuFFTError___init), 0, 0, 1, 1},
  {&__pyx_n_s_CuFFTError___reduce, __pyx_k_CuFFTError___reduce, sizeof(__pyx_k_CuFFTError___reduce), 0, 0, 1, 1},
  {&__pyx_kp_u_Currently_for_multiple_GPUs_only, __pyx_k_Currently_for_multiple_GPUs_only, sizeof(__pyx_k_Currently_for_multiple_GPUs_only), 0, 1, 0, 0},
  {&__pyx_n_s_Device, __pyx_k_Device, sizeof(__pyx_k_Device), 0, 0, 1, 1},
  {&__pyx_n_s_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
  {&__pyx_kp_u_For_GPUs_the_array_length_must_b, __pyx_k_For_GPUs_the_array_length_must_b, sizeof(__pyx_k_For_GPUs_the_array_length_must_b), 0, 1, 0, 0},
  {&__pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t, __pyx_k_For_multi_GPU_FFT_with_batch_1_t, sizeof(__pyx_k_For_multi_GPU_FFT_with_batch_1_t), 0, 1, 0, 0},
  {&__pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t_2, __pyx_k_For_multi_GPU_FFT_with_batch_1_t_2, sizeof(__pyx_k_For_multi_GPU_FFT_with_batch_1_t_2), 0, 1, 0, 0},
  {&__pyx_kp_u_Impossible_to_reach, __pyx_k_Impossible_to_reach, sizeof(__pyx_k_Impossible_to_reach), 0, 1, 0, 0},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_u_OWNDATA, __pyx_k_OWNDATA, sizeof(__pyx_k_OWNDATA), 0, 1, 0, 1},
  {&__pyx_n_s_Plan1d, __pyx_k_Plan1d, sizeof(__pyx_k_Plan1d), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d___del, __pyx_k_Plan1d___del, sizeof(__pyx_k_Plan1d___del), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d___enter, __pyx_k_Plan1d___enter, sizeof(__pyx_k_Plan1d___enter), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d___exit, __pyx_k_Plan1d___exit, sizeof(__pyx_k_Plan1d___exit), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d___init, __pyx_k_Plan1d___init, sizeof(__pyx_k_Plan1d___init), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__multi_gpu_fft, __pyx_k_Plan1d__multi_gpu_fft, sizeof(__pyx_k_Plan1d__multi_gpu_fft), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__multi_gpu_get_plan, __pyx_k_Plan1d__multi_gpu_get_plan, sizeof(__pyx_k_Plan1d__multi_gpu_get_plan), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__multi_gpu_memcpy, __pyx_k_Plan1d__multi_gpu_memcpy, sizeof(__pyx_k_Plan1d__multi_gpu_memcpy), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__multi_gpu_setup_buffer, __pyx_k_Plan1d__multi_gpu_setup_buffer, sizeof(__pyx_k_Plan1d__multi_gpu_setup_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__output_dtype_and_shape, __pyx_k_Plan1d__output_dtype_and_shape, sizeof(__pyx_k_Plan1d__output_dtype_and_shape), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__single_gpu_fft, __pyx_k_Plan1d__single_gpu_fft, sizeof(__pyx_k_Plan1d__single_gpu_fft), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d__single_gpu_get_plan, __pyx_k_Plan1d__single_gpu_get_plan, sizeof(__pyx_k_Plan1d__single_gpu_get_plan), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d_check_output_array, __pyx_k_Plan1d_check_output_array, sizeof(__pyx_k_Plan1d_check_output_array), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d_fft, __pyx_k_Plan1d_fft, sizeof(__pyx_k_Plan1d_fft), 0, 0, 1, 1},
  {&__pyx_n_s_Plan1d_get_output_array, __pyx_k_Plan1d_get_output_array, sizeof(__pyx_k_Plan1d_get_output_array), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd, __pyx_k_PlanNd, sizeof(__pyx_k_PlanNd), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd___del, __pyx_k_PlanNd___del, sizeof(__pyx_k_PlanNd___del), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd___enter, __pyx_k_PlanNd___enter, sizeof(__pyx_k_PlanNd___enter), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd___exit, __pyx_k_PlanNd___exit, sizeof(__pyx_k_PlanNd___exit), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd___init, __pyx_k_PlanNd___init, sizeof(__pyx_k_PlanNd___init), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd__output_dtype_and_shape, __pyx_k_PlanNd__output_dtype_and_shape, sizeof(__pyx_k_PlanNd__output_dtype_and_shape), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd_check_output_array, __pyx_k_PlanNd_check_output_array, sizeof(__pyx_k_PlanNd_check_output_array), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd_fft, __pyx_k_PlanNd_fft, sizeof(__pyx_k_PlanNd_fft), 0, 0, 1, 1},
  {&__pyx_n_s_PlanNd_get_output_array, __pyx_k_PlanNd_get_output_array, sizeof(__pyx_k_PlanNd_get_output_array), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_Stream, __pyx_k_Stream, sizeof(__pyx_k_Stream), 0, 0, 1, 1},
  {&__pyx_kp_u_User_managed_buffer_area_is_not, __pyx_k_User_managed_buffer_area_is_not, sizeof(__pyx_k_User_managed_buffer_area_is_not), 0, 1, 0, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_action, __pyx_k_action, sizeof(__pyx_k_action), 0, 0, 1, 1},
  {&__pyx_n_s_arr, __pyx_k_arr, sizeof(__pyx_k_arr), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_s_batch, __pyx_k_batch, sizeof(__pyx_k_batch), 0, 0, 1, 1},
  {&__pyx_n_s_batch_share, __pyx_k_batch_share, sizeof(__pyx_k_batch_share), 0, 0, 1, 1},
  {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 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_char, __pyx_k_char, sizeof(__pyx_k_char), 0, 0, 1, 1},
  {&__pyx_n_s_check_output_array, __pyx_k_check_output_array, sizeof(__pyx_k_check_output_array), 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_complex128, __pyx_k_complex128, sizeof(__pyx_k_complex128), 0, 0, 1, 1},
  {&__pyx_n_s_complex64, __pyx_k_complex64, sizeof(__pyx_k_complex64), 0, 0, 1, 1},
  {&__pyx_n_s_copy_from_device_async, __pyx_k_copy_from_device_async, sizeof(__pyx_k_copy_from_device_async), 0, 0, 1, 1},
  {&__pyx_n_s_count, __pyx_k_count, sizeof(__pyx_k_count), 0, 0, 1, 1},
  {&__pyx_n_s_cupy, __pyx_k_cupy, sizeof(__pyx_k_cupy), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_cuda_cufft, __pyx_k_cupy_cuda_cufft, sizeof(__pyx_k_cupy_cuda_cufft), 0, 0, 1, 1},
  {&__pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_k_cupy_cuda_cufft_pyx, sizeof(__pyx_k_cupy_cuda_cufft_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_cupy_cuda_device, __pyx_k_cupy_cuda_device, sizeof(__pyx_k_cupy_cuda_device), 0, 0, 1, 1},
  {&__pyx_n_s_cupy_cuda_stream, __pyx_k_cupy_cuda_stream, sizeof(__pyx_k_cupy_cuda_stream), 0, 0, 1, 1},
  {&__pyx_n_s_curr_event, __pyx_k_curr_event, sizeof(__pyx_k_curr_event), 0, 0, 1, 1},
  {&__pyx_n_s_curr_stream, __pyx_k_curr_stream, sizeof(__pyx_k_curr_stream), 0, 0, 1, 1},
  {&__pyx_n_s_current_plan, __pyx_k_current_plan, sizeof(__pyx_k_current_plan), 0, 0, 1, 1},
  {&__pyx_n_u_current_plan, __pyx_k_current_plan, sizeof(__pyx_k_current_plan), 0, 1, 0, 1},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_n_s_del, __pyx_k_del, sizeof(__pyx_k_del), 0, 0, 1, 1},
  {&__pyx_n_s_dev, __pyx_k_dev, sizeof(__pyx_k_dev), 0, 0, 1, 1},
  {&__pyx_n_s_devices, __pyx_k_devices, sizeof(__pyx_k_devices), 0, 0, 1, 1},
  {&__pyx_kp_u_devices_should_be_an_int_or_a_l, __pyx_k_devices_should_be_an_int_or_a_l, sizeof(__pyx_k_devices_should_be_an_int_or_a_l), 0, 1, 0, 0},
  {&__pyx_n_s_direction, __pyx_k_direction, sizeof(__pyx_k_direction), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dype, __pyx_k_dype, sizeof(__pyx_k_dype), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1},
  {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1},
  {&__pyx_n_s_exc_type, __pyx_k_exc_type, sizeof(__pyx_k_exc_type), 0, 0, 1, 1},
  {&__pyx_n_s_exc_value, __pyx_k_exc_value, sizeof(__pyx_k_exc_value), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_f_contiguous, __pyx_k_f_contiguous, sizeof(__pyx_k_f_contiguous), 0, 0, 1, 1},
  {&__pyx_n_s_fft, __pyx_k_fft, sizeof(__pyx_k_fft), 0, 0, 1, 1},
  {&__pyx_n_s_fft_type, __pyx_k_fft_type, sizeof(__pyx_k_fft_type), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 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_fmt, __pyx_k_fmt, sizeof(__pyx_k_fmt), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_free_all_blocks, __pyx_k_free_all_blocks, sizeof(__pyx_k_free_all_blocks), 0, 0, 1, 1},
  {&__pyx_n_u_gather, __pyx_k_gather, sizeof(__pyx_k_gather), 0, 1, 0, 1},
  {&__pyx_n_s_get_default_memory_pool, __pyx_k_get_default_memory_pool, sizeof(__pyx_k_get_default_memory_pool), 0, 0, 1, 1},
  {&__pyx_n_s_get_output_array, __pyx_k_get_output_array, sizeof(__pyx_k_get_output_array), 0, 0, 1, 1},
  {&__pyx_n_s_gpus, __pyx_k_gpus, sizeof(__pyx_k_gpus), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_idata, __pyx_k_idata, sizeof(__pyx_k_idata), 0, 0, 1, 1},
  {&__pyx_n_s_idist, __pyx_k_idist, sizeof(__pyx_k_idist), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_inembed, __pyx_k_inembed, sizeof(__pyx_k_inembed), 0, 0, 1, 1},
  {&__pyx_n_s_inembed_arr, __pyx_k_inembed_arr, sizeof(__pyx_k_inembed_arr), 0, 0, 1, 1},
  {&__pyx_n_s_inembed_ptr, __pyx_k_inembed_ptr, sizeof(__pyx_k_inembed_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_istride, __pyx_k_istride, sizeof(__pyx_k_istride), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_n_s_last_axis, __pyx_k_last_axis, sizeof(__pyx_k_last_axis), 0, 0, 1, 1},
  {&__pyx_n_s_last_size, __pyx_k_last_size, sizeof(__pyx_k_last_size), 0, 0, 1, 1},
  {&__pyx_n_s_local, __pyx_k_local, sizeof(__pyx_k_local), 0, 0, 1, 1},
  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_min_len, __pyx_k_min_len, sizeof(__pyx_k_min_len), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_multi_gpu_fft, __pyx_k_multi_gpu_fft, sizeof(__pyx_k_multi_gpu_fft), 0, 0, 1, 1},
  {&__pyx_n_s_multi_gpu_get_plan, __pyx_k_multi_gpu_get_plan, sizeof(__pyx_k_multi_gpu_get_plan), 0, 0, 1, 1},
  {&__pyx_n_s_multi_gpu_memcpy, __pyx_k_multi_gpu_memcpy, sizeof(__pyx_k_multi_gpu_memcpy), 0, 0, 1, 1},
  {&__pyx_n_s_multi_gpu_setup_buffer, __pyx_k_multi_gpu_setup_buffer, sizeof(__pyx_k_multi_gpu_setup_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_nGPUs, __pyx_k_nGPUs, sizeof(__pyx_k_nGPUs), 0, 0, 1, 1},
  {&__pyx_n_s_ndarray, __pyx_k_ndarray, sizeof(__pyx_k_ndarray), 0, 0, 1, 1},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_nx, __pyx_k_nx, sizeof(__pyx_k_nx), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_odata, __pyx_k_odata, sizeof(__pyx_k_odata), 0, 0, 1, 1},
  {&__pyx_n_s_odist, __pyx_k_odist, sizeof(__pyx_k_odist), 0, 0, 1, 1},
  {&__pyx_n_s_onembed, __pyx_k_onembed, sizeof(__pyx_k_onembed), 0, 0, 1, 1},
  {&__pyx_n_s_onembed_arr, __pyx_k_onembed_arr, sizeof(__pyx_k_onembed_arr), 0, 0, 1, 1},
  {&__pyx_n_s_onembed_ptr, __pyx_k_onembed_ptr, sizeof(__pyx_k_onembed_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_order, __pyx_k_order, sizeof(__pyx_k_order), 0, 0, 1, 1},
  {&__pyx_n_s_ostride, __pyx_k_ostride, sizeof(__pyx_k_ostride), 0, 0, 1, 1},
  {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
  {&__pyx_kp_u_out_dtype_mismatch_found_expecte, __pyx_k_out_dtype_mismatch_found_expecte, sizeof(__pyx_k_out_dtype_mismatch_found_expecte), 0, 1, 0, 0},
  {&__pyx_kp_u_out_must_have_shape, __pyx_k_out_must_have_shape, sizeof(__pyx_k_out_must_have_shape), 0, 1, 0, 0},
  {&__pyx_n_s_outer_stream, __pyx_k_outer_stream, sizeof(__pyx_k_outer_stream), 0, 0, 1, 1},
  {&__pyx_kp_u_output_contiguity_mismatch, __pyx_k_output_contiguity_mismatch, sizeof(__pyx_k_output_contiguity_mismatch), 0, 1, 0, 0},
  {&__pyx_kp_u_output_dimension_mismatch, __pyx_k_output_dimension_mismatch, sizeof(__pyx_k_output_dimension_mismatch), 0, 1, 0, 0},
  {&__pyx_n_s_output_dtype_and_shape, __pyx_k_output_dtype_and_shape, sizeof(__pyx_k_output_dtype_and_shape), 0, 0, 1, 1},
  {&__pyx_kp_u_output_dtype_is_unexpected, __pyx_k_output_dtype_is_unexpected, sizeof(__pyx_k_output_dtype_is_unexpected), 0, 1, 0, 0},
  {&__pyx_kp_u_output_dtype_mismatch, __pyx_k_output_dtype_mismatch, sizeof(__pyx_k_output_dtype_mismatch), 0, 1, 0, 0},
  {&__pyx_kp_u_output_shape_is_incorrecct, __pyx_k_output_shape_is_incorrecct, sizeof(__pyx_k_output_shape_is_incorrecct), 0, 1, 0, 0},
  {&__pyx_kp_u_output_shape_mismatch, __pyx_k_output_shape_mismatch, sizeof(__pyx_k_output_shape_mismatch), 0, 1, 0, 0},
  {&__pyx_n_s_plan, __pyx_k_plan, sizeof(__pyx_k_plan), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_prev_event, __pyx_k_prev_event, sizeof(__pyx_k_prev_event), 0, 0, 1, 1},
  {&__pyx_n_s_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_ptr2, __pyx_k_ptr2, sizeof(__pyx_k_ptr2), 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_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_ravel, __pyx_k_ravel, sizeof(__pyx_k_ravel), 0, 0, 1, 1},
  {&__pyx_n_s_record, __pyx_k_record, sizeof(__pyx_k_record), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_kp_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 0},
  {&__pyx_n_u_scatter, __pyx_k_scatter, sizeof(__pyx_k_scatter), 0, 1, 0, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_shape_arr, __pyx_k_shape_arr, sizeof(__pyx_k_shape_arr), 0, 0, 1, 1},
  {&__pyx_n_s_shape_ptr, __pyx_k_shape_ptr, sizeof(__pyx_k_shape_ptr), 0, 0, 1, 1},
  {&__pyx_n_s_share, __pyx_k_share, sizeof(__pyx_k_share), 0, 0, 1, 1},
  {&__pyx_n_s_single_gpu_fft, __pyx_k_single_gpu_fft, sizeof(__pyx_k_single_gpu_fft), 0, 0, 1, 1},
  {&__pyx_n_s_single_gpu_get_plan, __pyx_k_single_gpu_get_plan, sizeof(__pyx_k_single_gpu_get_plan), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_sizes, __pyx_k_sizes, sizeof(__pyx_k_sizes), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1},
  {&__pyx_n_s_streams, __pyx_k_streams, sizeof(__pyx_k_streams), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_synchronize, __pyx_k_synchronize, sizeof(__pyx_k_synchronize), 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_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_n_s_use_multi_gpus, __pyx_k_use_multi_gpus, sizeof(__pyx_k_use_multi_gpus), 0, 0, 1, 1},
  {&__pyx_n_s_use_multi_gpus_2, __pyx_k_use_multi_gpus_2, sizeof(__pyx_k_use_multi_gpus_2), 0, 0, 1, 1},
  {&__pyx_n_s_wait_event, __pyx_k_wait_event, sizeof(__pyx_k_wait_event), 0, 0, 1, 1},
  {&__pyx_n_s_work_area, __pyx_k_work_area, sizeof(__pyx_k_work_area), 0, 0, 1, 1},
  {&__pyx_n_s_work_area_ptr, __pyx_k_work_area_ptr, sizeof(__pyx_k_work_area_ptr), 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_xtArr, __pyx_k_xtArr, sizeof(__pyx_k_xtArr), 0, 0, 1, 1},
  {&__pyx_n_s_xtArr_buffer, __pyx_k_xtArr_buffer, sizeof(__pyx_k_xtArr_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_xtArr_desc, __pyx_k_xtArr_desc, sizeof(__pyx_k_xtArr_desc), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 134, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 249, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 138, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 174, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 224, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 224, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 319, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 500, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "cupy/cuda/cufft.pyx":225
 *     xtArr_desc.nGPUs = nGPUs
 *     for i, (gpu, size) in enumerate(zip(gpus, sizes)):
 *         with Device(gpu):             # <<<<<<<<<<<<<<
 *             buf = memory.alloc(size)
 *         assert gpu == buf.device_id
 */
  __pyx_tuple_ = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "cupy/cuda/cufft.pyx":319
 *         # some sanity checks
 *         if fft_type != CUFFT_C2C and fft_type != CUFFT_Z2Z:
 *             raise ValueError('Currently for multiple GPUs only C2C and Z2Z are'             # <<<<<<<<<<<<<<
 *                              ' supported.')
 *         if isinstance(devices, list):
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_Currently_for_multiple_GPUs_only); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 319, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "cupy/cuda/cufft.pyx":330
 *                 gpus.push_back(i)
 *         else:
 *             raise ValueError('\"devices\" should be an int or a list of int.')             # <<<<<<<<<<<<<<
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_devices_should_be_an_int_or_a_l); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "cupy/cuda/cufft.pyx":333
 *         if batch == 1:
 *             if (nx & (nx - 1)) != 0:
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the array '             # <<<<<<<<<<<<<<
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "cupy/cuda/cufft.pyx":336
 *                                  'size must be a power of 2.')
 *             if nGPUs not in (2, 4, 8, 16):
 *                 raise ValueError('For multi-GPU FFT with batch = 1, the number'             # <<<<<<<<<<<<<<
 *                                  ' of devices must be 2, 4, 8, or 16.')
 *             if nGPUs in (2, 4):
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_For_multi_GPU_FFT_with_batch_1_t_2); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "cupy/cuda/cufft.pyx":366
 * 
 *         for i in range(nGPUs):
 *             with Device(gpus[i]):             # <<<<<<<<<<<<<<
 *                 buf = memory.alloc(work_size[i])
 *                 stream = Stream()
 */
  __pyx_tuple__6 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 366, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "cupy/cuda/cufft.pyx":500
 *             # ndarrays, each of which is on a different GPU. Then, no data
 *             # copy is needed, just replace the pointers in the descriptor.
 *             raise NotImplementedError('User-managed buffer area is not yet '             # <<<<<<<<<<<<<<
 *                                       'supported.')
 *         else:
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_User_managed_buffer_area_is_not); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "cupy/cuda/cufft.pyx":503
 *                                       'supported.')
 *         else:
 *             raise ValueError('Impossible to reach.')             # <<<<<<<<<<<<<<
 * 
 *     def _multi_gpu_memcpy(self, a, str action):
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Impossible_to_reach); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cupy/cuda/cufft.pyx":785
 *         if self.fft_type in (CUFFT_C2C, CUFFT_Z2Z):
 *             if out.shape != a.shape:
 *                 raise ValueError('output shape mismatch')             # <<<<<<<<<<<<<<
 *             if out.dtype != a.dtype:
 *                 raise ValueError('output dtype mismatch')
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_output_shape_mismatch); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cupy/cuda/cufft.pyx":787
 *                 raise ValueError('output shape mismatch')
 *             if out.dtype != a.dtype:
 *                 raise ValueError('output dtype mismatch')             # <<<<<<<<<<<<<<
 *         else:
 *             if out.ndim != a.ndim:
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_output_dtype_mismatch); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cupy/cuda/cufft.pyx":790
 *         else:
 *             if out.ndim != a.ndim:
 *                 raise ValueError('output dimension mismatch')             # <<<<<<<<<<<<<<
 *             for i, size in enumerate(out.shape):
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_output_dimension_mismatch); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "cupy/cuda/cufft.pyx":794
 *                 if (i != self.last_axis and size != a.shape[i]) or \
 *                    (i == self.last_axis and size != self.last_size):
 *                     raise ValueError('output shape is incorrecct')             # <<<<<<<<<<<<<<
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_output_shape_is_incorrecct); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cupy/cuda/cufft.pyx":797
 *             if self.fft_type in (CUFFT_R2C, CUFFT_D2Z):
 *                 if out.dtype != cupy.dtype(a.dype.char.upper()):
 *                     raise ValueError('output dtype is unexpected')             # <<<<<<<<<<<<<<
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 */
  __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_output_dtype_is_unexpected); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 797, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cupy/cuda/cufft.pyx":800
 *             else:  # CUFFT_C2R or CUFFT_Z2D
 *                 if out.dtype != cupy.dtype(a.dype.char.lower()):
 *                     raise ValueError('output dtype is unexpected')             # <<<<<<<<<<<<<<
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_output_dtype_is_unexpected); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 800, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cupy/cuda/cufft.pyx":803
 *         if not ((out.flags.f_contiguous == a.flags.f_contiguous) and
 *                 (out.flags.c_contiguous == a.flags.c_contiguous)):
 *             raise ValueError('output contiguity mismatch')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_output_contiguity_mismatch); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cupy/cuda/cufft.pyx":134
 * 
 * 
 * class CuFFTError(RuntimeError):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, int result):
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_builtin_RuntimeError); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "cupy/cuda/cufft.pyx":136
 * class CuFFTError(RuntimeError):
 * 
 *     def __init__(self, int result):             # <<<<<<<<<<<<<<
 *         self.result = result
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 */
  __pyx_tuple__17 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_result); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);
  __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_init, 136, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 136, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":140
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (type(self), (self.result,))
 * 
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);
  __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_reduce, 140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 140, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":249
 * 
 * 
 * class Plan1d(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, int nx, int fft_type, int batch, *,
 *                  devices=None, out=None):
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "cupy/cuda/cufft.pyx":250
 * 
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,             # <<<<<<<<<<<<<<
 *                  devices=None, out=None):
 *         cdef Handle plan
 */
  __pyx_tuple__22 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_nx, __pyx_n_s_fft_type, __pyx_n_s_batch, __pyx_n_s_devices, __pyx_n_s_out, __pyx_n_s_plan, __pyx_n_s_use_multi_gpus_2, __pyx_n_s_result); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(4, 2, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_init, 250, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 250, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":276
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 * 
 *     def _single_gpu_get_plan(self, Handle plan, int nx, int fft_type,             # <<<<<<<<<<<<<<
 *                              int batch):
 *         cdef int result
 */
  __pyx_tuple__24 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_plan, __pyx_n_s_nx, __pyx_n_s_fft_type, __pyx_n_s_batch, __pyx_n_s_result, __pyx_n_s_work_size, __pyx_n_s_ptr, __pyx_n_s_work_area); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(5, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_single_gpu_get_plan, 276, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 276, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":307
 *         self.events = None
 * 
 *     def _multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch,             # <<<<<<<<<<<<<<
 *                             devices, out):
 *         cdef int nGPUs, min_len, result
 */
  __pyx_tuple__26 = PyTuple_Pack(20, __pyx_n_s_self, __pyx_n_s_plan, __pyx_n_s_nx, __pyx_n_s_fft_type, __pyx_n_s_batch, __pyx_n_s_devices, __pyx_n_s_out, __pyx_n_s_nGPUs, __pyx_n_s_min_len, __pyx_n_s_result, __pyx_n_s_gpus, __pyx_n_s_work_size, __pyx_n_s_work_area, __pyx_n_s_streams, __pyx_n_s_events, __pyx_n_s_work_area_ptr, __pyx_n_s_i, __pyx_n_s_buf, __pyx_n_s_stream, __pyx_n_s_event); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_multi_gpu_get_plan, 307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 307, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":384
 *         self.events = events        # for async, overlapped copies
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef int dev = runtime.getDevice()
 */
  __pyx_tuple__28 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_plan, __pyx_n_s_dev, __pyx_n_s_result); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);
  __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_del, 384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 384, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":402
 *             self.xtArr = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
  __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_enter, 402, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 402, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":406
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */
  __pyx_tuple__32 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_exc_type, __pyx_n_s_exc_value, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_exit, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 406, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":409
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         if self._use_multi_gpus:
 *             # Note: mult-GPU plans cannot set stream
 */
  __pyx_tuple__34 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_direction); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_fft, 409, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 409, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":416
 *             self._single_gpu_fft(a, out, direction)
 * 
 *     def _single_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */
  __pyx_tuple__36 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_direction, __pyx_n_s_plan, __pyx_n_s_stream, __pyx_n_s_result); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 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_cuda_cufft_pyx, __pyx_n_s_single_gpu_fft, 416, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 416, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":437
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 * 
 *     def _multi_gpu_setup_buffer(self, a):             # <<<<<<<<<<<<<<
 *         cdef XtArrayDesc* xtArr_desc
 *         cdef XtArray* xtArr
 */
  __pyx_tuple__38 = PyTuple_Pack(13, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_xtArr_desc, __pyx_n_s_xtArr, __pyx_n_s_ptr, __pyx_n_s_xtArr_buffer, __pyx_n_s_share, __pyx_n_s_sizes, __pyx_n_s_i, __pyx_n_s_nGPUs, __pyx_n_s_count, __pyx_n_s_fmt, __pyx_n_s_i); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(2, 0, 13, 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_cuda_cufft_pyx, __pyx_n_s_multi_gpu_setup_buffer, 437, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 437, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":505
 *             raise ValueError('Impossible to reach.')
 * 
 *     def _multi_gpu_memcpy(self, a, str action):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef list xtArr_buffer, share
 */
  __pyx_tuple__40 = PyTuple_Pack(20, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_action, __pyx_n_s_plan, __pyx_n_s_xtArr_buffer, __pyx_n_s_share, __pyx_n_s_start, __pyx_n_s_nGPUs, __pyx_n_s_i, __pyx_n_s_count, __pyx_n_s_result, __pyx_n_s_arr, __pyx_n_s_ptr, __pyx_n_s_ptr2, __pyx_n_s_size, __pyx_n_s_b, __pyx_n_s_curr_stream, __pyx_n_s_outer_stream, __pyx_n_s_prev_event, __pyx_n_s_curr_event); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);
  __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(3, 0, 20, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_multi_gpu_memcpy, 505, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 505, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":592
 *                 raise ValueError
 * 
 *     def _multi_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         # When we arrive here, the normal CuPy call path ensures a and out
 *         # reside on the same GPU -> must distribute a to all of the GPUs
 */
  __pyx_tuple__42 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_direction); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
  __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_multi_gpu_fft, 592, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 592, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":611
 *         self._multi_gpu_memcpy(out, 'gather')
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_tuple__44 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_shape, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);
  __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_output_dtype_and_shape, 611, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 611, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":631
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype)
 */
  __pyx_tuple__46 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_shape, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);
  __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_get_output_array, 631, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 631, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":635
 *         return cupy.empty(shape, dtype)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         """Verify shape and dtype of the output array.
 * 
 */
  __pyx_tuple__48 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_shape, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);
  __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_check_output_array, 635, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 635, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":655
 * 
 * 
 * class PlanNd(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, object shape, object inembed, int istride,
 *                  int idist, object onembed, int ostride, int odist,
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "cupy/cuda/cufft.pyx":656
 * 
 * class PlanNd(object):
 *     def __init__(self, object shape, object inembed, int istride,             # <<<<<<<<<<<<<<
 *                  int idist, object onembed, int ostride, int odist,
 *                  int fft_type, int batch, str order, int last_axis, last_size):
 */
  __pyx_tuple__51 = PyTuple_Pack(25, __pyx_n_s_self, __pyx_n_s_shape, __pyx_n_s_inembed, __pyx_n_s_istride, __pyx_n_s_idist, __pyx_n_s_onembed, __pyx_n_s_ostride, __pyx_n_s_odist, __pyx_n_s_fft_type, __pyx_n_s_batch, __pyx_n_s_order, __pyx_n_s_last_axis, __pyx_n_s_last_size, __pyx_n_s_plan, __pyx_n_s_work_size, __pyx_n_s_ndim, __pyx_n_s_i, __pyx_n_s_shape_arr, __pyx_n_s_inembed_arr, __pyx_n_s_onembed_arr, __pyx_n_s_shape_ptr, __pyx_n_s_inembed_ptr, __pyx_n_s_onembed_ptr, __pyx_n_s_result, __pyx_n_s_work_area); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(13, 0, 25, 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_cuda_cufft_pyx, __pyx_n_s_init, 656, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 656, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":720
 *         self.last_size = last_size  # = None (and ignored) for C2C
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         with nogil:
 */
  __pyx_tuple__53 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_plan, __pyx_n_s_result); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 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_cuda_cufft_pyx, __pyx_n_s_del, 720, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 720, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":726
 *         check_result(result)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 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_cuda_cufft_pyx, __pyx_n_s_enter, 726, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) __PYX_ERR(0, 726, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":730
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */
  __pyx_tuple__57 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_exc_type, __pyx_n_s_exc_value, __pyx_n_s_traceback); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(4, 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_cuda_cufft_pyx, __pyx_n_s_exit, 730, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 730, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":733
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */
  __pyx_tuple__59 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_direction, __pyx_n_s_plan, __pyx_n_s_stream, __pyx_n_s_result); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(4, 0, 7, 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_cuda_cufft_pyx, __pyx_n_s_fft, 733, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 733, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":755
 *             raise ValueError
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_tuple__61 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_shape, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 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_cuda_cufft_pyx, __pyx_n_s_output_dtype_and_shape, 755, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 755, __pyx_L1_error)

  /* "cupy/cuda/cufft.pyx":775
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a, order='C'):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype, order=order)
 */
  __pyx_tuple__63 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_order, __pyx_n_s_shape, __pyx_n_s_dtype); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
  __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 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_cuda_cufft_pyx, __pyx_n_s_get_output_array, 775, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 775, __pyx_L1_error)
  __pyx_tuple__65 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_C)); if (unlikely(!__pyx_tuple__65)) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "cupy/cuda/cufft.pyx":779
 *         return cupy.empty(shape, dtype, order=order)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         if out is a:
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 */
  __pyx_tuple__66 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_a, __pyx_n_s_out, __pyx_n_s_i, __pyx_n_s_size); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);
  __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cupy_cuda_cufft_pyx, __pyx_n_s_check_output_array, 779, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_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_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_14 = PyInt_FromLong(14); if (unlikely(!__pyx_int_14)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_modinit_global_init_code(void); /*proto*/
static int __Pyx_modinit_variable_export_code(void); /*proto*/
static int __Pyx_modinit_function_export_code(void); /*proto*/
static int __Pyx_modinit_type_init_code(void); /*proto*/
static int __Pyx_modinit_type_import_code(void); /*proto*/
static int __Pyx_modinit_variable_import_code(void); /*proto*/
static int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __pyx_v_4cupy_4cuda_5cufft__thread_local = Py_None; Py_INCREF(Py_None);
  __pyx_v_4cupy_4cuda_5cufft_RESULT = ((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 ---*/
  if (__Pyx_ExportFunction("get_current_plan", (void (*)(void))__pyx_f_4cupy_4cuda_5cufft_get_current_plan, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_ptype_4cupy_4cuda_6device_Handle = __Pyx_ImportType("cupy.cuda.device", "Handle", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Handle), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Handle)) __PYX_ERR(2, 7, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6device_Device = __Pyx_ImportType("cupy.cuda.device", "Device", sizeof(struct __pyx_obj_4cupy_4cuda_6device_Device), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6device_Device)) __PYX_ERR(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_ptype_4cupy_4cuda_6memory_BaseMemory = __Pyx_ImportType("cupy.cuda.memory", "BaseMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_BaseMemory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_BaseMemory)) __PYX_ERR(3, 11, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_MemoryPointer = __Pyx_ImportType("cupy.cuda.memory", "MemoryPointer", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPointer)) __PYX_ERR(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("cupy.cuda.memory", "MemoryPool", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_MemoryPool), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(3, 52, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_MemoryPool*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_MemoryPool->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_MemoryPool)) __PYX_ERR(3, 52, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory = __Pyx_ImportType("cupy.cuda.memory", "CFunctionAllocatorMemory", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocatorMemory), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocatorMemory)) __PYX_ERR(3, 69, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator = __Pyx_ImportType("cupy.cuda.memory", "CFunctionAllocator", sizeof(struct __pyx_obj_4cupy_4cuda_6memory_CFunctionAllocator), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator)) __PYX_ERR(3, 76, __pyx_L1_error)
  __pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator = (struct __pyx_vtabstruct_4cupy_4cuda_6memory_CFunctionAllocator*)__Pyx_GetVtable(__pyx_ptype_4cupy_4cuda_6memory_CFunctionAllocator->tp_dict); if (unlikely(!__pyx_vtabptr_4cupy_4cuda_6memory_CFunctionAllocator)) __PYX_ERR(3, 76, __pyx_L1_error)
  __pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes = __Pyx_ImportType("cupy.cuda.runtime", "PointerAttributes", sizeof(struct __pyx_obj_4cupy_4cuda_7runtime_PointerAttributes), 1); if (unlikely(!__pyx_ptype_4cupy_4cuda_7runtime_PointerAttributes)) __PYX_ERR(4, 8, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "_is_hip_environment", (void **)&__pyx_vp_4cupy_4cuda_7runtime__is_hip_environment, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "deviceAttributeComputeCapabilityMajor", (void **)&__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMajor, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "deviceAttributeComputeCapabilityMinor", (void **)&__pyx_vp_4cupy_4cuda_7runtime_deviceAttributeComputeCapabilityMinor, "int") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_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_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("cupy.cuda.memory"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "alloc", (void (**)(void))&__pyx_f_4cupy_4cuda_6memory_alloc, "struct __pyx_obj_4cupy_4cuda_6memory_MemoryPointer *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("cupy.cuda.runtime"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "getDevice", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_getDevice, "int (int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "setDevice", (void (**)(void))&__pyx_f_4cupy_4cuda_7runtime_setDevice, "PyObject *(int, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("cupy.cuda.stream"); if (!__pyx_t_3) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "get_current_stream_ptr", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream_ptr, "intptr_t (void)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_3, "get_current_stream", (void (**)(void))&__pyx_f_4cupy_4cuda_6stream_get_current_stream, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
    #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initcufft(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initcufft(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_cufft(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_cufft(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        result = PyDict_SetItemString(moddict, to_name, value);
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static int __pyx_pymod_exec_cufft(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cufft(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("cufft", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_cupy__cuda__cufft) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "cupy.cuda.cufft")) {
      if (unlikely(PyDict_SetItemString(modules, "cupy.cuda.cufft", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  if (unlikely(__Pyx_modinit_function_export_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_type_init_code();
  if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_variable_import_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "cupy/cuda/cufft.pyx":6
 * from libc.string cimport memset as c_memset
 * from libcpp cimport vector
 * import numpy             # <<<<<<<<<<<<<<
 * import threading
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 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_numpy, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":7
 * from libcpp cimport vector
 * import numpy
 * import threading             # <<<<<<<<<<<<<<
 * 
 * import cupy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_threading, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":9
 * import threading
 * 
 * import cupy             # <<<<<<<<<<<<<<
 * from cupy.cuda cimport driver
 * from cupy.cuda cimport memory
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_cupy, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":14
 * from cupy.cuda cimport runtime
 * from cupy.cuda cimport stream as stream_module
 * from cupy.cuda.device import Device             # <<<<<<<<<<<<<<
 * from cupy.cuda.stream import Event, Stream
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Device);
  __Pyx_GIVEREF(__pyx_n_s_Device);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Device);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cupy_cuda_device, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Device); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Device, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cupy/cuda/cufft.pyx":15
 * from cupy.cuda cimport stream as stream_module
 * from cupy.cuda.device import Device
 * from cupy.cuda.stream import Event, Stream             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Event);
  __Pyx_GIVEREF(__pyx_n_s_Event);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Event);
  __Pyx_INCREF(__pyx_n_s_Stream);
  __Pyx_GIVEREF(__pyx_n_s_Stream);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Stream);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_cupy_cuda_stream, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Event, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Stream); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Stream, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":18
 * 
 * 
 * cdef object _thread_local = threading.local()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_threading); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_local); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); 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_XGOTREF(__pyx_v_4cupy_4cuda_5cufft__thread_local);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4cuda_5cufft__thread_local, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":114
 * 
 * cdef dict RESULT = {
 *     0: 'CUFFT_SUCCESS',             # <<<<<<<<<<<<<<
 *     1: 'CUFFT_INVALID_PLAN',
 *     2: 'CUFFT_ALLOC_FAILED',
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, __pyx_n_u_CUFFT_SUCCESS) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, __pyx_n_u_CUFFT_INVALID_PLAN) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, __pyx_n_u_CUFFT_ALLOC_FAILED) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_3, __pyx_n_u_CUFFT_INVALID_TYPE) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_4, __pyx_n_u_CUFFT_INVALID_VALUE) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_5, __pyx_n_u_CUFFT_INTERNAL_ERROR) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_6, __pyx_n_u_CUFFT_EXEC_FAILED) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_7, __pyx_n_u_CUFFT_SETUP_FAILED) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_8, __pyx_n_u_CUFFT_INVALID_SIZE) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_9, __pyx_n_u_CUFFT_UNALIGNED_DATA) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_10, __pyx_n_u_CUFFT_INCOMPLETE_PARAMETER_LIST) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_11, __pyx_n_u_CUFFT_INVALID_DEVICE) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_12, __pyx_n_u_CUFFT_PARSE_ERROR) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_13, __pyx_n_u_CUFFT_NO_WORKSPACE) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_14, __pyx_n_u_CUFFT_NOT_IMPLEMENTED) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_15, __pyx_n_u_CUFFT_LICENSE_ERROR) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_int_16, __pyx_n_u_CUFFT_NOT_SUPPORTED) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_XGOTREF(__pyx_v_4cupy_4cuda_5cufft_RESULT);
  __Pyx_DECREF_SET(__pyx_v_4cupy_4cuda_5cufft_RESULT, ((PyObject*)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":134
 * 
 * 
 * class CuFFTError(RuntimeError):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, int result):
 */
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__16, __pyx_n_s_CuFFTError, __pyx_n_s_CuFFTError, (PyObject *) NULL, __pyx_n_s_cupy_cuda_cufft, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cuda/cufft.pyx":136
 * class CuFFTError(RuntimeError):
 * 
 *     def __init__(self, int result):             # <<<<<<<<<<<<<<
 *         self.result = result
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_10CuFFTError_1__init__, 0, __pyx_n_s_CuFFTError___init, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 136, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":140
 *         super(CuFFTError, self).__init__('%s' % (RESULT[result]))
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (type(self), (self.result,))
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_10CuFFTError_3__reduce__, 0, __pyx_n_s_CuFFTError___reduce, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_reduce, __pyx_t_3) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cupy/cuda/cufft.pyx":134
 * 
 * 
 * class CuFFTError(RuntimeError):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, int result):
 */
  __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_CuFFTError, __pyx_tuple__16, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CuFFTError, __pyx_t_3) < 0) __PYX_ERR(0, 134, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":249
 * 
 * 
 * class Plan1d(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, int nx, int fft_type, int batch, *,
 *                  devices=None, out=None):
 */
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__21); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__21, __pyx_n_s_Plan1d, __pyx_n_s_Plan1d, (PyObject *) NULL, __pyx_n_s_cupy_cuda_cufft, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cuda/cufft.pyx":250
 * 
 * class Plan1d(object):
 *     def __init__(self, int nx, int fft_type, int batch, *,             # <<<<<<<<<<<<<<
 *                  devices=None, out=None):
 *         cdef Handle plan
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_devices, ((PyObject *)Py_None)) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_out, ((PyObject *)Py_None)) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_1__init__, 0, __pyx_n_s_Plan1d___init, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_4, __pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":276
 *         self.xtArr_buffer = None  # actual multi-GPU intermediate buffer
 * 
 *     def _single_gpu_get_plan(self, Handle plan, int nx, int fft_type,             # <<<<<<<<<<<<<<
 *                              int batch):
 *         cdef int result
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_3_single_gpu_get_plan, 0, __pyx_n_s_Plan1d__single_gpu_get_plan, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_single_gpu_get_plan, __pyx_t_4) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":307
 *         self.events = None
 * 
 *     def _multi_gpu_get_plan(self, Handle plan, int nx, int fft_type, int batch,             # <<<<<<<<<<<<<<
 *                             devices, out):
 *         cdef int nGPUs, min_len, result
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_5_multi_gpu_get_plan, 0, __pyx_n_s_Plan1d__multi_gpu_get_plan, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_multi_gpu_get_plan, __pyx_t_4) < 0) __PYX_ERR(0, 307, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":384
 *         self.events = events        # for async, overlapped copies
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef int dev = runtime.getDevice()
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_7__del__, 0, __pyx_n_s_Plan1d___del, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_del, __pyx_t_4) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":402
 *             self.xtArr = 0
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_9__enter__, 0, __pyx_n_s_Plan1d___enter, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_enter, __pyx_t_4) < 0) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":406
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_11__exit__, 0, __pyx_n_s_Plan1d___exit, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_exit, __pyx_t_4) < 0) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":409
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         if self._use_multi_gpus:
 *             # Note: mult-GPU plans cannot set stream
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_13fft, 0, __pyx_n_s_Plan1d_fft, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_fft, __pyx_t_4) < 0) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":416
 *             self._single_gpu_fft(a, out, direction)
 * 
 *     def _single_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_15_single_gpu_fft, 0, __pyx_n_s_Plan1d__single_gpu_fft, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_single_gpu_fft, __pyx_t_4) < 0) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":437
 *             execZ2D(plan, a.data.ptr, out.data.ptr)
 * 
 *     def _multi_gpu_setup_buffer(self, a):             # <<<<<<<<<<<<<<
 *         cdef XtArrayDesc* xtArr_desc
 *         cdef XtArray* xtArr
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_17_multi_gpu_setup_buffer, 0, __pyx_n_s_Plan1d__multi_gpu_setup_buffer, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_multi_gpu_setup_buffer, __pyx_t_4) < 0) __PYX_ERR(0, 437, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":505
 *             raise ValueError('Impossible to reach.')
 * 
 *     def _multi_gpu_memcpy(self, a, str action):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef list xtArr_buffer, share
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_19_multi_gpu_memcpy, 0, __pyx_n_s_Plan1d__multi_gpu_memcpy, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_multi_gpu_memcpy, __pyx_t_4) < 0) __PYX_ERR(0, 505, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":592
 *                 raise ValueError
 * 
 *     def _multi_gpu_fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         # When we arrive here, the normal CuPy call path ensures a and out
 *         # reside on the same GPU -> must distribute a to all of the GPUs
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_21_multi_gpu_fft, 0, __pyx_n_s_Plan1d__multi_gpu_fft, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_multi_gpu_fft, __pyx_t_4) < 0) __PYX_ERR(0, 592, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":611
 *         self._multi_gpu_memcpy(out, 'gather')
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_23_output_dtype_and_shape, 0, __pyx_n_s_Plan1d__output_dtype_and_shape, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_output_dtype_and_shape, __pyx_t_4) < 0) __PYX_ERR(0, 611, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":631
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype)
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_25get_output_array, 0, __pyx_n_s_Plan1d_get_output_array, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_get_output_array, __pyx_t_4) < 0) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":635
 *         return cupy.empty(shape, dtype)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         """Verify shape and dtype of the output array.
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6Plan1d_27check_output_array, 0, __pyx_n_s_Plan1d_check_output_array, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_check_output_array, __pyx_t_4) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":249
 * 
 * 
 * class Plan1d(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, int nx, int fft_type, int batch, *,
 *                  devices=None, out=None):
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Plan1d, __pyx_tuple__21, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Plan1d, __pyx_t_4) < 0) __PYX_ERR(0, 249, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":655
 * 
 * 
 * class PlanNd(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, object shape, object inembed, int istride,
 *                  int idist, object onembed, int ostride, int odist,
 */
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__50); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__50, __pyx_n_s_PlanNd, __pyx_n_s_PlanNd, (PyObject *) NULL, __pyx_n_s_cupy_cuda_cufft, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "cupy/cuda/cufft.pyx":656
 * 
 * class PlanNd(object):
 *     def __init__(self, object shape, object inembed, int istride,             # <<<<<<<<<<<<<<
 *                  int idist, object onembed, int ostride, int odist,
 *                  int fft_type, int batch, str order, int last_axis, last_size):
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_1__init__, 0, __pyx_n_s_PlanNd___init, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":720
 *         self.last_size = last_size  # = None (and ignored) for C2C
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         with nogil:
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_3__del__, 0, __pyx_n_s_PlanNd___del, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_del, __pyx_t_4) < 0) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":726
 *         check_result(result)
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = self
 *         return self
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_5__enter__, 0, __pyx_n_s_PlanNd___enter, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_enter, __pyx_t_4) < 0) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":730
 *         return self
 * 
 *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
 *         _thread_local._current_plan = None
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_7__exit__, 0, __pyx_n_s_PlanNd___exit, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_exit, __pyx_t_4) < 0) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":733
 *         _thread_local._current_plan = None
 * 
 *     def fft(self, a, out, direction):             # <<<<<<<<<<<<<<
 *         cdef Handle plan = self.plan
 *         cdef intptr_t stream = stream_module.get_current_stream_ptr()
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_9fft, 0, __pyx_n_s_PlanNd_fft, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 733, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_fft, __pyx_t_4) < 0) __PYX_ERR(0, 733, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":755
 *             raise ValueError
 * 
 *     def _output_dtype_and_shape(self, a):             # <<<<<<<<<<<<<<
 *         shape = list(a.shape)
 *         if self.fft_type == CUFFT_C2C:
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_11_output_dtype_and_shape, 0, __pyx_n_s_PlanNd__output_dtype_and_shape, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_output_dtype_and_shape, __pyx_t_4) < 0) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":775
 *         return tuple(shape), dtype
 * 
 *     def get_output_array(self, a, order='C'):             # <<<<<<<<<<<<<<
 *         shape, dtype = self._output_dtype_and_shape(a)
 *         return cupy.empty(shape, dtype, order=order)
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_13get_output_array, 0, __pyx_n_s_PlanNd_get_output_array, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__65);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_get_output_array, __pyx_t_4) < 0) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":779
 *         return cupy.empty(shape, dtype, order=order)
 * 
 *     def check_output_array(self, a, out):             # <<<<<<<<<<<<<<
 *         if out is a:
 *             # TODO(leofang): think about in-place transforms for C2R & R2C
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4cupy_4cuda_5cufft_6PlanNd_15check_output_array, 0, __pyx_n_s_PlanNd_check_output_array, NULL, __pyx_n_s_cupy_cuda_cufft, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_check_output_array, __pyx_t_4) < 0) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cupy/cuda/cufft.pyx":655
 * 
 * 
 * class PlanNd(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, object shape, object inembed, int istride,
 *                  int idist, object onembed, int ostride, int odist,
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_PlanNd, __pyx_tuple__50, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PlanNd, __pyx_t_4) < 0) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cupy/cuda/cufft.pyx":1
 * cimport cython  # NOQA             # <<<<<<<<<<<<<<
 * from cpython.mem cimport PyMem_Malloc, PyMem_Free
 * from libc.stdint cimport intptr_t
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 ---*/
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2C);
    if (unlikely(!wrapped)) __PYX_ERR(5, 10, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_C2C", wrapped) < 0) __PYX_ERR(5, 10, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_C2R);
    if (unlikely(!wrapped)) __PYX_ERR(5, 12, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_C2R", wrapped) < 0) __PYX_ERR(5, 12, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_D2Z);
    if (unlikely(!wrapped)) __PYX_ERR(5, 14, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_D2Z", wrapped) < 0) __PYX_ERR(5, 14, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_FORWARD);
    if (unlikely(!wrapped)) __PYX_ERR(5, 17, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_FORWARD", wrapped) < 0) __PYX_ERR(5, 17, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_INVERSE);
    if (unlikely(!wrapped)) __PYX_ERR(5, 18, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_INVERSE", wrapped) < 0) __PYX_ERR(5, 18, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_R2C);
    if (unlikely(!wrapped)) __PYX_ERR(5, 11, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_R2C", wrapped) < 0) __PYX_ERR(5, 11, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2D);
    if (unlikely(!wrapped)) __PYX_ERR(5, 15, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_Z2D", wrapped) < 0) __PYX_ERR(5, 15, __pyx_L1_error);
  }
  {
    PyObject* wrapped = __Pyx_PyInt_From_int(__pyx_e_4cupy_4cuda_5cufft_CUFFT_Z2Z);
    if (unlikely(!wrapped)) __PYX_ERR(5, 13, __pyx_L1_error)
    if (PyObject_SetAttrString(__pyx_m, "CUFFT_Z2Z", wrapped) < 0) __PYX_ERR(5, 13, __pyx_L1_error);
  }

  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);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cupy.cuda.cufft", 0, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cupy.cuda.cufft");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* 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_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* GetModuleGlobalName */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    if (likely(result)) {
        Py_INCREF(result);
    } else if (unlikely(PyErr_Occurred())) {
        result = NULL;
    } else {
#else
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

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

/* DictGetItem */
    #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* PyCFunctionFastCall */
    #if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs);
    }
}
#endif

/* PyFunctionFastCall */
    #if CYTHON_FAST_PYCALL
#include "frameobject.h"
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = f->f_localsplus;
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

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

/* RaiseException */
    #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* RaiseTooManyValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

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

/* GetItemInt */
    static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* SetItemInt */
    static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* PyObjectCallNoArg */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* SaveResetException */
        #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if PY_VERSION_HEX >= 0x030700A2
    *type = tstate->exc_state.exc_type;
    *value = tstate->exc_state.exc_value;
    *tb = tstate->exc_state.exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = type;
    tstate->exc_state.exc_value = value;
    tstate->exc_state.exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
        #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
#endif
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if PY_VERSION_HEX >= 0x030700A2
    tmp_type = tstate->exc_state.exc_type;
    tmp_value = tstate->exc_state.exc_value;
    tmp_tb = tstate->exc_state.exc_traceback;
    tstate->exc_state.exc_type = local_type;
    tstate->exc_state.exc_value = local_value;
    tstate->exc_state.exc_traceback = local_tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* None */
          static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

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

/* BytesEquals */
          static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals */
          static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

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

/* PyIntBinop */
          #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            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_floor_divide(op1, op2);
            }
        }
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* ObjectGetItem */
          #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* GetVTable */
          static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* Import */
          static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
          static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* CalculateMetaclass */
          static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

/* FetchCommonType */
          static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CythonFunction */
          #include <structmember.h>
static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 0))
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_CallAsMethod,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_CyFunction_init(void) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__pyx_CyFunctionType == NULL)) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyObject_Malloc(size);
    if (unlikely(!m->defaults))
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

/* Py3ClassCreate */
              static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

/* CLineInTraceback */
              #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
      use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (PyObject_Not(use_cline) != 0) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
              static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
              #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
              #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_cufftHandle(cufftHandle value) {
    const cufftHandle neg_one = (cufftHandle) -1, const_zero = (cufftHandle) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(cufftHandle) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(cufftHandle) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(cufftHandle) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(cufftHandle) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(cufftHandle) <= 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(cufftHandle),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
              static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
              static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE cufftHandle __Pyx_PyInt_As_cufftHandle(PyObject *x) {
    const cufftHandle neg_one = (cufftHandle) -1, const_zero = (cufftHandle) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(cufftHandle) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(cufftHandle, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (cufftHandle) 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 (cufftHandle) 0;
                case  1: __PYX_VERIFY_RETURN_INT(cufftHandle, digit, digits[0])
                case 2:
                    if (8 * sizeof(cufftHandle) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) >= 2 * PyLong_SHIFT) {
                            return (cufftHandle) (((((cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(cufftHandle) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) >= 3 * PyLong_SHIFT) {
                            return (cufftHandle) (((((((cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(cufftHandle) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, 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(cufftHandle) >= 4 * PyLong_SHIFT) {
                            return (cufftHandle) (((((((((cufftHandle)digits[3]) << PyLong_SHIFT) | (cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)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 (cufftHandle) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(cufftHandle) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(cufftHandle, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(cufftHandle) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(cufftHandle, 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 (cufftHandle) 0;
                case -1: __PYX_VERIFY_RETURN_INT(cufftHandle, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(cufftHandle,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(cufftHandle) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) - 1 > 2 * PyLong_SHIFT) {
                            return (cufftHandle) (((cufftHandle)-1)*(((((cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(cufftHandle) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) - 1 > 2 * PyLong_SHIFT) {
                            return (cufftHandle) ((((((cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(cufftHandle) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) - 1 > 3 * PyLong_SHIFT) {
                            return (cufftHandle) (((cufftHandle)-1)*(((((((cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(cufftHandle) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(cufftHandle) - 1 > 3 * PyLong_SHIFT) {
                            return (cufftHandle) ((((((((cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(cufftHandle) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, 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(cufftHandle) - 1 > 4 * PyLong_SHIFT) {
                            return (cufftHandle) (((cufftHandle)-1)*(((((((((cufftHandle)digits[3]) << PyLong_SHIFT) | (cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(cufftHandle) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(cufftHandle, 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(cufftHandle) - 1 > 4 * PyLong_SHIFT) {
                            return (cufftHandle) ((((((((((cufftHandle)digits[3]) << PyLong_SHIFT) | (cufftHandle)digits[2]) << PyLong_SHIFT) | (cufftHandle)digits[1]) << PyLong_SHIFT) | (cufftHandle)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(cufftHandle) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(cufftHandle, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(cufftHandle) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(cufftHandle, 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
            cufftHandle 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 (cufftHandle) -1;
        }
    } else {
        cufftHandle val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (cufftHandle) -1;
        val = __Pyx_PyInt_As_cufftHandle(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to cufftHandle");
    return (cufftHandle) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to cufftHandle");
    return (cufftHandle) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
              static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* FastTypeChecks */
              #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
              static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionExport */
              static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

/* ModuleImport */
              #ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

/* TypeImport */
              #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* VoidPtrImport */
              #ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C variable %.200s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* FunctionImport */
              #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
              static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
