tests/testthat/test-0-threads.R

# theses tests must run the before any torch op.

test_that("can set threads", {
  skip_on_os("windows")
  skip_on_os("mac")

  old <- torch_get_num_interop_threads()
  torch_set_num_interop_threads(6)
  expect_equal(torch_get_num_interop_threads(), 6)

  old <- torch_get_num_threads()
  torch_set_num_threads(6)
  expect_equal(torch_get_num_threads(), 6)
  torch_set_num_threads(old)
})

Try the torch package in your browser

Any scripts or data that you put into this service are public.

torch documentation built on June 7, 2023, 6:19 p.m.