Leandro Campos
Leandro Campos
MModular
Created by Leandro Campos on 6/12/2024 in #community-showcase
Specials: Accurate, Hardware Accelerated, Special Functions in Mojo
Specials is a Mojo package designed to provide highly-optimized and hardware-acceleration-friendly special functions implementations for AI computing. https://github.com/leandrolcampos/specials
7 replies
MModular
Created by Leandro Campos on 2/1/2024 in #questions
DTypePointer to StaticTuple array
Suppose I have defined a static tuple x as follows: var x = StaticTuple[4, Float32](1.0, 2.0, 3.0, 4.0). Is it possible to create an instance of DTypePointer[DType.float32] from the address of x's underlying storage?
7 replies
MModular
Created by Leandro Campos on 12/7/2023 in #questions
Are literals splatted in SIMD Operations?
Is there any performance difference if I write this
fn multiply_by_two[
dtype: DType, simd_width: Int
](x: SIMD[dtype, simd_width]) -> SIMD[dtype, simd_width]:
alias splatted_two = SIMD[dtype, simd_width](2.)
return splatted_two * x
fn multiply_by_two[
dtype: DType, simd_width: Int
](x: SIMD[dtype, simd_width]) -> SIMD[dtype, simd_width]:
alias splatted_two = SIMD[dtype, simd_width](2.)
return splatted_two * x
instead of this?
fn multiply_by_two[
dtype: DType, simd_width: Int
](x: SIMD[dtype, simd_width]) -> SIMD[dtype, simd_width]:
return 2.0 * x
fn multiply_by_two[
dtype: DType, simd_width: Int
](x: SIMD[dtype, simd_width]) -> SIMD[dtype, simd_width]:
return 2.0 * x
In other words, is the literal 2 transformed into a splatted SIMD vector at runtime every time multiply_by_two is called? Or is this something that the compiler is able to optimize?
4 replies