Skip to content

Commit b132388

Browse files
committed
Update
[ghstack-poisoned]
1 parent 8fbbdee commit b132388

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

kernels/portable/cpu/util/dtype_util.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ enum class SupportedTensorDtypes {
228228
namespace internal {
229229

230230
template <typename CTYPE_COMPUTE, const char* op_name>
231-
load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn(
231+
load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn_impl(
232232
const Tensor& t,
233233
SupportedTensorDtypes dtypes) {
234234
switch (dtypes) {
@@ -251,6 +251,10 @@ load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn(
251251
return nullptr;
252252
}
253253

254+
// NOTE: applying the #ifdef EXECUTORCH_SELECTIVE_BUILD_DTYPE
255+
// technique used for get_load_to_compute_fn in this path was a size
256+
// regression rather than an improvement. Haven't fully investigated
257+
// why; just be aware when trying to improve size further.
254258
template <typename CTYPE_COMPUTE, const char* op_name>
255259
store_compute_to_tensor_fn<CTYPE_COMPUTE> get_store_compute_to_tensor_fn(
256260
const Tensor& t,
@@ -285,6 +289,28 @@ store_compute_to_tensor_fn<CTYPE_COMPUTE> get_store_compute_to_tensor_fn(
285289
return nullptr;
286290
}
287291

292+
#ifndef EXECUTORCH_SELECTIVE_BUILD_DTYPE
293+
inline constexpr const char kGenericElementwiseOpName[] = "generic_elementwise_op";
294+
#endif // EXECUTORCH_SELECTIVE_BUILD_DTYPE
295+
296+
template <typename CTYPE_COMPUTE, const char* op_name>
297+
load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn(
298+
const Tensor& t,
299+
SupportedTensorDtypes dtypes) {
300+
// NOTE: Selective build relies on the operator name being passed
301+
// here. When it's *not* active, using the same operator name
302+
// everywhere saves on size because we don't require a new template
303+
// instantiation for every operator.
304+
return get_load_to_compute_fn_impl<
305+
CTYPE_COMPUTE,
306+
#ifdef EXECUTORCH_SELECTIVE_BUILD_DTYPE
307+
op_name
308+
#else // EXECUTORCH_SELECTIVE_BUILD_DTYPE
309+
kGenericElementwiseOpName
310+
#endif // EXECUTORCH_SELECTIVE_BUILD_DTYPE
311+
>(t, dtypes);
312+
}
313+
288314
bool check_tensor_dtype(
289315
const Tensor t,
290316
SupportedTensorDtypes dtypes,

0 commit comments

Comments
 (0)