Skip to content

Commit 20e7ff3

Browse files
committed
Fix tensor set with int values. Solves #68
1 parent fcf17b8 commit 20e7ff3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/redisai.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int RedisAI_TensorSet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
206206
RAI_TensorFree(t);
207207
return RedisModule_ReplyWithError(ctx, "ERR invalid value");
208208
}
209-
int ret = RAI_TensorSetValueFromDouble(t, i, val);
209+
int ret = RAI_TensorSetValueFromLongLong(t, i, val);
210210
if (ret == -1) {
211211
RAI_TensorFree(t);
212212
return RedisModule_ReplyWithError(ctx, "ERR cannot specify values for this datatype");

test/basic_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def test_set_tensor(env):
5252
tensor = con.execute_command('AI.TENSORGET', 'x', 'VALUES')
5353
values = tensor[-1]
5454
env.assertEqual(values, [b'2', b'3'])
55+
con.execute_command('AI.TENSORSET', 'x', 'INT32', 2, 'VALUES', 2, 3)
56+
tensor = con.execute_command('AI.TENSORGET', 'x', 'VALUES')
57+
values = tensor[-1]
58+
env.assertEqual(values, [b'2', b'3'])
5559

5660
def test_set_tensor_multiproc(env):
5761
run_test_multiproc(env, 10,

0 commit comments

Comments
 (0)