any-tensor 0.0.0

Tensor of any data type
Documentation
  • Coverage
  • 13.04%
    3 out of 23 items documented2 out of 23 items with examples
  • Size
  • Source code size: 19.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.71 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • YdrMaster/tensor
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • YdrMaster

张量

CI Latest version Documentation license codecov

GitHub Issues GitHub Pull Requests GitHub repo size GitHub code size in bytes GitHub contributors GitHub commit activity

张量是一种数据的容器,代表在均质的数据上附加了数据类型、形状和数据布局的动态信息。

本项目提供 Tensor<T, N> 结构体,用于灵活管理多维数据,它能通过一系列方法对数据信息和内容进行变换,同时提供了类型安全和高效的操作接口。

使用示例

use tensor::Tensor;
use digit_layout::DigitLayout;
use ndarray_layout::{ArrayLayout, Endian::BigEndian};

// 定义一个数据类型,以 32 个 8 位无符号数为一组。
digit_layout::layout!(GROUP u(8); 32);
let shape = [7, 1024];
let element_size = 32;
let layout = ArrayLayout::<2>::new_contiguous(&shape, BigEndian, element_size);
let item = 7 * 1024;

// 创建张量。
let tensor = Tensor::from_raw_parts(GROUP, layout.clone(), item);

// 获取张量数据类型。
assert_eq!(tensor.dt(), GROUP);

// 获取张量布局信息。
assert_eq!(tensor.layout().shape(), layout.shape());

// 复制张量。
let mut cloned_tensor = tensor.clone();
*(cloned_tensor.get_mut()) += 1;
assert_eq!(*cloned_tensor.get(), item + 1);