Skip to content

Commit 85ec022

Browse files
cccclaifacebook-github-bot
authored andcommitted
Refactor Init function arg (#6673)
Summary: The actual init function takes in backend init context instead of memory allocator directly. See https://github.com/pytorch/executorch/blob/836d5561a61877507b6d5891485725996bb6b32c/runtime/backend/interface.h#L81-L84 Update the signature in the test so it's easier to add test for exposing method name in next diff Differential Revision: D65499276
1 parent c5b88cc commit 85ec022

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

runtime/executor/test/backend_integration_test.cpp

Lines changed: 6 additions & 6 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

@@ -84,7 +84,7 @@ class StubBackend final : public BackendInterface {
8484
ArrayRef<CompileSpec> compile_specs) const override {
8585
if (init_fn_) {
8686
return init_fn_.value()(
87-
processed, compile_specs, context.get_runtime_allocator());
87+
processed, compile_specs, context);
8888
}
8989
// Return a benign value otherwise.
9090
return nullptr;
@@ -351,7 +351,7 @@ TEST_P(BackendIntegrationTest, FreeingProcessedBufferSucceeds) {
351351
StubBackend::singleton().install_init(
352352
[&](FreeableBuffer* processed,
353353
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
354-
ET_UNUSED MemoryAllocator* runtime_allocator)
354+
ET_UNUSED BackendInitContext backend_init_context)
355355
-> Result<DelegateHandle*> {
356356
init_called = true;
357357
processed_data = processed->data();
@@ -395,7 +395,7 @@ TEST_P(BackendIntegrationTest, EndToEndTestWithProcessedAsHandle) {
395395
StubBackend::singleton().install_init(
396396
[&](FreeableBuffer* processed,
397397
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
398-
ET_UNUSED MemoryAllocator* runtime_allocator)
398+
ET_UNUSED BackendInitContext backend_init_context)
399399
-> Result<DelegateHandle*> {
400400
init_processed = processed;
401401
return processed;
@@ -492,7 +492,7 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
492492
StubBackend::singleton().install_init(
493493
[&](FreeableBuffer* processed,
494494
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
495-
ET_UNUSED MemoryAllocator* runtime_allocator)
495+
ET_UNUSED BackendInitContext backend_init_context)
496496
-> Result<DelegateHandle*> {
497497
processed_data = processed->data();
498498
processed->Free();
@@ -606,7 +606,7 @@ TEST_P(DelegateDataAlignmentTest, ExpectedDataAlignment) {
606606
StubBackend::singleton().install_init(
607607
[&](FreeableBuffer* processed,
608608
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
609-
ET_UNUSED MemoryAllocator* runtime_allocator)
609+
ET_UNUSED BackendInitContext backend_init_context)
610610
-> Result<DelegateHandle*> {
611611
processed_data = processed->data();
612612
return nullptr;

0 commit comments

Comments
 (0)