binius_compute/cpu/
tower_macro.rs

1// Copyright 2025 Irreducible Inc.
2#[macro_export]
3macro_rules! each_tower_subfield {
4    (
5        $tower_height:expr,
6        $tower_ty:ident,
7        $func:ident ::< _ $(, $type_args:ty)* >( $($args:expr),* $(,)? )
8    ) => {
9        match $tower_height {
10            0 => $func::< $tower_ty::B1 $(, $type_args,)* >( $($args),* ),
11            3 => $func::< $tower_ty::B8 $(, $type_args,)* >( $($args),* ),
12            4 => $func::< $tower_ty::B16 $(, $type_args,)* >( $($args),* ),
13            5 => $func::< $tower_ty::B32 $(, $type_args,)* >( $($args),* ),
14            6 => $func::< $tower_ty::B64 $(, $type_args,)* >( $($args),* ),
15            7 => $func::< $tower_ty::B128 $(, $type_args,)* >( $($args),* ),
16
17            _ => {
18                return Err(
19                    $crate::layer::Error::InputValidation(
20                        format!(
21                            "unsupported value of {}: {}",
22                            stringify!($tower_height),
23                            $tower_height
24                        )
25                    )
26                )
27            }
28        }
29    };
30}
31
32pub(super) use each_tower_subfield;