Replies: 1 comment
-
You can do it like this: import mlx.core as mx
class Test:
@mx.compile
def method(self, x):
return x
t = Test()
print(mx.compile(t.method)(mx.array(1.0))) Note though that the method capture What you have doesn' t work, because compile currently doesn't deal with instance methods (so the compiled function capture t.method(t, 1) But then import mlx.core as mx
class Test(dict):
@mx.compile
def method(self, x):
return x
t = Test()
print(t.method(t, mx.array(1.0))) I don't think that's a particularly good idea to do though if it can be avoided. Better to stick to compiling free functions for now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to compile a class method through
mx.compile
?I can't seem to find how to do it while I know that in jax you can do it in a couple different ways.
The helper function way shown in the jax docs linked above might work but it feels like there should be a different way of doing it using
mx.compile
's input and output.some example code:
the
1
here gets passed in asself
into the method, and trying to dot.method(t, 1)
leads to hashing errors.Have I missed a very obvious fix to this issue?
Beta Was this translation helpful? Give feedback.
All reactions