107 Commits

Author SHA1 Message Date
Rob Keevil
7db3ea8b1c upgrade to onnxruntime 1.23.2 v1.25.0 2025-12-16 08:54:12 -05:00
yalue
87f81219de Adjust README text on execution providers
- The README seemed a bit too CUDA-centric
2025-12-12 09:50:33 -05:00
yalue
737d7d2d9e Implement string tensor support
- This change adds support for tensors of
   ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING. Unfortunately, this can't be
   shoehorned into Tensor[T], since there's no obvious way to have go
   manage the backing buffer of memory. Instead this change adds a
   StringTensor type, that satisfies the OrtValue interface.

 - Added a new test .onnx file that takes a vector of strings and
   converts each string into uppercase and lowercase outputs.
v1.24.0
2025-12-04 12:02:03 -05:00
Kyle
b832b6b775 Remove RunWithContext v1.23.0 2025-11-30 09:13:28 -05:00
Kyle
594461b9b4 Support RunOptions 2025-11-30 09:13:28 -05:00
yalue
89bd925781 Support AppendExecutionProvider
- This changes adds a wrapper for the
   SessionOptionsAppendExecutionProvider API, which is a basic catch-all
   function for enabling several execution providers, some of which
   already have dedicated functions.

 - Added a very basic test for the new function's error. It would be
   nicer to test the function itself, but that would require a system
   that supports one of the providers.
v1.22.0
2025-10-24 20:02:50 -04:00
yalue
98a5f7041c Allow shapes with no dimensions at all
- Apparently some onnx models will use outputs that have no dimensions.
   This change supports such models.

 - Note: You still won't be able to create a ort.Tensor when the shape's
   length is 0. I plan to keep things this way unless someone complains.
v1.21.0
2025-07-07 20:19:53 -04:00
Anton Rosén
b8230be7b9 feat: add functions to get metadata with session options 2025-06-02 11:47:04 -04:00
yalue
f2f88a05ab Expose logging-level functions
- Added functions for setting per-session and environment-wide logging
   levels. This allows me to remove the stdout message when the test
   fails to load the OpenVINO library.
v1.20.0
2025-05-30 08:23:55 -04:00
yalue
f15b62b8d0 Allow tensors with sizes of 0
- Onnxruntime allows one or more dimensions of a tensor to be 0, and
   this is actually useful in some cases. This was previously
   (incorrectly) prohibited by the Go wrapper. No longer.

 - Added a test to ensure that tensors with a dimension of 0 are
   allowed.

 - Additionally, expose the LoggingLevel type, wrapping the
   OrtLoggingLevel enum. I plan to use this to hopefully silence the
   annoying failure messages printed to stdout when the OpenVINO tests
   run.
2025-05-29 20:38:24 -04:00
Anton Rosén
f70a71e4f5 feat: upgrade to onnxruntime 1.22.0 2025-05-21 09:49:02 -04:00
Alex Sadleir
f86bf9bd32 use map to c strings helper v1.19.0 2025-03-25 09:48:30 -04:00
Alex Sadleir
390db97ef5 Use string based coreml config 2025-03-25 09:48:30 -04:00
Alex Sadleir
217ac59cad Add CoreML provider with options struct 2025-03-25 09:48:30 -04:00
yalue
de03591892 Add unit test for initialization options
- The unit test is rather basic, and just makes sure errors don't occur
   for a couple things.

 - Fixed a potential issue where an environment could remain partially
   initialized if an initialization option failed to apply.
v1.18.0
2025-03-21 08:07:17 -04:00
William Muir
3cdf0a4558 Add functional option EnvironmentOption and options to update ORT environment logging level during initialization 2025-03-21 07:59:11 -04:00
Rob Keevil
2944d696fe upgrade to onnxruntime 1.21.0 2025-03-21 07:45:12 -04:00
yalue
b40ecf5001 Add Basic I/O binding, graph optimization level
- Added basic wrappers for I/O binding APIs. BindOutputToDevice is
   notably still not supported.

 - Added support for setting the GraphOptimizationLevel in session
   options.
v1.17.0
2025-02-16 21:33:49 -05:00
yalue
fe14322938 Add SessionOptions.SetExecutionMode()
- This adds a wrapper around the SetSessionExecutionMode C API, which
   allows setting a session's execution mode to ORT_PARALLEL or
   ORT_SEQUENTIAL.

 - This also introduces a wrapper for the ExecutionMode enum.

 - To test execution mode, introduced example_big_fanout.onnx, which
   does 100 matrix multiplies in parallel before recombining the result.
   It looks really funny in netron.app. Unfortunately, it performs worse
   with parallelism, likely due to the matrix sizes being tiny. However,
   the settings clearly make a difference.
