forked from gtbluesky/onnxruntime_flutter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gant
committed
Sep 12, 2023
0 parents
commit 8ed813a
Showing
114 changed files
with
16,179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
channel: stable | ||
|
||
project_type: plugin_ffi | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
- platform: android | ||
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
- platform: ios | ||
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# onnxruntime | ||
|
||
A new Flutter FFI plugin project. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter | ||
[FFI plugin](https://docs.flutter.dev/development/platform-integration/c-interop), | ||
a specialized package that includes native code directly invoked with Dart FFI. | ||
|
||
## Project structure | ||
|
||
This template uses the following structure: | ||
|
||
* `src`: Contains the native source code, and a CmakeFile.txt file for building | ||
that source code into a dynamic library. | ||
|
||
* `lib`: Contains the Dart code that defines the API of the plugin, and which | ||
calls into the native code using `dart:ffi`. | ||
|
||
* platform folders (`android`, `ios`, `windows`, etc.): Contains the build files | ||
for building and bundling the native code library with the platform application. | ||
|
||
## Building and bundling native code | ||
|
||
The `pubspec.yaml` specifies FFI plugins as follows: | ||
|
||
```yaml | ||
plugin: | ||
platforms: | ||
some_platform: | ||
ffiPlugin: true | ||
``` | ||
This configuration invokes the native build for the various target platforms | ||
and bundles the binaries in Flutter applications using these FFI plugins. | ||
This can be combined with dartPluginClass, such as when FFI is used for the | ||
implementation of one platform in a federated plugin: | ||
```yaml | ||
plugin: | ||
implements: some_other_plugin | ||
platforms: | ||
some_platform: | ||
dartPluginClass: SomeClass | ||
ffiPlugin: true | ||
``` | ||
A plugin can have both FFI and method channels: | ||
```yaml | ||
plugin: | ||
platforms: | ||
some_platform: | ||
pluginClass: SomeName | ||
ffiPlugin: true | ||
``` | ||
The native build systems that are invoked by FFI (and method channel) plugins are: | ||
* For Android: Gradle, which invokes the Android NDK for native builds. | ||
* See the documentation in android/build.gradle. | ||
* For iOS and MacOS: Xcode, via CocoaPods. | ||
* See the documentation in ios/onnxruntime.podspec. | ||
* See the documentation in macos/onnxruntime.podspec. | ||
* For Linux and Windows: CMake. | ||
* See the documentation in linux/CMakeLists.txt. | ||
* See the documentation in windows/CMakeLists.txt. | ||
## Binding to native code | ||
To use the native code, bindings in Dart are needed. | ||
To avoid writing these by hand, they are generated from the header file | ||
(`src/onnxruntime.h`) by `package:ffigen`. | ||
Regenerate the bindings by running `flutter pub run ffigen --config ffigen.yaml`. | ||
|
||
## Invoking native code | ||
|
||
Very short-running native functions can be directly invoked from any isolate. | ||
For example, see `sum` in `lib/onnxruntime.dart`. | ||
|
||
Longer-running functions should be invoked on a helper isolate to avoid | ||
dropping frames in Flutter applications. | ||
For example, see `sumAsync` in `lib/onnxruntime.dart`. | ||
|
||
## Flutter help | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// The Android Gradle Plugin builds the native code with the Android NDK. | ||
|
||
group 'com.example.onnxruntime' | ||
version '1.0' | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// The Android Gradle Plugin knows how to build native code with the NDK. | ||
classpath 'com.android.tools.build:gradle:7.3.0' | ||
} | ||
} | ||
|
||
rootProject.allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
// Bumping the plugin compileSdkVersion requires all clients of this plugin | ||
// to bump the version in their app. | ||
compileSdkVersion 31 | ||
|
||
// Bumping the plugin ndkVersion requires all clients of this plugin to bump | ||
// the version in their app and to download a newer version of the NDK. | ||
ndkVersion "23.1.7779620" | ||
|
||
// Invoke the shared CMake build with the Android Gradle Plugin. | ||
externalNativeBuild { | ||
// cmake { | ||
// path "../src/CMakeLists.txt" | ||
// | ||
// // The default CMake version for the Android Gradle Plugin is 3.10.2. | ||
// // https://developer.android.com/studio/projects/install-ndk#vanilla_cmake | ||
// // | ||
// // The Flutter tooling requires that developers have CMake 3.10 or later | ||
// // installed. You should not increase this version, as doing so will cause | ||
// // the plugin to fail to compile for some customers of the plugin. | ||
// // version "3.10.2" | ||
// } | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion 21 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("com.microsoft.onnxruntime:onnxruntime-android:1.15.1") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'onnxruntime' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.onnxruntime"> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# onnxruntime_example | ||
|
||
Demonstrates how to use the onnxruntime plugin. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
|
||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) | ||
|
||
For help getting started with Flutter development, view the | ||
[online documentation](https://docs.flutter.dev/), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties | ||
**/*.keystore | ||
**/*.jks |
Oops, something went wrong.