Created
July 7, 2022 15:29
-
-
Save Steboss89/c691f1d856454d3d90d510cc5d547d68 to your computer and use it in GitHub Desktop.
Initialisation, match case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| match i { | |
| Init::Const(cst) => { | |
| // Optimize the case for which a single C++ code can be done. | |
| if cst == 0. { | |
| Tensor::f_zeros(dims, (Kind::Float, device)) | |
| } else if (cst - 1.).abs() <= std::f64::EPSILON { | |
| Tensor::f_ones(dims, (Kind::Float, device)) | |
| } else { | |
| Tensor::f_ones(dims, (Kind::Float, device)).map(|t| t * cst) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment