Skip to content

Commit 5cd9f01

Browse files
cyyevermeta-codesync[bot]
authored andcommitted
Replace ALWAYS_INLINE with constexpr for specialization helpers (#5821)
Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/2746 Pull Request resolved: #5821 Reviewed By: henrylhtsang Differential Revision: D107339969 Pulled By: q10 fbshipit-source-id: 40dd1637875df5c3f7f339e51bdd0ad500db8a08
1 parent 1e8d007 commit 5cd9f01

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/EmbeddingSpMDMAutovec.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,10 @@ namespace specialization_helper {
12941294
/// The idea with the specialization helper is to create a copy of a given
12951295
/// algorithm with some parameters set to fixed values (specialized) so the
12961296
/// compiler can perform additional optimization for the specific variant.
1297-
/// This is achieved by marking the generic functions `ALWAYS_INLINE` inline
1298-
/// and defining a macro invoking match/specialize so you can choose between
1299-
/// fixed and variable values for each parameter.
1297+
/// This is achieved by marking the generic functions `constexpr` so their
1298+
/// results can be evaluated at compile time and defining a macro invoking
1299+
/// match/specialize so you can choose between fixed and variable values for
1300+
/// each parameter.
13001301

13011302
template <typename T>
13021303
struct FixedParameter {
@@ -1305,26 +1306,26 @@ struct FixedParameter {
13051306
struct VariableParameter {};
13061307

13071308
template <typename T>
1308-
ALWAYS_INLINE constexpr FixedParameter<T> fixed(T value) {
1309+
constexpr FixedParameter<T> fixed(T value) {
13091310
return FixedParameter<T>{value};
13101311
}
13111312
constexpr VariableParameter var = VariableParameter();
13121313

13131314
template <typename T>
1314-
ALWAYS_INLINE bool match(VariableParameter /*unused*/, T /*unused*/) {
1315+
constexpr bool match(VariableParameter /*unused*/, T /*unused*/) {
13151316
return true;
13161317
}
13171318
template <typename T>
1318-
ALWAYS_INLINE bool match(FixedParameter<T> fixed_parameter, T value) {
1319+
constexpr bool match(FixedParameter<T> fixed_parameter, T value) {
13191320
return fixed_parameter.value == value;
13201321
}
13211322

13221323
template <typename T>
1323-
ALWAYS_INLINE T specialize(VariableParameter /*unused*/, T value) {
1324+
constexpr T specialize(VariableParameter /*unused*/, T value) {
13241325
return value;
13251326
}
13261327
template <typename T>
1327-
ALWAYS_INLINE T specialize(FixedParameter<T> fixed_parameter, T /*unused*/) {
1328+
constexpr T specialize(FixedParameter<T> fixed_parameter, T /*unused*/) {
13281329
return fixed_parameter.value;
13291330
}
13301331
} // namespace specialization_helper

0 commit comments

Comments
 (0)