This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
tensor.dart
99 lines (87 loc) · 3.81 KB
/
tensor.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'dlib.dart';
import 'types.dart';
/// Returns the type of a tensor element.
TfLiteType TfLiteTensorType(Pointer<TfLiteTensor> t) =>
TfLiteType.values[_TfLiteTensorType(t)];
int Function(Pointer<TfLiteTensor>) _TfLiteTensorType = tflitelib
.lookup<NativeFunction<_TfLiteTensorType_native_t>>('TfLiteTensorType')
.asFunction();
typedef _TfLiteTensorType_native_t = /*TfLiteType*/ Int32 Function(
Pointer<TfLiteTensor>);
/// Returns the number of dimensions that the tensor has.
int Function(Pointer<TfLiteTensor>) TfLiteTensorNumDims = tflitelib
.lookup<NativeFunction<_TfLiteTensorNumDims_native_t>>(
'TfLiteTensorNumDims')
.asFunction();
typedef _TfLiteTensorNumDims_native_t = Int32 Function(Pointer<TfLiteTensor>);
/// Returns the length of the tensor in the 'dim_index' dimension.
///
/// REQUIRES: 0 <= dim_index < TFLiteTensorNumDims(tensor)
int Function(Pointer<TfLiteTensor> tensor, int dim_index) TfLiteTensorDim =
tflitelib
.lookup<NativeFunction<_TfLiteTensorDim_native_t>>('TfLiteTensorDim')
.asFunction();
typedef _TfLiteTensorDim_native_t = Int32 Function(
Pointer<TfLiteTensor> tensor, Int32 dim_index);
/// Returns the size of the underlying data in bytes.
int Function(Pointer<TfLiteTensor>) TfLiteTensorByteSize = tflitelib
.lookup<NativeFunction<_TfLiteTensorByteSize_native_t>>(
'TfLiteTensorByteSize')
.asFunction();
typedef _TfLiteTensorByteSize_native_t = Int32 Function(Pointer<TfLiteTensor>);
/// Returns a pointer to the underlying data buffer.
///
/// NOTE: The result may be null if tensors have not yet been allocated, e.g.,
/// if the Tensor has just been created or resized and `TfLiteAllocateTensors()`
/// has yet to be called, or if the output tensor is dynamically sized and the
/// interpreter hasn't been invoked.
Pointer<Void> Function(Pointer<TfLiteTensor>) TfLiteTensorData = tflitelib
.lookup<NativeFunction<_TfLiteTensorData_native_t>>('TfLiteTensorData')
.asFunction();
typedef _TfLiteTensorData_native_t = Pointer<Void> Function(
Pointer<TfLiteTensor>);
/// Returns the (null-terminated) name of the tensor.
Pointer<Utf8> Function(Pointer<TfLiteTensor>) TfLiteTensorName = tflitelib
.lookup<NativeFunction<_TfLiteTensorName_native_t>>('TfLiteTensorName')
.asFunction();
typedef _TfLiteTensorName_native_t = Pointer<Utf8> Function(
Pointer<TfLiteTensor>);
/// Copies from the provided input buffer into the tensor's buffer.
///
/// REQUIRES: input_data_size == TfLiteTensorByteSize(tensor)
/*TfLiteStatus*/ int Function(
Pointer<TfLiteTensor> tensor,
Pointer<Void> input_data,
int input_data_size,
) TfLiteTensorCopyFromBuffer = tflitelib
.lookup<NativeFunction<_TfLiteTensorCopyFromBuffer_native_t>>(
'TfLiteTensorCopyFromBuffer')
.asFunction();
typedef _TfLiteTensorCopyFromBuffer_native_t = /*TfLiteStatus*/ Int32 Function(
Pointer<TfLiteTensor> tensor,
Pointer<Void> input_data,
Int32 input_data_size,
);
/// Copies to the provided output buffer from the tensor's buffer.
///
/// REQUIRES: output_data_size == TfLiteTensorByteSize(tensor)
/*TfLiteStatus*/ int Function(
Pointer<TfLiteTensor> tensor,
Pointer<Void> output_data,
int output_data_size,
) TfLiteTensorCopyToBuffer = tflitelib
.lookup<NativeFunction<_TfLiteTensorCopyToBuffer_native_t>>(
'TfLiteTensorCopyToBuffer')
.asFunction();
typedef _TfLiteTensorCopyToBuffer_native_t = /*TfLiteStatus*/ Int32 Function(
Pointer<TfLiteTensor> tensor,
Pointer<Void> output_data,
Int32 output_data_size,
);
// Unimplemented functions:
// TfLiteTensorQuantizationParams