Commit Graph

37 Commits

Author SHA1 Message Date
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
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
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
mirecl
fb027886d1 📃 Add API for get version of the onnxruntime library 2024-07-20 21:01:07 -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
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.
2024-03-04 08:38:38 -05:00
yalue
e3c08ba136 Add test for dynamically-sized inputs & outputs
- I hadn't tested this properly before, but DynamicAdvancedSession
   seems perfectly capable of handling inputs and outputs with dynamic
   axes. This change introduces a test case for this behavior, including
   a basic ONNX network that computes a sum on an arbitrary batch of
   vectors.
2024-02-23 20:45:15 -05:00
yalue
ed34aa7356 Add GetModelMetadata API
- Added functionality to wrap the onnxruntime SessionGetModelMetadata
   for both AdvancedSession types and plain .onnx files.
2024-02-01 20:59:02 -05:00
Nathan
d7e65a16dc Add API for getting inputs and output info from .onnx file
- Added the GetInputOutputInfo() and GetInputOutputInfoWithONNXData()
   functions, which return a list of input and output names, shapes, and
   types for a .onnx file.
2024-01-06 09:57:44 -05:00
yalue
3d64d760c6 Add DirectML support
- This commit adds bindings to enable DirectML on supported onnxruntime
   builds and systems.

 - I couldn't get the tests to run on my own system, so it has not yet
   been tested.

 - I am still not happy with copying the OrtDmlApi struct, but think
   it's better than the "proper" alternative of trying to pull in the
   dml_provider_factory.h header.
2024-01-03 17:51:59 -05:00
yalue
f041744a27 Minor change to data-type test
- There was an old comment in the test about the data types not being
   exposed, which is no longer true as of the addition of
   TensorElementDataType to the go wrapper.
2023-12-11 08:36:43 -05:00
guowei wong
2b9a60b304 Add sessionOptions to set CpuMemArena and MemPattern
fix comments

fix format
2023-12-10 02:28:07 +08:00
yalue
c3635af6f5 Add Tensor.ZeroContents() function
- Added a function that sets the underlying data slice to 0 for any
   tensor type.

 - Added a test for the new function.

 - Nobody was asking for this, but I plan to use it myself.

 - It's probably worth benchmarking whether this is better to do using
   C.memset or just a loop in go. Probably depends on tensor size and
   the overhead of the C call.
2023-11-27 14:09:25 -05:00
Nathan
b0799d6c42 Fix incorrect testing code
- Some code intended to compare two floats only was comparing them if
   they had a negative difference. Fixed.

 - Fixing this issue made no difference in the tests passing; they still
   seem fine. Not surprising.
2023-11-23 20:08:29 -05:00
Yohay
26f9e04a46 added test and fixed doc comment 2023-10-23 23:30:12 +03:00
yalue
42f85c9f58 Add CustomDataTensor type
- This change introduces the CustomDataTensor type, which implements
   the ArbitraryTensor interface but, unlike the typed Tensor[T], is
   backed by an arbitrary slice of user-provided bytes. The user is
   responsible for providing the type of data the tensor is supposed to
   contain, as well as responsible for ensuring the data slice is in the
   correct format for the specified shape.

 - Added some test cases for the new CustomDataTensor type, which most
   notably will enable users to use float16 tensors (provided they
   converted the float16 array into bytes on their own).
2023-09-27 19:49:09 -04:00
yalue
99c8153427 Ignore onnxruntime C API header in language stats
- Add a .gitattributes file that will hopefully make github recognize
   this as a Go repo rather than a C++ one.

 - Remove an outdated comment from onnxruntime_test.go.
2023-09-07 09:26:41 -04:00
yalue
c1d6315273 Minor comment and test fixes
- A comment in onnxruntime_wrapper.h was written when I incorrectly
   assumed that CoreML was supported via the ort_api struct. Fixed.

 - The benchmark timer is not properly stopped before initializing the
   session and environment in the CoreML benchmark.
2023-08-30 14:26:17 -04:00
yalue
4254585834 Add CoreML Support
- This commit adds changes to support CoreML. CoreML is enabled via a
   function that's exported only in the onnxruntime dylib on supported
   platforms (i.e., Apple systems). So, this change enables support by
   looking up the required function if running on a platform where it is
   expected.  Doing this avoids the need for any headers, and support
   can be detected at runtime.

 - Refactors a bunch of testing and benchmarking code, to avoid
   replicating a bunch of code for yet another execution provider.
2023-08-30 13:32:29 -04:00
yalue
4768a7ba69 Add TensorRT Support
- This change introduces support for enabling the TensorRT execution
   backend. It is configured in basically the same manner as the CUDA
   backend, with analogous APIs.

 - Added a unit test and benchmark for the TensorRT backend. To try it,
   run "go test -v -bench=." on a system where TensorRT is installed,
   and you're using a build of onnxruntime with TensorRT enabled.
2023-08-28 11:51:04 -04:00
Cedric Joulain
50c95f2d62 Add MacOS arm64 to tests 2023-08-25 08:43:43 +02:00
yalue
608a1fa0f0 Add CUDA tests, enable env var for onnxruntime lib
- Added a CUDA test and benchmark. They seem to pass on a CUDA 11.8
   x86_64 Linux system, though I have not tested them elsewhere yet.

 - Updated the test code to check for the
   ONNXRUNTIME_SHARED_LIBRARY_TEST environment variable. If the
   environment variable is set, then the test code will use it as the
   path to the onnxruntime shared library binary, rather than attempting
   to use the copies in the test_data directory. This is helpful when
   testing with CUDA-enabled builds, which are huge and I don't want to
   include them in test_data.
