mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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:
@@ -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); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user