Closed santiago-imelio closed 6 months ago
You are trying to pass tensors as slice lengths, and that is not supported. This is because Nx doesn't currently support dynamic shapes
Upon re-reading the issue, I believe dynamic length means "passed as an argument". If that's the case, you can pass it via a keyword option list as a literal number:
defn f(a, opts \\ []) do
opts = keyword!(opts, [:window_dims])
{m, n} = opts[:window_dims]
...
As I had read before, I had interpreted dynamic as depending on the tensor values, which is what prompted my first response.
Hello, I'm working on a notebook to implement 2D median filter using Nx. For each pixel of an image, I take a window of a given size centered on the pixel and compute the median, so the pixel value will be replaced with the median.
For this I used two
while
loops to iterate over all pixels of the image, andNx.slice/3
to get the window. The lengths of the slice are dynamic and depend on values that I pass to the while context tuple.However, passing the lengths to
Nx.slice
within the while loop block gives this error. Is there something I need to do before passing the parameters toNx.slice
? Or is it just thatNx.slice
is not supported on while loops?Thanks in advance!