pub struct GpuStore { /* private fields */ }
Implementations§
Source§impl GpuStore
impl GpuStore
Sourcepub fn get_default() -> &'static GpuInstance
pub fn get_default() -> &'static GpuInstance
Examples found in repository?
examples/assignment/main.rs (line 4)
3fn main() {
4 println!("Running in {:?}", GpuStore::get_default().info());
5 let mut ma = Tensor::from_data_and_shape(vec![1., 2., 3., 4., 5., 6., 7., 8.], vec![2, 2, 2]);
6 println!("{:?}", ma);
7 ma.assign(s!(1..2; ..; 1..2), 10.);
8 ma.assign(s!(0;0;0), -50.);
9 println!("{:?}", ma);
10 /*
11 Shape: [2, 2, 2]
12 [[[ -50 2 ]
13 [ 3 4 ]]
14
15 [[ 5 10 ]
16 [ 7 10 ]]]
17 */
18}
More examples
examples/simple_mm/main.rs (line 4)
3fn main() {
4 println!("Running in {:?}", GpuStore::get_default().info());
5 let ma = Tensor::from_data_and_shape(vec![1., 2., 3., 4., 5., 6., 7., 8.], vec![2, 2, 2]);
6 let mb = Tensor::from_data_and_shape(vec![2., 3., 4., 5.], vec![2, 2]);
7 let result = ma.matmul(&mb);
8 println!("{:?}", result);
9 /*
10 Running in AdapterInfo { name: "AMD Radeon Pro 560", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }
11 Shape: [2, 2, 2]
12 [[[ 10 13 ]
13 [ 22 29 ]]
14
15 [[ 34 45 ]
16 [ 46 61 ]]]
17 */
18}
pub fn get(gpu_info: &AdapterInfo) -> &'static GpuInstance
pub async fn select_gpu(gpu_info: &AdapterInfo)
pub fn list_gpus() -> Vec<&'static AdapterInfo>
Auto Trait Implementations§
impl !Freeze for GpuStore
impl !RefUnwindSafe for GpuStore
impl Send for GpuStore
impl Sync for GpuStore
impl Unpin for GpuStore
impl !UnwindSafe for GpuStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more