Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.64 KB

README.md

File metadata and controls

50 lines (34 loc) · 1.64 KB

redisai-rs

A rust client for RedisAI

Please read the API documentation on doc.rs

MIT license Crates.io docs.rs GitHub Workflow Status

Installation

The RedisAI module needs to be installed first. A docker image is provided for convinience from redislab:

# cpu version
docker run -p 6379:6379 -it --rm redislabs/redisai:edge-cpu
# gpu version
docker run -p 6379:6379 -it --rm redislabs/redisai:edge-gpu

The gpu version use nvidia runtime so nvidia gpu needto be available. More information can be found in RedisAI github

Then simply add it to your Cargo.toml

[dependencies]
redis = "0.20.0"
redisai = "0.1.1"

Usage

use redis;

use redisai::RedisAIClient;
use redisai::tensor::{ToFromBlob,AITensor};

let aiclient: RedisAIClient = RedisAIClient { debug: true };
let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let mut con = client.get_connection().unwrap();

let tensor_data: Vec<i8> = vec![1, 2, 3, 127];
let shape: [usize; 1] = [4];
let ai_tensor: AITensor<i8, 1> = AITensor::new(shape, tensor_data.to_blob());

aiclient.ai_tensorset(&mut con, "example_one_dim_i8_tensor".to_string(), ai_tensor);

let ai_tensor: AITensor<i8, 1> = aiclient.ai_tensorget(&mut con, "example_one_dim_i8_tensor".to_string(), false).unwrap();