pytorch_dlprim icon indicating copy to clipboard operation
pytorch_dlprim copied to clipboard

clamp and clamp_min need to use self_c for X instead of self

Open artyom-beilis opened this issue 1 year ago • 4 comments

artyom-beilis avatar Mar 23 '24 16:03 artyom-beilis

What's the difference between self and self_c?

sukamenev avatar Mar 25 '24 22:03 sukamenev

dlprimitives work only on contiguous tensors, if input isn't contiguous it is converted to one by calling

Tensor self_c = self.contiguous();

self_c is promised to be contiguous, so self_c should be used. It is a bug in my original code, I noticed it when I reviewed the code.

artyom-beilis avatar Mar 26 '24 05:03 artyom-beilis

I fixed these and other errors in my pull request.

But the following line in my code confuses me. Will it cause a memory leak?

self = self.contigouos()

It seems that in modern C++ this should not cause problems. But I would like to hear your opinion as an expert.

sukamenev avatar Mar 27 '24 11:03 sukamenev

self = self.contigouos() 

Is incorrect indeed.

I'll describe in more details in pool request

artyom-beilis avatar Mar 28 '24 12:03 artyom-beilis

Fixed in the pull

artyom-beilis avatar Aug 08 '24 04:08 artyom-beilis