pub struct SparseProfiler {
pub config: BenchmarkConfig,
pub measurements: Vec<PerformanceMeasurement>,
pub operation_counters: HashMap<String, usize>,
}
Expand description
Comprehensive performance profiler for sparse tensor operations
The SparseProfiler
is the main class for benchmarking sparse tensor operations.
It provides methods for profiling format conversions, matrix operations, and
memory usage patterns.
Fields§
§config: BenchmarkConfig
Configuration for benchmark execution
measurements: Vec<PerformanceMeasurement>
Collected performance measurements
operation_counters: HashMap<String, usize>
Operation counters for tracking
Implementations§
Source§impl SparseProfiler
impl SparseProfiler
Sourcepub fn new(config: BenchmarkConfig) -> Self
pub fn new(config: BenchmarkConfig) -> Self
Create a new sparse profiler with the given configuration
Sourcepub fn benchmark_format_conversion(
&mut self,
dense_matrix: &Tensor,
) -> TorshResult<Vec<PerformanceMeasurement>>
pub fn benchmark_format_conversion( &mut self, dense_matrix: &Tensor, ) -> TorshResult<Vec<PerformanceMeasurement>>
Benchmark sparse format conversion operations
This method profiles the conversion between different sparse formats (COO, CSR, etc.) and measures the performance characteristics.
§Arguments
dense_matrix
- Input dense matrix to convert to sparse formats
§Returns
Vector of performance measurements for each format conversion
Sourcepub fn benchmark_sparse_matmul(
&mut self,
lhs: &dyn SparseTensor,
rhs: &dyn SparseTensor,
) -> TorshResult<Vec<PerformanceMeasurement>>
pub fn benchmark_sparse_matmul( &mut self, lhs: &dyn SparseTensor, rhs: &dyn SparseTensor, ) -> TorshResult<Vec<PerformanceMeasurement>>
Benchmark sparse matrix multiplication operations
This method profiles matrix multiplication between sparse matrices in different formats and measures performance characteristics.
§Arguments
lhs
- Left-hand side sparse matrixrhs
- Right-hand side sparse matrix
§Returns
Vector of performance measurements for matrix multiplication
Sourcepub fn benchmark_dense_to_sparse(
&mut self,
dense_matrix: &Tensor,
sparsity_threshold: f32,
) -> TorshResult<Vec<PerformanceMeasurement>>
pub fn benchmark_dense_to_sparse( &mut self, dense_matrix: &Tensor, sparsity_threshold: f32, ) -> TorshResult<Vec<PerformanceMeasurement>>
Benchmark dense to sparse conversion operations
This method profiles the conversion from dense matrices to sparse formats with different sparsity patterns and thresholds.
§Arguments
dense_matrix
- Input dense matrixsparsity_threshold
- Threshold for considering elements as zero
§Returns
Vector of performance measurements for dense-to-sparse conversion
Sourcepub fn profile_format_comparison(
&mut self,
dense_matrix: &Tensor,
) -> TorshResult<Vec<PerformanceMeasurement>>
pub fn profile_format_comparison( &mut self, dense_matrix: &Tensor, ) -> TorshResult<Vec<PerformanceMeasurement>>
Profile format comparison for a given dense matrix
This method converts a dense matrix to all supported sparse formats and compares their performance characteristics.
Sourcepub fn clear_measurements(&mut self)
pub fn clear_measurements(&mut self)
Clear all collected measurements and reset counters
Sourcepub fn measurement_count(&self) -> usize
pub fn measurement_count(&self) -> usize
Get the total number of measurements collected
Sourcepub fn get_measurements_for_operation(
&self,
operation: &str,
) -> Vec<&PerformanceMeasurement>
pub fn get_measurements_for_operation( &self, operation: &str, ) -> Vec<&PerformanceMeasurement>
Get measurements for a specific operation
Trait Implementations§
Source§impl Debug for SparseProfiler
impl Debug for SparseProfiler
Auto Trait Implementations§
impl Freeze for SparseProfiler
impl RefUnwindSafe for SparseProfiler
impl Send for SparseProfiler
impl Sync for SparseProfiler
impl Unpin for SparseProfiler
impl UnwindSafe for SparseProfiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more