Skip to content

Commit 5c02801

Browse files
committed
Update base for Update on "[executorch] Optimized 2D-by-1D broadcasting in optimized op_mul"
Detect that we are doing an elementwise multiplication for a 2D tensor and a 1D tensor. Dispatch to a vectorized kernel for this case. Differential Revision: [D61560826](https://our.internmc.facebook.com/intern/diff/D61560826/) [ghstack-poisoned]
1 parent 82ff5ec commit 5c02801

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

kernels/optimized/cpu/op_mul.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ template <
106106
typename CTYPE_OUT>
107107
struct MulInner<false, CTYPE_A, CTYPE_B, CTYPE_IN, CTYPE_OUT>
108108
: public ReportCanCastBug {};
109-
110-
Scalar tensor_to_scalar(RuntimeContext& ctx, const Tensor& t) {
111-
ET_DCHECK(t.numel() == 1);
112-
Scalar result;
113-
ET_SWITCH_REALHB_TYPES(t.scalar_type(), ctx, "mul.out", CTYPE, [&]() {
114-
result = Scalar(*t.const_data_ptr<CTYPE>());
115-
});
116-
return result;
117-
}
118109
} // namespace
119110

120111
Tensor& opt_mul_out(
@@ -129,8 +120,7 @@ Tensor& opt_mul_out(
129120
ScalarType out_type = out.scalar_type();
130121

131122
if (b.numel() == 1) {
132-
if (a_type == b_type && a_type == out_type &&
133-
a_type != ScalarType::Half) {
123+
if (a_type == b_type && a_type == out_type && a_type != ScalarType::Half) {
134124
auto error = resize_tensor(out, a.sizes());
135125
ET_KERNEL_CHECK_MSG(
136126
ctx,

0 commit comments

Comments
 (0)