ghostflow_core/
lib.rs

1//! GhostFlow Core - High-performance tensor operations
2//! 
3//! This crate provides the foundational tensor type and operations
4//! for the GhostFlow ML framework.
5//!
6//! ## Phase 4 Optimizations (Beat JAX!)
7//! - Operation fusion engine
8//! - JIT compilation
9//! - Memory layout optimization
10//! - Custom optimized kernels
11
12pub mod dtype;
13pub mod shape;
14pub mod storage;
15pub mod tensor;
16pub mod ops;
17pub mod device;
18pub mod error;
19pub mod serialize;
20pub mod sparse;
21pub mod hardware;
22pub mod rocm;
23pub mod metal;
24pub mod neon;
25pub mod tpu;
26
27// Phase 4: Advanced optimizations
28pub mod fusion;
29// pub mod jit; // Temporarily disabled - needs refactoring
30pub mod layout;
31
32// Performance optimizations
33pub mod simd_ops;
34pub mod memory;
35pub mod profiler;
36
37pub use dtype::DType;
38pub use shape::{Shape, Strides};
39pub use storage::Storage;
40pub use tensor::Tensor;
41pub use device::{Device, Cpu};
42pub use error::{GhostError, Result};
43pub use serialize::{StateDict, save_state_dict, load_state_dict, Serializable};
44pub use sparse::{SparseTensorCOO, SparseTensorCSR, SparseTensorCSC};
45pub use hardware::{HardwareBackend, HardwareDevice, HardwareOps, ElementwiseOp, list_devices};
46
47// Phase 4 exports
48pub use fusion::{FusionEngine, ComputeGraph, FusionPattern};
49// pub use jit::{JitCompiler, CompiledKernel}; // Temporarily disabled - needs refactoring
50pub use layout::{LayoutOptimizer, MemoryLayout, DeviceInfo};
51
52// Performance exports
53pub use simd_ops::{simd_add_f32, simd_mul_f32, simd_dot_f32, simd_relu_f32};
54pub use memory::{MemoryPool, MemoryStats, MemoryLayoutOptimizer, TrackedAllocator};
55pub use profiler::{Profiler, ProfileScope, Benchmark, BenchmarkResult, global_profiler};
56
57/// Prelude for convenient imports
58#[allow(unused_imports)]
59pub mod prelude {
60    pub use crate::{Tensor, DType, Shape, Device, Cpu};
61    pub use crate::tensor_ops::*;
62    pub use crate::serialize::{StateDict, save_state_dict, load_state_dict, Serializable};
63    pub use crate::{FusionEngine, LayoutOptimizer};
64}
65
66/// Tensor operations trait extensions
67#[allow(unused_imports)]
68pub mod tensor_ops {
69    pub use crate::ops::arithmetic::*;
70    pub use crate::ops::reduction::*;
71    pub use crate::ops::activation::*;
72    pub use crate::ops::matmul::*;
73}