Skip to content

Commit

Permalink
debuging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Kopcinski authored and Mateusz Kopcinski committed Aug 20, 2024
1 parent fdb204a commit 79fc97b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/ex_vision/style_transfer/style_transfer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ for {module, opts} <- TestConfiguration.configuration() do
use ExVision.Model.Case, module: unquote(opts[:module])

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference for batch (ExVision.StyleTransfer.MosaicFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test inference (ExVision.StyleTransfer.MosaicFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test inference for batch (ExVision.StyleTransfer.MosaicFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference (ExVision.StyleTransfer.MosaicFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference for batch (ExVision.StyleTransfer.UdnieFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test inference (ExVision.StyleTransfer.UdnieFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test inference for batch (ExVision.StyleTransfer.UdnieFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference (ExVision.StyleTransfer.UdnieFastTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference for batch (ExVision.StyleTransfer.MosaicTest)

Check failure on line 43 in test/ex_vision/style_transfer/style_transfer_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

test stateful/process workflow inference for batch (ExVision.StyleTransfer.PrincessFastTest)
use ExVision.TestUtils

require Logger

@impl true
def test_inference_result(result) do
expected_result =
"test/assets/results/style_transfer/#{unquote(opts[:gt_file])}"
|> File.read!()
|> Nx.deserialize()

assert_tensors_equal(result, expected_result)
assert_tensors_equal(result, expected_result, 5, 0.05)
end
end
end
4 changes: 2 additions & 2 deletions test/support/exvision/test_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ defmodule ExVision.TestUtils do
end
end

defmacro assert_tensors_equal(a, b, delta \\ @default_delta) do
defmacro assert_tensors_equal(a, b, delta \\ @default_delta, relative_delta \\ 0.0) do
quote do
assert unquote(a)
|> Nx.all_close(unquote(b), atol: unquote(delta))
|> Nx.all_close(unquote(b), atol: unquote(delta), rtol: unquote(relative_delta))
|> Nx.reduce_min()
|> Nx.to_number() == 1
end
Expand Down

0 comments on commit 79fc97b

Please sign in to comment.