Skip to content

Clone() doesn't actually clone? #1032

@TheNewSound

Description

@TheNewSound

To get help from the community, check out our Google group.

TensorFlow.js version

Latest (0.14.1)

Browser version

Latest Firefox + Chrome

Describe the problem or feature request

Clone() doesn't actually clone.

Code to reproduce the bug / link to feature request

You can run the following code on the tfjs API console (https://js.tensorflow.org/api/0.14.1/#clone)

const x = tf.tensor([3, 2, 1]);

x.clone().data().then(response => {
     const sorted = response.sort();
     console.log(sorted); // gets called second
     console.log(x.dataSync()); // gets called last
});
console.log(x.dataSync()); // gets called first

Or seen synchronous:

const x = tf.tensor([3, 2, 1]);
console.log(x.dataSync()); //gets called first
const data = tf.clone(x).dataSync();
const sorted = data.sort();
console.log(sorted); // gets called second
console.log(x.dataSync()); // gets called last

Output:

3,2,1
1,2,3
1,2,3

Expected output:

3,2,1
1,2,3
3,2,1

Metadata

Metadata

Labels

type:bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions