Anindya
Anindya
Explore posts from servers
MModular
Created by Anindya on 6/14/2024 in #questions
How to declare a function type in a trait?
This is a simple class in Python
class MyPair:
def __init__(first, second):
self.first = first
self.second = second

def _hello():
return None

self._hi = _hello
class MyPair:
def __init__(first, second):
self.first = first
self.second = second

def _hello():
return None

self._hi = _hello
Now I thought I could this in Mojo in someway but stucked
struct MyPair:
var first: Int
var second: Int
var _hi

fn __init__(inout self, first: Int, second: Int):
self.first = first
self.second = second
fn _hello():
return None

self._hi = _hello
struct MyPair:
var first: Int
var second: Int
var _hi

fn __init__(inout self, first: Int, second: Int):
self.first = first
self.second = second
fn _hello():
return None

self._hi = _hello
Is there any possible way of doing this in Mojo? Error:
error: Expression [17] wrapper:22:13: struct field declaration must have a type
var _hi
^
error: Expression [17]:12:13: 'MyPair' value has no attribute '_hi'
self._hi = _hello
error: Expression [17] wrapper:22:13: struct field declaration must have a type
var _hi
^
error: Expression [17]:12:13: 'MyPair' value has no attribute '_hi'
self._hi = _hello
10 replies
RRunPod
Created by Anindya on 3/14/2024 in #⚡|serverless
Streaming is not quite working
Hi I was trying to deploy a simple huggingface model where my inference code looks like this
4 replies