@@ -228,7 +228,7 @@ enum class SupportedTensorDtypes {
228
228
namespace internal {
229
229
230
230
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 (
232
232
const Tensor& t,
233
233
SupportedTensorDtypes dtypes) {
234
234
switch (dtypes) {
@@ -251,6 +251,10 @@ load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn(
251
251
return nullptr ;
252
252
}
253
253
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.
254
258
template <typename CTYPE_COMPUTE, const char * op_name>
255
259
store_compute_to_tensor_fn<CTYPE_COMPUTE> get_store_compute_to_tensor_fn (
256
260
const Tensor& t,
@@ -285,6 +289,28 @@ store_compute_to_tensor_fn<CTYPE_COMPUTE> get_store_compute_to_tensor_fn(
285
289
return nullptr ;
286
290
}
287
291
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
+
288
314
bool check_tensor_dtype (
289
315
const Tensor t,
290
316
SupportedTensorDtypes dtypes,
0 commit comments