Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handler(success) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (triggeredCallback) {
return;
}
if (success) {
triggerCallback.call.apply(triggerCallback, tslib.__spreadArrays([null, success], args));
return;
}
var mustStop = canceled() || hitTimeout;
if (mustStop) {
triggerCallback.call.apply(triggerCallback, tslib.__spreadArrays([null, success], args));
return;
}
if (waitSeconds < 64) {
/* TODO(andysoto): don't back off so quickly if we know we're offline. */
waitSeconds *= 2;
}
var waitMillis;
if (cancelState === 1) {
cancelState = 2;
waitMillis = 0;
}
else {
waitMillis = (waitSeconds + Math.random()) * 1000;
}
callWithDelay(waitMillis);
}
function handler(success) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (triggeredCallback) {
return;
}
if (success) {
triggerCallback.call.apply(triggerCallback, tslib.__spreadArrays([null, success], args));
return;
}
var mustStop = canceled() || hitTimeout;
if (mustStop) {
triggerCallback.call.apply(triggerCallback, tslib.__spreadArrays([null, success], args));
return;
}
if (waitSeconds < 64) {
/* TODO(andysoto): don't back off so quickly if we know we're offline. */
waitSeconds *= 2;
}
var waitMillis;
if (cancelState === 1) {
cancelState = 2;
waitMillis = 0;
}
setTimeout(function () {
// If there is no remainingTries left, stop retrying.
if (remainingTries === 0) {
return;
}
// If there are no events to process, wait for DEFAULT_SEND_INTERVAL_MS and try again.
if (!queue.length) {
return processQueue(DEFAULT_SEND_INTERVAL_MS);
}
// Capture a snapshot of the queue and empty the "official queue".
var staged = tslib.__spreadArrays(queue);
queue = [];
/* eslint-disable camelcase */
// We will pass the JSON serialized event to the backend.
var log_event = staged.map(function (evt) { return ({
source_extension_json: evt.message,
event_time_ms: String(evt.eventTime)
}); });
var data = {
request_time_ms: String(Date.now()),
client_info: {
client_type: 1,
js_client_info: {}
},
log_source: SettingsService.getInstance().logSource,
log_event: log_event
};
function addToQueue(evt) {
if (!evt.eventTime || !evt.message) {
throw ERROR_FACTORY.create("invalid cc log" /* INVALID_CC_LOG */);
}
// Add the new event to the queue.
queue = tslib.__spreadArrays(queue, [evt]);
}
/** Log handler for cc service to send the performance logs to the server. */
return tf.tidy(function () {
var r = meanRgb[0], g = meanRgb[1], b = meanRgb[2];
var avg_r = tf.fill(tslib_1.__spreadArrays(x.shape.slice(0, 3), [1]), r);
var avg_g = tf.fill(tslib_1.__spreadArrays(x.shape.slice(0, 3), [1]), g);
var avg_b = tf.fill(tslib_1.__spreadArrays(x.shape.slice(0, 3), [1]), b);
var avg_rgb = tf.concat([avg_r, avg_g, avg_b], 3);
return tf.sub(x, avg_rgb);
});
}
function residualDown(x, params) {
var out = convLayer_1.convDown(x, params.conv1);
out = convLayer_1.convNoRelu(out, params.conv2);
var pooled = tf.avgPool(x, 2, 2, 'valid');
var zeros = tf.zeros(pooled.shape);
var isPad = pooled.shape[3] !== out.shape[3];
var isAdjustShape = pooled.shape[1] !== out.shape[1] || pooled.shape[2] !== out.shape[2];
if (isAdjustShape) {
var padShapeX = tslib_1.__spreadArrays(out.shape);
padShapeX[1] = 1;
var zerosW = tf.zeros(padShapeX);
out = tf.concat([out, zerosW], 1);
var padShapeY = tslib_1.__spreadArrays(out.shape);
padShapeY[2] = 1;
var zerosH = tf.zeros(padShapeY);
out = tf.concat([out, zerosH], 2);
}
pooled = isPad ? tf.concat([pooled, zeros], 3) : pooled;
out = tf.add(pooled, out);
out = tf.relu(out);
return out;
}
exports.residualDown = residualDown;
return tf.tidy(function () {
var r = meanRgb[0], g = meanRgb[1], b = meanRgb[2];
var avg_r = tf.fill(__spreadArrays(x.shape.slice(0, 3), [1]), r);
var avg_g = tf.fill(__spreadArrays(x.shape.slice(0, 3), [1]), g);
var avg_b = tf.fill(__spreadArrays(x.shape.slice(0, 3), [1]), b);
var avg_rgb = tf.concat([avg_r, avg_g, avg_b], 3);
return tf.sub(x, avg_rgb);
});
}
.catch(function () {
/**
* If the request fails for some reason, add the events that were attempted
* back to the primary queue to retry later.
*/
queue = tslib.__spreadArrays(staged, queue);
remainingTries--;
consoleLogger.info("Tries left: " + remainingTries + ".");
processQueue(DEFAULT_SEND_INTERVAL_MS);
});
}, timeOffset);
export function residualDown(x, params) {
var out = convDown(x, params.conv1);
out = convNoRelu(out, params.conv2);
var pooled = tf.avgPool(x, 2, 2, 'valid');
var zeros = tf.zeros(pooled.shape);
var isPad = pooled.shape[3] !== out.shape[3];
var isAdjustShape = pooled.shape[1] !== out.shape[1] || pooled.shape[2] !== out.shape[2];
if (isAdjustShape) {
var padShapeX = __spreadArrays(out.shape);
padShapeX[1] = 1;
var zerosW = tf.zeros(padShapeX);
out = tf.concat([out, zerosW], 1);
var padShapeY = __spreadArrays(out.shape);
padShapeY[2] = 1;
var zerosH = tf.zeros(padShapeY);
out = tf.concat([out, zerosH], 2);
}
pooled = isPad ? tf.concat([pooled, zeros], 3) : pooled;
out = tf.add(pooled, out);
out = tf.relu(out);
return out;
}
//# sourceMappingURL=residualLayer.js.map