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

Some warning removals #635

Merged
merged 9 commits into from
Mar 22, 2024
Merged

Conversation

AngelEzquerra
Copy link
Contributor

This PR removes many warnings and some unnecessary hints. Some of this is similar to a draft PR that @mratsim opened a few months ago, so there is some overlap with his work.

Note that one of the warnings could not really be fixed so I just disabled it. This is explained in the code and in the corresponding commit message.

@AngelEzquerra AngelEzquerra force-pushed the some_warning_removals branch from 4fda79e to 1c50923 Compare March 17, 2024 12:51
Comment on lines +86 to +89
# The following cast removes the following warning:
# =destroy(storage.raw_buffer) can raise an unlisted exception: Exception
{.cast(raises: []).}:
`=destroy`(storage.raw_buffer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, interesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Courtesy of @beef, who I should have mentioned on the commit message :)

Comment on lines 44 to 72
proc `+`*[T: SomeNumber|Complex[float32]|Complex[float64]](a, b: Tensor[T]): Tensor[T] {.noinit.} =
## Tensor addition
#echo "+++++ SAME ++++++"
map2_inline(a, b, x + y)

proc `+`*[T, K: SomeNumber](a: Tensor[Complex[T]], b: Tensor[K]): Tensor[Complex[T]] {.noinit.} =
## Tensor addition
echo "+++++ COMPLEX ++++++"
when T is K:
echo "T is K"
map2_inline(a, b, x + y)
elif T is float64:
echo "T is float64"
map2_inline(a, b, x + float64(y))
else:
{.error: "Tensor addition not supported for tensors of types " & $T & " and " & $K}

proc `+`*[T, K: SomeNumber](a: Tensor[K], b: Tensor[Complex[T]]): Tensor[Complex[T]] {.noinit.} =
## Tensor addition
echo "+++++++++++2"
when T is K:
echo "T is K"
map2_inline(a, b, x + y)
elif T is float64:
echo "T is float64"
map2_inline(a, b, float64(x) + y)
else:
{.error: "Complex tensor addition only supported for tensors of the same type."}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is part of this PR by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, sorry about that. I'll remove this spurious change and update the PR.

@Vindaar
Copy link
Collaborator

Vindaar commented Mar 21, 2024

I'm pretty sure I added some of these "useless" import things (like the KnownSupportsCopyMem in some modules) for the doc generation. nim doc behaves differently for some reason (or maybe it boiled down to it attempting to 'compile' each module on its own, whereas these problems go away due to generics when imported in another module.

Given that doc generation is still partially broken, I'd merge it for now. Then do another pass soon to fix the doc generation soon. Maybe at this point we can attempt again to simplify the doc generation logic...

@AngelEzquerra AngelEzquerra force-pushed the some_warning_removals branch from 9758437 to be4eabb Compare March 21, 2024 19:48
…eprecated" warning from tensor\datatypes.nim

Note that there is still another similar warning left in:

\laser\primitives\matrix_multiplication\gemm_tiling.nim(321, 3)
In particular:
- Warning: imported and not used: 'datatypes'
- Warning: imported and not used: 'complex'
Warning: imported and not used: 'math'
Removed from `examples\ex06_shakespeare_generator.nim`.
…r is deprecated` warning

We cannot really fix that warning because it is due to the fact that (as for 2.0.2) nim creates a var destructor when `new X, T` is called. Since we cannot fix it we simply disable it.
This also removes a few unnecessary imports of the complex and math modules (which are automatically exported by arraymancer). The test touches a lot funtions but the changes are minimal and simple (basically changing things like `import unittest, os` into `import std / [unittest, os]` and so on).
This warning only happens with devel. The fix is to make sequninit.nim "used" when newSeqUninit is not needed.
@AngelEzquerra AngelEzquerra force-pushed the some_warning_removals branch from be4eabb to 5f82fe2 Compare March 21, 2024 19:49
@Vindaar
Copy link
Collaborator

Vindaar commented Mar 22, 2024

Let's see if the docgen will really break. Thanks!

@Vindaar Vindaar merged commit 115dacc into mratsim:master Mar 22, 2024
6 checks passed
@Vindaar
Copy link
Collaborator

Vindaar commented Mar 22, 2024

Yeah, the docgen is now broken again:

https://github.com/mratsim/Arraymancer/actions/runs/8387852728/job/22970876430

with:

Processing: /home/runner/work/Arraymancer/Arraymancer/arraymancer/docs/build/gemm.html [180/190]
stack trace: (most recent call last)
/tmp/nimblecache-946033505/nimscriptapi_4247050129.nim(210, 16)
/home/runner/work/Arraymancer/Arraymancer/arraymancer/arraymancer.nimble(283, 14) gen_docsTask
/home/runner/work/Arraymancer/Arraymancer/arraymancer/docs/docs.nim(152, 22) buildDocs
/home/runner/work/Arraymancer/Arraymancer/arraymancer/docs/docs.nim(43, 11) execAction
/home/runner/work/Arraymancer/Arraymancer/nim/lib/std/assertions.nim(41, 14) failedAssertImpl
/home/runner/work/Arraymancer/Arraymancer/nim/lib/std/assertions.nim(36, 13) raiseAssert
/home/runner/work/Arraymancer/Arraymancer/nim/lib/system/fatal.nim(53, 5) sysFatal
/home/runner/work/Arraymancer/Arraymancer/nim/lib/system/fatal.nim(53, 5) Error: unhandled exception: /home/runner/work/Arraymancer/Arraymancer/arraymancer/docs/docs.nim(43, 3) `ret == 0` Command failed: 1
cmd: cd /home/runner/work/Arraymancer/Arraymancer/arraymancer && /home/runner/work/Arraymancer/Arraymancer/nim/bin/nim doc  --hints:off --warnings:off --git.commit:master -o:/home/runner/work/Arraymancer/Arraymancer/arraymancer/docs/build/gemm.html --index:on /home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm.nim
result:
/home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm.nim(326, 17) template/generic instantiation of `gemm_strided` from here
/home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm.nim(259, 36) template/generic instantiation of `dispatch` from here
/home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm.nim(226, 14) template/generic instantiation of `apply` from here
/home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm.nim(216, 28) template/generic instantiation of `newTiles` from here
/home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/primitives/matrix_multiplication/gemm_tiling.nim(347, 43) template/generic instantiation of `align_raw_data` from here
Error: /home/runner/work/Arraymancer/Arraymancer/arraymancer/src/arraymancer/laser/private/memory.nim(9, 23) Error: undeclared identifier: 'KnownSupportsCopyMem'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (11, 7): 'closureScope' [AssertionDefect]
       Tip: 21 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(160) execScript

    Error:  Exception raised during nimble script execution
Error: Process completed with exit code 1.

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

Successfully merging this pull request may close these issues.

2 participants