Skip to content

Commit 5417bdd

Browse files
authored
Merge pull request #99 from bmansheim/patch-2
Style and formatting changes on commands
2 parents 8b8c4ab + 46acf4d commit 5417bdd

File tree

1 file changed

+68
-47
lines changed

1 file changed

+68
-47
lines changed

docs/commands.md

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# RedisAI Commands
22

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.
58

69
```sql
710
AI.TENSORSET tensor_key data_type shape1 shape2 ... [BLOB data | VALUES val1 val2 ...]
811
```
912

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
1316

1417
Optional args:
18+
1519
* BLOB data - provide tensor content as a binary buffer
1620
* VALUES val1 val2 - provide tensor content as individual values
1721

1822
> If no BLOB or VALUES are specified, the tensor is allocated but not initialized to any value.
1923
20-
### Example
24+
### TENSORSET Example
25+
2126
> Set a 2x2 tensor at `foo`
2227
> 1 2
2328
> 3 4
@@ -26,36 +31,43 @@ Optional args:
2631
AI.TENSORSET foo FLOAT 2 2 VALUES 1 2 3 4
2732
```
2833

29-
## AI.TENSORGET - get a tensor
34+
## AI.TENSORGET
35+
36+
Get a tensor.
37+
3038
```sql
3139
AI.TENSORGET tensor_key [BLOB | VALUES | META]
3240
```
3341

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)
3846

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.
4150

4251
```sql
4352
AI.TENSORGET foo BLOB
4453
```
4554

46-
## AI.MODELSET - set a model
55+
## AI.MODELSET
56+
57+
Set a model.
58+
4759
```sql
4860
AI.MODELSET model_key backend device [INPUTS name1 name2 ... OUTPUTS name1 name2 ...] model_blob
4961
```
5062

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
5769

58-
### Example
70+
### MODELSET Example
5971

6072
```sql
6173
AI.MODELSET resnet18 TORCH GPU < foo.pt
@@ -65,49 +77,56 @@ AI.MODELSET resnet18 TORCH GPU < foo.pt
6577
AI.MODELSET resnet18 TF CPU INPUTS in1 OUTPUTS linear4 < foo.pt
6678
```
6779

68-
## AI.MODELGET - get a model
80+
## AI.MODELGET
81+
82+
Get a model.
6983

7084
```sql
7185
AI.MODELGET model_key
7286
```
7387

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+
7592

76-
> The command returns the model as serialized by the backend (i.e. a string containing a protobuf)
93+
## AI.MODELRUN
7794

95+
Run a model.
7896

79-
## AI.MODELRUN - run a model
8097
```sql
8198
AI.MODELRUN model_key INPUTS input_key1 ... OUTPUTS output_key1 ...
8299
```
83100

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
87104

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.
89106

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.
91108

92-
### Example
109+
### MODELRUN Example
93110

94111
```sql
95112
AI.MODELRUN resnet18 INPUTS image12 OUTPUTS label12
96113
```
97114

115+
## AI.SCRIPTSET
116+
117+
Set a script.
98118

99-
## AI.SCRIPTSET - set a script
100119
```sql
101120
AI.SCRIPTSET script_key device script_source
102121
```
103122

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
107126

108-
### Example
127+
### SCRIPTSET Example
109128

110-
> Given addtwo.txt as:
129+
Given addtwo.txt as:
111130

112131
```python
113132
def addtwo(a, b):
@@ -118,36 +137,38 @@ def addtwo(a, b):
118137
AI.SCRIPTSET addscript GPU < addtwo.txt
119138
```
120139

121-
## AI.SCRIPTGET - get a script
140+
## AI.SCRIPTGET
141+
142+
Get a script.
122143

123144
```sql
124145
AI.SCRIPTGET script_key
125146
```
126147

127148
* script_key - key for the script
128149

129-
### Example
150+
### SCRIPTGET Example
130151

131152
```sql
132153
AI.SCRIPTGET addscript
133154
```
134155

156+
## AI.SCRIPTRUN
135157

136-
## AI.SCRIPTRUN - run a script
158+
Run a script.
137159

138160
```sql
139161
AI.SCRIPTRUN script_key fn_name INPUTS input_key1 ... OUTPUTS output_key1 ...
140162
```
141163

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
148168

169+
If needed, input tensors are copied to the device specified in `AI.SCRIPTSET` before execution.
149170

150-
### Example
171+
### SCRIPTRUN Example
151172

152173
```sql
153174
AI.SCRIPTRUN addscript addtwo INPUTS a b OUTPUTS c

0 commit comments

Comments
 (0)