clang-format: register EIGEN_IF_CONSTEXPR as an IfMacro

libeigen/eigen!2604

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-06-06 13:08:44 -07:00
co-authored by Rasmus Munk Larsen
parent 7b56b05698
commit 7966ea495e
97 changed files with 1714 additions and 1751 deletions
+22 -33
View File
@@ -144,15 +144,14 @@ template <int Layout, int NumDims>
static Index GetInputIndex(Index output_index, const array<Index, NumDims>& output_to_input_dim_map,
const array<Index, NumDims>& input_strides, const array<Index, NumDims>& output_strides) {
int input_index = 0;
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
for (int i = NumDims - 1; i > 0; --i) {
const Index idx = output_index / output_strides[i];
input_index += idx * input_strides[output_to_input_dim_map[i]];
output_index -= idx * output_strides[i];
}
return input_index + output_index * input_strides[output_to_input_dim_map[0]];
}
else {
} else {
for (int i = 0; i < NumDims - 1; ++i) {
const Index idx = output_index / output_strides[i];
input_index += idx * input_strides[output_to_input_dim_map[i]];
@@ -165,13 +164,12 @@ static Index GetInputIndex(Index output_index, const array<Index, NumDims>& outp
template <int Layout, int NumDims>
static array<Index, NumDims> ComputeStrides(const array<Index, NumDims>& sizes) {
array<Index, NumDims> strides;
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
strides[0] = 1;
for (int i = 1; i < NumDims; ++i) {
strides[i] = strides[i - 1] * sizes[i - 1];
}
}
else {
} else {
strides[NumDims - 1] = 1;
for (int i = NumDims - 2; i >= 0; --i) {
strides[i] = strides[i + 1] * sizes[i + 1];
@@ -228,7 +226,7 @@ static void test_uniform_block_shape() {
// Test shape 'UniformAllDims' with larger 'max_coeff count' which spills
// partially into first inner-most dimension.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 7 * 5 * 5 * 5 * 5;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -238,8 +236,7 @@ static void test_uniform_block_shape() {
VERIFY_IS_EQUAL(5, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 5 * 5 * 5 * 5 * 6;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -253,7 +250,7 @@ static void test_uniform_block_shape() {
// Test shape 'UniformAllDims' with larger 'max_coeff count' which spills
// fully into first inner-most dimension.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 5 * 5 * 5 * 5;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -263,8 +260,7 @@ static void test_uniform_block_shape() {
VERIFY_IS_EQUAL(5, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 5 * 5 * 5 * 5 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -278,7 +274,7 @@ static void test_uniform_block_shape() {
// Test shape 'UniformAllDims' with larger 'max_coeff count' which spills
// fully into first few inner-most dimensions.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(7, 5, 6, 17, 7);
const Index max_coeff_count = 7 * 5 * 6 * 7 * 5;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -289,8 +285,7 @@ static void test_uniform_block_shape() {
VERIFY_IS_EQUAL(7, block.dimensions()[3]);
VERIFY_IS_EQUAL(5, block.dimensions()[4]);
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(7, 5, 6, 9, 7);
const Index max_coeff_count = 5 * 5 * 5 * 6 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -304,7 +299,7 @@ static void test_uniform_block_shape() {
}
// Test shape 'UniformAllDims' with full allocation to all dims.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(7, 5, 6, 17, 7);
const Index max_coeff_count = 7 * 5 * 6 * 17 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -315,8 +310,7 @@ static void test_uniform_block_shape() {
VERIFY_IS_EQUAL(17, block.dimensions()[3]);
VERIFY_IS_EQUAL(7, block.dimensions()[4]);
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(7, 5, 6, 9, 7);
const Index max_coeff_count = 7 * 5 * 6 * 9 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kUniformAllDims, max_coeff_count, zeroCost()});
@@ -336,7 +330,7 @@ static void test_skewed_inner_dim_block_shape() {
typedef internal::TensorBlockMapper<5, Layout> TensorBlockMapper;
// Test shape 'SkewedInnerDims' with partial allocation to inner-most dim.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 10 * 1 * 1 * 1 * 1;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -346,8 +340,7 @@ static void test_skewed_inner_dim_block_shape() {
VERIFY_IS_EQUAL(1, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 1 * 1 * 1 * 1 * 6;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -360,7 +353,7 @@ static void test_skewed_inner_dim_block_shape() {
}
// Test shape 'SkewedInnerDims' with full allocation to inner-most dim.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 1 * 1 * 1 * 1;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -370,8 +363,7 @@ static void test_skewed_inner_dim_block_shape() {
VERIFY_IS_EQUAL(1, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 1 * 1 * 1 * 1 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -385,7 +377,7 @@ static void test_skewed_inner_dim_block_shape() {
// Test shape 'SkewedInnerDims' with full allocation to inner-most dim,
// and partial allocation to second inner-dim.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 3 * 1 * 1 * 1;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -396,8 +388,7 @@ static void test_skewed_inner_dim_block_shape() {
VERIFY_IS_EQUAL(1, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 1 * 1 * 1 * 15 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -412,7 +403,7 @@ static void test_skewed_inner_dim_block_shape() {
// Test shape 'SkewedInnerDims' with full allocation to inner-most dim,
// and partial allocation to third inner-dim.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 5 * 5 * 1 * 1;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -424,8 +415,7 @@ static void test_skewed_inner_dim_block_shape() {
VERIFY_IS_EQUAL(1, block.dimensions()[i]);
}
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 1 * 1 * 5 * 17 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -440,7 +430,7 @@ static void test_skewed_inner_dim_block_shape() {
}
// Test shape 'SkewedInnerDims' with full allocation to all dims.
EIGEN_IF_CONSTEXPR(Layout == ColMajor) {
EIGEN_IF_CONSTEXPR (Layout == ColMajor) {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 5 * 6 * 17 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});
@@ -451,8 +441,7 @@ static void test_skewed_inner_dim_block_shape() {
VERIFY_IS_EQUAL(17, block.dimensions()[3]);
VERIFY_IS_EQUAL(7, block.dimensions()[4]);
VERIFY(block.dimensions().TotalSize() <= max_coeff_count);
}
else {
} else {
DSizes<Index, 5> dims(11, 5, 6, 17, 7);
const Index max_coeff_count = 11 * 5 * 6 * 17 * 7;
TensorBlockMapper block_mapper(dims, {TensorBlockShapeType::kSkewedInnerDims, max_coeff_count, zeroCost()});