From 5083bf192b7ea911a5b8441a703600040bdbbca7 Mon Sep 17 00:00:00 2001 From: Barna Kovacs Date: Fri, 26 Jul 2024 08:42:20 +0200 Subject: [PATCH] Fix min / max value for 16 bit signed type (#1516) --- nx/lib/nx/constants.ex | 4 ++-- nx/lib/nx/shared.ex | 2 +- nx/lib/nx/type.ex | 4 ++-- nx/test/nx/vectorize_test.exs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nx/lib/nx/constants.ex b/nx/lib/nx/constants.ex index 80bcc5e99e..b05b756d94 100644 --- a/nx/lib/nx/constants.ex +++ b/nx/lib/nx/constants.ex @@ -158,7 +158,7 @@ defmodule Nx.Constants do iex> Nx.Constants.max_finite({:s, 16}) #Nx.Tensor< s16 - 32677 + 32767 > iex> Nx.Constants.max_finite({:f, 32}) @@ -220,7 +220,7 @@ defmodule Nx.Constants do iex> Nx.Constants.min_finite({:s, 16}) #Nx.Tensor< s16 - -32678 + -32768 > iex> Nx.Constants.min_finite({:f, 32}) diff --git a/nx/lib/nx/shared.ex b/nx/lib/nx/shared.ex index 1137e42120..88ec8748e9 100644 --- a/nx/lib/nx/shared.ex +++ b/nx/lib/nx/shared.ex @@ -560,7 +560,7 @@ defmodule Nx.Shared do @doc false def raise_vectorization_not_supported(%T{vectorized_axes: [_ | _]}, {function, arity}) do - raise ArgumentError, "#{function}/#{arity} is does not support vectorized inputs" + raise ArgumentError, "#{function}/#{arity} does not support vectorized inputs" end def raise_vectorization_not_supported(_, _), do: nil diff --git a/nx/lib/nx/type.ex b/nx/lib/nx/type.ex index 57ad91d1c3..d0084ec09f 100644 --- a/nx/lib/nx/type.ex +++ b/nx/lib/nx/type.ex @@ -63,7 +63,7 @@ defmodule Nx.Type do def min_finite_binary(type) def min_finite_binary({:s, 8}), do: <<-128::8-signed-native>> - def min_finite_binary({:s, 16}), do: <<-32678::16-signed-native>> + def min_finite_binary({:s, 16}), do: <<-32768::16-signed-native>> def min_finite_binary({:s, 32}), do: <<-2_147_483_648::32-signed-native>> def min_finite_binary({:s, 64}), do: <<-9_223_372_036_854_775_808::64-signed-native>> def min_finite_binary({:u, size}), do: <<0::size(size)-native>> @@ -85,7 +85,7 @@ defmodule Nx.Type do def max_finite_binary(type) def max_finite_binary({:s, 8}), do: <<127::8-signed-native>> - def max_finite_binary({:s, 16}), do: <<32677::16-signed-native>> + def max_finite_binary({:s, 16}), do: <<32767::16-signed-native>> def max_finite_binary({:s, 32}), do: <<2_147_483_647::32-signed-native>> def max_finite_binary({:s, 64}), do: <<9_223_372_036_854_775_807::64-signed-native>> def max_finite_binary({:u, 8}), do: <<255::8-native>> diff --git a/nx/test/nx/vectorize_test.exs b/nx/test/nx/vectorize_test.exs index 683e8f4ed9..36819460fa 100644 --- a/nx/test/nx/vectorize_test.exs +++ b/nx/test/nx/vectorize_test.exs @@ -577,7 +577,7 @@ defmodule Nx.VectorizeTest do end test "simple cond" do - # this tests the case where we have a two vectorized predicates + # this tests the case where we have two vectorized predicates pred1 = Nx.vectorize(~VEC[1 0 0], :pred) pred2 = Nx.vectorize(~VEC[0 0 0], :pred)