BinaryConnect icon indicating copy to clipboard operation
BinaryConnect copied to clipboard

Comparison between ".data.clone()" and ".data.copy_()"

Open ChaofanTao opened this issue 4 years ago • 3 comments

Thank you for your code!

I have a question about LINE 26 and LINE33 in the binaryconnect.py. I wonder why you choose two different functions ".data.clone()" and ".data.copy_()" in these lines?

I guess the "clone()" will create a new tensor with new address, while "copy_()" is a in-place operation, am I right?

I also wonder the Version of Pytorch that you implemented in this code.

Thank you again!

ChaofanTao avatar Jul 11 '20 06:07 ChaofanTao

Hello,

You are right concerning the difference between clone and copy . I tested the code on Pythorch 0.4 and 1

eghouti avatar Jul 14 '20 14:07 eghouti

@eghouti Hi, For self.saved_params, why use "clone" in BC.init and use "copy_" in BC.save_params ? Why choose two different approachs to store data for one list self.saved_params ?

649459021 avatar Oct 12 '20 12:10 649459021

Therefore, I guess the version of Torchvision you used is 0.2.2?

benjaminlblanc avatar Oct 28 '20 19:10 benjaminlblanc