@@ -55,7 +55,7 @@ class StubBackend final : public BackendInterface {
55
55
using InitFn = std::function<Result<DelegateHandle*>(
56
56
FreeableBuffer*,
57
57
ArrayRef<CompileSpec>,
58
- MemoryAllocator* )>;
58
+ BackendInitContext )>;
59
59
using ExecuteFn = std::function<Error(DelegateHandle*, EValue**)>;
60
60
using DestroyFn = std::function<void (DelegateHandle*)>;
61
61
@@ -84,7 +84,7 @@ class StubBackend final : public BackendInterface {
84
84
ArrayRef<CompileSpec> compile_specs) const override {
85
85
if (init_fn_) {
86
86
return init_fn_.value ()(
87
- processed, compile_specs, context. get_runtime_allocator () );
87
+ processed, compile_specs, context);
88
88
}
89
89
// Return a benign value otherwise.
90
90
return nullptr ;
@@ -351,7 +351,7 @@ TEST_P(BackendIntegrationTest, FreeingProcessedBufferSucceeds) {
351
351
StubBackend::singleton ().install_init (
352
352
[&](FreeableBuffer* processed,
353
353
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
354
- ET_UNUSED MemoryAllocator* runtime_allocator )
354
+ ET_UNUSED BackendInitContext backend_init_context )
355
355
-> Result<DelegateHandle*> {
356
356
init_called = true ;
357
357
processed_data = processed->data ();
@@ -395,7 +395,7 @@ TEST_P(BackendIntegrationTest, EndToEndTestWithProcessedAsHandle) {
395
395
StubBackend::singleton ().install_init (
396
396
[&](FreeableBuffer* processed,
397
397
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
398
- ET_UNUSED MemoryAllocator* runtime_allocator )
398
+ ET_UNUSED BackendInitContext backend_init_context )
399
399
-> Result<DelegateHandle*> {
400
400
init_processed = processed;
401
401
return processed;
@@ -492,7 +492,7 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
492
492
StubBackend::singleton ().install_init (
493
493
[&](FreeableBuffer* processed,
494
494
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
495
- ET_UNUSED MemoryAllocator* runtime_allocator )
495
+ ET_UNUSED BackendInitContext backend_init_context )
496
496
-> Result<DelegateHandle*> {
497
497
processed_data = processed->data ();
498
498
processed->Free ();
@@ -528,6 +528,25 @@ TEST_P(BackendIntegrationTest, SegmentInfoIsPassedIntoDataLoader) {
528
528
EXPECT_EQ (backend_load_was_called, using_segments ());
529
529
}
530
530
531
+ TEST_P (BackendIntegrationTest, GetMethodNameSuccess) {
532
+ Result<FileDataLoader> loader = FileDataLoader::from (program_path ());
533
+ ASSERT_EQ (loader.error (), Error::Ok);
534
+ const void * processed_data = nullptr ;
535
+ StubBackend::singleton ().install_init (
536
+ [&](FreeableBuffer* processed,
537
+ ET_UNUSED ArrayRef<CompileSpec> compile_specs,
538
+ ET_UNUSED BackendInitContext backend_init_context)
539
+ -> Result<DelegateHandle*> {
540
+ auto method_name = backend_init_context.get_method_name ();
541
+ EXPECT_EQ (method_name, " forward" );
542
+ processed_data = processed->data ();
543
+ return nullptr ;
544
+ });
545
+ Result<Program> program = Program::load (&loader.get ());
546
+ ASSERT_EQ (program.error (), Error::Ok);
547
+
548
+ }
549
+
531
550
// TODO: Add more tests for the runtime-to-backend interface. E.g.:
532
551
// - Errors during init() or execute() result in runtime init/execution failures
533
552
// - Correct values are passed to init()/execute()
@@ -606,7 +625,7 @@ TEST_P(DelegateDataAlignmentTest, ExpectedDataAlignment) {
606
625
StubBackend::singleton ().install_init (
607
626
[&](FreeableBuffer* processed,
608
627
ET_UNUSED ArrayRef<CompileSpec> compile_specs,
609
- ET_UNUSED MemoryAllocator* runtime_allocator )
628
+ ET_UNUSED BackendInitContext backend_init_context )
610
629
-> Result<DelegateHandle*> {
611
630
processed_data = processed->data ();
612
631
return nullptr ;
0 commit comments