mirror of
				https://github.com/yalue/onnxruntime_go.git
				synced 2025-11-01 03:02:49 +08:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -52,6 +52,14 @@ func run() int { | ||||
| 		return 1 | ||||
| 	} | ||||
| 	fmt.Printf("The onnxruntime environment initialized OK.\n") | ||||
| 	defer func() { | ||||
| 		e := onnxruntime.DestroyEnvironment() | ||||
| 		if e != nil { | ||||
| 			fmt.Printf("Error destroying onnx environment: %s\n", e) | ||||
| 		} else { | ||||
| 			fmt.Printf("Environment cleaned up OK.\n") | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	// Load the JSON with the test input and output data. | ||||
| 	testInputs, e := loadInputsJSON( | ||||
| @@ -98,15 +106,6 @@ func run() int { | ||||
| 		fmt.Printf("Output value %d: expected %f, got %f\n", i, | ||||
| 			outputTensor.GetData()[i], testInputs.FlattenedOutput[i]) | ||||
| 	} | ||||
|  | ||||
| 	// Ordinarily, it is probably fine to call this using defer, but we do it | ||||
| 	// here just so we can print a status message after the cleanup completes. | ||||
| 	e = onnxruntime.CleanupEnvironment() | ||||
| 	if e != nil { | ||||
| 		fmt.Printf("Error cleaning up the environment: %s\n", e) | ||||
| 		return 1 | ||||
| 	} | ||||
| 	fmt.Printf("The onnxruntime environment was cleaned up OK.\n") | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 yalue
					yalue