Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Generalize the tensor container to arbitrary depth #1083

Merged
merged 4 commits into from
Jun 6, 2018
Merged

Conversation

dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Jun 6, 2018

FEATURE

Currently, calling tf.dispose(obj) or tf.tidy(() => obj) results in walking the obj for depth of 1 and disposing of any tensors found.

With this change obj is walked to arbitrary depth with cycle-detection to defend against cyclical objects.

This makes tf.tidy() and tf.dispose() more useful in practice.

Also rename util.extractTensorsFromContainer to util.getTensorsFromContainer since we are not modifying (extracting from) the container.


For repository owners only:

Please remember to apply all applicable tags to your pull request.
Tags: FEATURE, BREAKING, BUG, PERF, DEV, DOC, SECURITY

For more info see: https://github.com/tensorflow/tfjs/blob/master/DEVELOPMENT.md


This change is Reviewable

@nsthorat
Copy link
Contributor

nsthorat commented Jun 6, 2018

:lgtm_strong:


Review status: 0 of 5 files reviewed at latest revision, all discussions resolved.


src/util.ts, line 459 at r1 (raw file):

export function getTensorsInContainer(result: TensorContainer): Tensor[] {
  const list: Tensor[] = [];
  const seen = new Set<{}|void>();

do you need |void?


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

dsmilkov commented Jun 6, 2018

Review status: 0 of 5 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


src/util.ts, line 459 at r1 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

do you need |void?

yeah because TensorContainer is void|otherStuff and void is needed for tidy's that won't return anything.


Comments from Reviewable

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

Successfully merging this pull request may close these issues.

2 participants