Skip to content

Commit 9371da8

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Java library (#1869)
Summary: Pull Request resolved: #1869 The demo app can be built with internal build system after this. Reviewed By: mcr229 Differential Revision: D53240967 fbshipit-source-id: 64966c5017cc4f8ee7e841e3481641320715d53b
1 parent 02cbaf2 commit 9371da8

File tree

11 files changed

+1329
-12
lines changed

11 files changed

+1329
-12
lines changed

examples/demo-apps/android/ExecuTorchDemo/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools">
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.executorchdemo">
5+
6+
<uses-sdk android:minSdkVersion="19"
7+
android:targetSdkVersion="34"
8+
android:maxSdkVersion="40" />
49

510
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
6-
<uses-permission android:name="android.permission.CAMERA" />
711

812
<application
913
android:allowBackup="true"
@@ -15,7 +19,7 @@
1519
android:supportsRtl="true"
1620
android:theme="@style/Theme.ExecuTorchDemo"
1721
android:extractNativeLibs="true"
18-
tools:targetApi="31">
22+
tools:targetApi="34">
1923

2024
<uses-native-library android:name="libexecutorchdemo.so"
2125
android:required="false"/>

examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/ClassificationActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import android.widget.Button;
1919
import android.widget.ImageView;
2020
import android.widget.TextView;
21-
import com.example.executorchdemo.executor.EValue;
22-
import com.example.executorchdemo.executor.Module;
23-
import com.example.executorchdemo.executor.Tensor;
24-
import com.example.executorchdemo.executor.TensorImageUtils;
2521
import java.io.IOException;
22+
import org.pytorch.executorch.EValue;
23+
import org.pytorch.executorch.Module;
24+
import org.pytorch.executorch.Tensor;
25+
import org.pytorch.executorch.TensorImageUtils;
2626

2727
public class ClassificationActivity extends Activity implements Runnable {
2828

examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/MainActivity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
import android.widget.Button;
2222
import android.widget.ImageView;
2323
import android.widget.ProgressBar;
24-
import com.example.executorchdemo.executor.EValue;
25-
import com.example.executorchdemo.executor.Module;
26-
import com.example.executorchdemo.executor.Tensor;
27-
import com.example.executorchdemo.executor.TensorImageUtils;
2824
import java.io.File;
2925
import java.io.FileOutputStream;
3026
import java.io.IOException;
3127
import java.io.InputStream;
3228
import java.io.OutputStream;
3329
import java.util.Objects;
30+
import org.pytorch.executorch.EValue;
31+
import org.pytorch.executorch.Module;
32+
import org.pytorch.executorch.Tensor;
33+
import org.pytorch.executorch.TensorImageUtils;
3434

3535
public class MainActivity extends Activity implements Runnable {
3636
private ImageView mImageView;

examples/demo-apps/android/ExecuTorchDemo/app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<item name="colorAccent">@color/colorAccent</item>
88
</style>
99

10-
</resources>
10+
</resources>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
package org.pytorch.executorch;
10+
11+
/** Codes representing tensor data types. */
12+
public enum DType {
13+
// NOTE: "jniCode" must be kept in sync with scalar_type.h.
14+
// NOTE: Never serialize "jniCode", because it can change between releases.
15+
16+
/** Code for dtype torch::executor::Byte */
17+
UINT8(0),
18+
/** Code for dtype torch::executor::Char */
19+
INT8(1),
20+
/** Code for dtype torch::executor::Short */
21+
INT16(2),
22+
/** Code for dtype torch::executor::Int */
23+
INT32(3),
24+
/** Code for dtype torch::executor::Long */
25+
INT64(4),
26+
/** Code for dtype torch::executor::Half */
27+
HALF(5),
28+
/** Code for dtype torch::executor::Float */
29+
FLOAT(6),
30+
/** Code for dtype torch::executor::Double */
31+
DOUBLE(7),
32+
/** Code for dtype torch::executor::ComplexHalf */
33+
COMPLEX_HALF(8),
34+
/** Code for dtype torch::executor::ComplexFloat */
35+
COMPLEX_FLOAT(9),
36+
/** Code for dtype torch::executor::ComplexDouble */
37+
COMPLEX_DOUBLE(10),
38+
/** Code for dtype torch::executor::Bool */
39+
BOOL(11),
40+
/** Code for dtype torch::executor::QInt8 */
41+
QINT8(12),
42+
/** Code for dtype torch::executor::QUInt8 */
43+
QUINT8(13),
44+
/** Code for dtype torch::executor::QInt32 */
45+
QINT32(14),
46+
/** Code for dtype torch::executor::BFloat16 */
47+
BFLOAT16(15),
48+
/** Code for dtype torch::executor::QUInt4x2 */
49+
QINT4X2(16),
50+
/** Code for dtype torch::executor::QUInt2x4 */
51+
QINT2X4(17),
52+
/** Code for dtype torch::executor::Bits1x8 */
53+
BITS1X8(18),
54+
/** Code for dtype torch::executor::Bits2x4 */
55+
BITS2X4(19),
56+
/** Code for dtype torch::executor::Bits4x2 */
57+
BITS4X2(20),
58+
/** Code for dtype torch::executor::Bits8 */
59+
BITS8(21),
60+
/** Code for dtype torch::executor::Bits16 */
61+
BITS16(22),
62+
;
63+
64+
final int jniCode;
65+
66+
DType(int jniCode) {
67+
this.jniCode = jniCode;
68+
}
69+
}

0 commit comments

Comments
 (0)