Skip to content

Commit b4c6fe1

Browse files
authored
Refactor Init function arg
Differential Revision: D65499276 Pull Request resolved: pytorch#6673
1 parent 068f43c commit b4c6fe1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

runtime/executor/test/backend_integration_test.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class StubBackend final : public BackendInterface {
5555
using InitFn = std::function<Result<DelegateHandle*>(
5656
FreeableBuffer*,
5757
ArrayRef<CompileSpec>,
58-
MemoryAllocator*)>;
58+
BackendInitContext&)>;
5959
using ExecuteFn = std::function<Error(DelegateHandle*, EValue**)>;
6060
using DestroyFn = std::function<void(DelegateHandle*)>;
6161

@@ -83,8 +83,7 @@ class StubBackend final : public BackendInterface {
8383
FreeableBuffer* processed,
8484
ArrayRef<CompileSpec> compile_specs) const override {
8585
if (init_fn_) {
86-
return init_fn_.value()(
87-
processed, compile_specs, context.get_runtime_allocator());
86+
return init_fn_.value()(processed, compile_specs, context);
8887
}
8988
// Return a benign value otherwise.
9089
return nullptr;
@@ -351,7 +350,7 @@ TEST_P(BackendIntegrationTest, FreeingProcessedBufferSucceeds) {
351350
StubBackend::singleton().install_init(
352351
[&](FreeableBuffer* processed,
353352
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
354-
ET_UNUSED MemoryAllocator* runtime_allocator)
353+
ET_UNUSED BackendInitContext& backend_init_context)
355354
-> Result<DelegateHandle*> {
356355
init_called = true;
357356
processed_data = processed->data();
@@ -395,7 +394,7 @@ TEST_P(BackendIntegrationTest, EndToEndTestWithProcessedAsHandle) {
395394
StubBackend::singleton().install_init(
396395
[&](FreeableBuffer* processed,
397396
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
398-
ET_UNUSED MemoryAllocator* runtime_allocator)
397+
ET_UNUSED BackendInitContext& backend_init_context)
399398
-> Result<DelegateHandle*> {
400399
init_processed = processed;
401400
return processed;
@@ -492,7 +491,7 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
492491
StubBackend::singleton().install_init(
493492
[&](FreeableBuffer* processed,
494493
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
495-
ET_UNUSED MemoryAllocator* runtime_allocator)
494+
ET_UNUSED BackendInitContext& backend_init_context)
496495
-> Result<DelegateHandle*> {
497496
processed_data = processed->data();
498497
processed->Free();
@@ -606,7 +605,7 @@ TEST_P(DelegateDataAlignmentTest, ExpectedDataAlignment) {
606605
StubBackend::singleton().install_init(
607606
[&](FreeableBuffer* processed,
608607
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
609-
ET_UNUSED MemoryAllocator* runtime_allocator)
608+
ET_UNUSED BackendInitContext& backend_init_context)
610609
-> Result<DelegateHandle*> {
611610
processed_data = processed->data();
612611
return nullptr;

0 commit comments

Comments
 (0)