Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"clang-format": "~1.2.4",
"chalk": "~2.4.2",
"shelljs": "~0.8.3",
"tslint": "^5.11.0",
"ts-node": "~4.1.0",
"typescript": "3.5.3"
},
Expand Down
1 change: 1 addition & 0 deletions tfjs-automl/src/img_classification_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import * as tf from '@tensorflow/tfjs-core';
import {Tensor3D, test_util} from '@tensorflow/tfjs-core';
// tslint:disable-next-line:no-imports-from-dist
import {BROWSER_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util';

import * as automl from './index';
Expand Down
1 change: 1 addition & 0 deletions tfjs-automl/src/test_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util';

// Run browser tests againts both the cpu and webgl backends.
Expand Down
1 change: 1 addition & 0 deletions tfjs-automl/src/test_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util';

// tslint:disable-next-line:no-require-imports
Expand Down
1 change: 1 addition & 0 deletions tfjs-backend-nodegl/src/run_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

// We import index.ts so that the Node backend gets registered.
// tslint:disable-next-line:no-imports-from-dist
import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util';
import * as tf from '@tensorflow/tfjs-core';

Expand Down
1 change: 1 addition & 0 deletions tfjs-backend-wasm/src/index_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import * as tf from '@tensorflow/tfjs-core';
import {test_util} from '@tensorflow/tfjs-core';
// tslint:disable-next-line:no-imports-from-dist
import {ALL_ENVS, describeWithFlags} from '@tensorflow/tfjs-core/dist/jasmine_util';

import {BackendWasm} from './index';
Expand Down
2 changes: 2 additions & 0 deletions tfjs-backend-wasm/src/setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util';

setTestEnvs([{name: 'test-wasm', backendName: 'wasm', isDataSync: true}]);
Expand Down Expand Up @@ -70,4 +71,5 @@ env.specFilter = spec => {
};

// Import and run all the tests from core.
// tslint:disable-next-line:no-imports-from-dist
import '@tensorflow/tfjs-core/dist/tests';
2 changes: 2 additions & 0 deletions tfjs-backend-webgpu/src/setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util';

setTestEnvs([{
Expand Down Expand Up @@ -119,4 +120,5 @@ env.specFilter = spec => {
};

// Import and run all the tests from core.
// tslint:disable-next-line:no-imports-from-dist
import '@tensorflow/tfjs-core/dist/tests';
1 change: 1 addition & 0 deletions tfjs-backend-webgpu/src/test_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {ALL_ENVS, describeWithFlags, TestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util';

export function describeWebGPU(name: string, tests: (env: TestEnv) => void) {
Expand Down
3 changes: 2 additions & 1 deletion tfjs-converter/scripts/test_snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* =============================================================================
*/
import * as tfc from '@tensorflow/tfjs-core';
import {parseAndEvaluateSnippets} from '@tensorflow/tfjs-core/dist/scripts/test_snippets/util';

import {parseAndEvaluateSnippets} from '@tensorflow/tfjs-core/scripts/test_snippets/util';

import * as tfconv from '../src/index';

Expand Down
2 changes: 1 addition & 1 deletion tfjs-core/src/backends/backend_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export * from '../ops/axis_util';
export * from '../ops/broadcast_util';
export * from '../ops/concat_util';
export * from '../ops/conv_util';
export {Activation} from '../ops/fused_util';
export {Activation, FusedBatchMatMulConfig} from '../ops/fused_util';

export {BackendValues, TypedArray, upcastType, PixelData} from '../types';
export {MemoryInfo, TimingInfo} from '../engine';
Expand Down
2 changes: 1 addition & 1 deletion tfjs-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export {Optimizer} from './optimizers/optimizer';
export {RMSPropOptimizer} from './optimizers/rmsprop_optimizer';
export {SGDOptimizer} from './optimizers/sgd_optimizer';
export {Scalar, Tensor, Tensor1D, Tensor2D, Tensor3D, Tensor4D, Tensor5D, TensorBuffer, variable, Variable} from './tensor';
export {GradSaveFunc, NamedTensorMap, TensorContainer, TensorContainerArray, TensorContainerObject} from './tensor_types';
export {GradSaveFunc, NamedTensor, NamedTensorMap, TensorContainer, TensorContainerArray, TensorContainerObject} from './tensor_types';
export {DataType, DataTypeMap, DataValues, Rank, RecursiveArray, ShapeMap, TensorLike} from './types';

export * from './ops/ops';
Expand Down
1 change: 1 addition & 0 deletions tfjs-data/src/test_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {setTestEnvs} from '@tensorflow/tfjs-core/dist/jasmine_util';

// tslint:disable-next-line:no-require-imports
Expand Down
1 change: 1 addition & 0 deletions tfjs-data/src/util/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* =============================================================================
*/

// tslint:disable-next-line:no-imports-from-dist
import {ALL_ENVS, BROWSER_ENVS, describeWithFlags, NODE_ENVS, registerTestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util';

// Provide fake video stream
Expand Down
3 changes: 1 addition & 2 deletions tfjs-layers/src/engine/training.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
/* Original Source: engine/training.py */

import * as tfc from '@tensorflow/tfjs-core';
import {io, ModelPredictConfig as ModelPredictArgs, NamedTensorMap, Optimizer, Scalar, scalar, serialization, Tensor, Tensor1D, tensor1d, util} from '@tensorflow/tfjs-core';
import {NamedTensor} from '@tensorflow/tfjs-core/dist/tensor_types';
import {io, ModelPredictConfig as ModelPredictArgs, NamedTensor, NamedTensorMap, Optimizer, Scalar, scalar, serialization, Tensor, Tensor1D, tensor1d, util} from '@tensorflow/tfjs-core';

import * as K from '../backend/tfjs_backend';
import {History, ModelLoggingVerbosity} from '../base_callbacks';
Expand Down
3 changes: 1 addition & 2 deletions tfjs-layers/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

/* Original source keras/models.py */

import {dispose, io, NamedTensorMap, Optimizer, Scalar, serialization, Tensor, util} from '@tensorflow/tfjs-core';
import {NamedTensor} from '@tensorflow/tfjs-core/dist/tensor_types';
import {dispose, io, NamedTensor, NamedTensorMap, Optimizer, Scalar, serialization, Tensor, util} from '@tensorflow/tfjs-core';

import {getUid} from './backend/state';
import {History} from './base_callbacks';
Expand Down
6 changes: 3 additions & 3 deletions tfjs-layers/src/models_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

import {DataType, ENV, io, memory, ones, randomNormal, Scalar, scalar, serialization, sum, Tensor, tensor1d, tensor2d, tensor3d, train, zeros} from '@tensorflow/tfjs-core';
import {ConfigDict} from '@tensorflow/tfjs-core/dist/serialization';

import {LayersModel} from './engine/training';
import * as tfl from './index';
Expand Down Expand Up @@ -534,8 +533,9 @@ describeMathCPU('modelFromJSON', () => {
'backend': 'tensorflow'
};
const model =
deserialize(convertPythonicToTs(modelTopology) as ConfigDict) as
LayersModel;
deserialize(
convertPythonicToTs(modelTopology) as serialization.ConfigDict
) as LayersModel;

expect(model.name.indexOf('BarSequential123')).toEqual(0);
expect(model.inputs.length).toEqual(1);
Expand Down
1 change: 1 addition & 0 deletions tfjs-layers/src/utils/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import {memory, Tensor, test_util, util} from '@tensorflow/tfjs-core';
// tslint:disable-next-line:no-imports-from-dist
import {ALL_ENVS, describeWithFlags, registerTestEnv} from '@tensorflow/tfjs-core/dist/jasmine_util';
import {ValueError} from '../errors';

Expand Down
7 changes: 3 additions & 4 deletions tfjs-node/src/io/file_system_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import * as tfc from '@tensorflow/tfjs-core';
import * as tfl from '@tensorflow/tfjs-layers';
import {expectArraysClose} from '@tensorflow/tfjs-core/dist/test_util';
import * as fs from 'fs';
import * as path from 'path';
import * as rimraf from 'rimraf';
Expand Down Expand Up @@ -224,7 +223,7 @@ describe('File system IOHandler', () => {
dtype: 'float32',
}
]);
expectArraysClose(
tfc.test_util.expectArraysClose(
new Float32Array(modelArtifacts.weightData),
new Float32Array([-1.1, -3.3, -3.3, -7.7]));
done();
Expand Down Expand Up @@ -347,7 +346,7 @@ describe('File system IOHandler', () => {
new NodeFileSystem([`${modelPath}`, `${modelManifestJSONPath}`]);
handler.load()
.then(modelArtifacts => {
expectArraysClose(
tfc.test_util.expectArraysClose(
new Uint8Array(modelArtifacts.modelTopology as ArrayBuffer),
new Uint8Array(modelData));
expect(modelArtifacts.weightSpecs).toEqual([
Expand All @@ -362,7 +361,7 @@ describe('File system IOHandler', () => {
dtype: 'float32',
}
]);
expectArraysClose(
tfc.test_util.expectArraysClose(
new Float32Array(modelArtifacts.weightData),
new Float32Array([-1.1, -3.3, -3.3, -7.7]));
done();
Expand Down
18 changes: 11 additions & 7 deletions tfjs-node/src/nodejs_kernel_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
* =============================================================================
*/

import {BackendTimingInfo, DataMover, DataType, fill, KernelBackend, ones, Rank, rsqrt, Scalar, scalar, ShapeMap, Tensor, Tensor1D, tensor1d, Tensor2D, tensor2d, Tensor3D, tensor3d, Tensor4D, tidy, util} from '@tensorflow/tfjs-core';
import {EPSILON_FLOAT32} from '@tensorflow/tfjs-core/dist/backends/backend';
import {Conv2DInfo, Conv3DInfo} from '@tensorflow/tfjs-core/dist/ops/conv_util';
import {BackendTimingInfo, backend_util, DataMover, DataType, fill, KernelBackend, ones, Rank, rsqrt, Scalar, scalar, ShapeMap, Tensor, Tensor1D, tensor1d, Tensor2D, tensor2d, Tensor3D, tensor3d, Tensor4D, Tensor5D, tidy, util} from '@tensorflow/tfjs-core';
import * as tfc from '@tensorflow/tfjs-core';

import {Activation, FusedBatchMatMulConfig} from '@tensorflow/tfjs-core/dist/ops/fused_util';
import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
import {BackendValues, upcastType} from '@tensorflow/tfjs-core/dist/types';
import {isNullOrUndefined, isArray} from 'util';

import {Int64Scalar} from './int64_tensors';
import {TensorMetadata, TFEOpAttr, TFJSBinding} from './tfjs_binding';

type Activation = backend_util.Activation;
type BackendValues = backend_util.BackendValues;
type Conv2DInfo = backend_util.Conv2DInfo;
type Conv3DInfo = backend_util.Conv3DInfo;
type FusedBatchMatMulConfig = backend_util.FusedBatchMatMulConfig;

type TensorInfo = {
shape: number[],
dtype: number,
Expand All @@ -37,6 +38,9 @@ type TensorInfo = {

interface DataId {}

const { upcastType } = backend_util;
const EPSILON_FLOAT32 = 1e-7;

export class NodeJSKernelBackend extends KernelBackend {
binding: TFJSBinding;
isGPUPackage: boolean;
Expand Down Expand Up @@ -2028,4 +2032,4 @@ export function ensureTensorflowBackend() {
tfc.getBackend() === 'tensorflow',
() => `Expect the current backend to be "tensorflow", but got "${
tfc.getBackend()}"`);
}
}
7 changes: 3 additions & 4 deletions tfjs-node/src/nodejs_kernel_backend_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
*/

import * as tf from '@tensorflow/tfjs-core';
import {Tensor5D} from '@tensorflow/tfjs-core/dist/tensor';
import {expectArraysClose} from '@tensorflow/tfjs-core/dist/test_util';
import {Tensor5D} from '@tensorflow/tfjs-core';

import {createTensorsTypeOpAttr, createTypeOpAttr, ensureTensorflowBackend, getTFDType, nodeBackend, NodeJSKernelBackend} from './nodejs_kernel_backend';

describe('delayed upload', () => {
it('should handle data before op execution', async () => {
const t = tf.tensor1d([1, 2, 3]);
expectArraysClose(await t.data(), [1, 2, 3]);
tf.test_util.expectArraysClose(await t.data(), [1, 2, 3]);

const r = t.add(tf.tensor1d([4, 5, 6]));
expectArraysClose(await r.data(), [5, 7, 9]);
tf.test_util.expectArraysClose(await r.data(), [5, 7, 9]);
});

it('Should not cache tensors in the tensor map for device support. ', () => {
Expand Down
1 change: 1 addition & 0 deletions tfjs-node/src/run_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// We import index.ts so that the Node backend gets registered.
import './index';
// tslint:disable-next-line:no-imports-from-dist
import * as jasmine_util from '@tensorflow/tfjs-core/dist/jasmine_util';
import {nodeBackend} from './nodejs_kernel_backend';

Expand Down
3 changes: 2 additions & 1 deletion tfjs-node/src/tfjs_binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* =============================================================================
*/

import {BackendValues} from '@tensorflow/tfjs-core/dist/types';
import {backend_util} from '@tensorflow/tfjs-core';
type BackendValues = backend_util.BackendValues;

export declare class TensorMetadata {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion tfjs-react-native/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.5.1.tgz#c496b4969eea5b91da1a5919a611046360b0c51f"
integrity sha512-Ssfx2uLYPnsuqIvDCuUOEZT6jh5AVy0U0mr2eHxNO2Syor1nfOrR/n4hTOFcBWc1wamDTGCqo+UHJpxURVXd2Q==

"@tensorflow/tfjs-core@^1.2.8":
"@tensorflow/tfjs-core@>=1.2.8":
version "1.2.8"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.8.tgz#d6873b88522f8cf25d34c10afd095866578d7d92"
integrity sha512-lWV4vAnXAAmahXpCWBwdGGW9HO6iNw9pUeVYih7pDXeJahMk3OJs6SgjRNhwn+ldsGwRoorR0/RHg0yNLmqWxQ==
Expand Down
2 changes: 1 addition & 1 deletion tfjs-vis/src/show/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* =============================================================================
*/

import {Logs} from '@tensorflow/tfjs-layers/dist/logs';
import {Logs} from '@tensorflow/tfjs-layers/src/logs';

import {linechart} from '../render/linechart';
import {getDrawArea, nextFrame} from '../render/render_utils';
Expand Down
2 changes: 2 additions & 0 deletions tfjs-vis/src/show/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/

import * as tf from '@tensorflow/tfjs';

// tslint:disable-next-line:no-imports-from-dist
import {Layer} from '@tensorflow/tfjs-layers/dist/engine/topology';

import {histogram} from '../render/histogram';
Expand Down
2 changes: 2 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": ["tslint-no-circular-imports"],
"rulesDirectory": ".tslint",
"rules": {
"array-type": [true, "array-simple"],
"arrow-return-shorthand": true,
Expand Down Expand Up @@ -37,6 +38,7 @@
"no-debugger": true,
"no-default-export": true,
"no-inferrable-types": true,
"no-imports-from-dist": true,
"no-namespace": [true, "allow-declarations"],
"no-reference": true,
"no-require-imports": true,
Expand Down
Loading