v1.16.0
2025-01-11 14:16:42 -05:00
yalue
4200277c8e Support SessionOptionsConfig APIs
- Added support for onnxruntime's string-based API for setting session
   options. This includes three functions for SessionOptions instances:
   HasSessionConfigEntry(key string), GetSessionConfigEntry(key string),
   and AddSessionConfigEntry(key, value string).

 - This can be used to change session settings that aren't otherwise
   exposed by the API, such as "session.inter_op_allow_spinning".
v1.15.0
2025-01-07 18:51:14 -05:00
yalue
fe41cf481b Allow Tensor[bool] types
- Added support for the bool tensor type; my main reservation is that
   Go may in the future represent bool slices by something other than
   single bytes. However, I doubt this will be the case for several
   reasons: 1) it would likely break many other Cgo libraries, 2) it
   would make binary.Write and binary.Read more complicated, since both
   guarantee one byte per bool, 3) Go seems to have no mechanism to
   have elements of slices be different sizes, which would be necessary
   for some slice-of-bits implementation of bool, and 4) there should
   never be a reason for a bool to be _larger_ than one byte. Given
   these thoughts, I think it's reasonable to assume this change will be
   safe. If any of this changes in the future, it would require
   deprecating and removing bool tensor support, which seems unlikely to
   be heavily used.
v1.14.0
2024-12-27 08:42:59 -05:00
yalue
765a41b274 Remove more training API stuff
- Removed testing data that was used only with
   onnxruntime_training_test.go, which was already removed.

 - Renamed legacy_types.go to legacy_code.go, since it's now a parking
   ground for legacy code that's not just "types".

 - Fixed some references to the training API in CONTRIBUTING.md.
2024-11-14 08:21:57 -05:00
yalue
11b449bb38 Remove training API
- The training API has been deprecated by onnxruntime itself, and it
   will be much easier to remove it rather than deprecate it.

 - The training API wrapper functions have been replaced by stubs that
   return errors in legacy_types.go.

 - The README mentions the old version required for the training API.

 - The Scalar type has been promoted to onnxruntime_go.go, and a test
   has been added for it.
v1.13.0
2024-11-13 20:34:22 -05:00
Rob Keevil
f9cafdda92 upgrade to onnxruntime 1.20.0 2024-11-12 20:12:11 -05:00
yalue
02239b0937 Minor cleanup
- The training test printed some stuff to stdout rather than the
   testing log.

 - The temporary buffer for UTF16 conversion was over-allocated.
