Skip to content

Commit 40df311

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
Remove initialized api from tensor
Summary: In aten tensor this is used to reason about if the Intrusive ptr to tensorImpl is set or not. We were using it to reason about the data ptr so I'd rather just delete it. If we need to reason about if the TensorImpl ptr in Tensor is null or not we can add it back with different semantics. Reviewed By: larryliu0820 Differential Revision: D46129275 fbshipit-source-id: 0ea311b1e5b2ae6048eabe20dbc7afcd41c0fe7d
1 parent 1819da5 commit 40df311

File tree

4 files changed

+1
-13
lines changed

4 files changed

+1
-13
lines changed

core/kernel_types/lean/tensor.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ class Tensor {
148148
impl_->set_data(ptr);
149149
}
150150

151-
// To be removed in follow up
152-
bool initialized() const {
153-
return impl_->initialized();
154-
}
155-
156151
private:
157152
TensorImpl* impl_ = nullptr;
158153
};

core/kernel_types/lean/tensor_impl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,5 @@ Error TensorImpl::internal_resize_contiguous(ArrayRef<SizesType> new_sizes) {
172172
return Error::Ok;
173173
}
174174

175-
bool TensorImpl::initialized() const {
176-
return data_ != nullptr;
177-
}
178-
179175
} // namespace executor
180176
} // namespace torch

core/kernel_types/lean/tensor_impl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ class TensorImpl {
177177
/// Sets the underlying data blob to the passed in pointer.
178178
void set_data(void* ptr);
179179

180-
/// Returns true if the tensor data pointer is not null.
181-
bool initialized() const;
182-
183180
/*
184181
* DEPRECATED: Use torch::executor::resize_tensor() or
185182
* torch::executor::resize_tensor_impl().

util/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ inline exec_aten::ArrayRef<void*> PrepareInputTensors(
8585
continue;
8686
}
8787
const auto& t = plan.get_input(i).toTensor();
88-
if (!t.initialized()) {
88+
if (t.data_ptr() == nullptr) {
8989
ET_LOG(Info, "input not initialized.");
9090
inputs[num_allocated++] = malloc(t.nbytes());
9191
t.set_data(inputs[num_allocated - 1]);

0 commit comments

Comments
 (0)