NEML2 2.0.0
Loading...
Searching...
No Matches
assertions.h
1// Copyright 2024, UChicago Argonne, LLC
2// All Rights Reserved
3// Software Name: NEML2 -- the New Engineering material Model Library, version 2
4// By: Argonne National Laboratory
5// OPEN SOURCE LICENSE (MIT)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23// THE SOFTWARE.
24
25#pragma once
26
27#include "neml2/misc/assertions.h"
28#include "neml2/tensors/shape_utils.h"
29
30namespace neml2
31{
34template <class... T>
35void neml_assert_broadcastable(const T &...);
36template <class... T>
39
42template <class... T>
44template <class... T>
47
50template <class... T>
52template <class... T>
55
58template <class... T>
60template <class... T>
63
66template <class... T>
68template <class... T>
71
74template <class... T>
76template <class... T>
79} // namespace neml2
80
82// Implementation
84
85namespace neml2
86{
87template <class... T>
88void
89neml_assert_broadcastable(const T &... tensors)
90{
92 "The ",
93 sizeof...(tensors),
94 " operands are not broadcastable. The dynamic shapes are ",
95 tensors.dynamic_sizes()...,
96 ", the intermediate shapes are ",
97 tensors.intmd_sizes()...,
98 ", and the base shapes are ",
99 tensors.base_sizes()...);
100}
101
102template <class... T>
103void
104neml_assert_broadcastable_dbg([[maybe_unused]] const T &... tensors)
105{
106#ifndef NDEBUG
107 neml_assert_broadcastable(tensors...);
108#endif
109}
110
111template <class... T>
112void
114{
116 "The ",
117 sizeof...(tensors),
118 " operands are not dynamic-broadcastable. The dynamic shapes are ",
119 tensors.dynamic_sizes()...);
120}
121
122template <class... T>
123void
124neml_assert_dynamic_broadcastable_dbg([[maybe_unused]] const T &... tensors)
125{
126#ifndef NDEBUG
128#endif
129}
130
131template <class... T>
132void
134{
136 "The ",
137 sizeof...(tensors),
138 " operands are not intermediate-broadcastable. The intermediate shapes are ",
139 tensors.intmd_sizes()...);
140}
141
142template <class... T>
143void
144neml_assert_intmd_broadcastable_dbg([[maybe_unused]] const T &... tensors)
145{
146#ifndef NDEBUG
148#endif
149}
150
151template <class... T>
152void
154{
156 "The ",
157 sizeof...(tensors),
158 " operands are not batch-broadcastable. The dynamic shapes are ",
159 tensors.dynamic_sizes()...,
160 ", and the intermediate shapes are ",
161 tensors.intmd_sizes()...);
162}
163
164template <class... T>
165void
166neml_assert_batch_broadcastable_dbg([[maybe_unused]] const T &... tensors)
167{
168#ifndef NDEBUG
170#endif
171}
172
173template <class... T>
174void
176{
178 "The ",
179 sizeof...(tensors),
180 " operands are not base-broadcastable. The base shapes are ",
181 tensors.base_sizes()...);
182}
183
184template <class... T>
185void
186neml_assert_base_broadcastable_dbg([[maybe_unused]] const T &... tensors)
187{
188#ifndef NDEBUG
190#endif
191}
192
193template <class... T>
194void
196{
198 "The ",
199 sizeof...(tensors),
200 " operands are not static-broadcastable. The intermediate shapes are ",
201 tensors.intmd_sizes()...,
202 ", and the base shapes are ",
203 tensors.base_sizes()...);
204}
205
206template <class... T>
207void
208neml_assert_static_broadcastable_dbg([[maybe_unused]] const T &... tensors)
209{
210#ifndef NDEBUG
212#endif
213}
214} // namespace neml2
bool intmd_broadcastable(const T &... tensors)
Definition shape_utils.h:198
bool dynamic_broadcastable(const T &... tensors)
Definition shape_utils.h:191
bool broadcastable(const T &... tensors)
Definition shape_utils.h:183
bool base_broadcastable(const T &... tensors)
Definition shape_utils.h:205
Definition DiagnosticsInterface.cxx:30
void neml_assert_batch_broadcastable(const T &...)
void neml_assert_batch_broadcastable_dbg(const T &...)
void neml_assert_dynamic_broadcastable(const T &...)
void neml_assert_broadcastable(const T &...)
void neml_assert_intmd_broadcastable_dbg(const T &...)
void neml_assert_base_broadcastable_dbg(const T &...)
void neml_assert_intmd_broadcastable(const T &...)
void neml_assert_broadcastable_dbg(const T &...)
void neml_assert_dynamic_broadcastable_dbg(const T &...)
void neml_assert_static_broadcastable(const T &...)
void neml_assert_base_broadcastable(const T &...)
void neml_assert_static_broadcastable_dbg(const T &...)
void neml_assert(bool assertion, Args &&... args)
Definition assertions.h:47