-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathTFTensorOperation.swift
137 lines (121 loc) · 5.09 KB
/
TFTensorOperation.swift
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// A protocol for a tensor operation.
public protocol TensorOperation {
// We use functions instead of fields to give freedom in the
// representation for the conforming types.
init(_ name: String, _ outputCount: Int)
func updateAttribute(_ name: String, _ value: Bool)
func updateAttribute(_ name: String, _ value: Int)
func updateAttribute(_ name: String, _ value: Int32)
func updateAttribute(_ name: String, _ value: Int64)
func updateAttribute(_ name: String, _ value: Float)
func updateAttribute(_ name: String, _ value: Double)
func updateAttribute(_ name: String, _ value: String)
func updateAttribute(_ name: String, _ value: [Bool])
func updateAttribute(_ name: String, _ value: [Int])
func updateAttribute(_ name: String, _ value: [Int32])
func updateAttribute(_ name: String, _ value: [Int64])
func updateAttribute(_ name: String, _ value: [Float])
func updateAttribute(_ name: String, _ value: [Double])
func updateAttribute(_ name: String, _ value: [String])
// TODO(https://bugs.swift.org/browse/TF-522): When we are able to
// use opaque return types everywhere, we should add an
// associatedtype requirement and add the following methods so that
// we can work with non-tensorflow backends if neeeded.
//
// associatedtype TensorValueHandle
//
// func addInput(_ input : TensorValueHandle)
// func evaluate() -> ([TensorValueHandle])
}
// A protocol for a tensor operation in TensorFlow library.
public protocol TFTensorOperation : TensorOperation {
func addInput<Scalar: TensorFlowScalar>(_ input: Tensor<Scalar>)
func addInput(_ input: StringTensor)
func addInput(_ input: VariantHandle)
func addInput(_ input: ResourceHandle)
func addInputList<T: TensorArrayProtocol>(_ input: T)
func updateAttribute(_ name: String, _ value: TensorDataType)
func updateAttribute(_ name: String, _ value: TensorShape)
func updateAttribute(_ name: String, _ value: TensorShape?)
func updateAttribute(_ name: String, _ value: [TensorDataType])
func updateAttribute(_ name: String, _ value: [TensorShape])
func updateAttribute(_ name: String, _ value: [TensorShape?])
func updateAttribute<In: TensorGroup, Out: TensorGroup>(
_ name: String, _ value: (In) -> Out)
func execute()
func execute<T0 : TensorArrayProtocol>(
_ count0: Int
) -> (T0)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int
) -> (T0, T1)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int
) -> (T0, T1, T2)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int
) -> (T0, T1, T2, T3)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int
) -> (T0, T1, T2, T3, T4)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int
) -> (T0, T1, T2, T3, T4, T5)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int
) -> (T0, T1, T2, T3, T4, T5, T6)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol, T8 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int,
_ count8: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8)
func execute<T0 : TensorArrayProtocol, T1 : TensorArrayProtocol, T2 : TensorArrayProtocol, T3 : TensorArrayProtocol, T4 : TensorArrayProtocol, T5 : TensorArrayProtocol, T6 : TensorArrayProtocol, T7 : TensorArrayProtocol, T8 : TensorArrayProtocol, T9 : TensorArrayProtocol>(
_ count0: Int,
_ count1: Int,
_ count2: Int,
_ count3: Int,
_ count4: Int,
_ count5: Int,
_ count6: Int,
_ count7: Int,
_ count8: Int,
_ count9: Int
) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
}