/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/utils
NameSizeModeActions
auto_gil.h10340644editdlrm
byte_order.h24840644editdlrm
crash_handler.h11460644editdlrm
cuda_enabled.h1540644editdlrm
cuda_lazy_init.h9740644editdlrm
disable_torch_function.h8630644editdlrm
disallow_copy.h1030644editdlrm
init.h3240644editdlrm
invalid_arguments.h3020644editdlrm
memory.h11730644editdlrm
numpy_stub.h3990644editdlrm
object_ptr.h13290644editdlrm
out_types.h2940644editdlrm
pybind.h79660644editdlrm
pycfunction_helpers.h2090644editdlrm
python_arg_parser.h307530644editdlrm
python_compat.h29040644editdlrm
python_dispatch.h1740644editdlrm
python_numbers.h50640644editdlrm
python_scalars.h29280644editdlrm
python_strings.h45920644editdlrm
python_stub.h560644editdlrm
python_tuples.h6840644editdlrm
six.h14250644editdlrm
structseq.h1530644editdlrm
tensor_apply.h4310644editdlrm
tensor_dtypes.h2440644editdlrm
tensor_flatten.h27800644editdlrm
tensor_layouts.h1070644editdlrm
tensor_list.h1960644editdlrm
tensor_memoryformats.h1130644editdlrm
tensor_new.h18070644editdlrm
tensor_numpy.h5420644editdlrm
tensor_qschemes.h1860644editdlrm
tensor_types.h4910644editdlrm
throughput_benchmark-inl.h52100644editdlrm
throughput_benchmark.h68680644editdlrm
variadic.h43940644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/utils/python_compat.h (2904B)
#pragma once #include #if PY_VERSION_HEX < 0x03070000 // METH_FASTCALL was introduced in Python 3.7, so we wrap _PyCFunctionFast // signatures for earlier versions. template PyObject* maybe_wrap_fastcall(PyObject *module, PyObject *args) { return f( module, // _PyTuple_ITEMS // Because this is only a compat shim for Python 3.6, we don't have // to worry about the representation changing. ((PyTupleObject *)args)->ob_item, PySequence_Fast_GET_SIZE(args) ); } #define MAYBE_METH_FASTCALL METH_VARARGS #define MAYBE_WRAP_FASTCALL(f) maybe_wrap_fastcall #else #define MAYBE_METH_FASTCALL METH_FASTCALL #define MAYBE_WRAP_FASTCALL(f) (PyCFunction)(void(*)(void))f #endif // PyPy 3.6 does not yet have PySlice_Unpack #if PY_VERSION_HEX < 0x03060100 || defined(PYPY_VERSION) // PySlice_Unpack not introduced till python 3.6.1 // included here for backwards compatibility // https://docs.python.org/3/c-api/slice.html#c.PySlice_Unpack // https://github.com/python/cpython/blob/master/Objects/sliceobject.c#L196 inline int __PySlice_Unpack(PyObject *_r, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step) { PySliceObject *r = (PySliceObject*)_r; /* this is harder to get right than you might think */ // Py_BUILD_ASSERT replaced because it is not available in all versions static_assert(PY_SSIZE_T_MIN + 1 <= -PY_SSIZE_T_MAX, "Build failed"); if (r->step == Py_None) { *step = 1; } else { if (!_PyEval_SliceIndex(r->step, step)) return -1; if (*step == 0) { PyErr_SetString(PyExc_ValueError, "slice step cannot be zero"); return -1; } /* Here *step might be -PY_SSIZE_T_MAX-1; in this case we replace it * with -PY_SSIZE_T_MAX. This doesn't affect the semantics, and it * guards against later undefined behaviour resulting from code that * does "step = -step" as part of a slice reversal. */ if (*step < -PY_SSIZE_T_MAX) *step = -PY_SSIZE_T_MAX; } if (r->start == Py_None) { *start = *step < 0 ? PY_SSIZE_T_MAX : 0; } else { if (!_PyEval_SliceIndex(r->start, start)) return -1; } if (r->stop == Py_None) { *stop = *step < 0 ? PY_SSIZE_T_MIN : PY_SSIZE_T_MAX; } else { if (!_PyEval_SliceIndex(r->stop, stop)) return -1; } return 0; } #define THPUtils_unpackSlice(SLICE, START, STOP, STEP) \ (__PySlice_Unpack(SLICE, START, STOP, STEP) == 0) #else #define THPUtils_unpackSlice(SLICE, START, STOP, STEP) \ (PySlice_Unpack(SLICE, START, STOP, STEP) == 0) #endif #define THPUtils_parseSlice(SLICE, LEN, START, STOP, LENGTH, STEP) \ (PySlice_GetIndicesEx(SLICE, LEN, START, STOP, LENGTH, STEP) == 0)