tkeitt
tkeitt
MModular
Created by tkeitt on 7/4/2024 in #questions
What github actions are folks using for CI?
I imagine an official mojo package workflow will emerge once packaging is reasonably settled. In the meantime, how do you all run tests, generate docs, etc. with github actions?
2 replies
MModular
Created by tkeitt on 6/23/2024 in #questions
Traits with compile-time SIMD size
I can't seem to fulfill a trait that can return different length SIMDs
trait PRNGEngine(Movable):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
pass

fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
pass

fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
pass


struct DummyEngine[n: Int](PRNGEngine):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
return 2

fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
return 42

fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
var res: SIMD[DType.uint64, Self.ndim()] = 42
return res
trait PRNGEngine(Movable):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
pass

fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
pass

fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
pass


struct DummyEngine[n: Int](PRNGEngine):
@staticmethod
fn ndim() -> Int:
"""SIMD size."""
return 2

fn next_scalar(inout self) -> UInt64:
"""Get only a single value from the generator."""
return 42

fn next(inout self) -> SIMD[DType.uint64, Self.ndim()]:
"""Get Self.ndim() values from the generator."""
var res: SIMD[DType.uint64, Self.ndim()] = 42
return res
I can fall back to next_scalar. I'd like to be able to use next e.g. to generate a set of normal deviates, etc.
9 replies
MModular
Created by tkeitt on 6/23/2024 in #questions
Specialize on trait
As far as I can tell, the following will not compile:
trait T1:
pass

trait T2:
pass

struct S[T: T1]:
pass

struct S[T: T2]:
pass
trait T1:
pass

trait T2:
pass

struct S[T: T1]:
pass

struct S[T: T2]:
pass
Is the intention to allow this sort of type specialization in the future? I have a workaround using static methods for compile-time branching. However, it requires the definition of a trait that is the superset of the two cases and so each has to fulfill functions that the (sub-)trait does not require.
8 replies
MModular
Created by tkeitt on 6/16/2024 in #questions
Parameterized function definitions in traits
Is this possible?
trait X:
fn x[Y: AnyType](self, y: Y) -> Y:
pass
trait X:
fn x[Y: AnyType](self, y: Y) -> Y:
pass
7 replies
MModular
Created by tkeitt on 6/13/2024 in #questions
Benchmarking code that raises
I am trying to use benchmark to time numpy code. However, numpy raises and it appears that benchmark.run cannot handle a function that raises. I am not a python programmer, so I am not familiar with the exception syntax. Is there a way to wrap numpy code such that the surrounding function does not raise?
4 replies