File tree Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.5.0 (Jul 17, 2020)
2
+ * Expose interpreter's address
3
+ * Create interpreter by address.
4
+
1
5
## 0.4.2 (Jul 6, 2020)
2
6
* Optimize getTensors and getTensor by Index
3
7
* Update readme
Original file line number Diff line number Diff line change 3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
5
import 'dart:io' ;
6
+ import 'dart:isolate' ;
6
7
import 'dart:typed_data' ;
7
8
8
9
import 'package:flutter/services.dart' ;
@@ -20,6 +21,7 @@ final int64FileName = 'int64.bin';
20
21
final multiInputFileName = 'multi_add.bin' ;
21
22
final addFileName = 'add.bin' ;
22
23
24
+ //flutter drive --driver=test_driver/tflite_flutter_plugin_example_e2e_test.dart test/tflite_flutter_plugin_example_e2e.dart
23
25
void main () {
24
26
E2EWidgetsFlutterBinding .ensureInitialized ();
25
27
@@ -45,6 +47,13 @@ void main() {
45
47
interpreter.close ();
46
48
});
47
49
50
+ test ('interpreter from address' , () async {
51
+ final interpreter = await tfl.Interpreter .fromAsset ('test/$dataFileName ' );
52
+ final interpreter2 = tfl.Interpreter .fromAddress (interpreter.address);
53
+ interpreter.close ();
54
+ interpreter2.close ();
55
+ });
56
+
48
57
group ('interpreter options' , () {
49
58
test ('default' , () async {
50
59
final dataFile = await getFile (dataFileName);
Original file line number Diff line number Diff line change @@ -127,6 +127,17 @@ class Interpreter {
127
127
return rawBytes;
128
128
}
129
129
130
+ /// Creates interpreter from an address.
131
+ ///
132
+ /// Typically used for passing interpreter between isolates.
133
+ factory Interpreter .fromAddress (int address,
134
+ {bool allocated: false , bool deleted: false }) {
135
+ final interpreter = Pointer <TfLiteInterpreter >.fromAddress (address);
136
+ return Interpreter ._(interpreter)
137
+ .._deleted = deleted
138
+ .._allocated = allocated;
139
+ }
140
+
130
141
/// Destroys the interpreter instance.
131
142
void close () {
132
143
checkState (! _deleted, message: 'Interpreter already deleted.' );
@@ -295,6 +306,13 @@ class Interpreter {
295
306
}
296
307
}
297
308
309
+ /// Returns the address to the interpreter
310
+ int get address => _interpreter.address;
311
+
312
+ bool get isAllocated => _allocated;
313
+
314
+ bool get isDeleted => _deleted;
315
+
298
316
//TODO: (JAVA) void modifyGraphWithDelegate(Delegate delegate)
299
317
//TODO: (JAVA) void resetVariableTensors()
300
318
Original file line number Diff line number Diff line change 1
1
name : tflite_flutter
2
2
description : TensorFlow Lite Flutter plugin provides easy, flexible and fast Dart API to integrate TFLite models in flutter apps.
3
- version : 0.4.2
3
+ version : 0.5.0
4
4
homepage : https://github.com/am15h/tflite_flutter_plugin
5
5
6
6
environment :
7
7
sdk : " >=2.6.0 <3.0.0"
8
+ flutter : " >=1.12.0 <2.0.0"
8
9
9
10
dependencies :
10
11
flutter :
@@ -29,8 +30,12 @@ flutter:
29
30
# be modified. They are used by the tooling to maintain consistency when
30
31
# adding or updating assets for this project.
31
32
plugin :
32
- androidPackage : com.tfliteflutter.tflite_flutter_plugin
33
- pluginClass : TfliteFlutterPlugin
33
+ platforms :
34
+ android :
35
+ package : com.tfliteflutter.tflite_flutter_plugin
36
+ pluginClass : TfliteFlutterPlugin
37
+ ios :
38
+ pluginClass : TfliteFlutterPlugin
34
39
35
40
# To add assets to your plugin package, add an assets section, like this:
36
41
# assets:
You can’t perform that action at this time.
0 commit comments