mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 18:48:51 +00:00
Apply suggestions from code review
This commit is contained in:

committed by
GitHub

parent
649202024c
commit
2c280007e8
14
README.md
14
README.md
@ -15,21 +15,11 @@ and ease of use. Try our online demos:
|
|||||||
Make sure that you have [`candle-core`](https://github.com/huggingface/candle/tree/main/candle-core) correctly installed as described in [**Installation**](https://huggingface.github.io/candle/guide/installation.html).
|
Make sure that you have [`candle-core`](https://github.com/huggingface/candle/tree/main/candle-core) correctly installed as described in [**Installation**](https://huggingface.github.io/candle/guide/installation.html).
|
||||||
|
|
||||||
Let's see how to run a simple matrix multiplication.
|
Let's see how to run a simple matrix multiplication.
|
||||||
|
Write the following to your `myapp/src/main.rs` file:
|
||||||
We will need the [`anyhow`](https://docs.rs/anyhow/latest/anyhow/) package for our example, so let's also add it to our app.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd myapp
|
|
||||||
cargo add anyhow
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, write the following to your `myapp/src/main.rs` file:
|
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use anyhow::Result;
|
|
||||||
use candle_core::{Device, Tensor};
|
use candle_core::{Device, Tensor};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let device = Device::Cpu;
|
let device = Device::Cpu;
|
||||||
|
|
||||||
let a = Tensor::randn(0f32, 1., (2, 3), &device)?;
|
let a = Tensor::randn(0f32, 1., (2, 3), &device)?;
|
||||||
|
@ -45,7 +45,7 @@ cd myapp
|
|||||||
cargo add --git https://github.com/huggingface/candle.git candle-core
|
cargo add --git https://github.com/huggingface/candle.git candle-core
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, run `cargo build` to make sure everything can be correctly built.
|
Finally, run `cargo run` to make sure everything can be correctly built.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo run
|
cargo run
|
||||||
|
Reference in New Issue
Block a user