MCPcopy Create free account
hub / github.com/Gadersd/stable-diffusion-burn / tensor_to_array

Function tensor_to_array

src/model/load.rs:168–178  ·  view source on GitHub ↗
(x: Tensor<B, 1>)

Source from the content-addressed store, hash-verified

166}
167
168pub fn tensor_to_array<const N: usize, B: Backend>(x: Tensor<B, 1>) -> [usize; N] {
169 let vec: Vec<<B as Backend>::FloatElem> = x.into_data().to_vec().unwrap();
170 assert!(vec.len() == N, "Tensor length must be {}.", N);
171
172 let mut arr = [0; N];
173 for (a, t) in arr.iter_mut().zip(vec) {
174 *a = t.to_usize();
175 }
176
177 arr
178}

Callers 1

load_padded_conv2dFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected