diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-03 16:56:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-03 16:56:06 -0700 |
| commit | 5e5c42f69fba527b6abf221ea5f17bb790e55c89 (patch) | |
| tree | 892e83ea736e9e91038917bd02562add54cbf210 /docs/user-guide | |
| parent | b68516e2c2e39af79dda2ec7871fe4d821ef67c4 (diff) | |
Update a1-02-slangpy.md
Diffstat (limited to 'docs/user-guide')
| -rw-r--r-- | docs/user-guide/a1-02-slangpy.md | 12 |
1 files changed, 8 insertions, 4 deletions
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<float> 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++; |
