10000 output sampler for 5d and 6d · tensorflow/tfjs-core@1d70923 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 1d70923

Browse files
committed
output sampler for 5d and 6d
1 parent e32e19e commit 1d70923

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/backends/webgl/shader_compiler.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ function getOutput5DCoords(
533533
shape: [number, number, number, number, number],
534534
texShape: [number, number]): string {
535535
const coordsFromIndexSnippet = shader_util.getLogicalCoordinatesFromFlatIndex(
536-
['r', 'c', 'd', 'd2', 'd3'], shape);
536+
['r', 'c', 'd', 'd2', 'd3'], shape, 'index', 'outputShape');
537537

538538
return `
539539
ivec5 getOutputCoords() {
@@ -554,7 +554,7 @@ function getOutput6DCoords(
554554
shape: [number, number, number, number, number, number],
555555
texShape: [number, number]): string {
556556
const coordsFromIndexSnippet = shader_util.getLogicalCoordinatesFromFlatIndex(
557-
['r', 'c', 'd', 'd2', 'd3', 'd4'], shape);
557+
['r', 'c', 'd', 'd2', 'd3', 'd4'], shape, 'index', 'outputShape');
558558

559559
return `
560560
ivec6 getOutputCoords() {
@@ -847,7 +847,7 @@ function getSampler2D(inputInfo: InputInfo): string {
847847
// index is used directly as physical (no risk of float16 overflow).
848848
return `
849849
float ${funcName}(int row, int col) {
850-
float index = dot(vec3(row, col, ${offset}),
850+
float index = dot(vec3(row, col, ${offset}),
851851
vec3(${shapeUniform}[1], 1, 1));
852852
vec2 uv = vec2(0.5, (index + 0.5) / float(${texShapeUniform}[0]));
853853
return sampleTexture(${texName}, uv);
@@ -858,7 +858,7 @@ function getSampler2D(inputInfo: InputInfo): string {
858858
// index is used directly as physical (no risk of float16 overflow).
859859
return `
860860
float ${funcName}(int row, int col) {
861-
float index = dot(vec3(row, col, ${offset}),
861+
float index = dot(vec3(row, col, ${offset}),
862862
vec3(${shapeUniform}[1], 1, 1));
863863
vec2 uv = vec2((index + 0.5) / float(${texShapeUniform}[1]), 0.5);
864864
return sampleTexture(${texName}, uv);
@@ -870,7 +870,7 @@ function getSampler2D(inputInfo: InputInfo): string {
870870
float ${funcName}(int row, int col) {
871871
// Explicitly use integer operations as dot() only works on floats.
872872
int index = row * ${shapeUniform}[1] + col + ${offset};
873-
vec2 uv = uvFromFlat(${texShapeUniform}[0],
873+
vec2 uv = uvFromFlat(${texShapeUniform}[0],
874874
${texShapeUniform}[1], index);
875875
return sampleTexture(${texName}, uv);
876876
}
@@ -961,7 +961,7 @@ function getSampler3D(inputInfo: InputInfo): string {
961961
float texR = float(row);
962962
float texC = dot(vec2(col, depth), vec2(${stride1Prog}, 1));
963963
vec2 uv = (vec2(texC, texR) + halfCR) /
964-
vec2(float(${texShapeUniform}[1]),
964+
vec2(float(${texShapeUniform}[1]),
965965
float(${texShapeUniform}[0]));
966966
return sampleTexture(${texName}, uv);
967967
}
@@ -985,9 +985,9 @@ function getSampler3D(inputInfo: InputInfo): string {
985985
return `
986986
float ${funcName}(int row, int col, int depth) {
987987
// Explicitly use integer operations as dot() only works on floats.
988-
int index = row * ${stride0Prog} + col * ${stride1Prog} + depth +
988+
int index = row * ${stride0Prog} + col * ${stride1Prog} + depth +
989989
${offset};
990-
vec2 uv = uvFromFlat(${texShapeUniform}[0],
990+
vec2 uv = uvFromFlat(${texShapeUniform}[0],
991991
${texShapeUniform}[1], index);
992992
return sampleTexture(${texName}, uv);
993993
}
@@ -1077,7 +1077,7 @@ function getSampler4D(inputInfo: InputInfo): string {
10771077
dot(vec3(col, depth, depth2),
10781078
vec3(${stride1Prog}, ${stride2Prog}, 1));
10791079
vec2 uv = (vec2(texC, texR) + halfCR) /
1080-
vec2(float(${texShapeUniform}[1]),
1080+
vec2(float(${texShapeUniform}[1]),
10811081
float(${texShapeUniform}[0]));
10821082
return sampleTexture(${texName}, uv);
10831083
}
@@ -1089,7 +1089,7 @@ function getSampler4D(inputInfo: InputInfo): string {
10891089
float ${funcName}(int row, int col, int depth, int depth2) {
10901090
float texR = dot(vec3(row, col, depth),
10911091
vec3(
1092-
${shapeUniform}[1] * ${shapeUniform}[2],
1092+
${shapeUniform}[1] * ${shapeUniform}[2],
10931093
${shapeUniform}[2], 1));
10941094
float texC = float(depth2);
10951095
vec2 uv = (vec2(texC, texR) + halfCR) /
@@ -1107,8 +1107,8 @@ function getSampler4D(inputInfo: InputInfo): string {
11071107
int index = row * ${stride0Prog} + col * ${stride1Prog} +
11081108
depth * ${stride2Prog} + depth2;
11091109
vec2 uv = uvFromFlat(
1110-
${texShapeUniform}[0],
1111-
${texShapeUniform}[1],
1110+
${texShapeUniform}[0],
1111+
${texShapeUniform}[1],
11121112
index + ${offset});
11131113
return sampleTexture(${texName}, uv);
11141114
}
@@ -1168,10 +1168,10 @@ function getSampler5D(inputInfo: InputInfo): string {
11681168
float ${funcName}(int row, int col, int depth, int depth2, int depth3) {
11691169
int texR = row;
11701170
float texC = dot(vec4(col, depth, depth2, depth3),
1171-
vec4(${stride1Prog}, ${stride2Prog},
1171+
vec4(${stride1Prog}, ${stride2Prog},
11721172
${stride3Prog}, 1));
11731173
vec2 uv = (vec2(texC, texR) + halfCR) /
1174-
vec2(float(${texShapeUniform}[1]),
1174+
vec2(float(${texShapeUniform}[1]),
11751175
float(${texShapeUniform}[0]));
11761176
return sampleTexture(${texName}, uv);
11771177
}
@@ -1188,7 +1188,7 @@ function getSampler5D(inputInfo: InputInfo): string {
11881188
${shapeUniform}[2] * ${shapeUniform}[3], ${shapeUniform}[3], 1));
11891189
int texC = depth3;
11901190
vec2 uv = (vec2(texC, texR) + halfCR) /
1191-
vec2(float(${texShapeUniform}[1]),
1191+
vec2(float(${texShapeUniform}[1]),
11921192
float(${texShapeUniform}[0]));
11931193
return sampleTexture(${texName}, uv);
11941194
}
@@ -1270,7 +1270,7 @@ function getSampler6D(inputInfo: InputInfo): string {
12701270
vec4(${stride1Prog}, ${stride2Prog}, ${stride3Prog}, ${stride4Prog}))
12711271
+ float(depth4);
12721272
vec2 uv = (vec2(texC, texR) + halfCR) /
1273-
vec2(float(${texShapeUniform}[1]),
1273+
vec2(float(${texShapeUniform}[1]),
12741274
float(${texShapeUniform}[0]));
12751275
return sampleTexture(${texName}, uv);
12761276
}
@@ -1282,7 +1282,7 @@ function getSampler6D(inputInfo: InputInfo): string {
12821282
float ${funcName}(int row, int col, int depth,
12831283
int depth2, int depth3, int depth4) {
12841284
float texR = dot(vec4(row, col, depth, depth2),
1285-
vec4(${shapeUniform}[1] * ${shapeUniform}[2] * ${shapeUniform}[3]
1285+
vec4(${shapeUniform}[1] * ${shapeUniform}[2] * ${shapeUniform}[3]
12861286
* ${shapeUniform}[4]},
12871287
${shapeUniform}[2] * ${shapeUniform}[3] * ${shapeUniform[4]},
12881288
${shapeUniform}[3] * ${shapeUniform}[4],
@@ -1300,7 +1300,7 @@ function getSampler6D(inputInfo: InputInfo): string {
13001300
int depth2, int depth3, int depth4) {
13011301
// Explicitly use integer operations as dot() only works on floats.
13021302
int index = row * ${stride0Prog} + col * ${stride1Prog} + depth * ${
1303-
stride2Prog} + depth2 * ${stride3Prog} + depth3 * ${stride4Prog} +
1303+
stride2Prog} + depth2 * ${stride3Prog} + depth3 * ${stride4Prog} +
13041304
depth4 + ${offset};
13051305
vec2 uv = uvFromFlat(${texShapeUniform}[0], ${texShapeUniform}[1], index);
13061306
return sampleTexture(${texName}, uv);

0 commit comments

Comments
 (0)
0