Skip to content

Commit 873ae94

Browse files
authored
Fix data pointer const-correctness in executorch kernels
Differential Revision: D88495144 Pull Request resolved: #16102
1 parent 42e3222 commit 873ae94

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

kernels/optimized/cpu/fft_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline pocketfft::shape_t shape_from_tensor(const Tensor& t) {
3838
template <typename T>
3939
inline std::complex<T>* tensor_cdata(Tensor& t) {
4040
return reinterpret_cast<std::complex<T>*>(
41-
t.data_ptr<executorch::runtime::etensor::complex<T>>());
41+
t.mutable_data_ptr<executorch::runtime::etensor::complex<T>>());
4242
}
4343

4444
template <typename T>

kernels/optimized/cpu/op_where.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Tensor& opt_where_out(
5151
const CTYPE_COMPUTE* const data_a = a.const_data_ptr<CTYPE_COMPUTE>();
5252
const CTYPE_COMPUTE* const data_b = b.const_data_ptr<CTYPE_COMPUTE>();
5353
const bool* const data_cond = cond.const_data_ptr<bool>();
54-
CTYPE_COMPUTE* const data_out = out.data_ptr<CTYPE_COMPUTE>();
54+
CTYPE_COMPUTE* const data_out = out.mutable_data_ptr<CTYPE_COMPUTE>();
5555
executorch::extension::parallel_for(
5656
0,
5757
out_numel,

kernels/portable/cpu/op_native_dropout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ std::tuple<Tensor&, Tensor&> native_dropout_out(
7676
out);
7777
});
7878
} else if (input.numel() > 0) {
79-
std::memcpy(out.mutable_data_ptr(), input.data_ptr(), input.nbytes());
79+
std::memcpy(out.mutable_data_ptr(), input.const_data_ptr(), input.nbytes());
8080
std::memset(mask.mutable_data_ptr(), true, mask.nbytes());
8181
}
8282
return ret;

0 commit comments

Comments
 (0)