partial void TappedDetectDigit(UIButton sender)
{
// get the digitView context so we can get the pixel values from it to intput to network
var context = DigitView.GetViewContext();
// validate NeuralNetwork was initialized properly
if (runningNet == null)
{
throw new InvalidProgramException();
}
// putting input into MTLTexture in the MPSImage
var region = new MTLRegion(new MTLOrigin(0, 0, 0), new MTLSize((nint)mnistInputWidth, mnistInputHeight, 1));
runningNet.SrcImage.Texture.ReplaceRegion(region,
level: 0,
slice: 0,
pixelBytes: context.Data,
bytesPerRow: mnistInputWidth,
bytesPerImage: 0);
// run the network forward pass
var label = runningNet.Forward();
// show the prediction
PredictionLabel.Text = $"{label}";
PredictionLabel.Hidden = false;
}