if (torch_is_installed()) {
x <- torch_randn(5, 5, dtype = torch_float32())
y <- torch_randn(5, 5, dtype = torch_float32())
foo <- function(x, y) {
local_autocast(device = "cpu")
z <- torch_mm(x, y)
w <- torch_mm(z, x)
w
}
out <- foo(x, y)
}
Run the code above in your browser using DataLab