artyom-beilis / pytorch_dlprim

DLPrimitives/OpenCL out of tree backend for pytorch
http://blog.dlprimitives.org/
MIT License
227 stars 16 forks source link

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

Open artyom-beilis opened 4 months ago

sukamenev commented 4 months ago

What's the difference between self and self_c?

artyom-beilis commented 4 months ago

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.

sukamenev commented 3 months ago

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.

artyom-beilis commented 3 months ago
self = self.contigouos() 

Is incorrect indeed.

I'll describe in more details in pool request