20    if (std::holds_alternative<std::monostate>(s)) {
 
   21      throw std::runtime_error(
 
   22          "[StreamContext] Invalid argument, please specify a stream or device.");
 
 
 
   39  inline void print(std::ostream& os, 
bool val);
 
   40  inline void print(std::ostream& os, int16_t val);
 
   41  inline void print(std::ostream& os, uint16_t val);
 
   42  inline void print(std::ostream& os, int32_t val);
 
   43  inline void print(std::ostream& os, uint32_t val);
 
   44  inline void print(std::ostream& os, int64_t val);
 
   45  inline void print(std::ostream& os, uint64_t val);
 
   48  inline void print(std::ostream& os, 
float val);
 
 
   66    const std::vector<int>& s1,
 
   67    const std::vector<int>& s2);
 
   74  constexpr bool is_signed = std::numeric_limits<T>::is_signed;
 
   75  using U = std::conditional_t<is_signed, ssize_t, size_t>;
 
   76  constexpr U 
min = 
static_cast<U
>(std::numeric_limits<int>::min());
 
   77  constexpr U 
max = 
static_cast<U
>(std::numeric_limits<int>::max());
 
   79  if ((is_signed && dim < 
min) || dim > 
max) {
 
   80    throw std::invalid_argument(
 
   81        "Shape dimension falls outside supported `int` range.");
 
   84  return static_cast<int>(dim);
 
 
   99std::ostream& 
operator<<(std::ostream& os, 
const std::vector<int>& v);
 
  100std::ostream& 
operator<<(std::ostream& os, 
const std::vector<size_t>& v);
 
  101std::ostream& 
operator<<(std::ostream& os, 
const std::vector<int64_t>& v);
 
  103  return os << v.real() << (v.imag() >= 0 ? 
"+" : 
"") << v.imag() << 
"j";
 
 
  106  return os << static_cast<float>(v);
 
 
  109  return os << static_cast<float>(v);
 
 
  113  return ((n & (n - 1)) == 0) && n != 0;
 
 
  120  return pow(2, std::ceil(std::log2(n)));
 
 
Dtype dtype() const
Get the arrays data type.
Definition array.h:127
 
array max(const array &a, bool keepdims, StreamOrDevice s={})
The maximum of all elements of the array.
 
array min(const array &a, bool keepdims, StreamOrDevice s={})
The minimum of all elements of the array.
 
array operator<<(const array &a, const array &b)
 
int normalize_axis(int axis, int ndim)
Returns the axis normalized to be in the range [0, ndim).
 
const Device & default_device()
 
std::vector< int > broadcast_shapes(const std::vector< int > &s1, const std::vector< int > &s2)
 
void set_default_device(const Device &d)
 
Stream to_stream(StreamOrDevice s)
 
Dtype promote_types(const Dtype &t1, const Dtype &t2)
 
int next_power_of_2(int n)
Definition utils.h:116
 
int check_shape_dim(const T dim)
Returns the shape dimension if it's within allowed range.
Definition utils.h:73
 
Dtype result_type(const array &a, const array &b)
The type from promoting the arrays' types with one another.
Definition utils.h:57
 
std::variant< std::monostate, Stream, Device > StreamOrDevice
Definition utils.h:14
 
Stream default_stream(Device d)
Get the default stream for the given device.
 
bool is_same_shape(const std::vector< array > &arrays)
 
bool is_power_of_2(int n)
Definition utils.h:112
 
void set_default_stream(Stream s)
Make the stream the default for its device.
 
PrintFormatter global_formatter
 
Kind
Definition dtype.h:30
 
StreamContext(StreamOrDevice s)
Definition utils.h:19
 
~StreamContext()
Definition utils.h:29
 
Device device
Definition stream.h:11