Quansight-Labs / udiff

Automatic differentiation with uarray/unumpy.
BSD 3-Clause "New" or "Revised" License
16 stars 11 forks source link

add np.stack #31

Closed sangyx closed 4 years ago

sangyx commented 4 years ago

I have added the diff function of np.stack.

When we extend the code to higher-order derivatives, the situation becomes a bit more complicated. There are some places to improve:

Do you have any idea about the above questions?

hameerabbasi commented 4 years ago

Ah, yes. I remember running into this when I was initially working with udiff. Basically, in your approach, it would work as follows:

sangyx commented 4 years ago

I have fixed the problem, we have to put all the calculations that need to register gradients in each diff function in lambda g (or vjp), so as to avoid infinite loops.

The error of <uarray multimethod '__instancecheck__'> in ci seem to be related to uarray.

hameerabbasi commented 4 years ago

I'll fix those up. Don't worry about them for now.

hameerabbasi commented 4 years ago

@peterbell10 I can reproduce the segfault in CI. Is it possible for you to investigate? I was also getting a bunch of "returned NULL without setting an error" on determine_backend.

hameerabbasi commented 4 years ago

@sangyx Passing the torch back to you. 😄 The segfaults should be resolved now.

Edit: To resolve them locally, get master of uarray and unumpy, and do pip install -e . in the directories of both.

sangyx commented 4 years ago

Thanks!

sangyx commented 4 years ago

@hameerabbasi Hi, I want to add <uarray multimethod '__instancecheck__'> to raw_functions. But I don't know how to refer it. How can I find it by code like np.ndim?

hameerabbasi commented 4 years ago

Hi, I want to add <uarray multimethod '__instancecheck__'> to raw_functions. But I don't know how to refer it. How can I find it by code like np.ndim?

You can probably do something like unumpy.ClassOverrideMeta.__instancecheck__.

sangyx commented 4 years ago

@hameerabbasi Could you help me to check whether the NoGradBackend is correct?

hameerabbasi commented 4 years ago

Thanks @sangyx!