Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'sideEffects' field from package.jsons #7057

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/estree": "^0.0.51",
"@types/jasmine": "~4.0.3",
"@types/js-yaml": "^4.0.5",
"@types/long": "4.0.1",
"@types/long": "5.0.0",
"@types/mkdirp": "^0.5.2",
"@types/node": "^12.7.5",
"@types/node-fetch": "~2.1.2",
Expand Down Expand Up @@ -50,7 +50,7 @@
"karma-jasmine-order-reporter": "^1.1.0",
"karma-requirejs": "^1.1.0",
"karma-sourcemap-loader": "^0.3.8",
"long": "4.0.0",
"long": "5.2.1",
"mkdirp": "~0.5.1",
"opn": "~5.1.0",
"protobufjs": "~6.11.3",
Expand Down
8 changes: 0 additions & 8 deletions tfjs-backend-cpu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
"util": false,
"crypto": false
},
"sideEffects": [
"./dist/register_all_kernels.js",
"./dist/base.js",
"./dist/index.js",
"./src/register_all_kernels.mjs",
"./src/base.mjs",
"./src/index.mjs"
],
"resolutions": {
"minimist": "1.2.6"
}
Expand Down
16 changes: 1 addition & 15 deletions tfjs-backend-webgl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,5 @@
"browser": {
"util": false,
"crypto": false
},
"sideEffects": [
"./dist/register_all_kernels.js",
"./dist/flags_webgl.js",
"./dist/base.js",
"./dist/index.js",
"./dist/register_all_kernels.mjs",
"./dist/flags_webgl.mjs",
"./dist/base.mjs",
"./dist/index.mjs",
"./src/register_all_kernels.mjs",
"./src/flags_webgl.mjs",
"./src/base.mjs",
"./src/index.mjs"
]
}
}
24 changes: 2 additions & 22 deletions tfjs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"test-snippets": "bazel test :test_snippets_test --test_output=streamed"
},
"dependencies": {
"@types/long": "^4.0.1",
"@types/long": "^5.0.0",
"@types/offscreencanvas": "~2019.7.0",
"@types/seedrandom": "^2.4.28",
"@types/webgl-ext": "0.0.30",
"@webgpu/types": "0.1.21",
"long": "4.0.0",
"long": "5.2.1",
"node-fetch": "~2.6.1",
"seedrandom": "^3.0.5"
},
Expand All @@ -52,26 +52,6 @@
"crypto": false,
"worker_threads": false
},
"sideEffects": [
"./dist/index.js",
"./dist/engine.js",
"./dist/tensor.js",
"./dist/base_side_effects.js",
"./dist/flags.js",
"./dist/platforms/*.js",
"./dist/register_all_gradients.js",
"./dist/public/chained_ops/*.js",
"./dist/io/*.js",
"./src/index.mjs",
"./src/engine.mjs",
"./src/tensor.mjs",
"./src/base_side_effects.mjs",
"./src/flags.mjs",
"./src/platforms/*.mjs",
"./src/register_all_gradients.mjs",
"./src/public/chained_ops/*.mjs",
"./src/io/*.mjs"
],
"resolutions": {
"minimist": "1.2.6"
}
Expand Down
2 changes: 2 additions & 0 deletions tfjs-core/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ ts_library(
deps = [
":tfjs-core_lib",
":tfjs-core_src_lib",
"@npm//@types/long",
"@npm//long",
],
)

Expand Down
15 changes: 5 additions & 10 deletions tfjs-core/src/hash_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,20 @@
* limitations under the License.
* =============================================================================
*/
// Workaround for allowing cjs module to be included in bundle created by
// rollup.
import * as LongExports from 'long';
// tslint:disable-next-line
const Long: LongExports.LongConstructor =
// tslint:disable-next-line
(LongExports as any).default || LongExports;

import Long from 'long';

export function hexToLong(hex: string): Long {
return Long.fromString(hex, true, 16);
}

// Some primes between 2^63 and 2^64 for various uses.
// Hex 0xc3a5c85c97cb3127
const k0: Long = hexToLong('c3a5c85c97cb3127');
const k0: Long = /* @__PURE__ */ hexToLong('c3a5c85c97cb3127');
// Hex 0xb492b66fbe98f273
const k1: Long = hexToLong('b492b66fbe98f273');
const k1: Long = /* @__PURE__ */ hexToLong('b492b66fbe98f273');
// Hex 0x9ae16a3b2f90404f
const k2: Long = hexToLong('9ae16a3b2f90404f');
const k2: Long = /* @__PURE__ */ hexToLong('9ae16a3b2f90404f');

