You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor tests: use the new commands instead of the deprecated ones. Use "tests_commands" to test the new commands syntax (not for a specific backend), and test the deprecated commands only in "test_deprecated".
Copy file name to clipboardExpand all lines: docs/commands.md
+27-13Lines changed: 27 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,15 +152,15 @@ redis> AI.TENSORGET mytensor META BLOB
152
152
!!! important "Using `BLOB` is preferable to `VALUES`"
153
153
While it is possible to get the tensor as binary data or numerical values, it is recommended that you use the `BLOB` option. It requires fewer resources and performs better compared to returning the values discretely.
154
154
155
-
## AI.MODELSET
156
-
The **`AI.MODELSET`**commands stores a model as the value of a key.
155
+
## AI.MODELSTORE
156
+
The **`AI.MODELSTORE`**command stores a model as the value of a key.
157
157
158
158
**Redis API**
159
159
160
160
```
161
-
AI.MODELSET <key> <backend> <device>
162
-
[TAG tag] [BATCHSIZE n [MINBATCHSIZE m]]
163
-
[INPUTS <name> ...] [OUTPUTS name ...] BLOB <model>
161
+
AI.MODELSTORE <key> <backend> <device>
162
+
[TAG tag] [BATCHSIZE n [MINBATCHSIZE m [MINBATCHTIMEOUT t]]]
***GPU:0**, ..., **GPU:n**: a specific GPU device on a multi-GPU system
178
178
***TAG**: an optional string for tagging the model such as a version number or any arbitrary identifier
179
-
***BATCHSIZE**: when provided with an `n` that is greater than 0, the engine will batch incoming requests from multiple clients that use the model with input tensors of the same shape. When `AI.MODELRUN` is called the requests queue is visited and input tensors from compatible requests are concatenated along the 0th (batch) dimension until `n` is exceeded. The model is then run for the entire batch and the results are unpacked back to the individual requests unblocking their respective clients. If the batch size of the inputs to of first request in the queue exceeds `BATCHSIZE`, the request is served immediately (default value: 0).
180
-
***MINBATCHSIZE**: when provided with an `m` that is greater than 0, the engine will postpone calls to `AI.MODELRUN` until the batch's size had reached `m`. In this case, note that requests for which `m` is not reached will hang indefinitely (default value: 0), unless `MINBATCHTIMEOUT` is provided.
181
-
***MINBATCHTIMEOUT**: when provided with a `t` (expressed in milliseconds) that is greater than 0, the engine will trigger a run even though `MINBATCHSIZE` has not been reached after `t` milliseconds from the time a `MODELRUN` (or the enclosing `DAGRUN`) is enqueued. This only applies to cases where both `BATCHSIZE` and `MINBATCHSIZE` are greater than 0.
182
-
***INPUTS**: one or more names of the model's input nodes (applicable only for TensorFlow models)
183
-
***OUTPUTS**: one or more names of the model's output nodes (applicable only for TensorFlow models)
179
+
***BATCHSIZE**: when provided with an `n` that is greater than 0, the engine will batch incoming requests from multiple clients that use the model with input tensors of the same shape. When `AI.MODELEXECUTE` (or `AI.MODELRUN`) is called the requests queue is visited and input tensors from compatible requests are concatenated along the 0th (batch) dimension until `n` is exceeded. The model is then run for the entire batch and the results are unpacked back to the individual requests unblocking their respective clients. If the batch size of the inputs to of first request in the queue exceeds `BATCHSIZE`, the request is served immediately (default value: 0).
180
+
***MINBATCHSIZE**: when provided with an `m` that is greater than 0, the engine will postpone calls to `AI.MODELEXECUTE` until the batch's size had reached `m`. In this case, note that requests for which `m` is not reached will hang indefinitely (default value: 0), unless `MINBATCHTIMEOUT` is provided.
181
+
***MINBATCHTIMEOUT**: when provided with a `t` (expressed in milliseconds) that is greater than 0, the engine will trigger a run even though `MINBATCHSIZE` has not been reached after `t` milliseconds from the time a `MODELEXECUTE` (or the enclosing `DAGRUN`) is enqueued. This only applies to cases where both `BATCHSIZE` and `MINBATCHSIZE` are greater than 0.
182
+
***INPUTS**: denotes that one or more names of the model's input nodes are following (applicable only for TensorFlow models)
183
+
***input_count**: a positive number that indicates the number of following input nodes.
184
+
***OUTPUTS**: denotes that one or more names of the model's output nodes are following (applicable only for TensorFlow models)
185
+
***output_count**: a positive number that indicates the number of following input nodes.
184
186
***model**: the Protobuf-serialized model. Since Redis supports strings up to 512MB, blobs for very large models need to be chunked, e.g. `BLOB chunk1 chunk2 ...`.
185
187
186
188
_Return_
@@ -192,10 +194,22 @@ A simple 'OK' string or an error.
192
194
This example shows to set a model 'mymodel' key using the contents of a local file with [`redis-cli`](https://redis.io/topics/cli). Refer to the [Clients Page](clients.md) for additional client choices that are native to your programming language:
193
195
194
196
```
195
-
$ cat resnet50.pb | redis-cli -x AI.MODELSET mymodel TF CPU TAG imagenet:5.0 INPUTS images OUTPUTS output BLOB
197
+
$ cat resnet50.pb | redis-cli -x AI.MODELSTORE mymodel TF CPU TAG imagenet:5.0 INPUTS 1 images OUTPUTS 1 output BLOB
196
198
OK
197
199
```
198
200
201
+
## AI.MODELSET
202
+
_This command is deprecated and will not be available in future versions. consider using AI.MODELSTORE command instead._
203
+
The **`AI.MODELSET`** command stores a model as the value of a key. The command's arguments and effect are both exactly the same as `AI.MODELEXECUTE` command, except that <input_count> and <output_count> arguments should not be specified for TF backend.
204
+
205
+
**Redis API**
206
+
207
+
```
208
+
AI.MODELSET <key> <backend> <device>
209
+
[TAG tag] [BATCHSIZE n [MINBATCHSIZE m [MNBATCHTIMEOUT t]]]
210
+
[INPUTS <name> ...] [OUTPUTS name ...] BLOB <model>
211
+
```
212
+
199
213
## AI.MODELGET
200
214
The **`AI.MODELGET`** command returns a model's metadata and blob stored as a key's value.
201
215
@@ -303,9 +317,9 @@ _Arguments_
303
317
304
318
***key**: the model's key name
305
319
***INPUTS**: denotes the beginning of the input tensors keys' list, followed by the number of inputs and one or more key names
306
-
***input_count**: A positive number that indicates the number of following input keys.
320
+
***input_count**: a positive number that indicates the number of following input keys.
307
321
***OUTPUTS**: denotes the beginning of the output tensors keys' list, followed by the number of outputs one or more key names
308
-
***output_count**: A positive number that indicates the number of output keys to follow.
322
+
***output_count**: a positive number that indicates the number of output keys to follow.
309
323
***TIMEOUT**: the time (in ms) after which the client is unblocked and a `TIMEDOUT` string is returned
Copy file name to clipboardExpand all lines: docs/intro.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,7 @@ RedisAI Tensors are used as inputs and outputs in the execution of models and sc
193
193
## Loading Models
194
194
A **Model** is a Deep Learning or Machine Learning frozen graph that was generated by some framework. The RedisAI Model data structure represents a DL/ML model that is stored in the database and can be run.
195
195
196
-
Models, like any other Redis and RedisAI data structures, are identified by keys. A Model's key is created using the [`AI.MODELSET` command](commands.md#aimodelset) and requires the graph payload serialized as protobuf for input.
196
+
Models, like any other Redis and RedisAI data structures, are identified by keys. A Model's key is created using the [`AI.MODELSTORE` command](commands.md#aimodelstore) and requires the graph payload serialized as protobuf for input.
197
197
198
198
In our examples, we'll use one of the graphs that RedisAI uses in its tests, namely 'graph.pb', which can be downloaded from [here](https://github.com/RedisAI/RedisAI/raw/master/tests/test_data/graph.pb). This graph was created using TensorFlow with [this script](https://github.com/RedisAI/RedisAI/blob/master/tests/test_data/tf-minimal.py).
199
199
@@ -214,13 +214,13 @@ redis-cli doesn't provide a way to read files' contents, so to load the model wi
Like most commands, `AI.MODELSET`'s first argument is a key's name, which is 'mymodel' in the example. The next two arguments are the model's DL/ML backend and the device it will be executed on. 'graph.pb' in the example is a TensorFlow graph and is denoted by `TF` argument. The model will be executed on the CPU as instructed by the `CPU` argument.
233
+
Like most commands, `AI.MODELSTORE`'s first argument is a key's name, which is 'mymodel' in the example. The next two arguments are the model's DL/ML backend and the device it will be executed on. 'graph.pb' in the example is a TensorFlow graph and is denoted by `TF` argument. The model will be executed on the CPU as instructed by the `CPU` argument.
234
234
235
-
TensorFlow models also require declaring the names of their inputs and outputs. The inputs for 'graph.pb' are called 'a' and 'b', whereas its single output is called 'c'. These names are provided as additional arguments after the 'INPUTS' and 'OUTPUTS' arguments, respectively.
235
+
TensorFlow models also require declaring the names of their inputs and outputs. The inputs for 'graph.pb' are called 'a' and 'b', whereas its single output is called 'c'. These names are provided as additional arguments after indicating 'INPUTS' along with the number of inputs to follow, and 'OUTPUTS' along with the number of outputs to follow, respectively.
236
236
237
237
## Running Models
238
-
Once a RedisAI Model key has been set with `AI.MODELSET` it can be run with any Tensor keys from the database as its input. The model's output, after it was executed, is stored in RedisAI Tensors as well.
238
+
Once a RedisAI Model key has been set with `AI.MODELSTORE` it can be run with any Tensor keys from the database as its input. The model's output, after it was executed, is stored in RedisAI Tensors as well.
239
239
240
240
The model stored at 'mymodel' expects two input tensors so we'll use the previously-create 'tA' and create another input tensor, $\begin{equation*} tB = \begin{bmatrix} 3 \\ 5 \end{bmatrix} \end{equation*}$, with the following command:
241
241
242
242
```
243
243
AI.TENSORSET tB FLOAT 2 VALUES 3 5
244
244
```
245
245
246
-
The model can now be run with the [`AI.MODELRUN` command](commands.md#aimodelrun) as follows:
246
+
The model can now be run with the [`AI.MODELEXECUTE` command](commands.md#aimodelexecute) as follows:
247
247
248
248
```
249
-
AI.MODELRUN mymodel INPUTS tA tB OUTPUTS tResult
249
+
AI.MODELEXECUTE mymodel INPUTS tA tB OUTPUTS tResult
127.0.0.1:6379> AI.MODELRUN mymodel INPUTS tA tB OUTPUTS tModel
259
+
127.0.0.1:6379> AI.MODELEXECUTE mymodel INPUTS 2 tA tB OUTPUTS 1 tModel
260
260
OK
261
261
```
262
262
263
-
The first argument to `AI.MODELRUN` is the name of the key at which the RedisAI Model is stored. The names of RedisAI Tensor keys that follow the `INPUTS`argument are used as input for the model. Similarly, following the `OUTPUT` argument are the key names of RedisAI Tensors that the model outputs.
263
+
The first argument to `AI.MODELEXECUTE` is the name of the key at which the RedisAI Model is stored. The names of RedisAI Tensor keys that follow the `INPUTS`and `input_count>` arguments are used as input for the model. Similarly, following the `OUTPUTS` and `output_count>`arguments are the key names of RedisAI Tensors that the model outputs.
264
264
265
265
The inputs for the example are the tensors stored under the 'tA' and 'tB' keys. Once the model's run had finished, a new RedisAI Tensor key called 'tResult' is created and stores the model's output.
0 commit comments