diff --git a/.clang-format b/.clang-format
index 378d37ada..efda3f867 100644
--- a/.clang-format
+++ b/.clang-format
@@ -4,7 +4,7 @@ BasedOnStyle: Google
# Setting ColumnLimit to 0 so developer choices about where to break lines are maintained.
# Developers are responsible for adhering to the 120 character maximum.
-ColumnLimit: 120
+ColumnLimit: 0
SortIncludes: false
DerivePointerAlignment: false
# Avoid adding spaces between tokens in GSL_SUPPRESS arguments.
diff --git a/plugin_execution_providers/basic/CMakeLists.txt b/plugin_execution_providers/basic/CMakeLists.txt
new file mode 100644
index 000000000..bef7f0b13
--- /dev/null
+++ b/plugin_execution_providers/basic/CMakeLists.txt
@@ -0,0 +1,71 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+cmake_minimum_required(VERSION 3.31)
+
+project(BasicPluginEp)
+
+set(CMAKE_CXX_STANDARD 20)
+
+set(plugin_ep_common_dir ${CMAKE_SOURCE_DIR}/../common)
+
+include(${plugin_ep_common_dir}/cmake/onnxruntime_library_utils.cmake)
+
+# Set ORT_HOME (e.g., with cmake -D) to specify the directory with the ONNX Runtime header and library files to use.
+# This is optional. If unspecified, the ONNX Runtime files will be downloaded.
+
+set_onnxruntime_paths(
+ ORT_HOME ${ORT_HOME}
+ DEFAULT_ORT_VERSION "1.23.2"
+ ORT_INCLUDE_DIR_VAR ORT_INCLUDE_DIR
+ ORT_LIBRARY_DIR_VAR ORT_LIBRARY_DIR)
+
+message(STATUS "ORT_LIBRARY_DIR: ${ORT_LIBRARY_DIR}")
+message(STATUS "ORT_INCLUDE_DIR: ${ORT_INCLUDE_DIR}")
+
+#
+# basic_plugin_ep
+#
+block()
+
+add_library(basic_plugin_ep MODULE)
+
+target_sources(basic_plugin_ep PRIVATE
+ ${CMAKE_SOURCE_DIR}/src/ep_factory.cc
+ ${CMAKE_SOURCE_DIR}/src/ep_factory.h
+ ${CMAKE_SOURCE_DIR}/src/ep_lib_entry.cc
+ ${CMAKE_SOURCE_DIR}/src/ep.cc
+ ${CMAKE_SOURCE_DIR}/src/ep.h
+ ${plugin_ep_common_dir}/src/plugin_ep_utils.h
+)
+
+target_include_directories(basic_plugin_ep PRIVATE
+ ${ORT_INCLUDE_DIR}
+ ${plugin_ep_common_dir}/src
+)
+
+target_link_directories(basic_plugin_ep PRIVATE ${ORT_LIBRARY_DIR})
+target_link_libraries(basic_plugin_ep PRIVATE onnxruntime)
+
+set(basic_plugin_ep_link_options)
+if(MSVC)
+ list(APPEND basic_plugin_ep_link_options
+ "-DEF:${CMAKE_SOURCE_DIR}/src/ep_lib.def")
+else()
+ if(UNIX)
+ if(APPLE)
+ list(APPEND basic_plugin_ep_link_options
+ "LINKER:-dead_strip")
+ else()
+ list(APPEND basic_plugin_ep_link_options
+ "LINKER:--version-script=${CMAKE_SOURCE_DIR}/src/ep_lib.lds"
+ "LINKER:--no-undefined"
+ "LINKER:--gc-sections"
+ "-z" "noexecstack")
+ endif()
+ endif()
+endif()
+
+target_link_options(basic_plugin_ep PRIVATE ${basic_plugin_ep_link_options})
+
+endblock()
diff --git a/plugin_execution_providers/basic/android/.gitignore b/plugin_execution_providers/basic/android/.gitignore
new file mode 100644
index 000000000..aa724b770
--- /dev/null
+++ b/plugin_execution_providers/basic/android/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties
diff --git a/plugin_execution_providers/basic/android/basicpluginep/.gitignore b/plugin_execution_providers/basic/android/basicpluginep/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/build.gradle.kts b/plugin_execution_providers/basic/android/basicpluginep/build.gradle.kts
new file mode 100644
index 000000000..e957ab956
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/build.gradle.kts
@@ -0,0 +1,63 @@
+// Specifies a directory containing ONNX Runtime libraries and headers to use. This directory
+// should match the onnxruntime-android AAR structure.
+// Specifying `ortHome` is optional. If unspecified, the ONNX Runtime files will be downloaded.
+val ortHome: String? = System.getProperty("ortHome")
+
+plugins {
+ alias(libs.plugins.android.library)
+ alias(libs.plugins.kotlin.android)
+}
+
+android {
+ namespace = "ai.onnxruntime.example.basicpluginep"
+ compileSdk {
+ version = release(36)
+ }
+
+ defaultConfig {
+ minSdk = 26
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles("consumer-rules.pro")
+ externalNativeBuild {
+ cmake {
+ if (ortHome != null) {
+ arguments += listOf("-DORT_HOME=${ortHome}")
+ }
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+
+ externalNativeBuild {
+ cmake {
+ path("../../CMakeLists.txt")
+ version = "3.31.6"
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+ kotlinOptions {
+ jvmTarget = "11"
+ }
+}
+
+dependencies {
+ implementation(libs.androidx.core.ktx)
+ implementation(libs.androidx.appcompat)
+ implementation(libs.material)
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.androidx.junit)
+ androidTestImplementation(libs.androidx.espresso.core)
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/consumer-rules.pro b/plugin_execution_providers/basic/android/basicpluginep/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/plugin_execution_providers/basic/android/basicpluginep/proguard-rules.pro b/plugin_execution_providers/basic/android/basicpluginep/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/src/androidTest/java/ai/onnxruntime/example/basicpluginep/ExampleInstrumentedTest.kt b/plugin_execution_providers/basic/android/basicpluginep/src/androidTest/java/ai/onnxruntime/example/basicpluginep/ExampleInstrumentedTest.kt
new file mode 100644
index 000000000..08f5e0837
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/src/androidTest/java/ai/onnxruntime/example/basicpluginep/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package ai.onnxruntime.example.basicpluginep
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("ai.onnxruntime.example.basicpluginep.test", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/src/main/AndroidManifest.xml b/plugin_execution_providers/basic/android/basicpluginep/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..a5918e68a
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/src/main/java/ai/onnxruntime/example/basicpluginep/BasicPluginEpLibrary.kt b/plugin_execution_providers/basic/android/basicpluginep/src/main/java/ai/onnxruntime/example/basicpluginep/BasicPluginEpLibrary.kt
new file mode 100644
index 000000000..6c58cdea9
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/src/main/java/ai/onnxruntime/example/basicpluginep/BasicPluginEpLibrary.kt
@@ -0,0 +1,11 @@
+package ai.onnxruntime.example.basicpluginep
+
+private const val basicPluginEpLibraryName = "basic_plugin_ep"
+
+/**
+ * Returns the path to the basic plugin EP library.
+ * This path can be used with `OrtEnvironment.registerExecutionProviderLibrary()`.
+ */
+fun getBasicPluginEpLibraryPath() : String {
+ return "lib${basicPluginEpLibraryName}.so"
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginep/src/test/java/ai/onnxruntime/example/basicpluginep/ExampleUnitTest.kt b/plugin_execution_providers/basic/android/basicpluginep/src/test/java/ai/onnxruntime/example/basicpluginep/ExampleUnitTest.kt
new file mode 100644
index 000000000..01ce950a4
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginep/src/test/java/ai/onnxruntime/example/basicpluginep/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package ai.onnxruntime.example.basicpluginep
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/.gitignore b/plugin_execution_providers/basic/android/basicpluginepusage/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/build.gradle.kts b/plugin_execution_providers/basic/android/basicpluginepusage/build.gradle.kts
new file mode 100644
index 000000000..1cb3214e5
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/build.gradle.kts
@@ -0,0 +1,69 @@
+plugins {
+ alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ alias(libs.plugins.kotlin.compose)
+}
+
+android {
+ namespace = "ai.onnxruntime.example.basicpluginepusage"
+ compileSdk {
+ version = release(36)
+ }
+
+ defaultConfig {
+ applicationId = "ai.onnxruntime.example.basicpluginepusage"
+ minSdk = 26
+ targetSdk = 36
+ versionCode = 1
+ versionName = "1.0"
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ isMinifyEnabled = false
+ proguardFiles(
+ getDefaultProguardFile("proguard-android-optimize.txt"),
+ "proguard-rules.pro"
+ )
+ }
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+ kotlinOptions {
+ jvmTarget = "11"
+ }
+ buildFeatures {
+ compose = true
+ }
+}
+
+dependencies {
+ // Plugin EP library module dependency
+ implementation(project(":basicpluginep"))
+
+ // onnxruntime-android dependency
+ // Note: Typically, we would want to use a release version, but some of the plugin EP
+ // infrastructure is not available in a released version yet. We'll depend on a dev version.
+ //implementation("com.microsoft.onnxruntime:onnxruntime-android:latest.release")
+ implementation(files("lib/onnxruntime-android-1.24.0-dev+commit-75d35474.aar"))
+
+ implementation(libs.androidx.core.ktx)
+ implementation(libs.androidx.lifecycle.runtime.ktx)
+ implementation(libs.androidx.activity.compose)
+ implementation(platform(libs.androidx.compose.bom))
+ implementation(libs.androidx.compose.ui)
+ implementation(libs.androidx.compose.ui.graphics)
+ implementation(libs.androidx.compose.ui.tooling.preview)
+ implementation(libs.androidx.compose.material3)
+ testImplementation(libs.junit)
+ androidTestImplementation(libs.androidx.junit)
+ androidTestImplementation(libs.androidx.espresso.core)
+ androidTestImplementation(platform(libs.androidx.compose.bom))
+ androidTestImplementation(libs.androidx.compose.ui.test.junit4)
+ debugImplementation(libs.androidx.compose.ui.tooling)
+ debugImplementation(libs.androidx.compose.ui.test.manifest)
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/gen_mul_model.py b/plugin_execution_providers/basic/android/basicpluginepusage/gen_mul_model.py
new file mode 100644
index 000000000..81acda2ad
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/gen_mul_model.py
@@ -0,0 +1,11 @@
+from pathlib import Path
+import onnx
+from onnxscript import script, FLOAT, opset15 as op
+
+@script(default_opset=op)
+def model(x: FLOAT[2, 3], y: FLOAT[2, 3]) -> FLOAT[2, 3]:
+ return x * y
+
+model_proto = model.to_model_proto()
+script_dir = Path(__file__).parent
+onnx.save(model_proto, f"{script_dir}/src/main/res/raw/mul.onnx")
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/lib/onnxruntime-android-1.24.0-dev+commit-75d35474.aar b/plugin_execution_providers/basic/android/basicpluginepusage/lib/onnxruntime-android-1.24.0-dev+commit-75d35474.aar
new file mode 100644
index 000000000..a4c5d13dd
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/lib/onnxruntime-android-1.24.0-dev+commit-75d35474.aar differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/proguard-rules.pro b/plugin_execution_providers/basic/android/basicpluginepusage/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/androidTest/java/ai/onnxruntime/example/basicpluginepusage/ExampleInstrumentedTest.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/androidTest/java/ai/onnxruntime/example/basicpluginepusage/ExampleInstrumentedTest.kt
new file mode 100644
index 000000000..c3b0f062f
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/androidTest/java/ai/onnxruntime/example/basicpluginepusage/ExampleInstrumentedTest.kt
@@ -0,0 +1,24 @@
+package ai.onnxruntime.example.basicpluginepusage
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+ @Test
+ fun useAppContext() {
+ // Context of the app under test.
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+ assertEquals("ai.onnxruntime.example.basicpluginepusage", appContext.packageName)
+ }
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/AndroidManifest.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..f6b2b661a
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/MainActivity.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/MainActivity.kt
new file mode 100644
index 000000000..b9685c99c
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/MainActivity.kt
@@ -0,0 +1,101 @@
+package ai.onnxruntime.example.basicpluginepusage
+
+import ai.onnxruntime.OnnxTensor
+import ai.onnxruntime.OrtEnvironment
+import ai.onnxruntime.OrtLoggingLevel
+import ai.onnxruntime.OrtSession
+import ai.onnxruntime.example.basicpluginep.getBasicPluginEpLibraryPath
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.activity.enableEdgeToEdge
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.ui.Modifier
+import ai.onnxruntime.example.basicpluginepusage.ui.theme.BasicPluginEpTheme
+import java.nio.FloatBuffer
+
+class MainActivity : ComponentActivity() {
+ private lateinit var ortEnv: OrtEnvironment
+ private lateinit var ortSession: OrtSession
+ private val pluginEpRegistrationName: String = "basic_plugin_ep"
+
+ private fun readResourceBytes(resourceId: Int): ByteArray {
+ return resources.openRawResource(resourceId).readBytes()
+ }
+
+ private fun setUpOnnxRuntime() {
+ ortEnv = OrtEnvironment.getEnvironment(OrtLoggingLevel.ORT_LOGGING_LEVEL_INFO)
+
+ val pluginEpLibraryPath = getBasicPluginEpLibraryPath()
+ ortEnv.registerExecutionProviderLibrary(pluginEpRegistrationName, pluginEpLibraryPath)
+
+ val modelBytes = readResourceBytes(R.raw.mul)
+ val sessionOptions = OrtSession.SessionOptions()
+ val allEpDevices = ortEnv.epDevices
+ val epDevicesToUse = allEpDevices.filter { it.epName == "BasicPluginEp" }
+ sessionOptions.addExecutionProvider(epDevicesToUse, emptyMap())
+ ortSession = ortEnv.createSession(modelBytes, sessionOptions)
+ }
+
+ private fun tearDownOnnxRuntime() {
+ ortEnv.unregisterExecutionProviderLibrary(pluginEpRegistrationName)
+
+ ortSession.close()
+ ortEnv.close()
+ }
+
+ private fun multiplyWithModel(x: Float, y: Float) : Float {
+ val inputShape = longArrayOf(2, 3)
+ val numElements = inputShape.reduce { product, dim -> product * dim }.toInt()
+
+ val xValues = FloatBuffer.allocate(numElements)
+ xValues.put(FloatArray(numElements) { x })
+ xValues.rewind()
+
+ val yValues = FloatBuffer.allocate(numElements)
+ yValues.put(FloatArray(numElements) { y })
+ yValues.rewind()
+
+ val xTensor = OnnxTensor.createTensor(ortEnv, xValues, inputShape)
+ return xTensor.use {
+ val yTensor = OnnxTensor.createTensor(ortEnv, yValues, inputShape)
+ yTensor.use {
+ val outputs = ortSession.run(mapOf("x" to xTensor, "y" to yTensor))
+ outputs.use {
+ val outputValues = outputs.get(0).value as Array
+ outputValues[0][0]
+ }
+ }
+ }
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ setUpOnnxRuntime()
+
+ val x = 3.0f
+ val y = 5.0f
+
+ enableEdgeToEdge()
+ setContent {
+ BasicPluginEpTheme {
+ Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
+ Text(
+ text = "ONNX Runtime with a plugin EP! ${x} * ${y} is ${multiplyWithModel(x, y)}",
+ modifier = Modifier.padding(innerPadding)
+ )
+ }
+ }
+ }
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+
+ tearDownOnnxRuntime()
+ }
+}
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Color.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Color.kt
new file mode 100644
index 000000000..ac55d94af
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Color.kt
@@ -0,0 +1,11 @@
+package ai.onnxruntime.example.basicpluginepusage.ui.theme
+
+import androidx.compose.ui.graphics.Color
+
+val Purple80 = Color(0xFFD0BCFF)
+val PurpleGrey80 = Color(0xFFCCC2DC)
+val Pink80 = Color(0xFFEFB8C8)
+
+val Purple40 = Color(0xFF6650a4)
+val PurpleGrey40 = Color(0xFF625b71)
+val Pink40 = Color(0xFF7D5260)
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Theme.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Theme.kt
new file mode 100644
index 000000000..0f829cf5a
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Theme.kt
@@ -0,0 +1,58 @@
+package ai.onnxruntime.example.basicpluginepusage.ui.theme
+
+import android.app.Activity
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.platform.LocalContext
+
+private val DarkColorScheme = darkColorScheme(
+ primary = Purple80,
+ secondary = PurpleGrey80,
+ tertiary = Pink80
+)
+
+private val LightColorScheme = lightColorScheme(
+ primary = Purple40,
+ secondary = PurpleGrey40,
+ tertiary = Pink40
+
+ /* Other default colors to override
+ background = Color(0xFFFFFBFE),
+ surface = Color(0xFFFFFBFE),
+ onPrimary = Color.White,
+ onSecondary = Color.White,
+ onTertiary = Color.White,
+ onBackground = Color(0xFF1C1B1F),
+ onSurface = Color(0xFF1C1B1F),
+ */
+)
+
+@Composable
+fun BasicPluginEpTheme(
+ darkTheme: Boolean = isSystemInDarkTheme(),
+ // Dynamic color is available on Android 12+
+ dynamicColor: Boolean = true,
+ content: @Composable () -> Unit
+) {
+ val colorScheme = when {
+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
+ val context = LocalContext.current
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ }
+
+ darkTheme -> DarkColorScheme
+ else -> LightColorScheme
+ }
+
+ MaterialTheme(
+ colorScheme = colorScheme,
+ typography = Typography,
+ content = content
+ )
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Type.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Type.kt
new file mode 100644
index 000000000..145ce0f06
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/java/ai/onnxruntime/example/basicpluginepusage/ui/theme/Type.kt
@@ -0,0 +1,34 @@
+package ai.onnxruntime.example.basicpluginepusage.ui.theme
+
+import androidx.compose.material3.Typography
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+
+// Set of Material typography styles to start with
+val Typography = Typography(
+ bodyLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ lineHeight = 24.sp,
+ letterSpacing = 0.5.sp
+ )
+ /* Other default text styles to override
+ titleLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 22.sp,
+ lineHeight = 28.sp,
+ letterSpacing = 0.sp
+ ),
+ labelSmall = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Medium,
+ fontSize = 11.sp,
+ lineHeight = 16.sp,
+ letterSpacing = 0.5.sp
+ )
+ */
+)
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_background.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 000000000..07d5da9cb
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_foreground.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 000000000..2b068d114
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher.xml
new file mode 100644
index 000000000..6f3b755bf
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher_round.xml
new file mode 100644
index 000000000..6f3b755bf
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-anydpi/ic_launcher_round.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 000000000..c209e78ec
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 000000000..b2dfe3d1b
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 000000000..4f0f1d64e
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 000000000..62b611da0
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 000000000..948a3070f
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 000000000..1b9a6956b
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 000000000..28d4b77f9
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 000000000..9287f5083
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 000000000..aa7d6427e
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 000000000..9126ae37c
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/raw/mul.onnx b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/raw/mul.onnx
new file mode 100644
index 000000000..f7a8b1dbd
Binary files /dev/null and b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/raw/mul.onnx differ
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/colors.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/colors.xml
new file mode 100644
index 000000000..f8c6127d3
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/strings.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/strings.xml
new file mode 100644
index 000000000..6747d2304
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ BasicPluginEpUsage
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/themes.xml b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/themes.xml
new file mode 100644
index 000000000..718587b67
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/main/res/values/themes.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/basicpluginepusage/src/test/java/ai/onnxruntime/example/basicpluginepusage/ExampleUnitTest.kt b/plugin_execution_providers/basic/android/basicpluginepusage/src/test/java/ai/onnxruntime/example/basicpluginepusage/ExampleUnitTest.kt
new file mode 100644
index 000000000..f5aeed802
--- /dev/null
+++ b/plugin_execution_providers/basic/android/basicpluginepusage/src/test/java/ai/onnxruntime/example/basicpluginepusage/ExampleUnitTest.kt
@@ -0,0 +1,17 @@
+package ai.onnxruntime.example.basicpluginepusage
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/build.gradle.kts b/plugin_execution_providers/basic/android/build.gradle.kts
new file mode 100644
index 000000000..5ea216fa0
--- /dev/null
+++ b/plugin_execution_providers/basic/android/build.gradle.kts
@@ -0,0 +1,7 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ alias(libs.plugins.android.application) apply false
+ alias(libs.plugins.kotlin.android) apply false
+ alias(libs.plugins.kotlin.compose) apply false
+ alias(libs.plugins.android.library) apply false
+}
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/gradle.properties b/plugin_execution_providers/basic/android/gradle.properties
new file mode 100644
index 000000000..20e2a0152
--- /dev/null
+++ b/plugin_execution_providers/basic/android/gradle.properties
@@ -0,0 +1,23 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. For more details, visit
+# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/plugin_execution_providers/basic/android/gradle/libs.versions.toml b/plugin_execution_providers/basic/android/gradle/libs.versions.toml
new file mode 100644
index 000000000..0e195b7ec
--- /dev/null
+++ b/plugin_execution_providers/basic/android/gradle/libs.versions.toml
@@ -0,0 +1,37 @@
+[versions]
+agp = "8.13.1"
+kotlin = "2.0.21"
+coreKtx = "1.17.0"
+junit = "4.13.2"
+junitVersion = "1.3.0"
+espressoCore = "3.7.0"
+lifecycleRuntimeKtx = "2.9.4"
+activityCompose = "1.11.0"
+composeBom = "2024.09.00"
+appcompat = "1.7.1"
+material = "1.13.0"
+
+[libraries]
+androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
+junit = { group = "junit", name = "junit", version.ref = "junit" }
+androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
+androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
+androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
+androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
+androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
+androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
+androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
+androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
+androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
+androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
+androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
+androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
+androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
+material = { group = "com.google.android.material", name = "material", version.ref = "material" }
+
+[plugins]
+android-application = { id = "com.android.application", version.ref = "agp" }
+kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
+kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
+android-library = { id = "com.android.library", version.ref = "agp" }
+
diff --git a/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.jar b/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..8bdaf60c7
Binary files /dev/null and b/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.properties b/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..aa65f8991
--- /dev/null
+++ b/plugin_execution_providers/basic/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,8 @@
+#Thu Nov 20 18:39:21 PST 2025
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/plugin_execution_providers/basic/android/gradlew b/plugin_execution_providers/basic/android/gradlew
new file mode 100644
index 000000000..ef07e0162
--- /dev/null
+++ b/plugin_execution_providers/basic/android/gradlew
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH="\\\"\\\""
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/plugin_execution_providers/basic/android/gradlew.bat b/plugin_execution_providers/basic/android/gradlew.bat
new file mode 100644
index 000000000..db3a6ac20
--- /dev/null
+++ b/plugin_execution_providers/basic/android/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/plugin_execution_providers/basic/android/readme.md b/plugin_execution_providers/basic/android/readme.md
new file mode 100644
index 000000000..0f5efb865
--- /dev/null
+++ b/plugin_execution_providers/basic/android/readme.md
@@ -0,0 +1,19 @@
+# Basic Plugin Execution Provider on Android
+
+## Contents
+- `basicpluginep`: An Android package containing the native basic plugin EP library. In addition to providing the EP library files, it also provides the `getBasicPluginEpLibraryPath()` function to get the EP library path.
+- `basicpluginepusage`: An example application showing how to use the basic plugin EP Android package. It registers the basic plugin EP library with ONNX Runtime and then runs inference using that EP.
+
+## Build Instructions
+
+### Android Studio
+This directory can be opened with Android Studio. Build and run `basicpluginepusage`.
+
+### Command Line
+Use Gradle to build the project:
+
+```
+./gradlew build
+```
+
+The AAR files for `basicpluginep` will be generated in the `./basicpluginep/build/outputs/aar` directory.
diff --git a/plugin_execution_providers/basic/android/settings.gradle.kts b/plugin_execution_providers/basic/android/settings.gradle.kts
new file mode 100644
index 000000000..093883267
--- /dev/null
+++ b/plugin_execution_providers/basic/android/settings.gradle.kts
@@ -0,0 +1,24 @@
+pluginManagement {
+ repositories {
+ google {
+ content {
+ includeGroupByRegex("com\\.android.*")
+ includeGroupByRegex("com\\.google.*")
+ includeGroupByRegex("androidx.*")
+ }
+ }
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+rootProject.name = "BasicPluginEp"
+include(":basicpluginep")
+include(":basicpluginepusage")
diff --git a/plugin_execution_providers/basic/readme.md b/plugin_execution_providers/basic/readme.md
new file mode 100644
index 000000000..f34181424
--- /dev/null
+++ b/plugin_execution_providers/basic/readme.md
@@ -0,0 +1,23 @@
+# Basic Plugin Execution Provider
+This directory contains a basic example of a custom ONNX Runtime Execution Provider (EP) implemented as a plugin.
+
+## Contents
+- `CMakeLists.txt`: Build configuration for the basic plugin EP.
+- `src`: Contains source code for the basic plugin EP.
+- `android`: Contains example code for setting up and using an Android package.
+
+## Build Instructions
+Use CMake to configure and build the project:
+
+```bash
+cmake -B ./build -S .
+cmake --build ./build
+```
+
+The resulting plugin EP library can be registered with ONNX Runtime for inference.
+
+## Usage
+Refer to the ONNX Runtime documentation for details on loading and using plugin EPs. This example is intended for plugin EP developers.
+
+## References
+- [ONNX Runtime Plugin EP Documentation](https://onnxruntime.ai/docs/execution-providers/plugin-ep-libraries.html)
diff --git a/plugin_execution_providers/basic/src/ep.cc b/plugin_execution_providers/basic/src/ep.cc
new file mode 100644
index 000000000..eac81cb82
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep.cc
@@ -0,0 +1,381 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#include "ep.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "ep_factory.h"
+#include "plugin_ep_utils.h"
+
+///
+/// Example implementation of ONNX Mul. Does not handle many things like broadcasting.
+///
+struct MulKernel {
+ MulKernel(const OrtApi& ort_api, const OrtLogger& logger,
+ const std::unordered_map& float_initializers,
+ std::string input0_name, std::string input1_name)
+ : ort_api(ort_api),
+ logger(logger),
+ float_initializers(float_initializers),
+ input0_name(input0_name),
+ input1_name(input1_name) {}
+
+ const FloatInitializer* TryGetSavedInitializer(const std::string& name) const {
+ auto iter = float_initializers.find(name);
+ return iter != float_initializers.end() ? &iter->second : nullptr;
+ }
+
+ OrtStatus* GetInputDataAndShape(Ort::KernelContext kernel_context, size_t index,
+ /*out*/ std::span& data,
+ /*out*/ std::vector& shape) const {
+ Ort::ConstValue input = kernel_context.GetInput(index);
+ auto type_shape = input.GetTensorTypeAndShapeInfo();
+
+ ONNXTensorElementDataType elem_type = type_shape.GetElementType();
+ RETURN_IF(elem_type != ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, "EP Expected float32 inputs");
+
+ const float* float_data = input.GetTensorData();
+ size_t num_elems = type_shape.GetElementCount();
+ data = std::span(float_data, num_elems);
+ shape = type_shape.GetShape();
+ return nullptr;
+ }
+
+ OrtStatus* Compute(OrtKernelContext* kernel_ctx) {
+ LOG(ort_api, &logger, INFO, "Running Mul kernel...");
+
+ Ort::KernelContext kernel_context(kernel_ctx);
+
+ std::span input0;
+ std::span input1;
+ std::vector shape0;
+ std::vector shape1;
+
+ size_t num_inputs = kernel_context.GetInputCount();
+
+ if (num_inputs == 2) {
+ // Both inputs are non-constant. Get them from ORT's KernelContext.
+ RETURN_IF_ERROR(GetInputDataAndShape(kernel_context, 0, input0, shape0));
+ RETURN_IF_ERROR(GetInputDataAndShape(kernel_context, 1, input1, shape1));
+ } else if (num_inputs == 1) {
+ // ORT is only providing one non-constant input because this EP chose not to request constant initializer inputs.
+ // Get the constant input from the initializers saved by the EP.
+ // Refer to "NodeFusionOptions_DropConstantInitializers()".
+
+ if (const FloatInitializer* const_input0 = TryGetSavedInitializer(input0_name); const_input0 != nullptr) {
+ RETURN_IF_ERROR(GetInputDataAndShape(kernel_context, 0, input1, shape1));
+ input0 = std::span(const_input0->data);
+ shape0 = const_input0->shape;
+ } else if (const FloatInitializer* const_input1 = TryGetSavedInitializer(input1_name); const_input1 != nullptr) {
+ RETURN_IF_ERROR(GetInputDataAndShape(kernel_context, 0, input0, shape0));
+ input1 = std::span(const_input1->data);
+ shape1 = const_input1->shape;
+ }
+ } else {
+ // Both inputs are constant. Should never happen unless all ORT optimizations (specifically constant-folding)
+ // are disabled.
+ const FloatInitializer* const_input0 = TryGetSavedInitializer(input0_name);
+ const FloatInitializer* const_input1 = TryGetSavedInitializer(input1_name);
+ RETURN_IF(const_input0 == nullptr || const_input1 == nullptr, "Expected 2 initializer inputs to be saved by EP");
+
+ input0 = std::span(const_input0->data);
+ input1 = std::span(const_input1->data);
+ shape0 = const_input0->shape;
+ shape1 = const_input1->shape;
+ }
+
+ RETURN_IF(shape0 != shape1, "Expected same dimensions for both inputs");
+
+ size_t num_outputs = kernel_context.GetOutputCount();
+ RETURN_IF(num_outputs != 1, "Expected 1 output for MulKernel");
+
+ auto output = kernel_context.GetOutput(0, shape0);
+ float* output_data = output.GetTensorMutableData();
+
+ for (size_t i = 0; i < input0.size(); ++i) {
+ output_data[i] = input0[i] * input1[i];
+ }
+
+ return nullptr;
+ }
+
+ const OrtApi& ort_api;
+ const OrtLogger& logger;
+ const std::unordered_map& float_initializers;
+ std::string input0_name;
+ std::string input1_name;
+};
+
+///
+/// Example OrtNodeComputeInfo that represents the computation function for a compiled OrtGraph.
+///
+struct ExampleNodeComputeInfo : OrtNodeComputeInfo {
+ explicit ExampleNodeComputeInfo(BasicPluginEp& ep);
+
+ static OrtStatus* ORT_API_CALL CreateStateImpl(OrtNodeComputeInfo* this_ptr,
+ OrtNodeComputeContext* compute_context,
+ void** compute_state);
+ static OrtStatus* ORT_API_CALL ComputeImpl(OrtNodeComputeInfo* this_ptr, void* compute_state,
+ OrtKernelContext* kernel_context);
+ static void ORT_API_CALL ReleaseStateImpl(OrtNodeComputeInfo* this_ptr, void* compute_state);
+
+ BasicPluginEp& ep;
+};
+
+BasicPluginEp::BasicPluginEp(BasicPluginEpFactory& factory, const BasicPluginEp::Config& config,
+ const OrtLogger& logger)
+ : OrtEp{}, // explicitly call the struct ctor to ensure all optional values are default initialized
+ config_{config},
+ ort_api_{factory.GetOrtApi()},
+ ep_api_{factory.GetEpApi()},
+ model_editor_api_{factory.GetModelEditorApi()},
+ name_{factory.GetEpName()},
+ logger_{logger} {
+ ort_version_supported = ORT_API_VERSION; // set to the ORT version we were compiled with.
+
+ // Initialize the execution provider's function table
+ GetName = GetNameImpl;
+ GetCapability = GetCapabilityImpl;
+ Compile = CompileImpl;
+ ReleaseNodeComputeInfos = ReleaseNodeComputeInfosImpl;
+
+ LOG(GetOrtApi(), &logger_, INFO, "BasicPluginEp has been created with name " << name_);
+}
+
+BasicPluginEp::~BasicPluginEp() = default;
+
+MulKernel* BasicPluginEp::FindKernelForFusedNode(const std::string& fused_node_name) {
+ if (auto it = kernels_.find(fused_node_name); it != kernels_.end()) {
+ return it->second.get();
+ }
+ return nullptr;
+}
+
+/*static*/
+const char* ORT_API_CALL BasicPluginEp::GetNameImpl(const OrtEp* this_ptr) noexcept {
+ const auto* ep = static_cast(this_ptr);
+ return ep->name_.c_str();
+}
+
+OrtStatus* BasicPluginEp::SaveConstantInitializers(const OrtGraph* ort_graph) {
+ Ort::ConstGraph graph{ort_graph};
+
+ std::vector initializers = graph.GetInitializers();
+
+ for (const auto& initializer : initializers) {
+ const bool is_constant = initializer.IsConstantInitializer();
+
+ if (is_constant) {
+ auto name = initializer.GetName();
+ Ort::ConstValue value;
+ RETURN_IF_ERROR(initializer.GetInitializer(value));
+
+ auto type_shape = value.GetTensorTypeAndShapeInfo();
+ const size_t num_elems = type_shape.GetElementCount();
+ const ONNXTensorElementDataType elem_type = type_shape.GetElementType();
+ RETURN_IF(elem_type != ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, "Expected float32 initializers");
+
+ std::vector dims = type_shape.GetShape();
+ const float* data = value.GetTensorData();
+
+ FloatInitializer ep_initializer = {std::move(dims), std::vector(data, data + num_elems)};
+ float_initializers_.emplace(std::move(name), std::move(ep_initializer));
+ }
+ }
+
+ return nullptr;
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEp::GetCapabilityImpl(OrtEp* this_ptr, const OrtGraph* ort_graph,
+ OrtEpGraphSupportInfo* graph_support_info) noexcept {
+ EP_API_IMPL_BEGIN
+
+ auto* ep = static_cast(this_ptr);
+
+ Ort::ConstGraph graph{ort_graph};
+ std::vector nodes = graph.GetNodes();
+ if (nodes.empty()) {
+ return nullptr; // No nodes to process
+ }
+
+ std::vector supported_nodes;
+
+ for (const auto& node : nodes) {
+ auto op_type = node.GetOperatorType();
+
+ if (op_type == "Mul") {
+ // Check that Mul has inputs/output of type float
+ std::vector inputs = node.GetInputs();
+ std::vector outputs = node.GetOutputs();
+
+ RETURN_IF(inputs.size() != 2 || outputs.size() != 1, "Mul should have 2 inputs and 1 output");
+
+ std::array is_float = {false, false, false};
+ IsFloatTensor(inputs[0], is_float[0]);
+ IsFloatTensor(inputs[1], is_float[1]);
+ IsFloatTensor(outputs[0], is_float[2]);
+ if (!is_float[0] || !is_float[1] || !is_float[2]) {
+ continue; // Input or output is not of type float
+ }
+
+ {
+ const auto input_0_shape = GetTensorShape(inputs[0]),
+ input_1_shape = GetTensorShape(inputs[1]);
+
+ if (!input_0_shape.has_value() || !input_1_shape.has_value()) {
+ continue; // unable to get input shape
+ }
+
+ const auto is_static_shape = [](std::span shape) -> bool {
+ return std::all_of(shape.begin(), shape.end(), [](int64_t dim) { return dim >= 0; });
+ };
+
+ if (!is_static_shape(*input_0_shape) || !is_static_shape(*input_1_shape)) {
+ continue; // input shape has dynamic dimensions
+ }
+
+ if (*input_0_shape != *input_1_shape) {
+ continue; // input shapes do not match (no broadcasting support for now)
+ }
+ }
+
+ supported_nodes.push_back(node); // Only support a single Mul for now.
+ break;
+ }
+ }
+
+ if (supported_nodes.empty()) {
+ return nullptr;
+ }
+
+ // Create (optional) fusion options for the supported nodes to fuse.
+ OrtNodeFusionOptions node_fusion_options = {};
+ node_fusion_options.ort_version_supported = ORT_API_VERSION;
+
+ // Set "drop constant initializers" to true if the compiling EP doesn't need ORT to provide constant initializers
+ // as inputs to the fused/compiled node at inference time. This allows ORT to release unused initializers.
+ // This example EP sets this to true and saves initializers during the call to OrtEp::Compile for use
+ // during inference.
+ node_fusion_options.drop_constant_initializers = true;
+ RETURN_IF_ERROR(ep->ep_api_.EpGraphSupportInfo_AddNodesToFuse(
+ graph_support_info,
+ reinterpret_cast(supported_nodes.data()),
+ supported_nodes.size(),
+ &node_fusion_options));
+
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEp::CompileImpl(_In_ OrtEp* this_ptr, _In_ const OrtGraph** ort_graphs,
+ _In_ const OrtNode** fused_nodes, _In_ size_t count,
+ _Out_writes_all_(count) OrtNodeComputeInfo** node_compute_infos,
+ _Out_writes_(count) OrtNode** ep_context_nodes) noexcept {
+ EP_API_IMPL_BEGIN
+
+ RETURN_IF(count != 1, "Expected to compile a single graph");
+
+ auto* ep = static_cast(this_ptr);
+
+ Ort::ConstGraph graph{ort_graphs[0]};
+
+ // In GetCapability(), this EP specified that it doesn't need ORT to provide constant initializers during inference.
+ // So, this EP saves constant initializers so that they're available during inference, but an actual EP
+ // implementation could transfer the weights to device memory.
+ RETURN_IF_ERROR(ep->SaveConstantInitializers(graph));
+
+ std::vector nodes = graph.GetNodes();
+ RETURN_IF(nodes.size() != 1, "Expected to compile a single node");
+
+ auto node_op_type = nodes[0].GetOperatorType();
+ RETURN_IF(node_op_type != "Mul", "Expected to compile a Mul node");
+
+ // Now we know we're compiling a single Mul node. Create a computation kernel.
+ std::vector node_inputs = nodes[0].GetInputs();
+ std::array node_input_names;
+ node_input_names[0] = node_inputs[0].GetName();
+ node_input_names[1] = node_inputs[1].GetName();
+
+ Ort::ConstNode fused_node{fused_nodes[0]};
+ auto ep_name = fused_node.GetEpName();
+ RETURN_IF(ep_name != ep->name_, "The fused node is expected to assigned to this EP to run on");
+
+ // Associate the name of the fused node with our MulKernel.
+ auto fused_node_name = fused_node.GetName();
+ ep->kernels_.emplace(std::move(fused_node_name), std::make_unique(ep->GetOrtApi(),
+ ep->logger_,
+ ep->float_initializers_,
+ node_input_names[0],
+ node_input_names[1]));
+
+ // Update the OrtNodeComputeInfo associated with the graph.
+ auto node_compute_info = std::make_unique(*ep);
+ node_compute_infos[0] = node_compute_info.release();
+
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+/*static*/
+void ORT_API_CALL BasicPluginEp::ReleaseNodeComputeInfosImpl(OrtEp* /*this_ptr*/,
+ OrtNodeComputeInfo** node_compute_infos,
+ size_t num_node_compute_infos) noexcept {
+ for (size_t i = 0; i < num_node_compute_infos; i++) {
+ delete static_cast(node_compute_infos[i]);
+ }
+}
+
+//
+// Implementation of ExampleNodeComputeInfo
+//
+ExampleNodeComputeInfo::ExampleNodeComputeInfo(BasicPluginEp& ep) : ep(ep) {
+ ort_version_supported = ORT_API_VERSION;
+ CreateState = CreateStateImpl;
+ Compute = ComputeImpl;
+ ReleaseState = ReleaseStateImpl;
+}
+
+OrtStatus* ORT_API_CALL ExampleNodeComputeInfo::CreateStateImpl(OrtNodeComputeInfo* this_ptr,
+ OrtNodeComputeContext* compute_context,
+ void** compute_state) {
+ EP_API_IMPL_BEGIN
+
+ auto* node_compute_info = static_cast(this_ptr);
+ BasicPluginEp& ep = node_compute_info->ep;
+
+ std::string fused_node_name = ep.GetEpApi().NodeComputeContext_NodeName(compute_context);
+ MulKernel* kernel = ep.FindKernelForFusedNode(fused_node_name);
+ if (kernel == nullptr) {
+ RETURN_ERROR(ORT_EP_FAIL, "Unable to get kernel for fused node with name " << fused_node_name);
+ }
+
+ *compute_state = kernel;
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+OrtStatus* ORT_API_CALL ExampleNodeComputeInfo::ComputeImpl(OrtNodeComputeInfo* this_ptr, void* compute_state,
+ OrtKernelContext* kernel_context) {
+ EP_API_IMPL_BEGIN(void)
+ this_ptr;
+ MulKernel& kernel = *reinterpret_cast(compute_state);
+ return kernel.Compute(kernel_context);
+ EP_API_IMPL_END
+}
+
+void ORT_API_CALL ExampleNodeComputeInfo::ReleaseStateImpl(OrtNodeComputeInfo* this_ptr, void* compute_state) {
+ (void)this_ptr;
+ MulKernel& kernel = *reinterpret_cast(compute_state);
+ (void)kernel;
+ // Do nothing for this example.
+}
diff --git a/plugin_execution_providers/basic/src/ep.h b/plugin_execution_providers/basic/src/ep.h
new file mode 100644
index 000000000..563ec1665
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep.h
@@ -0,0 +1,67 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+#define ORT_API_MANUAL_INIT
+#include "onnxruntime_cxx_api.h"
+#undef ORT_API_MANUAL_INIT
+
+class MulKernel;
+class BasicPluginEpFactory;
+
+struct FloatInitializer {
+ std::vector shape;
+ std::vector data;
+};
+
+///
+/// Basic plugin EP.
+/// Can only compile/execute a single Mul node.
+///
+class BasicPluginEp : public OrtEp {
+ public:
+ struct Config {
+ // EP configs (typically extracted from OrtSessionOptions or OrtHardwareDevice(s))
+ };
+
+ BasicPluginEp(BasicPluginEpFactory& factory, const Config& config, const OrtLogger& logger);
+ ~BasicPluginEp();
+
+ const OrtApi& GetOrtApi() const { return ort_api_; }
+ const OrtEpApi& GetEpApi() const { return ep_api_; }
+
+ MulKernel* FindKernelForFusedNode(const std::string& fused_node_name);
+
+ private:
+ static const char* ORT_API_CALL GetNameImpl(const OrtEp* this_ptr) noexcept;
+
+ static OrtStatus* ORT_API_CALL GetCapabilityImpl(OrtEp* this_ptr, const OrtGraph* graph,
+ OrtEpGraphSupportInfo* graph_support_info) noexcept;
+
+ static OrtStatus* ORT_API_CALL CompileImpl(_In_ OrtEp* this_ptr, _In_ const OrtGraph** graphs,
+ _In_ const OrtNode** fused_nodes, _In_ size_t count,
+ _Out_writes_all_(count) OrtNodeComputeInfo** node_compute_infos,
+ _Out_writes_(count) OrtNode** ep_context_nodes) noexcept;
+
+ static void ORT_API_CALL ReleaseNodeComputeInfosImpl(OrtEp* this_ptr,
+ OrtNodeComputeInfo** node_compute_infos,
+ size_t num_node_compute_infos) noexcept;
+
+ OrtStatus* SaveConstantInitializers(const OrtGraph* graph);
+
+ Config config_{};
+ const OrtApi& ort_api_;
+ const OrtEpApi& ep_api_;
+ const OrtModelEditorApi& model_editor_api_;
+ std::string name_;
+ const OrtLogger& logger_;
+ std::unordered_map> kernels_;
+ std::unordered_map float_initializers_;
+};
diff --git a/plugin_execution_providers/basic/src/ep_factory.cc b/plugin_execution_providers/basic/src/ep_factory.cc
new file mode 100644
index 000000000..08ea6ac9d
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep_factory.cc
@@ -0,0 +1,158 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#include "ep_factory.h"
+
+#include
+
+#include "onnxruntime_ep_device_ep_metadata_keys.h"
+
+#include "ep.h"
+#include "plugin_ep_utils.h"
+
+BasicPluginEpFactory::BasicPluginEpFactory(const OrtApi& ort_api, const OrtEpApi& ep_api,
+ const OrtModelEditorApi& model_editor_api,
+ const OrtLogger& /*default_logger*/)
+ : OrtEpFactory{}, ort_api_(ort_api), ep_api_(ep_api), model_editor_api_(model_editor_api) {
+ ort_version_supported = ORT_API_VERSION; // set to the ORT version we were compiled with.
+
+ GetName = GetNameImpl;
+ GetVendor = GetVendorImpl;
+ GetVendorId = GetVendorIdImpl;
+ GetVersion = GetVersionImpl;
+
+ GetSupportedDevices = GetSupportedDevicesImpl;
+
+ CreateEp = CreateEpImpl;
+ ReleaseEp = ReleaseEpImpl;
+
+ CreateAllocator = CreateAllocatorImpl;
+ ReleaseAllocator = ReleaseAllocatorImpl;
+
+ CreateDataTransfer = CreateDataTransferImpl;
+
+ IsStreamAware = IsStreamAwareImpl;
+ CreateSyncStreamForDevice = CreateSyncStreamForDeviceImpl;
+}
+
+BasicPluginEpFactory::~BasicPluginEpFactory() = default;
+
+/*static*/
+const char* ORT_API_CALL BasicPluginEpFactory::GetNameImpl(const OrtEpFactory* this_ptr) noexcept {
+ const auto* factory = static_cast(this_ptr);
+ return factory->ep_name_.c_str();
+}
+
+/*static*/
+const char* ORT_API_CALL BasicPluginEpFactory::GetVendorImpl(const OrtEpFactory* this_ptr) noexcept {
+ const auto* factory = static_cast(this_ptr);
+ return factory->vendor_.c_str();
+}
+
+/*static*/
+uint32_t ORT_API_CALL BasicPluginEpFactory::GetVendorIdImpl(const OrtEpFactory* this_ptr) noexcept {
+ const auto* factory = static_cast(this_ptr);
+ return factory->vendor_id_;
+}
+
+/*static*/
+const char* ORT_API_CALL BasicPluginEpFactory::GetVersionImpl(const OrtEpFactory* this_ptr) noexcept {
+ const auto* factory = static_cast(this_ptr);
+ return factory->ep_version_.c_str();
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEpFactory::GetSupportedDevicesImpl(OrtEpFactory* this_ptr,
+ const OrtHardwareDevice* const* devices,
+ size_t num_devices, OrtEpDevice** ep_devices,
+ size_t max_ep_devices,
+ size_t* p_num_ep_devices) noexcept {
+ EP_API_IMPL_BEGIN
+
+ size_t& num_ep_devices = *p_num_ep_devices;
+ auto* factory = static_cast(this_ptr);
+
+ for (size_t i = 0; i < num_devices && num_ep_devices < max_ep_devices; ++i) {
+ Ort::ConstHardwareDevice device(devices[i]);
+ if (device.Type() == OrtHardwareDeviceType::OrtHardwareDeviceType_CPU) {
+ Ort::KeyValuePairs ep_metadata;
+ // Implementations can add relevant EP metadata here.
+ Ort::KeyValuePairs ep_options;
+ // Implementations can add relevant EP options here.
+ Ort::EpDevice ep_device{*this_ptr, device, ep_metadata.GetConst(), ep_options.GetConst()};
+ ep_devices[num_ep_devices++] = ep_device.release();
+ }
+ }
+
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEpFactory::CreateEpImpl(OrtEpFactory* this_ptr,
+ const OrtHardwareDevice* const* /*devices*/,
+ const OrtKeyValuePairs* const* /*ep_metadata*/,
+ size_t num_devices, const OrtSessionOptions* session_options,
+ const OrtLogger* logger, OrtEp** ep) noexcept {
+ EP_API_IMPL_BEGIN
+
+ auto* factory = static_cast(this_ptr);
+ *ep = nullptr;
+
+ if (num_devices != 1) {
+ // we only registered for CPU and only expected to be selected for one device
+ return factory->ort_api_.CreateStatus(ORT_INVALID_ARGUMENT,
+ "BasicPluginEpFactory only supports selection for one device.");
+ }
+
+ BasicPluginEp::Config config = {};
+ auto actual_ep = std::make_unique(*factory, config, *logger);
+
+ *ep = actual_ep.release();
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+/*static*/
+void ORT_API_CALL BasicPluginEpFactory::ReleaseEpImpl(OrtEpFactory* /*this_ptr*/, OrtEp* ep) noexcept {
+ delete static_cast(ep);
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEpFactory::CreateAllocatorImpl(OrtEpFactory* /*this_ptr*/,
+ const OrtMemoryInfo* /*memory_info*/,
+ const OrtKeyValuePairs* /*allocator_options*/,
+ OrtAllocator** allocator) noexcept {
+ // Don't support custom allocators in this example for simplicity.
+ *allocator = nullptr;
+ return nullptr;
+}
+
+/*static*/
+void ORT_API_CALL BasicPluginEpFactory::ReleaseAllocatorImpl(OrtEpFactory* /*this_ptr*/,
+ OrtAllocator* /*allocator*/) noexcept {
+ // Do nothing.
+}
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEpFactory::CreateDataTransferImpl(OrtEpFactory* /*this_ptr*/,
+ OrtDataTransferImpl** data_transfer) noexcept {
+ // Don't support data transfer in this example for simplicity.
+ *data_transfer = nullptr;
+ return nullptr;
+}
+
+/*static*/
+bool ORT_API_CALL BasicPluginEpFactory::IsStreamAwareImpl(const OrtEpFactory* /*this_ptr*/) noexcept { return false; }
+
+/*static*/
+OrtStatus* ORT_API_CALL BasicPluginEpFactory::CreateSyncStreamForDeviceImpl(OrtEpFactory* /*this_ptr*/,
+ const OrtMemoryDevice* /*memory_device*/,
+ const OrtKeyValuePairs* /*stream_options*/,
+ OrtSyncStreamImpl** stream) noexcept {
+ // Don't support sync streams in this example.
+ *stream = nullptr;
+ return nullptr;
+}
diff --git a/plugin_execution_providers/basic/src/ep_factory.h b/plugin_execution_providers/basic/src/ep_factory.h
new file mode 100644
index 000000000..5c22623ca
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep_factory.h
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#pragma once
+
+#define ORT_API_MANUAL_INIT
+#include "onnxruntime_cxx_api.h"
+#undef ORT_API_MANUAL_INIT
+
+///
+/// EP factory that creates a BasicPluginEp.
+///
+class BasicPluginEpFactory : public OrtEpFactory {
+ public:
+ BasicPluginEpFactory(const OrtApi& ort_api, const OrtEpApi& ep_api, const OrtModelEditorApi& model_editor_api,
+ const OrtLogger& default_logger);
+ ~BasicPluginEpFactory();
+
+ const OrtApi& GetOrtApi() const { return ort_api_; }
+ const OrtEpApi& GetEpApi() const { return ep_api_; }
+ const OrtModelEditorApi& GetModelEditorApi() const { return model_editor_api_; }
+ const std::string& GetEpName() const { return ep_name_; }
+
+ private:
+ static const char* ORT_API_CALL GetNameImpl(const OrtEpFactory* this_ptr) noexcept;
+
+ static const char* ORT_API_CALL GetVendorImpl(const OrtEpFactory* this_ptr) noexcept;
+ static uint32_t ORT_API_CALL GetVendorIdImpl(const OrtEpFactory* this_ptr) noexcept;
+
+ static const char* ORT_API_CALL GetVersionImpl(const OrtEpFactory* this_ptr) noexcept;
+
+ static OrtStatus* ORT_API_CALL GetSupportedDevicesImpl(OrtEpFactory* this_ptr,
+ const OrtHardwareDevice* const* devices,
+ size_t num_devices,
+ OrtEpDevice** ep_devices,
+ size_t max_ep_devices,
+ size_t* p_num_ep_devices) noexcept;
+
+ static OrtStatus* ORT_API_CALL CreateEpImpl(OrtEpFactory* this_ptr,
+ const OrtHardwareDevice* const* /*devices*/,
+ const OrtKeyValuePairs* const* /*ep_metadata*/,
+ size_t num_devices,
+ const OrtSessionOptions* session_options,
+ const OrtLogger* logger,
+ OrtEp** ep) noexcept;
+
+ static void ORT_API_CALL ReleaseEpImpl(OrtEpFactory* /*this_ptr*/, OrtEp* ep) noexcept;
+
+ static OrtStatus* ORT_API_CALL CreateAllocatorImpl(OrtEpFactory* this_ptr,
+ const OrtMemoryInfo* memory_info,
+ const OrtKeyValuePairs* /*allocator_options*/,
+ OrtAllocator** allocator) noexcept;
+
+ static void ORT_API_CALL ReleaseAllocatorImpl(OrtEpFactory* /*this*/, OrtAllocator* allocator) noexcept;
+
+ static OrtStatus* ORT_API_CALL CreateDataTransferImpl(OrtEpFactory* this_ptr,
+ OrtDataTransferImpl** data_transfer) noexcept;
+
+ static bool ORT_API_CALL IsStreamAwareImpl(const OrtEpFactory* this_ptr) noexcept;
+
+ static OrtStatus* ORT_API_CALL CreateSyncStreamForDeviceImpl(OrtEpFactory* this_ptr,
+ const OrtMemoryDevice* memory_device,
+ const OrtKeyValuePairs* stream_options,
+ OrtSyncStreamImpl** stream) noexcept;
+
+ const OrtApi& ort_api_;
+ const OrtEpApi& ep_api_;
+ const OrtModelEditorApi& model_editor_api_;
+
+ const std::string ep_name_{"BasicPluginEp"};
+ const std::string vendor_{"Contoso"}; // EP vendor name
+ const uint32_t vendor_id_{0xB357}; // EP vendor ID
+ const std::string ep_version_{"0.1.0"}; // EP version
+};
diff --git a/plugin_execution_providers/basic/src/ep_lib.def b/plugin_execution_providers/basic/src/ep_lib.def
new file mode 100644
index 000000000..32a994982
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep_lib.def
@@ -0,0 +1,4 @@
+LIBRARY "basic_plugin_ep.dll"
+EXPORTS
+ CreateEpFactories @1
+ ReleaseEpFactory @2
diff --git a/plugin_execution_providers/basic/src/ep_lib.lds b/plugin_execution_providers/basic/src/ep_lib.lds
new file mode 100644
index 000000000..a6d2ef09a
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep_lib.lds
@@ -0,0 +1,7 @@
+VERS_1.0.0 {
+ global:
+ CreateEpFactories;
+ ReleaseEpFactory;
+ local:
+ *;
+};
diff --git a/plugin_execution_providers/basic/src/ep_lib_entry.cc b/plugin_execution_providers/basic/src/ep_lib_entry.cc
new file mode 100644
index 000000000..116e18a38
--- /dev/null
+++ b/plugin_execution_providers/basic/src/ep_lib_entry.cc
@@ -0,0 +1,60 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#include
+
+#define ORT_API_MANUAL_INIT
+#include "onnxruntime_cxx_api.h"
+#undef ORT_API_MANUAL_INIT
+
+#include "ep_factory.h"
+
+#include "plugin_ep_utils.h"
+
+// To make symbols visible on macOS/iOS
+#ifdef __APPLE__
+#define EXPORT_SYMBOL __attribute__((visibility("default")))
+#else
+#define EXPORT_SYMBOL
+#endif
+
+extern "C" {
+//
+// Public symbols
+//
+EXPORT_SYMBOL OrtStatus* CreateEpFactories(const char* /*registration_name*/, const OrtApiBase* ort_api_base,
+ const OrtLogger* default_logger,
+ OrtEpFactory** factories, size_t max_factories, size_t* num_factories) {
+ EP_API_IMPL_BEGIN
+
+ const OrtApi* ort_api = ort_api_base->GetApi(ORT_API_VERSION);
+ const OrtEpApi* ep_api = ort_api->GetEpApi();
+ const OrtModelEditorApi* model_editor_api = ort_api->GetModelEditorApi();
+
+ // Manual init for the C++ API
+ Ort::InitApi(ort_api);
+
+ std::unique_ptr factory = std::make_unique(*ort_api, *ep_api, *model_editor_api,
+ *default_logger);
+
+ if (max_factories < 1) {
+ return ort_api->CreateStatus(ORT_INVALID_ARGUMENT,
+ "Not enough space to return EP factory. Need at least one.");
+ }
+
+ factories[0] = factory.release();
+ *num_factories = 1;
+
+ return nullptr;
+
+ EP_API_IMPL_END
+}
+
+EXPORT_SYMBOL OrtStatus* ReleaseEpFactory(OrtEpFactory* factory) {
+ EP_API_IMPL_BEGIN
+ delete static_cast(factory);
+ return nullptr;
+ EP_API_IMPL_END
+}
+
+} // extern "C"
diff --git a/plugin_execution_providers/common/cmake/onnxruntime_library_utils.cmake b/plugin_execution_providers/common/cmake/onnxruntime_library_utils.cmake
new file mode 100644
index 000000000..1c59e302a
--- /dev/null
+++ b/plugin_execution_providers/common/cmake/onnxruntime_library_utils.cmake
@@ -0,0 +1,121 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+include(FetchContent)
+
+# Sets ONNX Runtime header and library paths.
+# If an ONNX Runtime directory is specified by `ORT_HOME`, this function will use that.
+# Otherwise, this function will download ONNX Runtime.
+function(set_onnxruntime_paths)
+ set(options)
+ set(one_value_keywords
+ # Specifies directory containing ONNX Runtime header and library files.
+ # Optional. If unset or empty, the ONNX Runtime files will be downloaded to the build directory.
+ ORT_HOME
+ # Specifies the ONNX Runtime version to use if downloading ONNX Runtime.
+ DEFAULT_ORT_VERSION
+ # Specifies the name of the output variable that will contain the ONNX Runtime include directory.
+ ORT_INCLUDE_DIR_VAR
+ # Specifies the name of the output variable that will contain the ONNX Runtime library directory.
+ ORT_LIBRARY_DIR_VAR)
+ set(multi_value_keywords)
+
+ cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_keywords}" "${multi_value_keywords}")
+
+ set(required_args ORT_INCLUDE_DIR_VAR ORT_LIBRARY_DIR_VAR)
+ foreach(required_arg IN ITEMS ${required_args})
+ if(NOT DEFINED arg_${required_arg})
+ message(FATAL_ERROR "${required_arg} must be provided.")
+ endif()
+ endforeach()
+
+ if(DEFINED arg_ORT_HOME AND (NOT arg_ORT_HOME STREQUAL ""))
+ use_onnxruntime_home_and_set_paths(${arg_ORT_HOME} ort_include_dir ort_lib_dir)
+ else()
+ if(NOT DEFINED arg_DEFAULT_ORT_VERSION)
+ message(FATAL_ERROR "DEFAULT_ORT_VERSION must be provided if ORT_HOME is not provided.")
+ endif()
+ download_onnxruntime_and_set_paths(${arg_DEFAULT_ORT_VERSION} ort_include_dir ort_lib_dir)
+ endif()
+
+ set(${arg_ORT_INCLUDE_DIR_VAR} ${ort_include_dir} PARENT_SCOPE)
+ set(${arg_ORT_LIBRARY_DIR_VAR} ${ort_lib_dir} PARENT_SCOPE)
+endfunction()
+
+function(download_onnxruntime_and_set_paths ORT_VERSION ORT_INCLUDE_DIR_VAR ORT_LIBRARY_DIR_VAR)
+ set(ORT_FEED_ORG_NAME "aiinfra")
+ set(ORT_FEED_PROJECT "2692857e-05ef-43b4-ba9c-ccf1c22c437c")
+ set(ORT_NIGHTLY_FEED_ID "7982ae20-ed19-4a35-a362-a96ac99897b7")
+ set(ORT_PACKAGE_NAME "Microsoft.ML.OnnxRuntime")
+
+ set(ORT_FETCH_URL "https://pkgs.dev.azure.com/${ORT_FEED_ORG_NAME}/${ORT_FEED_PROJECT}/_apis/packaging/feeds/${ORT_NIGHTLY_FEED_ID}/nuget/packages/${ORT_PACKAGE_NAME}/versions/${ORT_VERSION}/content?api-version=6.0-preview.1")
+
+ message(STATUS "Using ONNX Runtime package ${ORT_PACKAGE_NAME} version ${ORT_VERSION}")
+
+ FetchContent_Declare(
+ ortlib
+ URL ${ORT_FETCH_URL}
+ )
+ FetchContent_makeAvailable(ortlib)
+
+ set(ORT_HEADER_DIR ${ortlib_SOURCE_DIR}/build/native/include)
+
+ if(ANDROID)
+ file(ARCHIVE_EXTRACT INPUT ${ortlib_SOURCE_DIR}/runtimes/android/native/onnxruntime.aar DESTINATION ${ortlib_SOURCE_DIR}/runtimes/android/native/)
+ set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/android/native/jni/${ANDROID_ABI})
+ elseif(IOS OR MAC_CATALYST)
+ file(ARCHIVE_EXTRACT INPUT ${ortlib_SOURCE_DIR}/runtimes/ios/native/onnxruntime.xcframework.zip DESTINATION ${ortlib_SOURCE_DIR}/runtimes/ios/native/)
+ set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/ios/native/)
+ else()
+ set(ORT_BINARY_PLATFORM "x64")
+ if (APPLE)
+ if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
+ set(ORT_BINARY_PLATFORM "arm64")
+ endif()
+ set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/osx-${ORT_BINARY_PLATFORM}/native)
+ elseif(WIN32)
+ if (CMAKE_GENERATOR_PLATFORM)
+ if (CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64EC" OR CMAKE_GENERATOR_PLATFORM STREQUAL "arm64")
+ set(ORT_BINARY_PLATFORM "arm64")
+ endif()
+ elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
+ set(ORT_BINARY_PLATFORM "arm64")
+ endif()
+ set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/win-${ORT_BINARY_PLATFORM}/native)
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+ set(ORT_BINARY_PLATFORM "arm64")
+ endif()
+ set(ORT_LIB_DIR ${ortlib_SOURCE_DIR}/runtimes/linux-${ORT_BINARY_PLATFORM}/native)
+ else()
+ message(FATAL_ERROR "Auto download ONNX Runtime for this platform is not supported.")
+ endif()
+ endif()
+
+ set(${ORT_INCLUDE_DIR_VAR} ${ORT_HEADER_DIR} PARENT_SCOPE)
+ set(${ORT_LIBRARY_DIR_VAR} ${ORT_LIB_DIR} PARENT_SCOPE)
+endfunction()
+
+function(use_onnxruntime_home_and_set_paths ORT_HOME ORT_INCLUDE_DIR_VAR ORT_LIBRARY_DIR_VAR)
+ file(REAL_PATH ${ORT_HOME} ORT_HOME)
+
+ if(ANDROID)
+ # Paths are based on the directory structure of the ORT Android AAR.
+ set(ORT_HEADER_DIR ${ORT_HOME}/headers)
+ set(ORT_LIB_DIR ${ORT_HOME}/jni/${ANDROID_ABI})
+ else()
+ set(ORT_HEADER_DIR ${ORT_HOME}/include)
+ set(ORT_LIB_DIR ${ORT_HOME}/lib)
+ endif()
+
+ if(NOT IS_DIRECTORY ${ORT_HEADER_DIR})
+ message(FATAL_ERROR "ORT_HEADER_DIR (${ORT_HEADER_DIR}) is not a directory.")
+ endif()
+
+ if(NOT IS_DIRECTORY ${ORT_LIB_DIR})
+ message(FATAL_ERROR "ORT_LIB_DIR (${ORT_LIB_DIR}) is not a directory.")
+ endif()
+
+ set(${ORT_INCLUDE_DIR_VAR} ${ORT_HEADER_DIR} PARENT_SCOPE)
+ set(${ORT_LIBRARY_DIR_VAR} ${ORT_LIB_DIR} PARENT_SCOPE)
+endfunction()
diff --git a/plugin_execution_providers/common/src/plugin_ep_utils.h b/plugin_execution_providers/common/src/plugin_ep_utils.h
new file mode 100644
index 000000000..746a62176
--- /dev/null
+++ b/plugin_execution_providers/common/src/plugin_ep_utils.h
@@ -0,0 +1,113 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+#define ORT_API_MANUAL_INIT
+#include "onnxruntime_cxx_api.h"
+#undef ORT_API_MANUAL_INIT
+
+#define RETURN_IF_ERROR(status_expr) \
+ do { \
+ Ort::Status status{(status_expr)}; \
+ if (!status.IsOK()) { \
+ return status.release(); \
+ } \
+ } while (0)
+
+#define RETURN_IF(cond, msg) \
+ do { \
+ if ((cond)) { \
+ const char* msg_cstr = (msg); \
+ Ort::Status status{msg, ORT_EP_FAIL}; \
+ return status.release(); \
+ } \
+ } while (0)
+
+#define RETURN_IF_NOT(cond, msg) \
+ RETURN_IF(!(cond), msg)
+
+// Ignores an OrtStatus* while taking ownership of it so that it does not get leaked.
+#define IGNORE_ORTSTATUS(status_expr) \
+ do { \
+ OrtStatus* _status = (status_expr); \
+ Ort::Status _ignored{_status}; \
+ } while (false)
+
+#ifdef _WIN32
+#define EP_WSTR(x) L##x
+#define EP_FILE_INTERNAL(x) EP_WSTR(x)
+#define EP_FILE EP_FILE_INTERNAL(__FILE__)
+#else
+#define EP_FILE __FILE__
+#endif
+
+#define LOG(ort_api, ort_logger_ptr, level, ...) \
+ do { \
+ std::ostringstream ss; \
+ ss << __VA_ARGS__; \
+ IGNORE_ORTSTATUS((ort_api).Logger_LogMessage((ort_logger_ptr), ORT_LOGGING_LEVEL_##level, ss.str().c_str(), \
+ EP_FILE, __LINE__, __FUNCTION__)); \
+ } while (false)
+
+#define RETURN_ERROR(code, ...) \
+ do { \
+ std::ostringstream ss; \
+ ss << __VA_ARGS__; \
+ OrtErrorCode error_code = (code); \
+ Ort::Status status(ss.str().c_str(), error_code); \
+ return status.release(); \
+ } while (false)
+
+#define EP_API_IMPL_BEGIN \
+ try {
+#define EP_API_IMPL_END \
+ } \
+ catch (const Ort::Exception& ex) { \
+ Ort::Status status(ex); \
+ return status.release(); \
+ } \
+ catch (const std::exception& ex) { \
+ Ort::Status status(ex.what(), ORT_EP_FAIL); \
+ return status.release(); \
+ } \
+ catch (...) { \
+ Ort::Status status("Caught unknown exception.", ORT_EP_FAIL); \
+ return status.release(); \
+ }
+
+// Returns true (via output parameter) if the given OrtValueInfo represents a float tensor.
+inline void IsFloatTensor(Ort::ConstValueInfo value_info, bool& result) {
+ result = false;
+
+ auto type_info = value_info.TypeInfo();
+ ONNXType onnx_type = type_info.GetONNXType();
+ if (onnx_type != ONNX_TYPE_TENSOR) {
+ return;
+ }
+
+ auto type_shape = type_info.GetTensorTypeAndShapeInfo();
+ ONNXTensorElementDataType elem_type = type_shape.GetElementType();
+ if (elem_type != ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
+ return;
+ }
+ result = true;
+}
+
+// Gets the tensor shape from `value_info`. Returns std::nullopt if `value_info` is not a tensor.
+inline std::optional> GetTensorShape(Ort::ConstValueInfo value_info) {
+ const auto type_info = value_info.TypeInfo();
+ const auto onnx_type = type_info.GetONNXType();
+ if (onnx_type != ONNX_TYPE_TENSOR) {
+ return std::nullopt;
+ }
+
+ const auto type_shape = type_info.GetTensorTypeAndShapeInfo();
+ return type_shape.GetShape();
+}