Conditional SIMD Operations
Context Mojo Reference: SIMD select method Mojo Version: 24.2.0 Demo: Vectorized Relu Function This demo illustrates a practical application of conditional SIMD operations to implement the Relu activation function in a vectorized manner. The Relu function is defined as returning 0 for all input values less than 0 and the input value itself for those greater than 0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 from algorithm import vectorize alias LEN = 7 alias dtype = DType.