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
***TAG**: an optional string for tagging the script such as a version number or any arbitrary identifier
426
+
***device**: the device that will execute the model can be of:
427
+
***CPU**: a CPU device
428
+
***GPU**: a GPU device
429
+
***GPU:0**, ..., **GPU:n**: a specific GPU device on a multi-GPU system
430
+
***ENTRY_POINTS** A list of entry points to be used in the script. Each entry point should have the signature of `def entry_point(tensors: List[Tensor], keys: List[str], args: List[str])`. The purpose of each list is as follows:
431
+
*`tensors`: A list holding the input tensors to the function.
432
+
*`keys`: A list of keys that the torch script is about to preform read/write operations on.
433
+
*`args`: A list of additional arguments to the function. If the desired argument is not from type string, it is up to the caller to cast it to the right type, within the script.
434
+
***script**: a string containing [TorchScript](https://pytorch.org/docs/stable/jit.html) source code
435
+
436
+
_Return_
437
+
438
+
A simple 'OK' string or an error.
439
+
440
+
**Examples**
441
+
442
+
Given the following contents of the file 'addtwo.py':
It can be stored as a RedisAI script using the CPU device with [`redis-cli`](https://redis.io/topics/rediscli) as follows:
452
+
453
+
```
454
+
$ cat addtwo.py | redis-cli -x AI.SCRIPTSET myscript CPU TAG myscript:v0.1 ENTRY_POINTS 1 addtwo SOURCE
455
+
OK
456
+
```
457
+
411
458
## AI.SCRIPTSET
459
+
_This command is deprecated and will not be available in future versions. consider using AI.MODELSTORE command instead._
412
460
The **`AI.SCRIPTSET`** command stores a [TorchScript](https://pytorch.org/docs/stable/jit.html) as the value of a key.
413
461
414
462
**Redis API**
@@ -471,8 +519,9 @@ An array with alternating entries that represent the following key-value pairs:
471
519
!!!!The command returns a list of key-value strings, namely `DEVICE device TAG tag [SOURCE source]`.
472
520
473
521
1.**DEVICE**: the script's device as a String
474
-
1.**TAG**: the scripts's tag as a String
475
-
1.**SOURCE**: the script's source code as a String
522
+
2.**TAG**: the scripts's tag as a String
523
+
3.**SOURCE**: the script's source code as a String
524
+
***ENTRY_POINTS** will return an array containing the script entry points
476
525
477
526
**Examples**
478
527
@@ -487,6 +536,8 @@ redis> AI.SCRIPTGET myscript
487
536
5) "source"
488
537
6) def addtwo(a, b):
489
538
return a + b
539
+
7) "Entry Points"
540
+
8) 1) addtwo
490
541
```
491
542
492
543
## AI.SCRIPTDEL
@@ -519,7 +570,7 @@ OK
519
570
520
571
## AI.SCRIPTEXECUTE
521
572
522
-
The **`AI.SCRIPTEXECUTE`** command runs a script stored as a key's value on its specified device. It accepts one or more inputs, where the inputs could be tensors stored in RedisAI, int, float, or strings and stores the script outputs as RedisAI tensors if required.
573
+
The **`AI.SCRIPTEXECUTE`** command runs a script stored as a key's value on its specified device. It a list keys, input tensors and addtional script args.
523
574
524
575
The run request is put in a queue and is executed asynchronously by a worker thread. The client that had issued the run request is blocked until the script run is completed. When needed, tensors data is automatically copied to the device prior to execution.
525
576
@@ -533,7 +584,8 @@ A `TIMEOUT t` argument can be specified to cause a request to be removed from th
533
584
```
534
585
AI.SCRIPTEXECUTE <key> <function>
535
586
KEYS n <key> [keys...]
536
-
[INPUTS m <input> [input ...] | [LIST_INPUTS l <input> [input ...]]*]
587
+
[INPUTS m <input> [input ...]
588
+
[ARGS k <arg> [arg...]]
537
589
[OUTPUTS k <output> [output ...] [TIMEOUT t]]+
538
590
```
539
591
@@ -542,8 +594,8 @@ _Arguments_
542
594
***key**: the script's key name
543
595
***function**: the name of the function to run
544
596
***KEYS**: Either a squence of key names that the script will access before, during and after its execution, or a tag which all those keys share. `KEYS` is a mandatory scope in this command. Redis will verify that all potional key accesses are done to the right shard.
545
-
***INPUTS**: Denotes the beginning of the input parameters list, followed by its length and one or more inputs; The inputs can be tensor key name, `string`, `int` or `float`. The order of the input should be aligned with the order of their respected parameter at the function signature. Note that list inputs are treated in the **LIST_INPUTS** scope.
546
-
***LIST_INPUTS** Denotes the beginning of a list, followed by its length and one or more inputs; The inputs can be tensor key name, `string`, `int` or `float`. The order of the input should be aligned with the order of their respected parameter at the function signature. Note that if more than one list is provided, their order should be aligned with the order of their respected paramter at the function signature.
597
+
***INPUTS**: Denotes the beginning of the input parameters list, followed by its length and one or more input tensors.
598
+
***ARGS**: A list additional arguments that a user can send to the script. All args are sent as strings, but can be casted to other types supported by torch script, such as `int`, or `float`.
547
599
548
600
***OUTPUTS**: denotes the beginning of the output tensors keys' list, followed by its length and one or more key names.
549
601
***TIMEOUT**: the time (in ms) after which the client is unblocked and a `TIMEDOUT` string is returned
RedisAI TorchScript now supports simple (non-blocking) Redis commands via the `redis.execute` API. The following (useless) script gets a key name (`x{1}`), and an `int` value (3). First, the script `SET`s the value in the key. Next, the script `GET`s the value back from the key, and sets it in a tensor which is eventually stored under the key 'y{1}'. Note that the inputs are `str` and `int`. The script sets and gets the value and set it into a tensor.
661
+
In RedisAI TorchScript now supports simple (non-blocking) Redis commnands via the `redis.execute` API. The following script gets a key name (`x{1}`), and an `int` value (3). First, the script `SET`s the value in the key. Next, the script `GET`s the value back from the key, and sets it in a tensor which is eventually stored under the key 'y{1}'. Note that the inputs are `str` and `int`. The script sets and gets the value and set it into a tensor.
0 commit comments