@tensorflow/tfjs-core
Version:
Hardware-accelerated JavaScript library for machine intelligence
36 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var shader_compiler_1 = require("./shader_compiler");
var WhereProgram = (function () {
function WhereProgram(cRank, shape, rank) {
this.variableNames = ['c', 'a', 'b'];
this.outputShape = shape;
var cCoords;
var abCoords;
if (rank > 4) {
throw Error("Where for rank " + rank + " is not yet supported");
}
if (rank === 1) {
abCoords = "resRC";
cCoords = "resRC";
}
else {
var currentCoords = ['resRC.x', 'resRC.y', 'resRC.z', 'resRC.w'];
var cCoordVars = [];
var abCoordVars = [];
for (var i = 0; i < shape.length; i++) {
abCoordVars.push("" + currentCoords[i]);
if (i < cRank) {
cCoordVars.push("" + currentCoords[i]);
}
}
cCoords = cCoordVars.join();
abCoords = abCoordVars.join();
}
var dtype = shader_compiler_1.getCoordsDataType(rank);
this.userCode = "\n void main() {\n " + dtype + " resRC = getOutputCoords();\n float cVal = getC(" + cCoords + ");\n if (cVal >= 1.0) {\n setOutput(getA(" + abCoords + "));\n } else {\n setOutput(getB(" + abCoords + "));\n }\n }\n ";
}
return WhereProgram;
}());
exports.WhereProgram = WhereProgram;
//# sourceMappingURL=logical_gpu.js.map