function shiftMix(val: Long): Long {
return val.xor(val.shru(47));
Expand Down
1 change: 1 addition & 0 deletions tfjs-core/src/hash_util_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

import Long from 'long';
import {fingerPrint64, hexToLong} from './hash_util';
import {ALL_ENVS, describeWithFlags} from './jasmine_util';

Expand Down
7 changes: 7 additions & 0 deletions tfjs-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@

// Required side effectful code.
import './base_side_effects';

// TODO(mattSoulanille): Move this to base_side_effects.ts
// It is here for now because custom bundles need to avoid calling it, and they
// only replace the index.js file, not the base_side_effects file.
import {registerOptimizers} from './optimizers/register_optimizers';
registerOptimizers();

// All exports from this package should be in base.
export * from './base';
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/abs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ function abs_<T extends Tensor>(x: T|TensorLike): T {
}
}

export const abs = op({abs_});
export const abs = /* @__PURE__ */ op({abs_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/acos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ function acos_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Acos, inputs as unknown as NamedTensorMap);
}
export const acos = op({acos_});
export const acos = /* @__PURE__ */ op({acos_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/acosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ function acosh_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Acosh, inputs as unknown as NamedTensorMap);
}
export const acosh = op({acosh_});
export const acosh = /* @__PURE__ */ op({acosh_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ function add_<T extends Tensor>(a: Tensor|TensorLike, b: Tensor|TensorLike): T {
return ENGINE.runKernel(Add, inputs as unknown as NamedTensorMap);
}

export const add = op({add_});
export const add = /* @__PURE__ */ op({add_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/add_n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ function addN_<T extends Tensor>(tensors: Array<T|TensorLike>): T {
return ENGINE.runKernel(AddN, inputs as unknown as NamedTensorMap);
}

export const addN = op({addN_});
export const addN = /* @__PURE__ */ op({addN_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ function all_<T extends Tensor>(
attrs as unknown as NamedAttrMap);
}

export const all = op({all_});
export const all = /* @__PURE__ */ op({all_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ function any_<T extends Tensor>(
}

// tslint:disable-next-line:variable-name
export const any = op({any_});
export const any = /* @__PURE__ */ op({any_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/arg_max.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ function argMax_<T extends Tensor>(x: Tensor|TensorLike, axis = 0): T {
attrs as unknown as NamedAttrMap);
}

export const argMax = op({argMax_});
export const argMax = /* @__PURE__ */ op({argMax_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/arg_min.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ function argMin_<T extends Tensor>(x: Tensor|TensorLike, axis = 0): T {
attrs as unknown as NamedAttrMap);
}

export const argMin = op({argMin_});
export const argMin = /* @__PURE__ */ op({argMin_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/asin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ function asin_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Asin, inputs as unknown as NamedTensorMap);
}
export const asin = op({asin_});
export const asin = /* @__PURE__ */ op({asin_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/asinh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ function asinh_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Asinh, inputs as unknown as NamedTensorMap);
}
export const asinh = op({asinh_});
export const asinh = /* @__PURE__ */ op({asinh_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/atan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ function atan_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Atan, inputs as unknown as NamedTensorMap);
}
export const atan = op({atan_});
export const atan = /* @__PURE__ */ op({atan_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/atan2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function atan2_<T extends Tensor>(
return ENGINE.runKernel(Atan2, inputs as unknown as NamedTensorMap);
}

export const atan2 = op({atan2_});
export const atan2 = /* @__PURE__ */ op({atan2_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/atanh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ function atanh_<T extends Tensor>(x: T|TensorLike): T {

return ENGINE.runKernel(Atanh, inputs as unknown as NamedTensorMap);
}
export const atanh = op({atanh_});
export const atanh = /* @__PURE__ */ op({atanh_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/avg_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ function avgPool_<T extends Tensor3D|Tensor4D>(
return res;
}

export const avgPool = op({avgPool_});
export const avgPool = /* @__PURE__ */ op({avgPool_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/avg_pool_3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ function avgPool3d_<T extends Tensor4D|Tensor5D>(
return res;
}

export const avgPool3d = op({avgPool3d_});
export const avgPool3d = /* @__PURE__ */ op({avgPool3d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/avg_pool_3d_grad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ function avgPool3dGrad_<T extends Tensor4D|Tensor5D>(
return res;
}

export const avgPool3dGrad = op({avgPool3dGrad_});
export const avgPool3dGrad = /* @__PURE__ */ op({avgPool3dGrad_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/avg_pool_grad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ function avgPoolGrad_<T extends Tensor3D|Tensor4D>(
return res;
}

export const avgPoolGrad = op({avgPoolGrad_});
export const avgPoolGrad = /* @__PURE__ */ op({avgPoolGrad_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/basic_lstm_cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ function basicLSTMCell_(
return [newC, newH];
}

export const basicLSTMCell = op({basicLSTMCell_});
export const basicLSTMCell = /* @__PURE__ */ op({basicLSTMCell_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/batch_to_space_nd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ function batchToSpaceND_<T extends Tensor>(
attrs as unknown as NamedAttrMap);
}

export const batchToSpaceND = op({batchToSpaceND_});
export const batchToSpaceND = /* @__PURE__ */ op({batchToSpaceND_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/batchnorm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ function batchNorm_<R extends Rank>(
return reshape(res, $x.shape);
}

export const batchNorm = op({batchNorm_});
export const batchNorm = /* @__PURE__ */ op({batchNorm_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/batchnorm2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ function batchNorm2d_(
return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon);
}

export const batchNorm2d = op({batchNorm2d_});
export const batchNorm2d = /* @__PURE__ */ op({batchNorm2d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/batchnorm3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ function batchNorm3d_(
return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon);
}

export const batchNorm3d = op({batchNorm3d_});
export const batchNorm3d = /* @__PURE__ */ op({batchNorm3d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/batchnorm4d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ function batchNorm4d_(
return batchNorm($x, $mean, $variance, $offset, $scale, varianceEpsilon);
}

export const batchNorm4d = op({batchNorm4d_});
export const batchNorm4d = /* @__PURE__ */ op({batchNorm4d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/bincount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ function bincount_<T extends Tensor1D>(
attrs as unknown as NamedAttrMap);
}

export const bincount = op({bincount_});
export const bincount = /* @__PURE__ */ op({bincount_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/broadcast_args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ function broadcastArgs_<R extends Rank>(
return ENGINE.runKernel(BroadcastArgs, inputs as unknown as NamedTensorMap);
}

export const broadcastArgs = op({ broadcastArgs_ });
export const broadcastArgs = /* @__PURE__ */ op({ broadcastArgs_ });
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/broadcast_to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ function broadcastTo_<R extends Rank>(
attrs as unknown as NamedAttrMap);
}

export const broadcastTo = op({broadcastTo_});
export const broadcastTo = /* @__PURE__ */ op({broadcastTo_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,4 @@ export async function toPixels(
return bytes;
}

export const fromPixels = op({fromPixels_});
export const fromPixels = /* @__PURE__ */ op({fromPixels_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ function cast_<T extends Tensor>(x: T|TensorLike, dtype: DataType): T {
attrs as unknown as NamedAttrMap);
}

export const cast = op({cast_});
export const cast = /* @__PURE__ */ op({cast_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/ceil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ function ceil_<T extends Tensor>(x: T|TensorLike): T {
const inputs: CeilInputs = {x: $x};
return ENGINE.runKernel(Ceil, inputs as unknown as NamedTensorMap);
}
export const ceil = op({ceil_});
export const ceil = /* @__PURE__ */ op({ceil_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/clip_by_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ function clipByValue_<T extends Tensor>(
attrs as unknown as NamedAttrMap);
}

export const clipByValue = op({clipByValue_});
export const clipByValue = /* @__PURE__ */ op({clipByValue_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ function clone_<T extends Tensor>(x: T|TensorLike): T {
return ENGINE.runKernel(Identity, inputs as unknown as NamedTensorMap);
}

export const clone = op({clone_});
export const clone = /* @__PURE__ */ op({clone_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/complex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ function complex_<T extends Tensor>(real: T|TensorLike, imag: T|TensorLike): T {
return ENGINE.runKernel(Complex, inputs as unknown as NamedTensorMap);
}

export const complex = op({complex_});
export const complex = /* @__PURE__ */ op({complex_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ function concat_<T extends Tensor>(tensors: Array<T|TensorLike>, axis = 0): T {
attr as unknown as NamedAttrMap);
}

export const concat = op({concat_});
export const concat = /* @__PURE__ */ op({concat_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/concat_1d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ function concat1d_(tensors: Array<Tensor1D|TensorLike>): Tensor1D {
return concat(tensors, 0 /* axis */);
}

export const concat1d = op({concat1d_});
export const concat1d = /* @__PURE__ */ op({concat1d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/concat_2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function concat2d_(
return concat(tensors, axis);
}

export const concat2d = op({concat2d_});
export const concat2d = /* @__PURE__ */ op({concat2d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/concat_3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ function concat3d_(
return concat(tensors, axis);
}

export const concat3d = op({concat3d_});
export const concat3d = /* @__PURE__ */ op({concat3d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/concat_4d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function concat4d_(
return concat(tensors, axis);
}

export const concat4d = op({concat4d_});
export const concat4d = /* @__PURE__ */ op({concat4d_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/confusion_matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ export function confusionMatrix_(
return cast(product, 'int32');
}

export const confusionMatrix = op({confusionMatrix_});
export const confusionMatrix = /* @__PURE__ */ op({confusionMatrix_});
2 changes: 1 addition & 1 deletion tfjs-core/src/ops/conv1d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ function conv1d_<T extends Tensor2D|Tensor3D>(
return reshape(res, [res.shape[0], res.shape[2], res.shape[3]]) as T;
}

export const conv1d = op({conv1d_});
export const conv1d = /* @__PURE__ */ op({conv1d_});
Loading