@@ -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,29 @@ 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 [] =
294
+ " generic_elementwise_op" ;
295
+ #endif // EXECUTORCH_SELECTIVE_BUILD_DTYPE
296
+
297
+ template <typename CTYPE_COMPUTE, const char * op_name>
298
+ load_to_compute_fn<CTYPE_COMPUTE> get_load_to_compute_fn (
299
+ const Tensor& t,
300
+ SupportedTensorDtypes dtypes) {
301
+ // NOTE: Selective build relies on the operator name being passed
302
+ // here. When it's *not* active, using the same operator name
303
+ // everywhere saves on size because we don't require a new template
304
+ // instantiation for every operator.
305
+ return get_load_to_compute_fn_impl<
306
+ CTYPE_COMPUTE,
307
+ #ifdef EXECUTORCH_SELECTIVE_BUILD_DTYPE
308
+ op_name
309
+ #else // EXECUTORCH_SELECTIVE_BUILD_DTYPE
310
+ kGenericElementwiseOpName
311
+ #endif // EXECUTORCH_SELECTIVE_BUILD_DTYPE
312
+ >(t, dtypes);
313
+ }
314
+
288
315
bool check_tensor_dtype (
289
316
const Tensor t,
290
317
SupportedTensorDtypes dtypes,
0 commit comments