Skip to content

Commit e5471a5

Browse files
swolchokfacebook-github-bot
authored andcommitted
Inline val_at (#3273)
Summary: Pull Request resolved: #3273 Otherwise, we require LTO for decent performance for this thing in kernels. Reviewed By: kimishpatel, iseeyuan, manuelcandales Differential Revision: D56503573 fbshipit-source-id: 186cd570919b38a072a316bd1e3da63f4dcda011
1 parent 6c06f26 commit e5471a5

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

kernels/portable/cpu/util/kernel_ops_util.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ bool param_array_is_valid(
4646

4747
} // namespace
4848

49-
int64_t val_at(IntArrayRef array, size_t i, int64_t default_value) {
50-
if (array.size() == 1) {
51-
return array[0];
52-
} else if (array.size() > 1) {
53-
return array[i];
54-
} else {
55-
return default_value;
56-
}
57-
}
58-
5949
bool int_array_all_ge(IntArrayRef array, int64_t val) {
6050
for (size_t i = 0; i < array.size(); ++i) {
6151
if (array[i] < val) {

kernels/portable/cpu/util/kernel_ops_util.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ namespace executor {
2020
* the first element will be returned regardless of what i is requested to
2121
* simulate broadcasting.
2222
*/
23-
int64_t val_at(IntArrayRef array, size_t i, int64_t default_value = 1);
23+
inline int64_t val_at(IntArrayRef array, size_t i, int64_t default_value = 1) {
24+
if (array.size() == 1) {
25+
return array[0];
26+
} else if (array.size() > 1) {
27+
return array[i];
28+
} else {
29+
return default_value;
30+
}
31+
}
2432

2533
/**
2634
* Checks that all elements of an IntArray are greater than or equal to `val`.

0 commit comments

Comments
 (0)