Skip to content

Commit 2dcb6db

Browse files
committed
Update
[ghstack-poisoned]
1 parent 5dc8b27 commit 2dcb6db

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernels/portable/cpu/util/reduce_util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,15 @@ template <typename Func>
675675
optional<int64_t> dim,
676676
const Tensor& out,
677677
const Func& func) {
678+
#ifdef ET_USE_THREADPOOL
678679
const ssize_t reduction_size = get_reduced_dim_product(in, dim);
679680
const auto grain_size = std::max(
680681
static_cast<ssize_t>(1),
681682
static_cast<ssize_t>(executorch::extension::internal::GRAIN_SIZE) /
682683
reduction_size);
684+
#else // ET_USE_THREADPOOL
685+
const auto grain_size = 1;
686+
#endif // ET_USE_THREADPOOL
683687
return executorch::extension::parallel_for(0, out.numel(), grain_size, func);
684688
}
685689

@@ -694,11 +698,15 @@ template <typename Func>
694698
optional<ArrayRef<int64_t>> dim_list,
695699
const Tensor& out,
696700
const Func& func) {
701+
#ifdef ET_UE_THREADPOOL
697702
const ssize_t reduction_size = get_reduced_dim_product(in, dim_list);
698703
const auto grain_size = std::max(
699704
static_cast<ssize_t>(1),
700705
static_cast<ssize_t>(executorch::extension::internal::GRAIN_SIZE) /
701706
reduction_size);
707+
#else // ET_USE_THREADPOOL
708+
const auto grain_size = 1;
709+
#endif // ET_USE_THREADPOOL
702710
return executorch::extension::parallel_for(0, out.numel(), grain_size, func);
703711
}
704712

0 commit comments

Comments
 (0)