Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Nx.LinAlg.norm's axes option #1486

Open
LostKobrakai opened this issue May 19, 2024 · 0 comments
Open

Problem with Nx.LinAlg.norm's axes option #1486

LostKobrakai opened this issue May 19, 2024 · 0 comments

Comments

@LostKobrakai
Copy link

Copy from a discussion on slack:

t = #Nx.Tensor<
  f64[3][2]
  [
    [-1.0, -1.0],
    [0.0, 0.0],
    [1.0, 1.0]
  ]
>

Nx.LinAlg.norm(t, axes: [1])

This fails with:

** (ArgumentError) cannot broadcast tensor of dimensions {3, 2} to {3}
    (nx 0.7.2) lib/nx/shape.ex:345: Nx.Shape.binary_broadcast/4
    (nx 0.7.2) lib/nx.ex:5407: Nx.devectorized_element_wise_bin_op/4
    (nx 0.7.2) lib/nx/lin_alg.ex:402: Nx.LinAlg.norm_integer/3
    (nx 0.7.2) lib/nx/defn/compiler.ex:173: Nx.Defn.Compiler.runtime_fun/3
    (nx 0.7.2) lib/nx/defn/evaluator.ex:87: Nx.Defn.Evaluator.precompile/3
    (nx 0.7.2) lib/nx/defn/evaluator.ex:65: Nx.Defn.Evaluator.__compile__/4
    (nx 0.7.2) lib/nx/defn/evaluator.ex:58: Nx.Defn.Evaluator.__jit__/5
    /Volumes/benni/Livebook/voronoi.livemd#cell:ptoi3arwh7gaepjoxh74lpa3sxz7zlw7:5: (file)

I think the expected result should be:

#Nx.Tensor<
  f64[3]
  [
    1.4142135623730951,
    0.0,
    1.4142135623730951
  ]
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant