This source file includes following definitions.
- get
- get
- get
- get_builtin
#ifndef HALIDE_NUMPY_DTYPE_HPP_INCLUDED
#define HALIDE_NUMPY_DTYPE_HPP_INCLUDED
#include "numpy_object_mgr_traits.hpp"
#include <boost/python.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/type_traits/add_pointer.hpp>
namespace Halide {
namespace numpy {
using namespace boost;
class dtype : public python::object {
static python::detail::new_reference convert(python::object::object_cref arg, bool align);
public:
template <typename T>
explicit dtype(T arg, bool align = false) : python::object(convert(arg, align)) {}
template <typename T>
static dtype get_builtin();
int get_itemsize() const;
friend bool equivalent(dtype const &a, dtype const &b);
static void register_scalar_converters();
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dtype, python::object);
};
bool equivalent(dtype const &a, dtype const &b);
namespace detail {
template <int bits, bool isUnsigned>
dtype get_int_dtype();
template <int bits>
dtype get_float_dtype();
template <int bits>
dtype get_complex_dtype();
template <typename T, bool isInt = boost::is_integral<T>::value>
struct builtin_dtype;
template <typename T>
struct builtin_dtype<T, true> {
static dtype get() { return get_int_dtype<8 * sizeof(T), boost::is_unsigned<T>::value>(); }
};
template <>
struct builtin_dtype<bool, true> {
static dtype get();
};
template <typename T>
struct builtin_dtype<T, false> {
static dtype get() { return get_float_dtype<8 * sizeof(T)>(); }
};
template <typename T>
struct builtin_dtype<std::complex<T>, false> {
static dtype get() { return get_complex_dtype<16 * sizeof(T)>(); }
};
}
template <typename T>
inline dtype dtype::get_builtin() { return detail::builtin_dtype<T>::get(); }
}
}
namespace boost {
namespace python {
namespace converter {
NUMPY_OBJECT_MANAGER_TRAITS(Halide::numpy::dtype);
}
}
}
#endif