#ifndef _ASDFDAFVVAFF_PYCUDA_HEADER_SEEN_TOOLS_HPP #define _ASDFDAFVVAFF_PYCUDA_HEADER_SEEN_TOOLS_HPP #include #include #include "numpy_init.hpp" namespace pyopencl { inline npy_intp size_from_dims(int ndim, const npy_intp *dims) { if (ndim != 0) return std::accumulate(dims, dims+ndim, 1, std::multiplies()); else return 1; } inline void run_python_gc() { namespace py = pybind11; py::module::import("gc").attr("collect")(); } // https://stackoverflow.com/a/28139075 template struct reversion_wrapper { T& iterable; }; template auto begin (reversion_wrapper w) { return w.iterable.rbegin(); } template auto end (reversion_wrapper w) { return w.iterable.rend(); } template reversion_wrapper reverse (T&& iterable) { return { iterable }; } // https://stackoverflow.com/a/44175911 class noncopyable { public: noncopyable() = default; ~noncopyable() = default; private: noncopyable(const noncopyable&) = delete; noncopyable& operator=(const noncopyable&) = delete; }; } #endif