Skip to content

Commit

Permalink
New Mojmelo version (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetalit authored Jan 31, 2025
1 parent 5139e38 commit 93ffa92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions recipes/mojmelo/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
context:
version: "0.0.2"
version: "0.0.3"

package:
name: "mojmelo"
version: ${{ version }}

source:
- git: https://github.com/yetalit/mojmelo.git
rev: e53bb63aa35c4f377fe5c6e7ff5da7b3e13fbbcd
rev: 9531118fb9df74c3b376befe30da82281f24375f

build:
number: 0
Expand Down
13 changes: 10 additions & 3 deletions recipes/mojmelo/tests/mojmelo/utils/Matrix.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ struct Matrix:

# initialize from UnsafePointer
@always_inline
fn __init__(out self, data: UnsafePointer[Float32], height: Int, width: Int, order: String = 'c'):
self.height = height
self.width = width
self.size = height * width
self.data = data
self.order = order.lower()

# initialize by copying from UnsafePointer
@always_inline
fn __init__(out self, height: Int, width: Int, data: UnsafePointer[Float32] = UnsafePointer[Float32](), order: String = 'c'):
self.height = height
self.width = width
Expand Down Expand Up @@ -68,9 +77,7 @@ struct Matrix:
var C = matmul.Matrix[DType.float32]((self.height, rhs.width))
memset_zero(C.data, self.height * rhs.width)
matmul.matmul(self.height, self.width, rhs.width, C, A, B)
var mat = Matrix(self.height, rhs.width)
mat.data = C.data
return mat^
return Matrix(C.data, self.height, rhs.width)

@always_inline
fn __imul__(mut self, rhs: Self) raises:
Expand Down
2 changes: 1 addition & 1 deletion recipes/mojmelo/tests/setup.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fn main() raises:
from collections import InlineArray
import time

alias NUM_ITER = 20
alias NUM_ITER = 16
results = InlineArray[Int, 3](fill=0)
var junk: Float32 = 0.0
a = Matrix.random(512, 4096)
Expand Down

0 comments on commit 93ffa92

Please sign in to comment.