CoreML backend should log on failure not success (#82604)

### Description
The original intention of this code was to log whenever inference fails, not whenever it succeeds. This change updates the logic of should_log to match this intention.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/82604
Approved by: https://github.com/SS-JIA
This commit is contained in:
John Detloff 2022-08-02 04:14:43 +00:00 committed by PyTorch MergeBot
parent 09a6d0b5bb
commit 7d490dba72

View File

@ -187,8 +187,7 @@ class CoreMLBackend: public torch::jit::PyTorchBackendInterface {
// Check if this inference session is logged. If so, log every N inferences
bool succeeded = outputsProvider != nil;
bool should_log = load_id < kSampleThreshold && inferences > 1;
should_log = should_log && (inferences % kSampleEvery == 0);
should_log = should_log || succeeded;
should_log = !succeeded || (should_log && (inferences % kSampleEvery == 0));
observer->onExitExecuteModel(instance_key, inferences, succeeded, should_log);
}