Skip to content

Commit

Permalink
Merge branch 'main' into jfowers/xformer3
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyfowers authored Jan 17, 2024
2 parents c4eeb64 + 270ff6c commit fa20025
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
13 changes: 13 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PORTIONS LICENSED AS FOLLOWS

\> TurnkeyML used code from the [MLAgility](https://github.com/groq/mlagility) and [GroqFlow](https://github.com/groq/groqflow) projects as a starting point. Much of that code was refactored, improved, or replaced by the time TurnkeyML was published.

>The MIT License
>
>Copyright 2023 Groq Inc.
>
>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,7 @@ This project is sponsored by the [ONNX Model Zoo](https://github.com/onnx/models
## License

This project is licensed under the [Apache 2.0 License](https://github.com/onnx/turnkeyml/blob/main/LICENSE).

## Attribution

TurnkeyML used code from other open source projects as a starting point (see [NOTICE.md](NOTICE.md)). Thank you Philip Colangelo, Derek Elkins, Jeremy Fowers, Dan Gard, Victoria Godsoe, Mark Heaps, Daniel Holanda, Brian Kurtz, Mariah Larwood, Philip Lassen, Andrew Ling, Adrian Macias, Gary Malik, Sarah Massengill, Ashwin Murthy, Hatice Ozen, Tim Sears, Sean Settle, Krishna Sivakumar, Aviv Weinstein, Xueli Xao, Bill Xing, and Lev Zlotnik for your contributions to that work.
18 changes: 12 additions & 6 deletions src/turnkeyml/build/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,24 @@ def fire(self, state: build.State):
default_warnings = warnings.showwarning
warnings.showwarning = _warn_to_stdout

stats = fs.Stats(
state.cache_dir, state.config.build_name, state.evaluation_id
)
stats = fs.Stats(state.cache_dir, state.config.build_name, state.evaluation_id)

# Verify if the exported model matches the input torch model
try:
# Tolerance levels for the torch export are recommended by Pytorch here:
# https://pytorch.org/docs/stable/testing.html#module-torch.testing
fp32_tolerance = torch.onnx.verification.VerificationOptions(
rtol=1.3e-6, atol=1e-5
)

# The `torch.onnx.verification.find_mismatch()` takes input arguments to the
# model as `input_args (Tuple[Any, ...])`
export_verification = torch.onnx.verification.find_mismatch(
state.model,
tuple(state.inputs.values()),
opset_version=state.config.onnx_opset)
opset_version=state.config.onnx_opset,
options=fp32_tolerance,
)

# `export_verification.has_mismatch()` returns True if a mismatch is found and
# False otherwise. If no mismatch is found,# `is_export_valid` is set to "Valid",
Expand All @@ -311,8 +317,8 @@ def fire(self, state: build.State):
is_export_valid = "unverified"

stats.save_model_eval_stat(
fs.Keys.TORCH_ONNX_EXPORT_VALIDITY,
is_export_valid,
fs.Keys.TORCH_ONNX_EXPORT_VALIDITY,
is_export_valid,
)

# Export the model to ONNX
Expand Down

0 comments on commit fa20025

Please sign in to comment.