Skip to content

Commit 088836c

Browse files
phaitingHaiting Pu
andauthored
getMethodMetadata should contain used backend name (#14397)
### Summary This change added the metadata for used backend name for API getMethodMetadata() ### Test plan Run E2E test locally --------- Co-authored-by: Haiting Pu <[email protected]>
1 parent 8c74545 commit 088836c

File tree

2 files changed

+9
-2
lines changed
  • extension/android/executorch_android/src

2 files changed

+9
-2
lines changed

extension/android/executorch_android/src/androidTest/java/org/pytorch/executorch/ModuleE2ETest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ package org.pytorch.executorch
1010
import android.Manifest
1111
import android.graphics.Bitmap
1212
import android.graphics.BitmapFactory
13-
import androidx.test.InstrumentationRegistry
1413
import androidx.test.ext.junit.runners.AndroidJUnit4
1514
import androidx.test.rule.GrantPermissionRule
1615
import java.io.File
1716
import java.io.IOException
1817
import java.net.URISyntaxException
1918
import org.apache.commons.io.FileUtils
2019
import org.junit.Assert
20+
import org.junit.Assert.assertArrayEquals
2121
import org.junit.Rule
2222
import org.junit.Test
2323
import org.junit.runner.RunWith
@@ -70,6 +70,7 @@ class ModuleE2ETest {
7070

7171
val module = Module.load(getTestFilePath("/mv3_xnnpack_fp32.pte"))
7272
val expectedBackends = arrayOf("XnnpackBackend")
73+
assertArrayEquals(expectedBackends, module.getMethodMetadata("forward").backends)
7374
}
7475

7576
@Test

extension/android/executorch_android/src/main/java/org/pytorch/executorch/Module.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ public MethodMetadata getMethodMetadata(String name) {
203203
if (!mMethodMetadata.containsKey(name)) {
204204
throw new RuntimeException("method " + name + "does not exist for this module");
205205
}
206-
return mMethodMetadata.get(name);
206+
207+
MethodMetadata methodMetadata =mMethodMetadata.get(name);
208+
if (methodMetadata != null) {
209+
methodMetadata.setBackends(getUsedBackends(name));
210+
211+
}
212+
return methodMetadata;
207213
}
208214

209215
/** Retrieve the in-memory log buffer, containing the most recent ExecuTorch log entries. */

0 commit comments

Comments
 (0)