27#include "neml2/misc/types.h"
28#include "neml2/misc/error.h"
92std::string
demangle(
const char * name);
128template <
typename...
S>
158template <
typename...
S>
185 return std::max({tensor.batch_dim()...});
195 " operands are not broadcastable. The batch shapes are ",
197 ", and the base shapes are ",
209 " operands are not broadcastable. The batch shapes are ",
211 ", and the base shapes are ",
223 " operands are not batch-broadcastable. The batch shapes are ",
235 " operands are not batch-broadcastable. The batch shapes are ",
256 auto dim = std::max({
shapes.size()...});
259 for (
size_t i = 0;
i < dim;
i++)
284 auto dim = std::max({
shapes.size()...});
288 for (
size_t i = 0;
i < dim;
i++)
296template <
typename...
S>
301 return details::add_shapes_impl(
net, std::forward<S>(
shape)...);
308 std::ostringstream
os;
317 return t ?
"true" :
"false";
322template <
typename...
S>
326 net.insert(
net.end(),
s.begin(),
s.end());
327 return add_shapes_impl(
net, std::forward<S>(
rest)...);
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:56
bool sizes_broadcastable(T &&... shapes)
Check if the shapes are broadcastable.
Definition utils.h:254
Size storage_size(TensorShapeRef shape)
The flattened storage size of a tensor with given shape.
Definition utils.cxx:40
bool sizes_same(T &&... shapes)
Check if all shapes are the same.
Definition utils.h:243
TensorShape pad_prepend(TensorShapeRef s, Size dim, Size pad)
Pad shape s to dimension dim by prepending sizes of pad.
Definition utils.cxx:47
TensorShape broadcast_sizes(T &&... shapes)
Return the broadcast shape of all the shapes.
Definition utils.h:280
TensorShape add_shapes(S &&... shape)
Definition utils.h:298
std::string stringify(const T &t)
Definition utils.h:306
std::string indentation(int level, int indent)
Definition utils.cxx:64
std::string demangle(const char *name)
Demangle a piece of cxx abi type information.
Definition utils.cxx:33
TensorShape pad_append(TensorShapeRef s, Size dim, Size pad)
Pad shape s to dimension dim by appending sizes of pad.
Definition utils.cxx:55
Definition CrossRef.cxx:30
void neml_assert_dbg(bool assertion, Args &&... args)
Definition error.h:76
void neml_assert_broadcastable(T &&...)
A helper function to assert that all tensors are broadcastable.
void neml_assert_batch_broadcastable_dbg(T &&...)
A helper function to assert that (in Debug mode) all tensors are batch-broadcastable.
Size broadcast_batch_dim(T &&...)
The batch dimension after broadcasting.
bool broadcastable(T &&... tensors)
Definition utils.h:174
torch::SmallVector< Size > TensorShape
Definition types.h:34
void neml_assert_batch_broadcastable(T &&...)
A helper function to assert that all tensors are batch-broadcastable.
int64_t Size
Definition types.h:33
void neml_assert_broadcastable_dbg(T &&...)
A helper function to assert (in Debug mode) that all tensors are broadcastable.
torch::IntArrayRef TensorShapeRef
Definition types.h:35
void neml_assert(bool assertion, Args &&... args)
Definition error.h:64