pub fn tensor_map<F>(input: &Tensor<f32>, f: F) -> Result<Tensor<f32>>Expand description
Functional map operation over tensor elements
Applies a function to each element of the tensor in parallel.
§Arguments
input- Input tensorf- Function to apply to each element
§Performance
- Time Complexity: O(n) where n is number of elements
- Space Complexity: O(n) for output tensor
- Uses scirs2-core parallel operations when beneficial
§Examples
ⓘ
use torsh_functional::transformations::tensor_map;
let input = Tensor::randn(&[100, 100])?;
let output = tensor_map(&input, |x| x.powi(2))?;