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.
This commit is contained in:
yalue
2023-02-04 13:51:45 -05:00
parent e0cd5f977c
commit bb5039f6ad
7 changed files with 96 additions and 157 deletions

View File

@@ -160,13 +160,15 @@ func TestExampleNetwork(t *testing.T) {
defer outputTensor.Destroy()
// Set up and run the session.
session, e := NewSimpleSession[float32]("test_data/example_network.onnx")
session, e := NewSession[float32]("test_data/example_network.onnx",
[]string{"1x4 Input Vector"}, []string{"1x2 Output Vector"},
[]*Tensor[float32]{inputTensor}, []*Tensor[float32]{outputTensor})
if e != nil {
t.Logf("Failed creating simple session: %s\n", e)
t.Logf("Failed creating session: %s\n", e)
t.FailNow()
}
defer session.Destroy()
e = session.SimpleRun(inputTensor, outputTensor)
e = session.Run()
if e != nil {
t.Logf("Failed to run the session: %s\n", e)
t.FailNow()