2023-08-24 10:53:14 -04:00
yalue
242cf08feb Write CUDA test
- Not yet tested on a system where CUDA is actually enabled

 - Updated the README to include more information about onnxruntime
   library versions.
2023-08-23 13:48:43 -04:00
yalue
22bf308e63 Add test for SessionOptions
- Added a test for setting SessionOptions.

 - Added another network: example_big_compute.onnx. It is deterministic,
   and I hope to use it when testing CUDA acceleration due to the
   relatively large amount of compute it does (a series of scalar
   multiplications and divisions across a 50M element tensor).

 - Added a benchmark for single-threaded vs. multi-threaded evaluation
   of a network. Unfortunately, they don't show any performance
   difference; something may be wrong but I'll investigate more later.
2023-08-23 13:04:23 -04:00
yalue
c127ad7875 Add new DynamicAdvancedSession tests
- Added tests to exercise the DynamicAdvancedSession API. Also checks
   that errors correctly occur when providing incorrect inputs or
   outputs.
2023-08-23 11:39:37 -04:00
yalue
695d751819 Add AdvancedSession
- This commit introduces the AdvancedSession type, which supersedes all
   existing typed Session[T] types. It addresses two big deficiencies
   with the previous Session implementation: 1) lack of ability to
   provide options, and 2) unecessary use of type parameters.

 - Removing the type parameters allows the AdvancedSession to use an
   arbitrary set of different-type input and output tensors. Added a new
   test case to verify this works, along with the example_multitype.onnx
   file and the pytorch script to generate it.

 - Added the SessionOptions struct, which at the moment should allow for
   setting the InterOpNumThreads or IntraOpNumThreads, as well as
   enabling CUDA. However, the options settings have not yet been tested
   at this time.

 - Made the typed Session and DynamicSession delegate their
   functionality to AdvancedSession instances.

 - Moved the old typed Session struct definitions to the legacy_types.go
   file.

 - Updated the README and comments to make it clear that the typed
   sessions probably shouldn't be used in new code.
2023-08-23 10:37:12 -04:00
yalue
dc65e9492a Add ArbitraryTensor interface
- Added a new interface that is satisfied by any tensor regardless of
   data type. While not useful in this commit alone, the plan is to use
   it to facilitate a new Session type that will allow arbitrary
   different combinations of input and output tensor types.
2023-08-16 19:38:21 -04:00
riccardo
dfe07269ca Implemented dynamicSession to allow for different input/output types and dynamic input/output sizes 2023-08-02 17:16:10 +02:00
Nathan
ccbc079746 Expose telemetry control APIs
- This change adds the DisableTelemetry() and EnableTelemetry()
   top-level functions, which wrap the DisableTelemetryEvents() and
   EnableTelemetryEvents() C API functions for the package's internal
   onnxruntime environment.

 - This change rolls back some of the prior commit.  As a fan of the
   onnxruntime library, I decided to take a more charitable approach to
   their telemetry and not disable it by default in these bindings.
2023-06-21 20:52:39 -04:00
yalue
ca658dac00 Check for valid shapes more thoroughly
- This change adds several more detailed error types that may be
   returned when attempting to work with shapes that are invalid for
   some reason.

 - Added the Shape.Validate() function, which may be called by users,
   but is internally called when creating new tensors.
2023-05-11 10:11:39 -04:00
Nathan
33ddad1553 Implement Tensor.Clone
- Take care of an easy TODO.

 - Also added a Shape.Equals function, to compare two shapes.
2023-02-24 08:34:52 -05:00
yalue
36dc614e49 Rename package to make it clear that this is Go
- I hate the convention of putting "go" on every library wrapper, but
   unfortunately the utility is undeniable.  I don't want people to find
   this repo when they are actually looking for the "real" onnxruntime
   repo.
2023-02-08 09:47:18 -05:00
yalue
bb5039f6ad Enable multiple inputs and outputs
- Modified the Session API so that the user must provide all input and
   output tensors when creating the session (Run() no longer takes any
   arguments).  This should avoid allocations and fix the incorrect way
   I was using input and output names before.

 - Updated the test to use the new API.

 - Removed the onnx_example_application; it was only doing the same
   thing as the unit test anyway.
2023-02-04 13:51:45 -05:00
yalue
e0cd5f977c Rename CleanupEnvironment -> DestroyEnvironment
- Named the cleanup function something more consistent with the other
   cleanup functions.

 - Fixed a couple bugs where deferred stuff was executed after the
   environment was destroyed, causing a segfault.
2023-02-04 12:41:35 -05:00
yalue
137ec8f64f Can now load and run a network
- The library is now capable of loading the test session and running
   it successfully.

 - Updated the example application, which is really the same as the test
   and should probably be deleted.

 - TODO: The input names actually *do* need to match the names when the
   network was created. The hardcoded names in onnxruntime_wrapper.c
   will *not* do!
2023-02-04 10:31:57 -05:00
yalue
ff910beb76 Add tensor support
- There is now a wrapper to create generic Tensor objects in Go, that
   should be appropriately backed by the onnxruntime.

 - Did some minor tests.

 - Still to do: update the example, and put together a nice API that
   uses the tensors.
2023-02-01 19:47:53 -05:00
yalue
75e3434f7e Initial commit
- Sets up the onnxruntime environment, but doesn't load or run networks
   yet.

 - The things builds and run on Windows.

 - Still working on getting the Linux (arm64 for now) test to work.
2023-01-28 13:49:33 -05:00