Module tensor

Module tensor 

Source
Expand description

Tensor operations and data structures テンソル操作とデータ構造

§Tensor Operations and Data Structures

テンソル操作とデータ構造

This module provides the core tensor functionality for RusTorch, including basic tensor operations, advanced parallel processing, GPU acceleration, and memory optimization features.

§Core Components

  • core: The main tensor data structure with n-dimensional array support
  • operations: Mathematical operations and arithmetic for tensors
  • parallel_traits: Unified parallel tensor operations system
  • gpu_parallel: GPU-accelerated tensor operations with device management
  • memory_optimized: Advanced memory management strategies
  • zero_copy: Zero-copy tensor views and shared ownership
  • simd_aligned: SIMD-aligned tensor operations for vectorization

§Key Features

§High-Performance Computing

  • Parallel Processing: Automatic parallelization for large tensor operations
  • SIMD Acceleration: AVX2/SSE4.1 vectorized operations for f32 tensors
  • GPU Integration: CUDA/Metal/OpenCL support with intelligent fallback
  • Memory Optimization: Pool allocation, zero-copy views, and cache-friendly operations

§Mathematical Operations

  • Element-wise Operations: Addition, multiplication, trigonometric functions
  • Linear Algebra: Matrix multiplication, decompositions, eigenvalues
  • Broadcasting: NumPy-style broadcasting for operations on different shapes
  • Reduction Operations: Sum, mean, variance, and statistical functions

§Memory Management

  • Zero-Copy Views: Efficient tensor slicing without data duplication
  • Memory Pooling: Reduced allocation overhead for frequent operations
  • SIMD Alignment: 32-byte aligned allocation for optimal vectorization
  • Shared Ownership: Thread-safe reference counting for tensor sharing

§Usage Examples

§Basic Tensor Operations

use rustorch::tensor::Tensor;

// Create tensors
let a = Tensor::<f32>::ones(&[3, 3]);
let b = Tensor::<f32>::zeros(&[3, 3]);

// Basic arithmetic
let c = &a + &b;
let d = a.matmul(&b);

// Mathematical functions (using ndarray methods)
let e = a.data.mapv(|x| x.sin());
let f = a.data.mapv(|x| x.exp());

§Parallel Operations

RusTorch provides efficient parallel tensor operations for high-performance computing.

§GPU Acceleration

RusTorch supports GPU acceleration with automatic fallback to CPU when GPU is unavailable.

§Memory Optimization

Advanced memory management strategies for optimal performance and memory usage.

Re-exports§

pub use crate::error::RusTorchResult as ParallelResult;
pub use core::Tensor;
pub use device::Device;
pub use memory::optimization::MemoryOptimization;
pub use memory::optimization::TensorMemoryInfo;
pub use operations::zero_copy::TensorIterOps;
pub use operations::zero_copy::ZeroCopyOps;

Modules§

complex
Complex number support for tensors テンソルの複素数サポート Complex number support for tensors - Legacy compatibility layer テンソルの複素数サポート - レガシー互換レイヤー
complex_impl
Modular complex number implementation モジュール化された複素数実装 Complex number support for tensors - Modular Organization テンソルの複素数サポート - モジュール構成
core
Core tensor data structure コアテンソルデータ構造
Core tensor data structure and basic operations コアテンソルデータ構造と基本操作
device
Device management for tensor operations テンソル操作用デバイス管理 Device management for tensor operations テンソル操作用デバイス管理
gpu_parallel
GPU-Integrated Parallel Tensor Operations
macros
Convenient macros for tensor creation with literal syntax リテラル構文によるテンソル作成のための便利なマクロ
memory
Modern memory management system 現代的なメモリ管理システム Memory Management Module for RusTorch Tensors RusTorchテンソルのメモリ管理モジュール
numeric_safety
Numeric safety and overflow protection 数値安全性とオーバーフロー保護 Numeric safety and overflow protection 数値安全性とオーバーフロー保護
operations
Organized tensor operations by category (trait-based system) カテゴリ別に整理されたテンソル操作(トレイトベースシステム) Organized tensor operations module 整理されたテンソル操作モジュール
ops
Organized tensor operations by category (new modular system) カテゴリ別に整理されたテンソル操作(新しいモジュールシステム) Modular tensor operations モジュール化されたテンソル演算
parallel_errors
並列テンソル操作の統一エラーハンドリング Unified error handling for parallel tensor operations - now using RusTorchError only
parallel_impl
並列テンソル操作の実装 Implementation of parallel tensor operations
parallel_ops
Parallel tensor operations module 並列テンソル演算モジュール
parallel_traits
Parallel Tensor Operations Traits
shared_ops
Shared operations between regular and WASM tensors 通常テンソルとWASMテンソル間の共通操作 Shared tensor operations for both regular and WASM tensors 通常テンソルとWASMテンソル両方用の共通操作
simd_avx512
AVX-512 SIMD optimizations for high-performance tensor operations 高性能テンソル演算のためのAVX-512 SIMD最適化
simd_integration
Parallel tensor operations for batch processing and SIMD acceleration バッチ処理とSIMD加速のための並列テンソル操作
type_safe
Type-safe tensor operations with compile-time verification コンパイル時検証付きの型安全テンソル操作 Type-safe tensor shapes and operations 型安全なテンソル形状と操作
utilities
Phase 8: Advanced tensor utilities for conditional, indexing, and statistical operations フェーズ8: 条件、インデックス、統計操作のための高度なテンソルユーティリティ Phase 8: Tensor Utilities Implementation - Refactored フェーズ8: テンソルユーティリティ実装 - リファクタリング版