@@ -87,7 +87,8 @@ public enum _RuntimeConfig {
87
87
88
88
/// When true, run the entire tensor computation in
89
89
/// _TFCStartTensorComputation(), instead of running it on a separate thread.
90
- /// - Note: Set to true only for debugging purposes.
90
+ /// - Note: Set to true only for debugging purposes, as it has limited
91
+ /// functionality (e.g. no sends/recvs support).
91
92
static public var usesSynchronousExecution = false
92
93
93
94
/// For CPU and GPU execution without XLA, use the auto mode. For XLA and/or
@@ -466,6 +467,8 @@ extension TFState {
466
467
inputTensors. append ( cTensor!)
467
468
}
468
469
470
+ /// Runs the tensor program. Aborts the process on error, and emits an error
471
+ /// string to STDERR.
469
472
/// See the comment on _TensorComputation.helperFunctionCount on the concept
470
473
/// of a "helper function".
471
474
func execute( _ entryFunctionBaseName: String ,
@@ -547,7 +550,10 @@ extension TFState {
547
550
targetNodeSpecs, Int32 ( targetNodeSpecs. count) ,
548
551
/*run_metadata*/nil , status
549
552
)
550
- checkOk ( status)
553
+ if ( TF_GetCode ( status) != TF_OK) {
554
+ _ = fputs ( TF_Message ( status) , stderr)
555
+ exit ( - 1 )
556
+ }
551
557
debugLog ( " Done running TF computation. " )
552
558
553
559
// Delete input tensors.
@@ -715,7 +721,7 @@ public final class _TensorComputation {
715
721
// TODO(hongm): do error handling.
716
722
internalConsistencyCheck ( creationStatus == 0 )
717
723
}
718
- // If it's asynchronous , we call execute() on the main thread directly.
724
+ // If it's synchronous , we call execute() on the main thread directly.
719
725
else {
720
726
// Log a debug message to differentiate from async computation.
721
727
debugLog ( " Running tensor computation synchronously. " )
@@ -731,6 +737,8 @@ public final class _TensorComputation {
731
737
}
732
738
733
739
private extension _TensorComputation {
740
+ /// Runs the tensor program. Aborts the process on error, and emits an error
741
+ /// string to STDERR.
734
742
// NOTE: This is to be called by the initializer. The computation gets
735
743
// executed on initialization, thus this method will not be exposed to users.
736
744
private func execute( ) {
@@ -758,6 +766,7 @@ public extension _TensorComputation {
758
766
759
767
/// Waits for completion the computation as given by 'program', and returns
760
768
/// output handles, whose underlying tensors may live on CPU or GPU.
769
+ /// Aborts the process on error, and emits an error string to STDERR.
761
770
func finish( ) -> [ CTensorHandle ] {
762
771
debugLog ( " Calling _TensorComputation.finish(). " )
763
772
if let pthread = pthread {
@@ -842,6 +851,7 @@ public func _TFCStartTensorComputation(
842
851
843
852
/// Waits for completion of the computation as given by `computation`, and
844
853
/// returns results.
854
+ /// Aborts the process on error, and emits an error string to STDERR.
845
855
///
846
856
/// - Parameters:
847
857
/// - computation: The tensor computation to finish.
0 commit comments