@@ -79,6 +79,7 @@ TEST_F(OnnxRuntimeTest, InputTensorNames) {
7979 // Test expected input names from the simple model
8080 EXPECT_TRUE (input_names.contains (" float_input" ));
8181 EXPECT_TRUE (input_names.contains (" int_input" ));
82+ EXPECT_TRUE (input_names.contains (" int64_input" ));
8283 EXPECT_TRUE (input_names.contains (" bool_input" ));
8384 EXPECT_TRUE (input_names.contains (" init_float_input" ));
8485}
@@ -93,6 +94,7 @@ TEST_F(OnnxRuntimeTest, OutputTensorNames) {
9394 // Test expected output names from the simple model
9495 EXPECT_TRUE (output_names.contains (" float_output" ));
9596 EXPECT_TRUE (output_names.contains (" int_output" ));
97+ EXPECT_TRUE (output_names.contains (" int64_output" ));
9698 EXPECT_TRUE (output_names.contains (" bool_output" ));
9799}
98100
@@ -196,6 +198,14 @@ TEST_F(OnnxRuntimeTest, SimpleModelWithDifferentTensorTypes) {
196198 int_buffer.value ()[1 ] = 20 ;
197199 int_buffer.value ()[2 ] = 30 ;
198200
201+ // Test int64 tensor
202+ auto int64_buffer = runtime.inputBuffer <int64_t >(" int64_input" );
203+ ASSERT_TRUE (int64_buffer.has_value ());
204+ EXPECT_EQ (int64_buffer->size (), 3 );
205+ int64_buffer.value ()[0 ] = 100 ;
206+ int64_buffer.value ()[1 ] = 200 ;
207+ int64_buffer.value ()[2 ] = 300 ;
208+
199209 // Test bool tensor
200210 auto bool_buffer = runtime.inputBuffer <bool >(" bool_input" );
201211 ASSERT_TRUE (bool_buffer.has_value ());
@@ -221,6 +231,13 @@ TEST_F(OnnxRuntimeTest, SimpleModelWithDifferentTensorTypes) {
221231 EXPECT_EQ (int_output.value ()[1 ], 21 ); // 20 + 1
222232 EXPECT_EQ (int_output.value ()[2 ], 31 ); // 30 + 1
223233
234+ // Check int64 output (should be input + 2)
235+ auto int64_output = runtime.outputBuffer <int64_t >(" int64_output" );
236+ ASSERT_TRUE (int64_output.has_value ());
237+ EXPECT_EQ (int64_output.value ()[0 ], 102 ); // 100 + 2
238+ EXPECT_EQ (int64_output.value ()[1 ], 202 ); // 200 + 2
239+ EXPECT_EQ (int64_output.value ()[2 ], 302 ); // 300 + 2
240+
224241 // Check bool output (should be logical NOT of input)
225242 auto bool_output = runtime.outputBuffer <bool >(" bool_output" );
226243 ASSERT_TRUE (bool_output.has_value ());
@@ -259,6 +276,10 @@ TEST_F(OnnxRuntimeTest, ResetBuffersDifferentTypes) {
259276 ASSERT_TRUE (int_buffer.has_value ());
260277 int_buffer.value ()[0 ] = 99 ;
261278
279+ auto int64_buffer = runtime.inputBuffer <int64_t >(" int64_input" );
280+ ASSERT_TRUE (int64_buffer.has_value ());
281+ int64_buffer.value ()[0 ] = 12345 ;
282+
262283 auto bool_buffer = runtime.inputBuffer <bool >(" bool_input" );
263284 ASSERT_TRUE (bool_buffer.has_value ());
264285 bool_buffer.value ()[0 ] = true ;
@@ -269,6 +290,7 @@ TEST_F(OnnxRuntimeTest, ResetBuffersDifferentTypes) {
269290 // Verify all buffers are reset to their default values
270291 EXPECT_EQ (float_buffer.value ()[0 ], 0 .0f );
271292 EXPECT_EQ (int_buffer.value ()[0 ], 0 );
293+ EXPECT_EQ (int64_buffer.value ()[0 ], 0 );
272294 EXPECT_EQ (bool_buffer.value ()[0 ], false );
273295}
274296
@@ -340,6 +362,63 @@ TEST_F(OnnxRuntimeTest, CopyOutputToInputIntType) {
340362 EXPECT_EQ (int_input.value ()[2 ], 31 );
341363}
342364
365+ TEST_F (OnnxRuntimeTest, Int64BufferType) {
366+ OnnxRuntime runtime;
367+ ASSERT_TRUE (runtime.initialize (simple_model_path_));
368+
369+ // Test getting input buffer for existing int64 tensor
370+ auto int64_buffer = runtime.inputBuffer <int64_t >(" int64_input" );
371+ ASSERT_TRUE (int64_buffer.has_value ());
372+ EXPECT_EQ (int64_buffer->size (), 3 ); // Based on simple model shape (1, 3)
373+
374+ // Test getting output buffer for existing int64 tensor
375+ auto int64_output_buffer = runtime.outputBuffer <int64_t >(" int64_output" );
376+ ASSERT_TRUE (int64_output_buffer.has_value ());
377+ EXPECT_EQ (int64_output_buffer->size (), 3 );
378+
379+ // Accessing an int64 tensor with the wrong type must fail
380+ auto wrong_type_buffer = runtime.inputBuffer <int32_t >(" int64_input" );
381+ EXPECT_FALSE (wrong_type_buffer.has_value ());
382+
383+ // Accessing an int32 tensor as int64 must also fail
384+ auto wrong_int64_buffer = runtime.inputBuffer <int64_t >(" int_input" );
385+ EXPECT_FALSE (wrong_int64_buffer.has_value ());
386+ }
387+
388+ TEST_F (OnnxRuntimeTest, CopyOutputToInputInt64Type) {
389+ OnnxRuntime runtime;
390+ ASSERT_TRUE (runtime.initialize (simple_model_path_));
391+
392+ // Set input values and run evaluation to get output
393+ auto int64_input = runtime.inputBuffer <int64_t >(" int64_input" );
394+ ASSERT_TRUE (int64_input.has_value ());
395+ int64_input.value ()[0 ] = 100 ;
396+ int64_input.value ()[1 ] = 200 ;
397+ int64_input.value ()[2 ] = 300 ;
398+
399+ ASSERT_TRUE (runtime.evaluate ());
400+
401+ // Get the output values (should be input + 2)
402+ auto int64_output = runtime.outputBuffer <int64_t >(" int64_output" );
403+ ASSERT_TRUE (int64_output.has_value ());
404+ EXPECT_EQ (int64_output.value ()[0 ], 102 ); // 100 + 2
405+ EXPECT_EQ (int64_output.value ()[1 ], 202 ); // 200 + 2
406+ EXPECT_EQ (int64_output.value ()[2 ], 302 ); // 300 + 2
407+
408+ // Reset input to different values
409+ int64_input.value ()[0 ] = 0 ;
410+ int64_input.value ()[1 ] = 0 ;
411+ int64_input.value ()[2 ] = 0 ;
412+
413+ // Copy output to input
414+ ASSERT_TRUE (runtime.copyOutputToInput (" int64_output" , " int64_input" ));
415+
416+ // Verify input now contains the output values
417+ EXPECT_EQ (int64_input.value ()[0 ], 102 );
418+ EXPECT_EQ (int64_input.value ()[1 ], 202 );
419+ EXPECT_EQ (int64_input.value ()[2 ], 302 );
420+ }
421+
343422TEST_F (OnnxRuntimeTest, CopyOutputToInputBoolType) {
344423 OnnxRuntime runtime;
345424 ASSERT_TRUE (runtime.initialize (simple_model_path_));
@@ -398,6 +477,12 @@ TEST_F(OnnxRuntimeTest, CopyOutputToInputTypeMismatch) {
398477 // Test copying int output to float input (should fail due to type mismatch)
399478 EXPECT_FALSE (runtime.copyOutputToInput (" float_output" , " int_input" ));
400479
480+ // Test copying int32 output to int64 input (should fail due to type mismatch)
481+ EXPECT_FALSE (runtime.copyOutputToInput (" int_output" , " int64_input" ));
482+
483+ // Test copying int64 output to int32 input (should fail due to type mismatch)
484+ EXPECT_FALSE (runtime.copyOutputToInput (" int64_output" , " int_input" ));
485+
401486 // Test copying bool output to float input (should fail due to type mismatch)
402487 EXPECT_FALSE (runtime.copyOutputToInput (" float_output" , " bool_input" ));
403488}
0 commit comments