mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
[js/react_native] Use a mobile ORT instead of a full ORT (#8042)
* Change full ort to mobile ort * Update Android example to load mobile ort * Change the format of test models to ort * update ios to use mobile ort * revise README * use onnxruntime-mobile-c CocoaPods in a npm package
This commit is contained in:
parent
6a1b000125
commit
887c3149e3
65 changed files with 324 additions and 553 deletions
96
js/README.md
96
js/README.md
|
|
@ -303,86 +303,86 @@ This project provides an ONNX Runtime React Native JavaScript library to run ONN
|
|||
- [CMake](https://cmake.org/download/)
|
||||
- [Python 3](https://www.python.org/downloads/mac-osx/)
|
||||
|
||||
### Models with ORT format
|
||||
|
||||
By default, ONNX Runtime React Native leverages ONNX Runtime Mobile package with ORT format. Follow the [instruciton](https://www.onnxruntime.ai/docs/how-to/mobile/model-conversion.html#converting-onnx-models-to-ort-format) to covert ONNX model to ORT format.
|
||||
|
||||
### Build
|
||||
|
||||
1. Install NPM packages for ONNX Runtime common JavaScript library and required React Native JavaScript libraries
|
||||
|
||||
1. in `<ORT_ROOT>/js/`, run `npm ci`.
|
||||
2. in `<ORT_ROOT>/js/common/`, run `npm ci`.
|
||||
3. in `<ORT_ROOT>/js/react_native/`, run `yarn`.
|
||||
- in `<ORT_ROOT>/js/`, run `npm ci`.
|
||||
- in `<ORT_ROOT>/js/common/`, run `npm ci`.
|
||||
- in `<ORT_ROOT>/js/react_native/`, run `yarn`.
|
||||
|
||||
2. Build Android ONNX Runtime package
|
||||
|
||||
1. Set up an Android build environment referring to [instruction](https://www.onnxruntime.ai/docs/how-to/build.html#android)
|
||||
1. To use a published Android ONNX Runtime Mobile package from Maven, go to step 5.
|
||||
|
||||
2. In `<ORT_ROOT>`, run this python script to build ONNX Runtime Android archive file. In windows, this requires admin account to build. If an app uses a fixed set of models, refer to [instruction](https://www.onnxruntime.ai/docs/how-to/build.html#android) and build a mobile version package
|
||||
2. Set up an Android build environment referring to [instruction](https://www.onnxruntime.ai/docs/how-to/build/android-ios.html#android)
|
||||
|
||||
```python
|
||||
python tools/ci_build/github/android/build_aar_package.py js/react_native/scripts/aar_build_settings.json --config MinSizeRel --android_sdk_path <ANDROID_SDK_PATH> --android_ndk_path <ANDROID_NDK_PATH> --build_dir <BUILD_DIRECTORY>
|
||||
```
|
||||
3. In `<ORT_ROOT>`, run this python script to build ONNX Runtime Android archive file. In windows, this requires an admin account to build. To build a model specific package with reduced size, refer to [instruction](https://www.onnxruntime.ai/docs/how-to/build/reduced.html#build-ort-with-reduced-size).
|
||||
|
||||
3. This generates `onnxruntime-mobile-<version>.aar` in `<BUILD_DIRECTORY>/aar_out/MinSizeRel/com/microsoft/onnxruntime/onnxruntime-mobile/<version>`. Copy `aar` file into `<ORT_ROOT>/js/react_native/android/libs` and rename it as `onnxruntime.aar`
|
||||
```sh
|
||||
python tools/ci_build/github/android/build_aar_package.py tools/ci_build/github/android/default_mobile_aar_build_settings.json --config MinSizeRel --android_sdk_path <ANDROID_SDK_PATH> --android_ndk_path <ANDROID_NDK_PATH> --build_dir <BUILD_DIRECTORY> --include_ops_by_config tools/ci_build/github/android/mobile_package.required_operators.config
|
||||
```
|
||||
|
||||
4. To verify, open Android Emulator and run this command from `<ORT_ROOT>/js/react_native/android`
|
||||
4. Copy `<BUILD_DIRECTORY>/aar_out/MinSizeRel/com/microsoft/onnxruntime/onnxruntime-mobile/<version>/onnxruntime-mobile-<version>.aar` into `<ORT_ROOT>/js/react_native/android/libs` directory.
|
||||
|
||||
```sh
|
||||
adb shell am instrument -w ai.onnxruntime.react_native.test/androidx.test.runner.AndroidJUnitRunner
|
||||
```
|
||||
5. Modify `Onnxruntime_mobileVersion` property in `<ORT_ROOT>/js/react_native/android/build.properties` to consume a locally built package or a newly published package from Maven.
|
||||
|
||||
6. To verify, open Android Emulator and run this command from `<ORT_ROOT>/js/react_native/android`
|
||||
|
||||
```sh
|
||||
adb shell am instrument -w ai.onnxruntime.react_native.test/androidx.test.runner.AndroidJUnitRunner
|
||||
```
|
||||
|
||||
3. Build iOS ONNX Runtime package
|
||||
|
||||
1. Set up iOS build environment referring to [instruction](https://www.onnxruntime.ai/docs/how-to/build.html#ios).
|
||||
1. To use a published c/c++ ONNX Runtime Mobile package from CocoaPods, skip all steps below.
|
||||
|
||||
2. Build ONNX Runtime library for iOS from `<ORT_ROOT>` using this command,
|
||||
2. Set up iOS build environment referring to [instruction](https://www.onnxruntime.ai/docs/how-to/build/android-ios.html#ios).
|
||||
|
||||
```sh
|
||||
./build.sh --config MinSizeRel --use_xcode --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 11
|
||||
```
|
||||
3. Build a fat ONNX Runtime Mobile Framework for iOS and iOS simulator from `<ORT_ROOT>` using this command,
|
||||
|
||||
Copy `<ORT_ROOT>/build/iOS/MinSizeRel/MinSizeRel-iphoneos/libonnxruntime.<version>.dylib` file into `<ORT_ROOT>/js/react_native/ios/Libraries/onnxruntime/lib/iphoneos`
|
||||
```sh
|
||||
python tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config tools/ci_build/github/android/mobile_package.required_operators.config
|
||||
```
|
||||
|
||||
3. Clean up the previous build and build ONNX Runtime library for iOS Simulator from `<ORT_ROOT>`
|
||||
It creates `onnxruntime.framework` in `build/iOS_framework/framework_out` directory. Create an archive file of `onnxruntime.framework` directory as follows and copy to `<ORT_ROOT>/js/react_native/local_pods` directory.
|
||||
|
||||
```sh
|
||||
./build.sh --config MinSizeRel --use_xcode --ios --ios_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target 11
|
||||
```
|
||||
```sh
|
||||
zip -r onnxruntime-mobile-c.zip onnxruntime.framework
|
||||
```
|
||||
|
||||
Copy `<ORT_ROOT>/build/iOS/MinSizeRel/MinSizeRel-iphonesimulator/libonnxruntime.<version>.dylib` file into `<ORT_ROOT>/js/react_native/ios/Libraries/onnxruntime/lib/iphonesimulator`
|
||||
4. To verify, open iOS Simulator and run this command from `<ORT_ROOT>/js/react_native/ios`. Change a destination to specify a running iOS Simulator.
|
||||
|
||||
4. Edit `onnxruntime-react-native.iphoneos.podspec` and `onnxruntime-react-native.iphonesimulator.podsepc` in `<ORT_ROOT>/js/react_native` to change a version of ONNX Runtime library.
|
||||
```sh
|
||||
pod install
|
||||
xcodebuild test -workspace OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.5'
|
||||
```
|
||||
|
||||
5. Copy ONNX Runtime header files
|
||||
4. Test an example for Android and iOS. In Windows, open Android Emulator first. From `<ORT_ROOT>/js/react_native`
|
||||
|
||||
```sh
|
||||
cp <ORT_ROOT>/include/onnxruntime/core/session/*.h <ORT_ROOT>/js/react_native/ios/Libraries/onnxruntime/include
|
||||
```
|
||||
|
||||
6. To verify, open iOS Simulator and run this command from `<ORT_ROOT>/js/react_native/ios`. Change a destination to specify a running iOS Simulator.
|
||||
```sh
|
||||
pod install
|
||||
export ONNXRUNTIME_VERSION=<version>; xcodebuild test -workspace OnnxruntimeModule.xcworkspace -scheme OnnxruntimeModuleTest -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.5'
|
||||
```
|
||||
|
||||
4. Update a version in `package.json` to align with ONNX Runtime version.
|
||||
|
||||
5. Test an example for Android and iOS. In Windows, open Android Emulator first. From `<ORT_ROOT>/js/react_native`
|
||||
```sh
|
||||
yarn bootstrap
|
||||
yarn example ios
|
||||
yarn example android
|
||||
```
|
||||
```sh
|
||||
yarn bootstrap
|
||||
yarn example ios
|
||||
yarn example android
|
||||
```
|
||||
|
||||
### NPM Packaging
|
||||
|
||||
1. Update a version using `npm verison <version>` from `<ORT_ROOT>/js/react_native` folder. If it's for a dev, use `npm version <version>-dev.<subversion>`
|
||||
|
||||
2. Run `yarn prepack` to change `onnxruntime-common` to point to a published npm package
|
||||
2. Modify Onnxruntime_mobileVersion property in `<ORT_ROOT>/js/react_native/android/build.properties` to update ONNX Runtime Android package version.
|
||||
|
||||
3. Run `npm pack` and verify NPM package contents
|
||||
3. Run `yarn prepack` to change `onnxruntime-common` to point to a published npm package
|
||||
|
||||
4. Run `npm publish <tgz> --dry-run` to see how it's going to be published
|
||||
4. Run `npm pack` and verify NPM package contents
|
||||
|
||||
5. Run `npm publish <tgz>` to publish to npmjs. If it's for a dev, add flag `--tag dev`.
|
||||
5. Run `npm publish <tgz> --dry-run` to see how it's going to be published
|
||||
|
||||
6. Run `npm publish <tgz>` to publish to npmjs. If it's for a dev, add flag `--tag dev`.
|
||||
|
||||
### Distribution
|
||||
|
||||
|
|
|
|||
7
js/react_native/.gitignore
vendored
7
js/react_native/.gitignore
vendored
|
|
@ -35,7 +35,8 @@ android.iml
|
|||
|
||||
# Cocoapods
|
||||
#
|
||||
example/ios/Pods
|
||||
ios/Pods/
|
||||
example/ios/Pods/
|
||||
|
||||
# node.js
|
||||
#
|
||||
|
|
@ -57,6 +58,4 @@ dist/
|
|||
android/libs/*.aar
|
||||
|
||||
# iOS
|
||||
iOS/Libraries/onnxruntime/include/*.h
|
||||
iOS/Libraries/onnxruntime/lib/iphoneos/*.dylib
|
||||
iOS/Libraries/onnxruntime/lib/iphonesimulator/*.dylib
|
||||
local_pods/
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
/.vscode/
|
||||
/scripts/
|
||||
|
||||
/dist/commonjs/*.js.map
|
||||
/dist/module/*.js.map
|
||||
|
||||
/tsconfig.json
|
||||
/tsconfig.build.json
|
||||
|
|
@ -2,13 +2,21 @@
|
|||
|
||||
ONNX Runtime React Native provides a JavaScript library for running ONNX models on React Native app.
|
||||
|
||||
## Installation
|
||||
### Why ONNX models
|
||||
|
||||
The [Open Neural Network Exchange](http://onnx.ai/) (ONNX) is an open standard for representing machine learning models. The biggest advantage of ONNX is that it allows interoperability across different open source AI frameworks, which itself offers more flexibility for AI frameworks adoption.
|
||||
|
||||
### Why ONNX Runtime React Native
|
||||
|
||||
With ONNX Runtime React Native, React Native developers can score pre-trained ONNX models directy on React Native apps by leveraging [ONNX Runtime Mobile](https://www.onnxruntime.ai/docs/reference/mobile/prebuilt-package/), so it provides a light-weight inference solution for Android and iOS.
|
||||
|
||||
### Installation
|
||||
|
||||
```sh
|
||||
yarn add onnxruntime-react-native
|
||||
```
|
||||
|
||||
## Usage
|
||||
### Usage
|
||||
|
||||
```js
|
||||
import { InferenceSession } from "onnxruntime-react-native";
|
||||
|
|
@ -19,11 +27,15 @@ const session: InferenceSession = await InferenceSession.create(modelPath);
|
|||
const result = session.run(input, ['num_detection:0', 'detection_classes:0'])
|
||||
```
|
||||
|
||||
Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxruntime-inference-examples/js) for samples and tutorials. Different from other JavaScript frameworks like node.js and web, React Native library doesn't support these features
|
||||
Refer to [ONNX Runtime JavaScript examples](https://github.com/microsoft/onnxruntime-inference-examples/tree/main/js) for samples and tutorials. Different from other JavaScript frameworks like node.js and web, React Native library doesn't support these features.
|
||||
|
||||
- Unsigned data type at Tensor
|
||||
- Model loading using ArrayBuffer
|
||||
|
||||
## License
|
||||
### Operator and type support
|
||||
|
||||
ONNX Runtime React Native currently supports most operators used by popular models. Refer to [ONNX Runtime Mobile Pacakge Operator and Type](https://www.onnxruntime.ai/docs/reference/mobile/prebuilt-package/1.8%20ORTMobilePackageOperatorTypeSupport).
|
||||
|
||||
### License
|
||||
|
||||
License information can be found [here](https://github.com/microsoft/onnxruntime/blob/master/README.md#license).
|
||||
|
|
|
|||
|
|
@ -121,16 +121,18 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
def onnxruntimeMobileVersion = project.properties['Onnxruntime_mobileVersion']
|
||||
|
||||
// noinspection GradleDynamicVersion
|
||||
api 'com.facebook.react:react-native:+'
|
||||
api 'org.mockito:mockito-core:2.28.2'
|
||||
api "com.facebook.react:react-native:+"
|
||||
api "org.mockito:mockito-core:2.28.2"
|
||||
|
||||
androidTestImplementation 'androidx.test:runner:1.1.0'
|
||||
androidTestImplementation 'androidx.test:rules:1.1.0'
|
||||
androidTestImplementation "androidx.test:runner:1.1.0"
|
||||
androidTestImplementation "androidx.test:rules:1.1.0"
|
||||
|
||||
implementation 'junit:junit:4.12'
|
||||
implementation "junit:junit:4.12"
|
||||
|
||||
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline-extended:2.28.1'
|
||||
androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito-inline-extended:2.28.1"
|
||||
|
||||
api(name:'onnxruntime', ext:'aar')
|
||||
implementation "com.microsoft.onnxruntime:onnxruntime-mobile:$onnxruntimeMobileVersion@aar"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,3 +16,4 @@ android.useAndroidX=true
|
|||
OnnxruntimeModule_buildToolsVersion=29.0.2
|
||||
OnnxruntimeModule_compileSdkVersion=29
|
||||
OnnxruntimeModule_targetSdkVersion=29
|
||||
Onnxruntime_mobileVersion=1.8.0
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class OnnxruntimeModuleTest {
|
|||
}
|
||||
inputTensorMap.putArray("dims", dimsArray);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeFloat);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeFloat);
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(5 * Float.BYTES).order(ByteOrder.nativeOrder());
|
||||
FloatBuffer floatBuffer = buffer.asFloatBuffer();
|
||||
|
|
@ -109,7 +109,7 @@ public class OnnxruntimeModuleTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeFloat);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeFloat);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
FloatBuffer buffer = ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT))
|
||||
.order(ByteOrder.nativeOrder())
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class TensorHelperTest {
|
|||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeFloat);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeFloat);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3 * 4).order(ByteOrder.nativeOrder());
|
||||
FloatBuffer dataFloatBuffer = dataByteBuffer.asFloatBuffer();
|
||||
|
|
@ -87,7 +87,7 @@ public class TensorHelperTest {
|
|||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeByte);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeByte);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3);
|
||||
dataByteBuffer.put(Byte.MIN_VALUE);
|
||||
|
|
@ -107,38 +107,6 @@ public class TensorHelperTest {
|
|||
outputTensor.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInputTensor_int16() throws Exception {
|
||||
OnnxTensor outputTensor =
|
||||
OnnxTensor.createTensor(ortEnvironment, new short[] {Short.MIN_VALUE, 2, Short.MAX_VALUE});
|
||||
|
||||
JavaOnlyMap inputTensorMap = new JavaOnlyMap();
|
||||
|
||||
JavaOnlyArray dims = new JavaOnlyArray();
|
||||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeShort);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3 * 2).order(ByteOrder.nativeOrder());
|
||||
ShortBuffer dataShortBuffer = dataByteBuffer.asShortBuffer();
|
||||
dataShortBuffer.put(Short.MIN_VALUE);
|
||||
dataShortBuffer.put((short)2);
|
||||
dataShortBuffer.put(Short.MAX_VALUE);
|
||||
String dataEncoded = Base64.encodeToString(dataByteBuffer.array(), Base64.DEFAULT);
|
||||
inputTensorMap.putString("data", dataEncoded);
|
||||
|
||||
OnnxTensor inputTensor = TensorHelper.createInputTensor(inputTensorMap, ortEnvironment);
|
||||
|
||||
Assert.assertEquals(inputTensor.getInfo().onnxType, TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16);
|
||||
Assert.assertEquals(outputTensor.getInfo().onnxType, TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16);
|
||||
Assert.assertEquals(inputTensor.toString(), outputTensor.toString());
|
||||
Assert.assertArrayEquals(inputTensor.getShortBuffer().array(), outputTensor.getShortBuffer().array());
|
||||
|
||||
inputTensor.close();
|
||||
outputTensor.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInputTensor_int32() throws Exception {
|
||||
OnnxTensor outputTensor =
|
||||
|
|
@ -150,7 +118,7 @@ public class TensorHelperTest {
|
|||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeInt);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeInt);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3 * 4).order(ByteOrder.nativeOrder());
|
||||
IntBuffer dataIntBuffer = dataByteBuffer.asIntBuffer();
|
||||
|
|
@ -182,7 +150,7 @@ public class TensorHelperTest {
|
|||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeLong);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeLong);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3 * 8).order(ByteOrder.nativeOrder());
|
||||
LongBuffer dataLongBuffer = dataByteBuffer.asLongBuffer();
|
||||
|
|
@ -203,38 +171,6 @@ public class TensorHelperTest {
|
|||
outputTensor.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInputTensor_string() throws Exception {
|
||||
OnnxTensor outputTensor = OnnxTensor.createTensor(ortEnvironment, new String[] {"a", "b", "c"}, new long[] {3});
|
||||
|
||||
JavaOnlyMap inputTensorMap = new JavaOnlyMap();
|
||||
|
||||
JavaOnlyArray dims = new JavaOnlyArray();
|
||||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeString);
|
||||
|
||||
JavaOnlyArray data = new JavaOnlyArray();
|
||||
data.pushString("a");
|
||||
data.pushString("b");
|
||||
data.pushString("c");
|
||||
inputTensorMap.putArray("data", data);
|
||||
|
||||
OnnxTensor inputTensor = TensorHelper.createInputTensor(inputTensorMap, ortEnvironment);
|
||||
|
||||
Assert.assertEquals(inputTensor.getInfo().onnxType, TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING);
|
||||
Assert.assertEquals(outputTensor.getInfo().onnxType,
|
||||
TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING);
|
||||
Assert.assertEquals(inputTensor.toString(), outputTensor.toString());
|
||||
String[] inputData = (String[])inputTensor.getValue();
|
||||
String[] outputData = (String[])outputTensor.getValue();
|
||||
Assert.assertArrayEquals(inputData, outputData);
|
||||
|
||||
inputTensor.close();
|
||||
outputTensor.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInputTensor_double() throws Exception {
|
||||
OnnxTensor outputTensor =
|
||||
|
|
@ -246,7 +182,7 @@ public class TensorHelperTest {
|
|||
dims.pushInt(3);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
||||
inputTensorMap.putString("type", TensorHelper.TensorTypeDouble);
|
||||
inputTensorMap.putString("type", TensorHelper.JsTensorTypeDouble);
|
||||
|
||||
ByteBuffer dataByteBuffer = ByteBuffer.allocate(3 * 8).order(ByteOrder.nativeOrder());
|
||||
DoubleBuffer dataDoubleBuffer = dataByteBuffer.asDoubleBuffer();
|
||||
|
|
@ -295,7 +231,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeBool);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeBool);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
ByteBuffer buffer = ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT));
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
|
|
@ -335,7 +271,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeDouble);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeDouble);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
DoubleBuffer buffer =
|
||||
ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT)).order(ByteOrder.nativeOrder()).asDoubleBuffer();
|
||||
|
|
@ -376,7 +312,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeFloat);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeFloat);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
FloatBuffer buffer =
|
||||
ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT)).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
|
|
@ -417,7 +353,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeByte);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeByte);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
ByteBuffer buffer = ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT));
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
|
|
@ -430,47 +366,6 @@ public class TensorHelperTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOutputTensor_int16() throws Exception {
|
||||
MockitoSession mockSession = mockitoSession().mockStatic(Arguments.class).startMocking();
|
||||
try {
|
||||
when(Arguments.createMap()).thenAnswer(i -> new JavaOnlyMap());
|
||||
when(Arguments.createArray()).thenAnswer(i -> new JavaOnlyArray());
|
||||
|
||||
OrtSession.SessionOptions options = new OrtSession.SessionOptions();
|
||||
byte[] modelData = readBytesFromResourceFile(ai.onnxruntime.reactnative.test.R.raw.test_types_int16);
|
||||
OrtSession session = ortEnvironment.createSession(modelData, options);
|
||||
|
||||
long[] dims = new long[] {1, 5};
|
||||
short[] inputData = new short[] {1, 2, -3, Short.MIN_VALUE, Short.MAX_VALUE};
|
||||
|
||||
String inputName = session.getInputNames().iterator().next();
|
||||
Map<String, OnnxTensor> container = new HashMap<>();
|
||||
Object tensorInput = OrtUtil.reshape(inputData, dims);
|
||||
OnnxTensor onnxTensor = OnnxTensor.createTensor(ortEnvironment, tensorInput);
|
||||
container.put(inputName, onnxTensor);
|
||||
|
||||
OrtSession.Result result = session.run(container);
|
||||
|
||||
ReadableMap resultMap = TensorHelper.createOutputTensor(result);
|
||||
ReadableMap outputMap = resultMap.getMap("output");
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeShort);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
ShortBuffer buffer =
|
||||
ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT)).order(ByteOrder.nativeOrder()).asShortBuffer();
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
Assert.assertEquals(buffer.get(i), inputData[i]);
|
||||
}
|
||||
|
||||
OnnxValue.close(container);
|
||||
} finally {
|
||||
mockSession.finishMocking();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOutputTensor_int32() throws Exception {
|
||||
MockitoSession mockSession = mockitoSession().mockStatic(Arguments.class).startMocking();
|
||||
|
|
@ -498,7 +393,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeInt);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeInt);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
IntBuffer buffer =
|
||||
ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT)).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
|
|
@ -539,7 +434,7 @@ public class TensorHelperTest {
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeLong);
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.JsTensorTypeLong);
|
||||
String dataEncoded = outputMap.getString("data");
|
||||
LongBuffer buffer =
|
||||
ByteBuffer.wrap(Base64.decode(dataEncoded, Base64.DEFAULT)).order(ByteOrder.nativeOrder()).asLongBuffer();
|
||||
|
|
@ -553,44 +448,6 @@ public class TensorHelperTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOutputTensor_string() throws Exception {
|
||||
MockitoSession mockSession = mockitoSession().mockStatic(Arguments.class).startMocking();
|
||||
try {
|
||||
when(Arguments.createMap()).thenAnswer(i -> new JavaOnlyMap());
|
||||
when(Arguments.createArray()).thenAnswer(i -> new JavaOnlyArray());
|
||||
|
||||
OrtSession.SessionOptions options = new OrtSession.SessionOptions();
|
||||
byte[] modelData = readBytesFromResourceFile(ai.onnxruntime.reactnative.test.R.raw.test_types_string);
|
||||
OrtSession session = ortEnvironment.createSession(modelData, options);
|
||||
|
||||
long[] dims = new long[] {1, 5};
|
||||
String[] inputData = new String[] {"a", "b", "c", "d", "e"};
|
||||
|
||||
String inputName = session.getInputNames().iterator().next();
|
||||
Map<String, OnnxTensor> container = new HashMap<>();
|
||||
OnnxTensor onnxTensor = OnnxTensor.createTensor(ortEnvironment, inputData, dims);
|
||||
container.put(inputName, onnxTensor);
|
||||
|
||||
OrtSession.Result result = session.run(container);
|
||||
String[] outputData = (String[])((OnnxTensor)result.get(0)).getValue();
|
||||
|
||||
ReadableMap resultMap = TensorHelper.createOutputTensor(result);
|
||||
ReadableMap outputMap = resultMap.getMap("output");
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("dims").getInt(i), dims[i]);
|
||||
}
|
||||
Assert.assertEquals(outputMap.getString("type"), TensorHelper.TensorTypeString);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
Assert.assertEquals(outputMap.getArray("data").getString(i), inputData[i]);
|
||||
}
|
||||
|
||||
OnnxValue.close(container);
|
||||
} finally {
|
||||
mockSession.finishMocking();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readBytesFromResourceFile(int resourceId) throws Exception {
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
InputStream inputStream = context.getResources().openRawResource(resourceId);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
js/react_native/example/android/app/src/main/assets/mnist.ort
Normal file
BIN
js/react_native/example/android/app/src/main/assets/mnist.ort
Normal file
Binary file not shown.
|
|
@ -64,7 +64,7 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
@ReactMethod
|
||||
public void getLocalModelPath(Promise promise) {
|
||||
try {
|
||||
String modelPath = copyFile(reactContext, "mnist.onnx");
|
||||
String modelPath = copyFile(reactContext, "mnist.ort");
|
||||
promise.resolve(modelPath);
|
||||
} catch (Exception e) {
|
||||
promise.reject("Can't get a mdoel", e);
|
||||
|
|
@ -111,7 +111,6 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
// returns cooked data formatted as input of a model by promise.
|
||||
private WritableMap preprocess(String uri) throws Exception {
|
||||
final int batchSize = 1;
|
||||
final int channelSize = 1;
|
||||
final int imageHeight = 28;
|
||||
final int imageWidth = 28;
|
||||
|
||||
|
|
@ -127,8 +126,7 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
// Resize bitmap to 28x28
|
||||
bitmap = Bitmap.createScaledBitmap(bitmap, imageWidth, imageHeight, false);
|
||||
|
||||
ByteBuffer imageByteBuffer =
|
||||
ByteBuffer.allocate(imageHeight * imageWidth * channelSize * 4).order(ByteOrder.nativeOrder());
|
||||
ByteBuffer imageByteBuffer = ByteBuffer.allocate(imageHeight * imageWidth * 4).order(ByteOrder.nativeOrder());
|
||||
FloatBuffer imageFloatBuffer = imageByteBuffer.asFloatBuffer();
|
||||
for (int h = 0; h < imageHeight; ++h) {
|
||||
for (int w = 0; w < imageWidth; ++w) {
|
||||
|
|
@ -145,7 +143,6 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
|
||||
WritableArray dims = Arguments.createArray();
|
||||
dims.pushInt(batchSize);
|
||||
dims.pushInt(channelSize);
|
||||
dims.pushInt(imageHeight);
|
||||
dims.pushInt(imageWidth);
|
||||
inputTensorMap.putArray("dims", dims);
|
||||
|
|
@ -158,7 +155,7 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
String data = Base64.encodeToString(imageByteBuffer.array(), Base64.DEFAULT);
|
||||
inputTensorMap.putString("data", data);
|
||||
|
||||
inputDataMap.putMap("Input3", inputTensorMap);
|
||||
inputDataMap.putMap("flatten_2_input", inputTensorMap);
|
||||
|
||||
return inputDataMap;
|
||||
}
|
||||
|
|
@ -167,7 +164,7 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
private WritableMap postprocess(ReadableMap result) throws Exception {
|
||||
String detectionResult = "";
|
||||
|
||||
ReadableMap outputTensor = result.getMap("Plus214_Output_0");
|
||||
ReadableMap outputTensor = result.getMap("Identity");
|
||||
|
||||
String outputData = outputTensor.getString("data");
|
||||
FloatBuffer buffer =
|
||||
|
|
@ -177,24 +174,16 @@ public class MNISTDataHandler extends ReactContextBaseJavaModule {
|
|||
dataArray.add((double)buffer.get());
|
||||
}
|
||||
|
||||
final double max = Collections.max(dataArray);
|
||||
double total = 0.0f;
|
||||
for (int i = 0; i < dataArray.size(); ++i) {
|
||||
dataArray.set(i, Math.exp((double)dataArray.get(i) - max));
|
||||
total += dataArray.get(i);
|
||||
}
|
||||
double[] softmax = new double[dataArray.size()];
|
||||
int argmax = 0;
|
||||
double maxValue = 0;
|
||||
for (int i = 0; i < dataArray.size(); ++i) {
|
||||
softmax[i] = dataArray.get(i) / total;
|
||||
if (softmax[i] > maxValue) {
|
||||
maxValue = softmax[i];
|
||||
if (dataArray.get(i) > maxValue) {
|
||||
maxValue = dataArray.get(i);
|
||||
argmax = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (max == 0) {
|
||||
if (maxValue == 0) {
|
||||
detectionResult = "No match";
|
||||
} else {
|
||||
detectionResult = "I guess, it's " + argmax;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ RCT_EXPORT_MODULE(MNISTDataHandler)
|
|||
// so that onnxruntime is able to load a model using a given path.
|
||||
RCT_EXPORT_METHOD(getLocalModelPath : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
||||
@try {
|
||||
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"mnist" ofType:@"onnx"];
|
||||
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"mnist" ofType:@"ort"];
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
if ([fileManager fileExistsAtPath:modelPath]) {
|
||||
resolve(modelPath);
|
||||
|
|
@ -97,8 +97,7 @@ RCT_EXPORT_METHOD(postprocess
|
|||
CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
|
||||
CGContextRelease(context);
|
||||
|
||||
const NSInteger channelSize = 1;
|
||||
const NSInteger dimSize = height * width * channelSize;
|
||||
const NSInteger dimSize = height * width;
|
||||
const NSInteger byteBufferSize = dimSize * sizeof(float);
|
||||
|
||||
unsigned char *byteBuffer = static_cast<unsigned char *>(malloc(byteBufferSize));
|
||||
|
|
@ -118,7 +117,7 @@ RCT_EXPORT_METHOD(postprocess
|
|||
|
||||
// dims
|
||||
NSArray *dims = @[
|
||||
[NSNumber numberWithInt:1], [NSNumber numberWithInt:channelSize], [NSNumber numberWithInt:static_cast<int>(height)],
|
||||
[NSNumber numberWithInt:1], [NSNumber numberWithInt:static_cast<int>(height)],
|
||||
[NSNumber numberWithInt:static_cast<int>(width)]
|
||||
];
|
||||
inputTensorMap[@"dims"] = dims;
|
||||
|
|
@ -130,7 +129,7 @@ RCT_EXPORT_METHOD(postprocess
|
|||
NSString *data = [byteBufferRef base64EncodedStringWithOptions:0];
|
||||
inputTensorMap[@"data"] = data;
|
||||
|
||||
inputDataMap[@"Input3"] = inputTensorMap;
|
||||
inputDataMap[@"flatten_2_input"] = inputTensorMap;
|
||||
|
||||
return inputDataMap;
|
||||
}
|
||||
|
|
@ -138,31 +137,18 @@ RCT_EXPORT_METHOD(postprocess
|
|||
- (NSDictionary *)postprocess:(NSDictionary *)result {
|
||||
NSMutableString *detectionResult = [NSMutableString string];
|
||||
|
||||
NSDictionary *outputTensor = [result objectForKey:@"Plus214_Output_0"];
|
||||
NSDictionary *outputTensor = [result objectForKey:@"Identity"];
|
||||
|
||||
NSString *data = [outputTensor objectForKey:@"data"];
|
||||
NSData *buffer = [[NSData alloc] initWithBase64EncodedString:data options:0];
|
||||
float *values = (float *)[buffer bytes];
|
||||
int count = (int)[buffer length] / 4;
|
||||
|
||||
double maxValue = 0.0f;
|
||||
int argmax = 0;
|
||||
float maxValue = 0.0f;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (values[i] > maxValue) {
|
||||
maxValue = values[i];
|
||||
}
|
||||
}
|
||||
double total = 0.0f;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
values[i] = exp(values[i] - maxValue);
|
||||
total += values[i];
|
||||
}
|
||||
std::vector<double> softmax(count);
|
||||
int argmax = 0;
|
||||
maxValue = 0.0f;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
softmax[i] = values[i] / total;
|
||||
if (softmax[i] > maxValue) {
|
||||
maxValue = softmax[i];
|
||||
argmax = i;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||
2B52F02C66A197669308C74D /* libPods-OnnxruntimeModuleExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6784A38AC4BD8C34E1D90B74 /* libPods-OnnxruntimeModuleExample.a */; };
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
|
||||
A769E116237385B138BCB816 /* Pods_OnnxruntimeModuleExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C2AC7C168BAB1163669C38C /* Pods_OnnxruntimeModuleExample.framework */; };
|
||||
DBA8BA87267293C4008CC55A /* mnist.ort in Resources */ = {isa = PBXBuildFile; fileRef = DBA8BA86267293C4008CC55A /* mnist.ort */; };
|
||||
DBBF7412263B8C7100487C77 /* MNISTDataHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = DBBF7411263B8C7100487C77 /* MNISTDataHandler.mm */; };
|
||||
DBBF7414263B8CCB00487C77 /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = DBBF7413263B8CCB00487C77 /* 3.jpg */; };
|
||||
DBBF7416263B8CD900487C77 /* mnist.onnx in Resources */ = {isa = PBXBuildFile; fileRef = DBBF7415263B8CD900487C77 /* mnist.onnx */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
|
||||
0C2AC7C168BAB1163669C38C /* Pods_OnnxruntimeModuleExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OnnxruntimeModuleExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
13B07F961A680F5B00A75B9A /* OnnxruntimeModuleExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnnxruntimeModuleExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = OnnxruntimeModuleExample/AppDelegate.h; sourceTree = "<group>"; };
|
||||
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = OnnxruntimeModuleExample/AppDelegate.m; sourceTree = "<group>"; };
|
||||
|
|
@ -39,12 +40,11 @@
|
|||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = OnnxruntimeModuleExample/Info.plist; sourceTree = "<group>"; };
|
||||
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = OnnxruntimeModuleExample/main.m; sourceTree = "<group>"; };
|
||||
47F7ED3B7971BE374F7B8635 /* Pods-OnnxruntimeModuleExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleExample.debug.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleExample/Pods-OnnxruntimeModuleExample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
6784A38AC4BD8C34E1D90B74 /* libPods-OnnxruntimeModuleExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OnnxruntimeModuleExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = OnnxruntimeModuleExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
DBA8BA86267293C4008CC55A /* mnist.ort */ = {isa = PBXFileReference; lastKnownFileType = file; name = mnist.ort; path = ../src/mnist.ort; sourceTree = "<group>"; };
|
||||
DBBF7410263B8C5F00487C77 /* MNISTDataHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNISTDataHandler.h; sourceTree = "<group>"; };
|
||||
DBBF7411263B8C7100487C77 /* MNISTDataHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MNISTDataHandler.mm; sourceTree = "<group>"; };
|
||||
DBBF7413263B8CCB00487C77 /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = 3.jpg; path = ../src/3.jpg; sourceTree = "<group>"; };
|
||||
DBBF7415263B8CD900487C77 /* mnist.onnx */ = {isa = PBXFileReference; lastKnownFileType = file; name = mnist.onnx; path = ../src/mnist.onnx; sourceTree = "<group>"; };
|
||||
E00ACF0FDA8BF921659E2F9A /* Pods-OnnxruntimeModuleExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleExample.release.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleExample/Pods-OnnxruntimeModuleExample.release.xcconfig"; sourceTree = "<group>"; };
|
||||
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2B52F02C66A197669308C74D /* libPods-OnnxruntimeModuleExample.a in Frameworks */,
|
||||
A769E116237385B138BCB816 /* Pods_OnnxruntimeModuleExample.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
|
||||
6784A38AC4BD8C34E1D90B74 /* libPods-OnnxruntimeModuleExample.a */,
|
||||
0C2AC7C168BAB1163669C38C /* Pods_OnnxruntimeModuleExample.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
83CBB9F61A601CBA00E9B192 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DBBF7415263B8CD900487C77 /* mnist.onnx */,
|
||||
DBA8BA86267293C4008CC55A /* mnist.ort */,
|
||||
DBBF7413263B8CCB00487C77 /* 3.jpg */,
|
||||
13B07FAE1A68108700A75B9A /* OnnxruntimeModuleExample */,
|
||||
832341AE1AAA6A7D00B99B32 /* Libraries */,
|
||||
|
|
@ -139,9 +139,8 @@
|
|||
13B07F8C1A680F5B00A75B9A /* Frameworks */,
|
||||
13B07F8E1A680F5B00A75B9A /* Resources */,
|
||||
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
|
||||
C1D60D28B925C94BD88E79D7 /* [CP] Copy Pods Resources */,
|
||||
DB8FCD9C25C3404B00C72F26 /* Embed Libraries */,
|
||||
3EBF64FAD8377366F1ED4D7E /* [CP] Embed Pods Frameworks */,
|
||||
16EFC8544779C8326869A95A /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
@ -189,7 +188,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DBBF7416263B8CD900487C77 /* mnist.onnx in Resources */,
|
||||
DBA8BA87267293C4008CC55A /* mnist.ort in Resources */,
|
||||
DBBF7414263B8CCB00487C77 /* 3.jpg in Resources */,
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||
|
|
@ -213,18 +212,62 @@
|
|||
shellPath = /bin/sh;
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
|
||||
};
|
||||
3EBF64FAD8377366F1ED4D7E /* [CP] Embed Pods Frameworks */ = {
|
||||
16EFC8544779C8326869A95A /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleExample/Pods-OnnxruntimeModuleExample-frameworks.sh",
|
||||
"${PODS_ROOT}/../../../ios/Libraries/onnxruntime/lib/iphonesimulator/libonnxruntime.1.7.0.dylib",
|
||||
"${BUILT_PRODUCTS_DIR}/DoubleConversion/DoubleConversion.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/FBReactNativeSpec/FBReactNativeSpec.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Folly/folly.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-Core/React.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-CoreModules/CoreModules.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTAnimation/RCTAnimation.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTBlob/RCTBlob.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTImage/RCTImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTLinking/RCTLinking.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTNetwork/RCTNetwork.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTSettings/RCTSettings.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTText/RCTText.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTVibration/RCTVibration.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-cxxreact/cxxreact.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsi/jsi.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsiexecutor/jsireact.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsinspector/jsinspector.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/ReactCommon/ReactCommon.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Yoga/yoga.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/glog/glog.framework",
|
||||
"${PODS_ROOT}/onnxruntime-mobile-c/onnxruntime.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/onnxruntime-react-native/onnxruntime_react_native.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libonnxruntime.1.7.0.dylib",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DoubleConversion.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBReactNativeSpec.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/folly.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTTypeSafety.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/React.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CoreModules.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTAnimation.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTBlob.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTLinking.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTNetwork.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTSettings.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTText.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTVibration.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cxxreact.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsi.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsireact.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsinspector.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReactCommon.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/yoga.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime_react_native.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
|
|
@ -253,24 +296,6 @@
|
|||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
C1D60D28B925C94BD88E79D7 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleExample/Pods-OnnxruntimeModuleExample-resources.sh",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleExample/Pods-OnnxruntimeModuleExample-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
FD10A7F022414F080027D42C /* Start Packager */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||
|
||||
platform :ios, '10.0'
|
||||
platform :ios, '13.0'
|
||||
|
||||
target 'OnnxruntimeModuleExample' do
|
||||
config = use_native_modules!
|
||||
|
||||
use_react_native!(:path => config["reactNativePath"])
|
||||
|
||||
pod 'onnxruntime-react-native.iphonesimulator', :path => '../..'
|
||||
use_frameworks!
|
||||
pod 'onnxruntime-mobile-c', :podspec => '../../onnxruntime-mobile-c.podspec'
|
||||
pod 'onnxruntime-react-native', :path => '../..'
|
||||
|
||||
inherit! :search_paths
|
||||
end
|
||||
|
|
|
|||
Binary file not shown.
BIN
js/react_native/example/src/mnist.ort
Normal file
BIN
js/react_native/example/src/mnist.ort
Normal file
Binary file not shown.
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#import "OnnxruntimeModule.h"
|
||||
#import "TensorHelper.h"
|
||||
#import "onnxruntime_cxx_api.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <onnxruntime/onnxruntime_cxx_api.h>
|
||||
|
||||
@implementation OnnxruntimeModule
|
||||
|
||||
|
|
|
|||
|
|
@ -7,16 +7,14 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
D1D81F804850BCAF0F66320B /* libPods-OnnxruntimeModuleTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4ED4282B152369F0F6753107 /* libPods-OnnxruntimeModuleTest.a */; };
|
||||
094C43D4312FB83139FA4E3B /* Pods_OnnxruntimeModule.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B4C5FACE5CEC3A22F50945 /* Pods_OnnxruntimeModule.framework */; };
|
||||
9B52917A0F2BDC354D087A67 /* Pods_OnnxruntimeModuleTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69B56D4AAAA9C6D8C15652DC /* Pods_OnnxruntimeModuleTest.framework */; };
|
||||
DB8FC9B525C2867800C72F26 /* OnnxruntimeModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = DB8FC9B425C2867800C72F26 /* OnnxruntimeModule.mm */; };
|
||||
DB8FC9B825C2868700C72F26 /* TensorHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = DB8FC9B725C2868700C72F26 /* TensorHelper.mm */; };
|
||||
DBD3F06A263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DBD3F069263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib */; };
|
||||
DBD3F06B263F803D00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DBD3F069263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib */; };
|
||||
DBDB57DA2603211A004F16BE /* TensorHelperTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = DBDB57D92603211A004F16BE /* TensorHelperTest.mm */; };
|
||||
DBDB57DC2603211A004F16BE /* libOnnxruntimeModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 134814201AA4EA6300B7C361 /* libOnnxruntimeModule.a */; };
|
||||
DBDB588B2609B18F004F16BE /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = DBDB588A2609B18F004F16BE /* Resources */; };
|
||||
DBDB58B0262A92D7004F16BE /* OnnxruntimeModuleTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = DBDB58AF262A92D6004F16BE /* OnnxruntimeModuleTest.mm */; };
|
||||
F92876D1F6656034AD2EC8D1 /* libPods-OnnxruntimeModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6E96BE961E158CBAAD5BA677 /* libPods-OnnxruntimeModule.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
|
@ -42,29 +40,20 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
01C2D06548A9114EA7E75A55 /* Pods-OnnxruntimeModuleTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleTest.debug.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
134814201AA4EA6300B7C361 /* libOnnxruntimeModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOnnxruntimeModule.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4ED4282B152369F0F6753107 /* libPods-OnnxruntimeModuleTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OnnxruntimeModuleTest.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4EF73D38B9D8F90FB428108C /* Pods-OnnxruntimeModuleTest.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleTest.debug.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
4FA772A32BE6D874419D9094 /* Pods-OnnxruntimeModule.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModule.debug.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModule/Pods-OnnxruntimeModule.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
6E96BE961E158CBAAD5BA677 /* libPods-OnnxruntimeModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OnnxruntimeModule.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
69B56D4AAAA9C6D8C15652DC /* Pods_OnnxruntimeModuleTest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OnnxruntimeModuleTest.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
83B4C5FACE5CEC3A22F50945 /* Pods_OnnxruntimeModule.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OnnxruntimeModule.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
94FB38C2CBF8DFA9F2AEAB37 /* Pods-OnnxruntimeModule.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModule.release.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModule/Pods-OnnxruntimeModule.release.xcconfig"; sourceTree = "<group>"; };
|
||||
BD5F629FF761AD0F444C93B5 /* Pods-OnnxruntimeModuleTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleTest.release.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest.release.xcconfig"; sourceTree = "<group>"; };
|
||||
DB8FC9A325C2850300C72F26 /* onnxruntime_session_options_config_keys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onnxruntime_session_options_config_keys.h; sourceTree = "<group>"; };
|
||||
DB8FC9A425C2850300C72F26 /* automl_data_containers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = automl_data_containers.h; sourceTree = "<group>"; };
|
||||
DB8FC9A525C2850300C72F26 /* experimental_onnxruntime_cxx_inline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = experimental_onnxruntime_cxx_inline.h; sourceTree = "<group>"; };
|
||||
DB8FC9A625C2850300C72F26 /* environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = environment.h; sourceTree = "<group>"; };
|
||||
DB8FC9A725C2850300C72F26 /* onnxruntime_cxx_inline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onnxruntime_cxx_inline.h; sourceTree = "<group>"; };
|
||||
DB8FC9A825C2850300C72F26 /* onnxruntime_cxx_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onnxruntime_cxx_api.h; sourceTree = "<group>"; };
|
||||
DB8FC9A925C2850300C72F26 /* onnxruntime_c_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onnxruntime_c_api.h; sourceTree = "<group>"; };
|
||||
DB8FC9AA25C2850300C72F26 /* experimental_onnxruntime_cxx_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = experimental_onnxruntime_cxx_api.h; sourceTree = "<group>"; };
|
||||
DB8FC9B425C2867800C72F26 /* OnnxruntimeModule.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OnnxruntimeModule.mm; sourceTree = SOURCE_ROOT; };
|
||||
DB8FC9B725C2868700C72F26 /* TensorHelper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TensorHelper.mm; sourceTree = SOURCE_ROOT; };
|
||||
DBD3F069263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libonnxruntime.${ONNXRUNTIME_VERSION}.dylib"; path = "Libraries/onnxruntime/lib/iphonesimulator/libonnxruntime.${ONNXRUNTIME_VERSION}.dylib"; sourceTree = "<group>"; };
|
||||
DBDB57D72603211A004F16BE /* OnnxruntimeModuleTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OnnxruntimeModuleTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DBDB57D92603211A004F16BE /* TensorHelperTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TensorHelperTest.mm; sourceTree = "<group>"; };
|
||||
DBDB57DB2603211A004F16BE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
DBDB588A2609B18F004F16BE /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Resources; path = OnnxruntimeModuleTest/Resources; sourceTree = "<group>"; };
|
||||
DBDB58AF262A92D6004F16BE /* OnnxruntimeModuleTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OnnxruntimeModuleTest.mm; sourceTree = "<group>"; };
|
||||
FEC2B1289C2940FC626B52E2 /* Pods-OnnxruntimeModuleTest.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OnnxruntimeModuleTest.release.xcconfig"; path = "Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest.release.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -72,8 +61,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F92876D1F6656034AD2EC8D1 /* libPods-OnnxruntimeModule.a in Frameworks */,
|
||||
DBD3F06A263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib in Frameworks */,
|
||||
094C43D4312FB83139FA4E3B /* Pods_OnnxruntimeModule.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -81,9 +69,8 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DBD3F06B263F803D00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib in Frameworks */,
|
||||
DBDB57DC2603211A004F16BE /* libOnnxruntimeModule.a in Frameworks */,
|
||||
D1D81F804850BCAF0F66320B /* libPods-OnnxruntimeModuleTest.a in Frameworks */,
|
||||
9B52917A0F2BDC354D087A67 /* Pods_OnnxruntimeModuleTest.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -103,7 +90,6 @@
|
|||
children = (
|
||||
DBDB588A2609B18F004F16BE /* Resources */,
|
||||
DB8FC9B325C2861300C72F26 /* OnnxruntimeModule */,
|
||||
DB8FC9A125C284E700C72F26 /* Libraries */,
|
||||
DBDB57D82603211A004F16BE /* OnnxruntimeModuleTest */,
|
||||
134814211AA4EA7D00B7C361 /* Products */,
|
||||
DB8FC99D25C284A200C72F26 /* Frameworks */,
|
||||
|
|
@ -117,8 +103,8 @@
|
|||
children = (
|
||||
4FA772A32BE6D874419D9094 /* Pods-OnnxruntimeModule.debug.xcconfig */,
|
||||
94FB38C2CBF8DFA9F2AEAB37 /* Pods-OnnxruntimeModule.release.xcconfig */,
|
||||
01C2D06548A9114EA7E75A55 /* Pods-OnnxruntimeModuleTest.debug.xcconfig */,
|
||||
BD5F629FF761AD0F444C93B5 /* Pods-OnnxruntimeModuleTest.release.xcconfig */,
|
||||
4EF73D38B9D8F90FB428108C /* Pods-OnnxruntimeModuleTest.debug.xcconfig */,
|
||||
FEC2B1289C2940FC626B52E2 /* Pods-OnnxruntimeModuleTest.release.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -126,36 +112,12 @@
|
|||
DB8FC99D25C284A200C72F26 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DBD3F069263F7F9C00CD0373 /* libonnxruntime.${ONNXRUNTIME_VERSION}.dylib */,
|
||||
6E96BE961E158CBAAD5BA677 /* libPods-OnnxruntimeModule.a */,
|
||||
4ED4282B152369F0F6753107 /* libPods-OnnxruntimeModuleTest.a */,
|
||||
83B4C5FACE5CEC3A22F50945 /* Pods_OnnxruntimeModule.framework */,
|
||||
69B56D4AAAA9C6D8C15652DC /* Pods_OnnxruntimeModuleTest.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DB8FC9A125C284E700C72F26 /* Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DB8FC9A225C2850300C72F26 /* onnxruntime */,
|
||||
);
|
||||
path = Libraries;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DB8FC9A225C2850300C72F26 /* onnxruntime */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DB8FC9A325C2850300C72F26 /* onnxruntime_session_options_config_keys.h */,
|
||||
DB8FC9A425C2850300C72F26 /* automl_data_containers.h */,
|
||||
DB8FC9A525C2850300C72F26 /* experimental_onnxruntime_cxx_inline.h */,
|
||||
DB8FC9A625C2850300C72F26 /* environment.h */,
|
||||
DB8FC9A725C2850300C72F26 /* onnxruntime_cxx_inline.h */,
|
||||
DB8FC9A825C2850300C72F26 /* onnxruntime_cxx_api.h */,
|
||||
DB8FC9A925C2850300C72F26 /* onnxruntime_c_api.h */,
|
||||
DB8FC9AA25C2850300C72F26 /* experimental_onnxruntime_cxx_api.h */,
|
||||
);
|
||||
path = onnxruntime;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
DB8FC9B325C2861300C72F26 /* OnnxruntimeModule */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -200,11 +162,11 @@
|
|||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = DBDB57E12603211A004F16BE /* Build configuration list for PBXNativeTarget "OnnxruntimeModuleTest" */;
|
||||
buildPhases = (
|
||||
5B732845A8C64D3A3B502FEC /* [CP] Check Pods Manifest.lock */,
|
||||
4723405DB17478264B2CEA2A /* [CP] Check Pods Manifest.lock */,
|
||||
DBDB57D32603211A004F16BE /* Sources */,
|
||||
DBDB57D42603211A004F16BE /* Frameworks */,
|
||||
DBDB57D52603211A004F16BE /* Resources */,
|
||||
0E58273833B892727485824E /* [CP] Copy Pods Resources */,
|
||||
08C0DD8EAE25681EA57D04AB /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
@ -266,22 +228,64 @@
|
|||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
0E58273833B892727485824E /* [CP] Copy Pods Resources */ = {
|
||||
08C0DD8EAE25681EA57D04AB /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest-resources.sh",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
|
||||
"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/DoubleConversion/DoubleConversion.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/FBReactNativeSpec/FBReactNativeSpec.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Folly/folly.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/RCTTypeSafety/RCTTypeSafety.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-Core/React.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-CoreModules/CoreModules.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTAnimation/RCTAnimation.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTBlob/RCTBlob.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTImage/RCTImage.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTLinking/RCTLinking.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTNetwork/RCTNetwork.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTSettings/RCTSettings.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTText/RCTText.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-RCTVibration/RCTVibration.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-cxxreact/cxxreact.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsi/jsi.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsiexecutor/jsireact.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/React-jsinspector/jsinspector.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/ReactCommon/ReactCommon.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/Yoga/yoga.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/glog/glog.framework",
|
||||
"${PODS_ROOT}/onnxruntime-mobile-c/onnxruntime.framework",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DoubleConversion.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBReactNativeSpec.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/folly.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTTypeSafety.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/React.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CoreModules.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTAnimation.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTBlob.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTImage.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTLinking.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTNetwork.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTSettings.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTText.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RCTVibration.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cxxreact.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsi.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsireact.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/jsinspector.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ReactCommon.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/yoga.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework",
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/onnxruntime.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest-resources.sh\"\n";
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-OnnxruntimeModuleTest/Pods-OnnxruntimeModuleTest-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
148DE3680F0F3FE8BA6A82D1 /* [CP] Check Pods Manifest.lock */ = {
|
||||
|
|
@ -306,7 +310,7 @@
|
|||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
5B732845A8C64D3A3B502FEC /* [CP] Check Pods Manifest.lock */ = {
|
||||
4723405DB17478264B2CEA2A /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
|
|
@ -403,9 +407,9 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "$(PROJECT_DIR)/Libraries/onnxruntime/include";
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Libraries/onnxruntime/lib";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
|
|
@ -448,9 +452,9 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "$(PROJECT_DIR)/Libraries/onnxruntime/include";
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/Libraries/onnxruntime/lib";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
|
@ -467,11 +471,10 @@
|
|||
"$(SRCROOT)/../../../React/**",
|
||||
"$(SRCROOT)/../../react-native/React/**",
|
||||
);
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "\"$(PODS_ROOT)/onnxruntime-mobile/onnxruntime.framework/Headers\"";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator",
|
||||
);
|
||||
OTHER_LDFLAGS = "$(inherited)";
|
||||
PRODUCT_NAME = OnnxruntimeModule;
|
||||
|
|
@ -492,11 +495,10 @@
|
|||
"$(SRCROOT)/../../../React/**",
|
||||
"$(SRCROOT)/../../react-native/React/**",
|
||||
);
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = "\"$(PODS_ROOT)/onnxruntime-mobile/onnxruntime.framework/Headers\"";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator",
|
||||
);
|
||||
OTHER_LDFLAGS = "$(inherited)";
|
||||
PRODUCT_NAME = OnnxruntimeModule;
|
||||
|
|
@ -508,7 +510,7 @@
|
|||
};
|
||||
DBDB57DF2603211A004F16BE /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 01C2D06548A9114EA7E75A55 /* Pods-OnnxruntimeModuleTest.debug.xcconfig */;
|
||||
baseConfigurationReference = 4EF73D38B9D8F90FB428108C /* Pods-OnnxruntimeModuleTest.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
|
|
@ -543,7 +545,7 @@
|
|||
"\"${PODS_ROOT}/Headers/Public/Yoga\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/glog\"",
|
||||
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/include",
|
||||
"\"$(PODS_ROOT)/onnxruntime-mobile/onnxruntime.framework/Headers\"",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = (
|
||||
|
|
@ -565,17 +567,12 @@
|
|||
"\"${PODS_ROOT}/Headers/Public/Yoga\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/glog\"",
|
||||
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/include",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
INFOPLIST_FILE = OnnxruntimeModuleTest/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Libraries/onnxruntime/lib $(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator",
|
||||
);
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ai.onnxruntime.reactnative.OnnxruntimeModuleTest;
|
||||
|
|
@ -586,7 +583,7 @@
|
|||
};
|
||||
DBDB57E02603211A004F16BE /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = BD5F629FF761AD0F444C93B5 /* Pods-OnnxruntimeModuleTest.release.xcconfig */;
|
||||
baseConfigurationReference = FEC2B1289C2940FC626B52E2 /* Pods-OnnxruntimeModuleTest.release.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
|
|
@ -622,7 +619,7 @@
|
|||
"\"${PODS_ROOT}/Headers/Public/Yoga\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/glog\"",
|
||||
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/include",
|
||||
"\"$(PODS_ROOT)/onnxruntime-mobile/onnxruntime.framework/Headers\"",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
"HEADER_SEARCH_PATHS[arch=*]" = (
|
||||
|
|
@ -644,17 +641,12 @@
|
|||
"\"${PODS_ROOT}/Headers/Public/Yoga\"",
|
||||
"\"${PODS_ROOT}/Headers/Public/glog\"",
|
||||
"\"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/include",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
INFOPLIST_FILE = OnnxruntimeModuleTest/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Libraries/onnxruntime/lib $(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib",
|
||||
"$(PROJECT_DIR)/Libraries/onnxruntime/lib/iphonesimulator",
|
||||
);
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ai.onnxruntime.reactnative.OnnxruntimeModuleTest;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#import "OnnxruntimeModule.h"
|
||||
#import "TensorHelper.h"
|
||||
#import "onnxruntime_cxx_api.h"
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <onnxruntime/onnxruntime_cxx_api.h>
|
||||
|
||||
@interface OnnxruntimeModuleTest : XCTestCase
|
||||
|
||||
|
|
@ -14,7 +15,7 @@
|
|||
|
||||
- (void)testOnnxruntimeModule {
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[OnnxruntimeModuleTest class]];
|
||||
NSString *dataPath = [bundle pathForResource:@"test_types_FLOAT" ofType:@"pb"];
|
||||
NSString *dataPath = [bundle pathForResource:@"test_types_float" ofType:@"ort"];
|
||||
|
||||
OnnxruntimeModule *onnxruntimeModule = [OnnxruntimeModule new];
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -2,8 +2,9 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
#import "TensorHelper.h"
|
||||
#import "onnxruntime_cxx_api.h"
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <onnxruntime/onnxruntime_cxx_api.h>
|
||||
|
||||
@interface TensorHelperTest : XCTestCase
|
||||
|
||||
|
|
@ -205,104 +206,38 @@ static void testCreateOutputTensorT(const std::array<T, 5> &outValues, std::func
|
|||
std::array<float_t, 5> outValues{std::numeric_limits<float_t>::min(), 1.0f, 2.0f, 3.0f,
|
||||
std::numeric_limits<float_t>::max()};
|
||||
std::function<NSNumber *(float_t value)> convert = [](float_t value) { return [NSNumber numberWithFloat:value]; };
|
||||
testCreateOutputTensorT<float_t>(outValues, convert, JsTensorTypeFloat, @"test_types_FLOAT", @"pb");
|
||||
testCreateOutputTensorT<float_t>(outValues, convert, JsTensorTypeFloat, @"test_types_float", @"ort");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorDouble {
|
||||
std::array<double_t, 5> outValues{std::numeric_limits<double_t>::min(), 1.0f, 2.0f, 3.0f,
|
||||
std::numeric_limits<double_t>::max()};
|
||||
std::function<NSNumber *(double_t value)> convert = [](double_t value) { return [NSNumber numberWithDouble:value]; };
|
||||
testCreateOutputTensorT<double_t>(outValues, convert, JsTensorTypeDouble, @"test_types_DOUBLE", @"pb");
|
||||
testCreateOutputTensorT<double_t>(outValues, convert, JsTensorTypeDouble, @"test_types_double", @"ort");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorBool {
|
||||
std::array<bool, 5> outValues{false, true, true, false, true};
|
||||
std::function<NSNumber *(bool value)> convert = [](bool value) { return [NSNumber numberWithBool:value]; };
|
||||
testCreateOutputTensorT<bool>(outValues, convert, JsTensorTypeBool, @"test_types_BOOL", @"pb");
|
||||
testCreateOutputTensorT<bool>(outValues, convert, JsTensorTypeBool, @"test_types_bool", @"ort");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorInt8 {
|
||||
std::array<int8_t, 5> outValues{std::numeric_limits<int8_t>::min(), 1, -2, 3, std::numeric_limits<int8_t>::max()};
|
||||
std::function<NSNumber *(int8_t value)> convert = [](int8_t value) { return [NSNumber numberWithChar:value]; };
|
||||
testCreateOutputTensorT<int8_t>(outValues, convert, JsTensorTypeByte, @"test_types_INT8", @"pb");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorInt16 {
|
||||
std::array<int16_t, 5> outValues{std::numeric_limits<int16_t>::min(), 1, -2, 3, std::numeric_limits<int16_t>::max()};
|
||||
std::function<NSNumber *(int16_t value)> convert = [](int16_t value) { return [NSNumber numberWithShort:value]; };
|
||||
testCreateOutputTensorT<int16_t>(outValues, convert, JsTensorTypeShort, @"test_types_INT16", @"pb");
|
||||
testCreateOutputTensorT<int8_t>(outValues, convert, JsTensorTypeByte, @"test_types_int8", @"ort");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorInt32 {
|
||||
std::array<int32_t, 5> outValues{std::numeric_limits<int32_t>::min(), 1, -2, 3, std::numeric_limits<int32_t>::max()};
|
||||
std::function<NSNumber *(int32_t value)> convert = [](int32_t value) { return [NSNumber numberWithInt:value]; };
|
||||
testCreateOutputTensorT<int32_t>(outValues, convert, JsTensorTypeInt, @"test_types_INT32", @"pb");
|
||||
testCreateOutputTensorT<int32_t>(outValues, convert, JsTensorTypeInt, @"test_types_int32", @"ort");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorInt64 {
|
||||
std::array<int64_t, 5> outValues{std::numeric_limits<int64_t>::min(), 1, -2, 3, std::numeric_limits<int64_t>::max()};
|
||||
std::function<NSNumber *(int64_t value)> convert = [](int64_t value) { return [NSNumber numberWithLongLong:value]; };
|
||||
testCreateOutputTensorT<int64_t>(outValues, convert, JsTensorTypeLong, @"test_types_INT64", @"pb");
|
||||
}
|
||||
|
||||
- (void)testCreateOutputTensorString {
|
||||
std::array<std::string, 5> outValues{"a", "b", "c", "d", "e"};
|
||||
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[TensorHelperTest class]];
|
||||
NSString *dataPath = [bundle pathForResource:@"test_types_STRING" ofType:@"pb"];
|
||||
|
||||
std::unique_ptr<Ort::Env> ortEnv{new Ort::Env(ORT_LOGGING_LEVEL_INFO, "Default")};
|
||||
Ort::SessionOptions sessionOptions;
|
||||
std::unique_ptr<Ort::Session> session{new Ort::Session(*ortEnv, [dataPath UTF8String], sessionOptions)};
|
||||
|
||||
Ort::AllocatorWithDefaultOptions ortAllocator;
|
||||
std::vector<Ort::MemoryAllocation> allocations;
|
||||
|
||||
std::vector<const char *> inputNames;
|
||||
inputNames.reserve(session->GetInputCount());
|
||||
for (size_t i = 0; i < session->GetInputCount(); ++i) {
|
||||
auto inputName = session->GetInputName(i, ortAllocator);
|
||||
allocations.emplace_back(ortAllocator, inputName, strlen(inputName) + 1);
|
||||
inputNames.emplace_back(inputName);
|
||||
}
|
||||
|
||||
std::vector<const char *> outputNames;
|
||||
outputNames.reserve(session->GetOutputCount());
|
||||
for (size_t i = 0; i < session->GetOutputCount(); ++i) {
|
||||
auto outputName = session->GetOutputName(i, ortAllocator);
|
||||
allocations.emplace_back(ortAllocator, outputName, strlen(outputName) + 1);
|
||||
outputNames.emplace_back(outputName);
|
||||
}
|
||||
|
||||
NSMutableDictionary *inputTensorMap = [NSMutableDictionary dictionary];
|
||||
|
||||
// dims
|
||||
NSArray *dims = @[ [NSNumber numberWithLong:1], [NSNumber numberWithLong:outValues.size()] ];
|
||||
inputTensorMap[@"dims"] = dims;
|
||||
|
||||
// type
|
||||
inputTensorMap[@"type"] = JsTensorTypeString;
|
||||
|
||||
// data
|
||||
NSMutableArray *data = [NSMutableArray array];
|
||||
for (auto value : outValues) {
|
||||
[data addObject:[NSString stringWithUTF8String:value.c_str()]];
|
||||
}
|
||||
inputTensorMap[@"data"] = data;
|
||||
|
||||
Ort::Value inputTensor = [TensorHelper createInputTensor:inputTensorMap
|
||||
ortAllocator:ortAllocator
|
||||
allocations:allocations];
|
||||
|
||||
std::vector<Ort::Value> feeds;
|
||||
feeds.emplace_back(std::move(inputTensor));
|
||||
|
||||
Ort::RunOptions runOptions;
|
||||
auto output = session->Run(runOptions, inputNames.data(), feeds.data(), inputNames.size(), outputNames.data(),
|
||||
outputNames.size());
|
||||
|
||||
NSDictionary *resultMap = [TensorHelper createOutputTensor:outputNames values:output];
|
||||
XCTAssertTrue([[resultMap objectForKey:@"output"] isEqualToDictionary:inputTensorMap]);
|
||||
testCreateOutputTensorT<int64_t>(outValues, convert, JsTensorTypeLong, @"test_types_int64", @"ort");
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,16 +1,25 @@
|
|||
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||
|
||||
platform :ios, '10.0'
|
||||
platform :ios, '13.0'
|
||||
|
||||
target 'OnnxruntimeModule' do
|
||||
def shared
|
||||
config = use_native_modules!
|
||||
|
||||
use_react_native!(:path => config["reactNativePath"])
|
||||
|
||||
# Comment the next line if you don't want to use dynamic frameworks
|
||||
use_frameworks!
|
||||
|
||||
pod 'onnxruntime-mobile-c', :podspec => '../onnxruntime-mobile-c.podspec'
|
||||
|
||||
inherit! :search_paths
|
||||
end
|
||||
|
||||
target 'OnnxruntimeModule' do
|
||||
shared
|
||||
end
|
||||
|
||||
target 'OnnxruntimeModuleTest' do
|
||||
config = use_native_modules!
|
||||
|
||||
use_react_native!(:path => config["reactNativePath"])
|
||||
shared
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#define TensorHelper_h
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "onnxruntime_cxx_api.h"
|
||||
#import <onnxruntime/onnxruntime_cxx_api.h>
|
||||
|
||||
@interface TensorHelper : NSObject
|
||||
|
||||
|
|
|
|||
21
js/react_native/onnxruntime-mobile-c.podspec
Normal file
21
js/react_native/onnxruntime-mobile-c.podspec
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require "json"
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = "onnxruntime-mobile-c"
|
||||
spec.version = package["version"]
|
||||
spec.summary = "ONNX Runtime C/C++ Package"
|
||||
spec.description = <<-DESC
|
||||
ONNX Runtime C/C++ framework pod.
|
||||
DESC
|
||||
|
||||
spec.homepage = "https://github.com/microsoft/onnxruntime"
|
||||
spec.license = { :type => 'MIT' }
|
||||
spec.authors = { "ONNX Runtime" => "onnxruntime@microsoft.com" }
|
||||
spec.platform = :ios, '13.0'
|
||||
# if you are going to use a file as the spec.source, add 'file:' before your file path
|
||||
spec.source = { :http => 'file:' + __dir__ + '/local_pods/onnxruntime-mobile-c.zip' }
|
||||
spec.vendored_frameworks = 'onnxruntime.framework'
|
||||
spec.source_files = 'onnxruntime.framework/Headers/*.h'
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
require "json"
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "onnxruntime-react-native.iphoneos"
|
||||
s.version = package["version"]
|
||||
s.summary = package["description"]
|
||||
s.homepage = package["homepage"]
|
||||
s.license = package["license"]
|
||||
s.authors = package["author"]
|
||||
|
||||
s.platforms = { :ios => "10.0" }
|
||||
s.source = { :git => "https://github.com/Microsoft/onnxruntime.git", :tag => "#{s.version}" }
|
||||
|
||||
|
||||
s.source_files = "ios/*.{h,mm}", "ios/Libraries/**/*.h"
|
||||
|
||||
s.dependency "React-Core"
|
||||
|
||||
s.subspec 'Onnxruntime' do |onnxruntime|
|
||||
onnxruntime.preserve_paths = 'ios/Libraries/onnxruntime/include/*.h'
|
||||
onnxruntime.vendored_libraries = 'ios/Libraries/onnxruntime/lib/iphoneos/libonnxruntime.1.7.0.dylib'
|
||||
onnxruntime.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Libraries/onnxruntime/include/**", 'LIBRARY_SEARCH_PATHS' => "${PODS_ROOT)/#{s.name}/Libraries/onnxruntime/lib/iphoneos/**" }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
require "json"
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "onnxruntime-react-native.iphonesimulator"
|
||||
s.version = package["version"]
|
||||
s.summary = package["description"]
|
||||
s.homepage = package["homepage"]
|
||||
s.license = package["license"]
|
||||
s.authors = package["author"]
|
||||
|
||||
s.platforms = { :ios => "10.0" }
|
||||
s.source = { :git => "https://github.com/Microsoft/onnxruntime.git", :tag => "#{s.version}" }
|
||||
|
||||
|
||||
s.source_files = "ios/*.{h,mm}", "ios/Libraries/**/*.h"
|
||||
|
||||
s.dependency "React-Core"
|
||||
|
||||
s.subspec 'Onnxruntime' do |onnxruntime|
|
||||
onnxruntime.preserve_paths = 'ios/Libraries/onnxruntime/include/*.h'
|
||||
onnxruntime.vendored_libraries = 'ios/Libraries/onnxruntime/lib/iphonesimulator/libonnxruntime.1.7.0.dylib'
|
||||
onnxruntime.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/Libraries/onnxruntime/include/**", 'LIBRARY_SEARCH_PATHS' => "${PODS_ROOT)/#{s.name}/Libraries/onnxruntime/lib/iphonesimulator/**" }
|
||||
end
|
||||
|
||||
end
|
||||
20
js/react_native/onnxruntime-react-native.podspec
Normal file
20
js/react_native/onnxruntime-react-native.podspec
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require "json"
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||||
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = "onnxruntime-react-native"
|
||||
spec.version = package["version"]
|
||||
spec.summary = package["description"]
|
||||
spec.homepage = package["homepage"]
|
||||
spec.license = package["license"]
|
||||
spec.authors = package["author"]
|
||||
|
||||
spec.platforms = { :ios => "13.0" }
|
||||
spec.source = { :git => "https://github.com/Microsoft/onnxruntime.git", :tag => "rel-#{spec.version}" }
|
||||
|
||||
spec.source_files = "ios/*.{h,mm}"
|
||||
|
||||
spec.dependency "React-Core"
|
||||
spec.dependency "onnxruntime-mobile-c"
|
||||
end
|
||||
|
|
@ -11,17 +11,14 @@
|
|||
"lib",
|
||||
"dist",
|
||||
"android",
|
||||
"ios",
|
||||
"onnxruntime-react-native.iphoneos.podspec",
|
||||
"onnxruntime-react-native.iphonesimulator.podspec",
|
||||
"!dist/typescript/example",
|
||||
"!android/build",
|
||||
"!ios/build",
|
||||
"!**/__tests__",
|
||||
"!**/__fixtures__",
|
||||
"!**/__mocks__",
|
||||
"!.gitignore",
|
||||
"!.placeholder"
|
||||
"ios/*.h",
|
||||
"ios/*.mm",
|
||||
"onnxruntime-react-native.podspec",
|
||||
"!dist/commonjs/*.js.map",
|
||||
"!dist/module/*.js.map",
|
||||
"!android/.gitignore",
|
||||
"!android/.idea",
|
||||
"!android/build"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
|
|
@ -42,7 +39,7 @@
|
|||
"ONNX Runtime"
|
||||
],
|
||||
"repository": "https://github.com/Microsoft/onnxruntime.git",
|
||||
"author": "hanbitmyths",
|
||||
"author": "ONNX Runtime",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/onnxruntime/issues"
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"build_abis": [
|
||||
"armeabi-v7a",
|
||||
"arm64-v8a",
|
||||
"x86",
|
||||
"x86_64"
|
||||
],
|
||||
"android_min_sdk_version": 24,
|
||||
"android_target_sdk_version": 29,
|
||||
"build_params": [
|
||||
"--android",
|
||||
"--parallel",
|
||||
"--cmake_generator=Ninja",
|
||||
"--build_java",
|
||||
"--build_shared_lib",
|
||||
"--disable_rtti",
|
||||
"--disable_ml_ops",
|
||||
"--skip_tests"
|
||||
]
|
||||
}
|
||||
|
|
@ -162,7 +162,9 @@ static void TestInference(Ort::Env& env, const std::basic_string<ORTCHAR_T>& mod
|
|||
|
||||
static constexpr PATH_TYPE MODEL_URI = TSTR("testdata/mul_1.onnx");
|
||||
static constexpr PATH_TYPE MATMUL_MODEL_URI = TSTR("testdata/matmul_1.onnx");
|
||||
#ifndef ORT_NO_RTTI
|
||||
static constexpr PATH_TYPE SEQUENCE_MODEL_URI = TSTR("testdata/sequence_length.onnx");
|
||||
#endif
|
||||
static constexpr PATH_TYPE CUSTOM_OP_MODEL_URI = TSTR("testdata/foo_1.onnx");
|
||||
static constexpr PATH_TYPE CUSTOM_OP_LIBRARY_TEST_MODEL_URI = TSTR("testdata/custom_op_library/custom_op_test.onnx");
|
||||
static constexpr PATH_TYPE OVERRIDABLE_INITIALIZER_MODEL_URI = TSTR("testdata/overridable_initializer.onnx");
|
||||
|
|
@ -1494,4 +1496,4 @@ TEST(CApiTest, ConfigureCudaArenaAndDemonstrateMemoryArenaShrinkage) {
|
|||
// (Memory arena for the CPU should not have been disabled)
|
||||
// run_option.AddConfigEntry(kOrtRunOptionsConfigEnableMemoryArenaShrinkage, "cpu:0;gpu:0");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue