Skip to content

[C++] copy_gpu a transposed array #2064

Answered by awni
zcbenz asked this question in Q&A
Apr 11, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

which does not work and it took me quite a while to realize that it is because trans has not been evaluated yet and it does not contain any data

Yes you can't call MLX operations from inside the eval functions.

So made it work by adding an metal::eval

I'm glad this makes you nervous because that's a bad idea, we shouldn't evaluate anything inside an eval.

Is there a better way to do this?

There isn't a super clean way to do it. But you can see for example here where we transpose an array inside the eval_cpu.

A potentially cleaner option is to refactor the actual impentation of Transpose::eval so that you can call it from inside your eval_gpu. A lot of ops work like that where we hav…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zcbenz
Comment options

Answer selected by zcbenz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants