Skip to content

Commit e1719b8

Browse files
dbortfacebook-github-bot
authored andcommitted
Migrate pybindings to use the new HierarchicalAllocator span ctor (#389)
Summary: Pull Request resolved: #389 Stop using the deprecated HierarchicalAllocator ctor. ghstack-source-id: 201128785 exported-using-ghexport Reviewed By: tarun292 Differential Revision: D49344928 fbshipit-source-id: e8346222e99faf4a02bdb9c1c1677dc92e852486
1 parent 0bce2cb commit e1719b8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

extension/pybindings/pybindings.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,9 @@ class Module final {
183183
explicit Memory(std::vector<std::vector<uint8_t>>&& non_const_buffers)
184184
: runtime_allocator_(),
185185
non_const_buffers_(std::move(non_const_buffers)),
186-
non_const_allocator_list_(create_non_const_allocators()),
186+
non_const_spans_(create_non_const_spans()),
187187
non_const_allocator_(
188-
non_const_allocator_list_.size(),
189-
non_const_allocator_list_.data()),
188+
{non_const_spans_.data(), non_const_spans_.size()}),
190189
mem_manager_(
191190
&const_allocator_,
192191
&non_const_allocator_,
@@ -211,17 +210,17 @@ class Module final {
211210

212211
std::vector<std::vector<uint8_t>> non_const_buffers_;
213212

214-
std::vector<MemoryAllocator> non_const_allocator_list_;
213+
std::vector<Span<uint8_t>> non_const_spans_;
215214

216215
HierarchicalAllocator non_const_allocator_;
217216

218217
MemoryManager mem_manager_;
219218

220-
std::vector<MemoryAllocator> create_non_const_allocators() {
221-
std::vector<MemoryAllocator> result;
219+
std::vector<Span<uint8_t>> create_non_const_spans() {
220+
std::vector<Span<uint8_t>> result;
222221
for (size_t i = 0; i < non_const_buffers_.size(); i++) {
223-
result.push_back(MemoryAllocator(
224-
non_const_buffers_[i].size(), non_const_buffers_[i].data()));
222+
result.push_back(
223+
{non_const_buffers_[i].data(), non_const_buffers_[i].size()});
225224
}
226225
return result;
227226
}

0 commit comments

Comments
 (0)