Skip to content

Commit 5e2e6ce

Browse files
lucylqfacebook-github-bot
authored andcommitted
replace deprecated functions (#596)
Summary: Pull Request resolved: #596 to run internal size test locally (macbook arm) |**build, stripped** | **x86_64 (devserver)** | **arm64 (macbook)** | |With ET_LOG, verification | 82576 | 122376 | |Without ET_LOG | 67576 | 105720 | |Without ET_LOG, verification | 48584 | 89280| Reviewed By: larryliu0820 Differential Revision: D49742299 fbshipit-source-id: c26efa9874fea07c3d624c7707dee7341084d0a9
1 parent 97189f9 commit 5e2e6ce

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

kernels/prim_ops/et_copy_index.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ void et_copy_index(RuntimeContext& context, EValue** stack) {
9595
}
9696

9797
if (copy_to.sizes()[0] != expected_output_size[0]) {
98-
void* data_ptr = copy_to.data_ptr();
98+
const void* data_ptr = copy_to.const_data_ptr();
9999
Error err =
100100
resize_tensor(copy_to, {expected_output_size, copy_to.sizes().size()});
101101
ET_CHECK(err == Error::Ok);
102102
ET_CHECK_MSG(
103-
data_ptr == copy_to.data_ptr(),
103+
data_ptr == copy_to.const_data_ptr(),
104104
"Data ptr of copy_to tensor changed after resize which isn't allowed for static/upper-bounded tensors");
105105
}
106106

107-
auto copy_to_ptr = copy_to.data_ptr();
108-
auto copy_from_ptr = copy_from.data_ptr();
107+
auto copy_to_ptr = copy_to.const_data_ptr();
108+
auto copy_from_ptr = copy_from.const_data_ptr();
109109

110110
// If we've reached here, it means the copy_to tensor has been
111111
// successfully resized so we can now copy over the data from

runtime/core/exec_aten/util/tensor_util_portable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Error share_tensor_data(
9090
InvalidArgument,
9191
"Source tensor should have data_ptr not being nullptr.");
9292
// Assign internal data_ptr as the one in forwarded tensor
93-
t_dst.set_data(t_src.mutable_data_ptr());
93+
t_dst.unsafeGetTensorImpl()->set_data(t_src.mutable_data_ptr());
9494

9595
return Error::Ok;
9696
}
@@ -132,7 +132,7 @@ __ET_NODISCARD Error set_tensor_data(
132132

133133
void reset_data_ptr(const torch::executor::Tensor& tensor) {
134134
// Lean mode doesn't deallocate the tensor data_ptr in the allocator
135-
tensor.set_data(nullptr);
135+
tensor.unsafeGetTensorImpl()->set_data(nullptr);
136136
}
137137

138138
class TensorResizerFriend final {

runtime/executor/method_meta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ size_t MethodMeta::num_memory_planned_buffers() const {
180180
}
181181

182182
Result<int64_t> MethodMeta::memory_planned_buffer_size(size_t index) const {
183-
auto num_buffers = this->num_non_const_buffers();
183+
auto num_buffers = this->num_memory_planned_buffers();
184184
ET_CHECK_OR_RETURN_ERROR(
185185
index >= 0 && index < num_buffers,
186186
InvalidArgument,

0 commit comments

Comments
 (0)