A matrix type is defined as
alias type = DType.float32
struct Matrix[rows: Int, cols: Int]:
var data: DTypePointer[type]
@staticmethod
fn rand() -> Self:
var data = DTypePointer[type].alloc(rows * cols)
rand(data, rows * cols)
return Self(data)
Then a Logits type is defined with Matrix with only 1 column:
struct Logits[rows: Int]:
alias LogitsM = Matrix[rows, 1]
var logits: Self.LogitsM
fn __init__(inout self):
self.logits.__init__()
@staticmethod
fn rand() -> Self:
return Self.LogitsM.rand()
Got compile error:
error: Expression [20]:9:33: cannot implicitly convert 'Matrix[rows, 1]' value to 'Logits[rows]' in return value
return Self.LogitsM.rand()
~~~~~~~~~~~~~~~~~^~
expression failed to parse (no further compiler diagnostics)