1
1
# RedisAI Commands
2
2
3
- ## AI.TENSORSET - set a tensor
4
- > Stores a tensor of defined type with shape given by shape1..shapeN
3
+ ## AI.TENSORSET
4
+
5
+ Set a tensor.
6
+
7
+ Stores a tensor of defined type with shape given by shape1..shapeN.
5
8
6
9
``` sql
7
10
AI .TENSORSET tensor_key data_type shape1 shape2 ... [BLOB data | VALUES val1 val2 ...]
8
11
```
9
12
10
- * tensor_key - key for storing the tensor
11
- * data_type - numeric data type of tensor elements, one of FLOAT, DOUBLE, INT8, INT16, INT32, INT64, UINT8, UINT16
12
- * shape - shape of the tensor, i.e. how many elements for each axis
13
+ * tensor_key - Key for storing the tensor
14
+ * data_type - Numeric data type of tensor elements, one of FLOAT, DOUBLE, INT8, INT16, INT32, INT64, UINT8, UINT16
15
+ * shape - Shape of the tensor, that is how many elements for each axis
13
16
14
17
Optional args:
18
+
15
19
* BLOB data - provide tensor content as a binary buffer
16
20
* VALUES val1 val2 - provide tensor content as individual values
17
21
18
22
> If no BLOB or VALUES are specified, the tensor is allocated but not initialized to any value.
19
23
20
- ### Example
24
+ ### TENSORSET Example
25
+
21
26
> Set a 2x2 tensor at ` foo `
22
27
> 1 2
23
28
> 3 4
@@ -26,36 +31,43 @@ Optional args:
26
31
AI .TENSORSET foo FLOAT 2 2 VALUES 1 2 3 4
27
32
```
28
33
29
- ## AI.TENSORGET - get a tensor
34
+ ## AI.TENSORGET
35
+
36
+ Get a tensor.
37
+
30
38
``` sql
31
39
AI .TENSORGET tensor_key [BLOB | VALUES | META]
32
40
```
33
41
34
- * tensor_key - key for the tensor
35
- * BLOB - return tensor content as a binary buffer
36
- * VALUES - return tensor content as a list of values
37
- * META - only return tensor meta data (datat type and shape)
42
+ * tensor_key - Key for the tensor
43
+ * BLOB - Return tensor content as a binary buffer
44
+ * VALUES - Return tensor content as a list of values
45
+ * META - Only return tensor meta data (datat type and shape)
38
46
39
- ### Example
40
- > Get binary data for tensor at ` foo ` . Meta data is also returned.
47
+ ### TENSORGET Example
48
+
49
+ Get binary data for tensor at ` foo ` . Meta data is also returned.
41
50
42
51
``` sql
43
52
AI .TENSORGET foo BLOB
44
53
```
45
54
46
- ## AI.MODELSET - set a model
55
+ ## AI.MODELSET
56
+
57
+ Set a model.
58
+
47
59
``` sql
48
60
AI .MODELSET model_key backend device [INPUTS name1 name2 ... OUTPUTS name1 name2 ...] model_blob
49
61
```
50
62
51
- * model_key - key for storing the model
52
- * backend - the backend corresponding to the model being set. Allowed values: ` TF ` , ` TORCH ` .
53
- * device - device where the model is loaded and where the computation will run. Allowed values: ` CPU ` , ` GPU ` .
54
- * INPUTS name1 name2 ... - name of the nodes in the provided graph corresponding to inputs [ ` TF ` backend only]
55
- * OUTPUTS name1 name2 ... - name of the nodes in the provided graph corresponding to outputs [ ` TF ` backend only]
56
- * model_blob - binary buffer containing the model protobuf saved from a supported backend
63
+ * model_key - Key for storing the model
64
+ * backend - The backend corresponding to the model being set. Allowed values: ` TF ` , ` TORCH ` .
65
+ * device - Device where the model is loaded and where the computation will run. Allowed values: ` CPU ` , ` GPU ` .
66
+ * INPUTS name1 name2 ... - Name of the nodes in the provided graph corresponding to inputs [ ` TF ` backend only]
67
+ * OUTPUTS name1 name2 ... - Name of the nodes in the provided graph corresponding to outputs [ ` TF ` backend only]
68
+ * model_blob - Binary buffer containing the model protobuf saved from a supported backend
57
69
58
- ### Example
70
+ ### MODELSET Example
59
71
60
72
``` sql
61
73
AI .MODELSET resnet18 TORCH GPU < foo .pt
@@ -65,49 +77,56 @@ AI.MODELSET resnet18 TORCH GPU < foo.pt
65
77
AI .MODELSET resnet18 TF CPU INPUTS in1 OUTPUTS linear4 < foo .pt
66
78
```
67
79
68
- ## AI.MODELGET - get a model
80
+ ## AI.MODELGET
81
+
82
+ Get a model.
69
83
70
84
``` sql
71
85
AI .MODELGET model_key
72
86
```
73
87
74
- * model_key - key for the model
88
+ * model_key - Key for the model
89
+
90
+ The command returns the model as serialized by the backend, that is a string containing a protobuf.
91
+
75
92
76
- > The command returns the model as serialized by the backend (i.e. a string containing a protobuf)
93
+ ## AI.MODELRUN
77
94
95
+ Run a model.
78
96
79
- ## AI.MODELRUN - run a model
80
97
``` sql
81
98
AI .MODELRUN model_key INPUTS input_key1 ... OUTPUTS output_key1 ...
82
99
```
83
100
84
- * model_key - key for the model
85
- * INPUTS input_key1 ... - keys for tensors to use as inputs
86
- * OUTPUTS output_key2 ... - keys for storing output tensors
101
+ * model_key - Key for the model
102
+ * INPUTS input_key1 ... - Keys for tensors to use as inputs
103
+ * OUTPUTS output_key2 ... - Keys for storing output tensors
87
104
88
- > The request is queued and evaded asynchronously from a separate thread. The client blocks until the computation finishes.
105
+ The request is queued and evaded asynchronously from a separate thread. The client blocks until the computation finishes.
89
106
90
- > If needed, input tensors are copied to the device specified in ` AI.MODELSET ` before execution.
107
+ If needed, input tensors are copied to the device specified in ` AI.MODELSET ` before execution.
91
108
92
- ### Example
109
+ ### MODELRUN Example
93
110
94
111
``` sql
95
112
AI .MODELRUN resnet18 INPUTS image12 OUTPUTS label12
96
113
```
97
114
115
+ ## AI.SCRIPTSET
116
+
117
+ Set a script.
98
118
99
- ## AI.SCRIPTSET - set a script
100
119
``` sql
101
120
AI .SCRIPTSET script_key device script_source
102
121
```
103
122
104
- * script_key - key for storing the script
105
- * device - the device where the script will execute
106
- * script_source - a string containing [ TorchScript] ( https://pytorch.org/docs/stable/jit.html ) source code
123
+ * script_key - Key for storing the script
124
+ * device - The device where the script will execute
125
+ * script_source - A string containing [ TorchScript] ( https://pytorch.org/docs/stable/jit.html ) source code
107
126
108
- ### Example
127
+ ### SCRIPTSET Example
109
128
110
- > Given addtwo.txt as:
129
+ Given addtwo.txt as:
111
130
112
131
``` python
113
132
def addtwo (a , b ):
@@ -118,36 +137,38 @@ def addtwo(a, b):
118
137
AI .SCRIPTSET addscript GPU < addtwo .txt
119
138
```
120
139
121
- ## AI.SCRIPTGET - get a script
140
+ ## AI.SCRIPTGET
141
+
142
+ Get a script.
122
143
123
144
``` sql
124
145
AI .SCRIPTGET script_key
125
146
```
126
147
127
148
* script_key - key for the script
128
149
129
- ### Example
150
+ ### SCRIPTGET Example
130
151
131
152
``` sql
132
153
AI .SCRIPTGET addscript
133
154
```
134
155
156
+ ## AI.SCRIPTRUN
135
157
136
- ## AI.SCRIPTRUN - run a script
158
+ Run a script.
137
159
138
160
``` sql
139
161
AI .SCRIPTRUN script_key fn_name INPUTS input_key1 ... OUTPUTS output_key1 ...
140
162
```
141
163
142
- * tensor_key - key for the script
143
- * fn_name - name of the function to execute
144
- * INPUTS input_key1 ... - keys for tensors to use as inputs
145
- * OUTPUTS output_key1 ... - keys for storing output tensors
146
-
147
- > If needed, input tensors are copied to the device specified in ` AI.SCRIPTSET ` before execution.
164
+ * tensor_key - Key for the script
165
+ * fn_name - Name of the function to execute
166
+ * INPUTS input_key1 ... - Keys for tensors to use as inputs
167
+ * OUTPUTS output_key1 ... - Keys for storing output tensors
148
168
169
+ If needed, input tensors are copied to the device specified in ` AI.SCRIPTSET ` before execution.
149
170
150
- ### Example
171
+ ### SCRIPTRUN Example
151
172
152
173
``` sql
153
174
AI .SCRIPTRUN addscript addtwo INPUTS a b OUTPUTS c
0 commit comments