Skip to content

Possible fix for exploding object size #1322

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion R/nn.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#' @include utils-data.R
NULL

default_parent_env = function() {
env = parent.frame(2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mayvbve add a comment about the 2 here

pe = parent.env(env)
if (all(sapply(c(".__active__", "self", "private", "super"), function(field) exists(field, pe)))) {
get("inherit", pe)$parent_env
} else {
env
}
}

get_inherited_classes <- function(inherit) {
inherit_class <- inherit$public_fields$.classes
# Filter out classes that we eventually add in our normal flow.
Expand Down Expand Up @@ -496,7 +506,7 @@ is_nn_module <- function(x) {
#' @export
nn_module <- function(classname = NULL, inherit = nn_Module, ...,
private = NULL, active = NULL,
parent_env = parent.frame()) {
parent_env = default_parent_env()) {
if (inherits(inherit, "nn_module")) {
inherit <- attr(inherit, "module")
}
Expand Down
14 changes: 7 additions & 7 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ template:
primary: "#7e1f77"
params:
ganalytics: G-9ZJSKW3L0N

development:
mode: auto

Expand Down Expand Up @@ -62,11 +62,11 @@ navbar:
- text: basic-nn-module
href: articles/examples/basic-nn-module.html
- text: dataset
href: articles/examples/dataset.html
reference:
href: articles/examples/dataset.html

reference:
- title: Tensor creation utilities
contents:
contents:
- torch_empty
- torch_arange
- torch_eye
Expand Down Expand Up @@ -136,7 +136,7 @@ reference:
contents:
- starts_with("lr_")
- title: Datasets
contents:
contents:
- starts_with("dataset")
- iterable_dataset
- starts_with("dataloader")
Expand Down Expand Up @@ -179,7 +179,7 @@ reference:
contents:
- starts_with("cuda_")
- title: JIT
contents:
contents:
- starts_with("jit")
- title: Backends
contents:
Expand Down
Loading