Harden unsupported tensor tests for sanitizers

libeigen/eigen!2321

Co-authored-by: Rasmus Munk Larsen <rlarsen@nvidia.com>
Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-03-20 15:12:41 -07:00
parent 9d161e0c87
commit 6540bf4787
7 changed files with 38 additions and 11 deletions

View File

@@ -13,6 +13,16 @@
using Eigen::internal::TensorBlockDescriptor;
using Eigen::internal::TensorExecutor;
template <typename T, int NumDims, int Layout>
static void setRandomForBinaryProduct(Tensor<T, NumDims, Layout>& tensor) {
EIGEN_IF_CONSTEXPR((std::is_integral<T>::value && !std::is_same<T, bool>::value)) {
setRandomDataInRange(tensor, T(-1000), T(1000));
}
else {
tensor.setRandom();
}
}
// -------------------------------------------------------------------------- //
// Utility functions to generate random tensors, blocks, and evaluate them.
@@ -220,8 +230,8 @@ template <typename T, int NumDims, int Layout>
static void test_eval_tensor_binary_expr_block() {
DSizes<Index, NumDims> dims = RandomDims<NumDims>(10, 20);
Tensor<T, NumDims, Layout> lhs(dims), rhs(dims);
lhs.setRandom();
rhs.setRandom();
setRandomForBinaryProduct(lhs);
setRandomForBinaryProduct(rhs);
VerifyBlockEvaluator<T, NumDims, Layout>(lhs * rhs, [&dims]() { return RandomBlock<Layout>(dims, 1, 10); });
}