Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloning of PipeOpModule #168

Closed
sebffischer opened this issue Dec 18, 2023 · 2 comments
Closed

Cloning of PipeOpModule #168

sebffischer opened this issue Dec 18, 2023 · 2 comments

Comments

@sebffischer
Copy link
Sponsor Member

Blocked by: mlverse/torch#1126

@sebffischer
Copy link
Sponsor Member Author

some code for testing that I already wrote:

test_that("cloning works", {
  p1 = po("module", nn_linear(1, 1), id = "test1")
  unlockBinding(".additional_phash_input", get_private(p1))
  get_private(p1, ".additional_phash_input") = function(...) NULL
  p1deep = p1$clone(deep = TRUE)
  unlockBinding(".additional_phash_input", get_private(p1))
  get_private(p1deep, ".additional_phash_input") = function(...) NULL
  expect_deep_clone(p1, p1deep)

  p1shallow = p1$clone(deep = FALSE)
  expect_false(identical(p1$module$parameters$weight, p1deep$module$parameters$weight))
  expect_true(identical(p1$module$parameters$weight, p1shallow$module$parameters$weight))

})

@sebffischer
Copy link
Sponsor Member Author

duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant