Skip to content

Commit ffd4084

Browse files
authored
Merge pull request #561 from RedisAI/Support_TENSORGET_command_without_format_arg
Let TENSORGET command return BLOB+META by default
2 parents 7947e6e + 0c9c805 commit ffd4084

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Depending on the specified reply format:
7979
1. The tensor's shape as an Array consisting of an item per dimension
8080
* **BLOB**: the tensor's binary data as a String. If used together with the **META** option, the binary data string will put after the metadata in the array reply.
8181
* **VALUES**: Array containing the numerical representation of the tensor's data. If used together with the **META** option, the binary data string will put after the metadata in the array reply.
82-
82+
* Default: **META** and **BLOB** are returned by default, in case that non of the arguments above is specified.
8383

8484

8585
**Examples**

src/tensor.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@ uint ParseTensorGetArgs(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
851851
RedisModule_WrongArity(ctx);
852852
return fmt;
853853
}
854+
if (argc == 2) {
855+
return TENSOR_BLOB | TENSOR_META;
856+
}
854857
for (int i = 2; i < argc; i++) {
855858
const char *fmtstr = RedisModule_StringPtrLen(argv[i], NULL);
856859
if (!strcasecmp(fmtstr, "BLOB")) {

tests/flow/tests_common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ def test_common_tensorget(env):
205205
env.assertEqual(datatype.encode('utf-8'), tensor_dtype)
206206
env.assertEqual([2], tensor_dim)
207207

208+
# Confirm that default reply format is META BLOB
209+
for datatype in tested_datatypes:
210+
_, tensor_dtype, _, tensor_dim, _, tensor_blob = con.execute_command('AI.TENSORGET', 'tensor_{0}'.format(datatype),
211+
'META', 'BLOB')
212+
_, tensor_dtype_default, _, tensor_dim_default, _, tensor_blob_default = con.execute_command('AI.TENSORGET',
213+
'tensor_{0}'.format(datatype))
214+
env.assertEqual(tensor_dtype, tensor_dtype_default)
215+
env.assertEqual(tensor_dim, tensor_dim_default)
216+
env.assertEqual(tensor_blob, tensor_blob_default)
217+
208218

209219
def test_common_tensorget_error_replies(env):
210220
con = env.getConnection()

0 commit comments

Comments
 (0)