Skip to content

Commit

Permalink
Add function to get temp allocator (pytorch#4034)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#4034

Expose the temp allocator in the `BackendExecutionContext`. For the custom allocator provided by the backend, it's possible that they can support more than allocate function and we want to provide the flexibility if they have the custom allocator.

Reviewed By: tarun292, cmt0

Differential Revision: D58881648

fbshipit-source-id: d124f529991ef3cbb9e3b3db4c6d447b809bdbee
  • Loading branch information
cccclai authored and facebook-github-bot committed Jun 21, 2024
1 parent b2a4bb6 commit 5e22836
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions runtime/backend/backend_execution_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ class BackendExecutionContext final {
return temp_allocator_->allocate(size, alignment);
}

/**
* Returns the temp allocator. This allocator will be reset every instruction.
*/
MemoryAllocator* get_temp_allocator() {
return temp_allocator_;
}

private:
EventTracer* event_tracer_ = nullptr;
MemoryAllocator* temp_allocator_ = nullptr;
Expand Down

0 comments on commit 5e22836

Please sign in to comment.