v1.12.1
2024-09-14 23:24:31 -04:00
Nathan O
b5a29a1390 Convert paths to UTF16 on Windows, enable path-based APIs (#69)
Convert paths to UTF16 on Windows, enable path-based APIs

 - This change adds a function to convert UTF8 to UTF16 strings on
   Windows, enabling direct usage of the onnxruntime CreateSession
   functions in lieu of always buffering files and using
   CreateSessionFromArray.

 - Adding functionality for converting paths to UTF16 also enables the
   training API on Windows.

 - This is an in-progress commit that still may require some touchups,
   as well as proper test cases for the now-underutilized *WithONNXData
   functions.

 - Added a simple .onnx file to test_data with a name containing
   non-ascii characters.

 - Used the new file to test that the non-ASCII paths work correctly on
   Windows and Linux, in both the current and "legacy" session API.

 - Removed the old "example_network.onnx" and associated tests. This was
   an overengineered idea from when I first started the library.
2024-09-10 17:36:13 -04:00
Rob Keevil
90678d6a1d Update README.md to clarify the requirement for CUDA 12.x v1.12.0 2024-09-06 16:36:24 -04:00
Rob Keevil
9abc5adfda Upgrade to onnxruntime 1.19.0 2024-09-06 16:36:24 -04:00
Nathan
f987f8136a Minor adjustments
- Fix typos and minor text in CONTRIBUTING.md

 - .gitignore doesn't refer to any artifacts within the repo. Removing
   the unused lines made the file empty, so removed the file.

 - Added the training API header to .gitattributes so it won't count
   towards the LoC in the github statistics.
2024-08-23 19:49:00 -04:00
yalue
75416c0bb6 Fix memory leak in createTensorFromOrtValue
- Fixing this memory leak required changing the semantics for the
   internal createGoValueFromOrtValue function, since the input OrtValue
   will now be released and replaced if it was a Tensor.

 - This fixes the memory leak by releasing C-managed data and copying it
   into a Go slice. Previously, the C-managed data would never be freed,
   because the OrtValue containing it would never be released. This
   wouldn't cause a segfault, but it would potentially slowly leak
   memory.
v1.11.0
2024-07-25 21:07:41 -04:00
yalue
4904ca2553 Add Map support, sklearn test passes
- Added support for the ONNX Map type. It's kind of a cumbersome type
   to use, honestly.

 - The sklearn network now works.
2024-07-25 20:41:52 -04:00
Nathan
94ba83d77d Change Sequence API
- I wanted to change this before anyone started using the previous
   version.

 - This new version is much easier to use; you no longer need to
   manually free every value that you read from a sequence; they're
   fetched when the sequence is created and destroyed when it's
   destroyed.
2024-07-23 21:11:54 -04:00
Nathan
80e480e2a8 Initial Sequence tests: added and passing
- Added tests for the Sequence type, including preliminary ones
   launching the sklearn network.

 - The sklearn test will be finished after map support is added.
2024-07-23 20:35:37 -04:00
Nathan
4aa8513549 Initial Sequence support
- This adds support for ONNX sequences, along with basic unit tests for
   the sequence types.

 - This also introduces a new test network generated via sklearn in an
   included script.

 - The test using sklearn_randomforest.onnx has not been written yet,
   but I wanted to commit after doing all the work so far. The existing
   tests all pass.
2024-07-22 21:13:10 -04:00
Nathan O
0334e9617f Merge pull request #62 from yalue/minor_updates
Replace `ArbitraryTensor` with `Value`, test updates
2024-07-20 22:38:22 -04:00
yalue
ec47fbd4ba Fix Writing in CONTRIBUTING.md
- Just going over it again after some proofreading.
2024-07-20 22:34:43 -04:00
yalue
2428c6c495 Replace ArbitraryTensor usage in tests
- Updated tests and examples to use Value rather than ArbitraryTensor.

 - Left a couple small tests to make sure the alias remains defined.
2024-07-20 22:19:00 -04:00
yalue
ec3349aba8 Replace ArbitraryTensor with Value
- This is in preparation for supporting non-Tensor types in the future.

 - Haven't updated the tests yet.
2024-07-20 22:06:03 -04:00
yalue
81d704b3e8 Use t.Fatalf and t.Errorf in onnxruntime_test.go
- I used t.Logf(), t.FailNow() in many places when a single function would
   have sufficed.  Apparently I need to read the Go docs a bit better.
2024-07-20 21:48:44 -04:00
yalue
4dda46b3a6 Add CONTRIBUTING.md
- Decided to write down some contribution guidelines.

 - Clean up the files generated by onnxruntime_training_test.go.
2024-07-20 21:01:57 -04:00
mirecl
fb027886d1 📃 Add API for get version of the onnxruntime library 2024-07-20 21:01:07 -04:00
riccardopinosio
b996588c79 feat: implemented bindings to onnxruntime on-device training C api 2024-07-18 08:05:55 -04:00
riccardopinosio
3aa90cfd7c fix: make readme example runnable 2024-07-14 13:30:13 -04:00
Rob Keevil
bfd36f8b0d Upgrade to ONNXRuntime 1.18.0 (#55)
The change has been tested and seems to run without issues on CPU and CUDA on Windows, as well as CPU, CUDA, and TensorRT on arm64 Linux.
v1.10.0
2024-05-29 20:02:45 -04:00
yalue
839fd69a21 Add test to ensure proper handling of empty .onnx
- This test is just intended to catch regressions, it would have
   caught the bugs fixed in commit 387fb46836
2024-04-16 10:39:31 -04:00
yalue
387fb46836 Use existing createCSession function in more places
- Use the createCSession function in GetInputOutputInfoWithONNXData and
   GetModelMetadataWithONNXData.

 - The createCSession function contains some essential error checks and
   it's better to reuse code anyway. This should fix some bugs that
   hadn't been reported yet (e.g., passing an empty slice to either of
   these functions or calling GetInputOutputInfo with an empty file,
   etc)
2024-04-14 20:02:39 -04:00
yalue
36525d3bca Remove incorrect newline in error message
- Noticed this when running tests: one of the error messages
   potentially returned by NewTensor included a newline
2024-03-06 08:23:43 -05:00
yalue
258a996438 Small README update
- The README mentioned not including arm64 osx binaries in test_data/,
   which is no longer true.  I'd personally prefer to keep the number
   of libraries in test_data to a minimum, but it's valuable to make it
   easier for other users to test on osx, which I personally am not able
   to test.
2024-03-06 08:12:45 -05:00
yalue
9bd3a72fe3 Support OpenVINO Execution Provider
- Add SessionOptions.AppendExecutionProviderOpenVINO, which should
   enable the OpenVINO execution provider on supported systems.
   Internally it calls the
   SessionOptionsAppendExecutionProvider_OpenVINO_V2 API.
v1.9.0
2024-03-04 08:38:38 -05:00
yalue
fff18e7522 Update to version 1.17.1 of onnxruntime
- This change updates the headers and included shared library binaries
   release 1.17.1 of onnxruntime. The tests (including CUDA support)
   still seem to pass.
2024-02-28 09:59:38 -05:00