From 5e5c42f69fba527b6abf221ea5f17bb790e55c89 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 3 Apr 2023 16:56:06 -0700 Subject: Update a1-02-slangpy.md --- docs/user-guide/a1-02-slangpy.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/user-guide/a1-02-slangpy.md b/docs/user-guide/a1-02-slangpy.md index 4e7c8d0a4..d71ee6a75 100644 --- a/docs/user-guide/a1-02-slangpy.md +++ b/docs/user-guide/a1-02-slangpy.md @@ -238,13 +238,15 @@ float computeOutputPixel(TensorView input, uint2 pixelLoc) float sumValue = 0.0; // Iterate through the surrounding area. - for (int x = pixelLoc.x - 1; x <= pixelLoc.x + 1; x++) + for (int offsetX = -1; offsetX <= 1; offsetX++) { // Skip out of bounds pixels. + int x = pixelLoc.x + offsetX; if (x < 0 || x >= width) continue; - for (int y = pixelLoc.y - 1; y <= pixelLoc.y + 1; y++) + for (int offsetY = -1; offsetY <= 1; offsetY++) { + int y = pixelLoc.y + offsetY; if (y < 0 || y >= height) continue; sumValue += input[x, y]; count++; @@ -318,13 +320,15 @@ float computeOutputPixel( float sumValue = 0.0; // Iterate through the surrounding area. - for (int x = pixelLoc.x - 1; x <= pixelLoc.x + 1; x++) + for (int offsetX = -1; offsetX <= 1; offsetX++) { // Skip out of bounds pixels. + int x = pixelLoc.x + offsetX; if (x < 0 || x >= width) continue; - for (int y = pixelLoc.y - 1; y <= pixelLoc.y + 1; y++) + for (int offsetY = -1; offsetY <= 1; offsetY++) { + int y = pixelLoc.y + offsetY; if (y < 0 || y >= height) continue; sumValue += getInputElement(input, inputGradToPropagateTo, uint2(x, y)); count++; -- cgit v1.2.3