INNER CODE UNIT · Rust

data

sonos/tract · api/ffi/src/lib.rs:1061

        let data = std::slice::from_raw_parts(data as *const u8, len * datum_type.size_of());
        let it = Tensor::from_bytes(datum_type, shape, data)?;
        *tensor = Box::into_raw(Box::new(TractTensor(it)));
        Ok(())
    })
}

/// Write a tensor as a debug string
///
/// The returned string must be freed by the caller using tract_free_cstring.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tract_tensor_dump(
    tensor: *const TractTensor,
    spec: *mut *mut c_char,
) -> TRACT_RESULT {
    wrap(|| unsafe {
        check_not_null!(tensor, spec);
        *spec = CString::new(format!("{:?}", (*tensor).0))?.into_raw();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…