Skip to content

Commit

Permalink
[tfjs-converter] Use global lint settings (tensorflow#1904)
Browse files Browse the repository at this point in the history
DEV

- Migrate tfjs-converter to Typescript 3.5.3
- Use global lint settings
- Fix lint errors
  • Loading branch information
dsmilkov authored Aug 27, 2019
1 parent e3ae753 commit d65d13e
Show file tree
Hide file tree
Showing 27 changed files with 136 additions and 197 deletions.
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "2.0.0",
"tasks": [
{
"command": "yarn",
"label": "lint",
"type": "shell",
"args": [
"lint"
],
"problemMatcher": {
"base": "$tslint5",
"owner": "tslint-type-checked",
"fileLocation": "absolute"
}
},
{
"command": "yarn",
"label": "build",
"type": "shell",
"args": ["build", "--pretty", "false", "--noEmit"],
"problemMatcher": [
"$tsc"
]
}
]
}
1 change: 1 addition & 0 deletions tfjs-converter/.vscode/tasks.json
2 changes: 1 addition & 1 deletion tfjs-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"ts-node": "~4.1.0",
"tslint": "~5.8.0",
"tslint-no-circular-imports": "~0.5.0",
"typescript": "3.3.3333",
"typescript": "3.5.3",
"yalc": "~1.0.0-pre.21"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions tfjs-converter/src/data/compiled_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* =============================================================================
*/

/* tslint:disable */

/** Properties of an Any. */
export declare interface IAny {
/** Any typeUrl */
Expand Down
3 changes: 1 addition & 2 deletions tfjs-converter/src/executor/execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ export class ExecutionContext {
this.contexts = this.contexts.slice();
this.lastId++;
const context =
Object.assign({}, this.contexts[this.contexts.length - 1]) as
ExecutionContextInfo;
Object.assign({}, this.contexts[this.contexts.length - 1]);
context.iterationId += 1;
context.id = this.lastId;
this.contexts.splice(-1, 1, context);
Expand Down
2 changes: 1 addition & 1 deletion tfjs-converter/src/executor/tensor_array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
* =============================================================================
*/
// tslint:disable-next-line:max-line-length

import {concat, DataType, slice, stack, Tensor, tensor, tidy, unstack, util} from '@tensorflow/tfjs-core';

export interface TensorWithState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import * as tfc from '@tensorflow/tfjs-core';

import {ExecutionContext} from '../../executor/execution_context';
import * as basic_math from '../op_list/basic_math';
import {Node, OpMapper} from '../types';
import {Node} from '../types';

import {executeOp} from './basic_math_executor';
// tslint:disable-next-line:max-line-length
import {createNumberAttr, createNumericArrayAttrFromIndex, createTensorAttr, validateParam} from './test_helper';

describe('basic math', () => {
Expand Down Expand Up @@ -59,8 +58,7 @@ describe('basic math', () => {
it('should match op def', () => {
node.op = op;

expect(validateParam(node, basic_math.json as OpMapper[]))
.toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('Relu6', () => {
Expand All @@ -79,7 +77,7 @@ describe('basic math', () => {
node.attrParams['clipValueMax'] = createNumberAttr(6);
node.attrParams['clipValueMin'] = createNumberAttr(0);

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('Prod', () => {
Expand All @@ -97,7 +95,7 @@ describe('basic math', () => {
node.op = 'Prod';
node.inputParams['axes'] = createNumericArrayAttrFromIndex(1);

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('Rsqrt', () => {
Expand All @@ -112,7 +110,7 @@ describe('basic math', () => {
it('should match op def', () => {
node.op = 'Rsqrt';

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('LeakyRelu', () => {
Expand All @@ -128,7 +126,7 @@ describe('basic math', () => {
it('should match op def', () => {
node.op = 'LeakyRelu';
node.attrParams['alpha'] = createNumberAttr(1);
expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('Atan2', () => {
Expand All @@ -146,7 +144,7 @@ describe('basic math', () => {
node.op = 'Atan2';
node.inputParams['y'] = createTensorAttr(1);

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('ComplexAbs', () => {
Expand All @@ -161,7 +159,7 @@ describe('basic math', () => {
it('should match op def', () => {
node.op = 'ComplexAbs';

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
describe('Complex', () => {
Expand All @@ -185,7 +183,7 @@ describe('basic math', () => {
imag: createTensorAttr(1)
};

expect(validateParam(node, basic_math.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, basic_math.json)).toBeTruthy();
});
});
});
Expand Down
31 changes: 15 additions & 16 deletions tfjs-converter/src/operations/executors/control_executor_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import {test_util} from '@tensorflow/tfjs-core';
import {ExecutionContext} from '../../executor/execution_context';
import {TensorArray} from '../../executor/tensor_array';
import * as control from '../op_list/control';
import {Node, OpMapper} from '../types';
import {Node} from '../types';

import {executeOp} from './control_executor';
// tslint:disable-next-line:max-line-length
import {createBoolAttr, createDtypeAttr, createNumberAttrFromIndex, createNumericArrayAttrFromIndex, createStrAttr, createTensorAttr, createTensorShapeAttr, validateParam} from './test_helper';

describe('control', () => {
Expand Down Expand Up @@ -74,7 +73,7 @@ describe('control', () => {
node.inputParams['pred'] = createTensorAttr(1);
node.inputParams['data'] = createTensorAttr(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});
describe('Merge', () => {
Expand All @@ -100,7 +99,7 @@ describe('control', () => {
it('should match json def', () => {
node.op = 'Merge';

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -121,7 +120,7 @@ describe('control', () => {
node.op = 'Enter';
node.inputParams['tensor'] = createTensorAttr(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});
describe('Exit', () => {
Expand All @@ -140,7 +139,7 @@ describe('control', () => {
node.op = 'Exit';
node.inputParams['tensor'] = createTensorAttr(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});
describe('NextIteration', () => {
Expand All @@ -159,7 +158,7 @@ describe('control', () => {
node.op = 'NextIteration';
node.inputParams['tensor'] = createTensorAttr(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand Down Expand Up @@ -189,7 +188,7 @@ describe('control', () => {
node.attrParams['clearAfterRead'] = createBoolAttr(true);
node.attrParams['identicalElementShapes'] = createBoolAttr(true);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -215,7 +214,7 @@ describe('control', () => {
node.inputParams['index'] = createNumberAttrFromIndex(1);
node.inputParams['tensor'] = createTensorAttr(2);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -242,7 +241,7 @@ describe('control', () => {
node.inputParams['tensorArrayId'] = createNumberAttrFromIndex(0);
node.inputParams['index'] = createNumberAttrFromIndex(1);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand Down Expand Up @@ -273,7 +272,7 @@ describe('control', () => {
node.inputParams['indices'] = createNumericArrayAttrFromIndex(1);
node.attrParams['dtype'] = createDtypeAttr('int32');

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand Down Expand Up @@ -301,7 +300,7 @@ describe('control', () => {
node.inputParams['indices'] = createNumericArrayAttrFromIndex(1);
node.inputParams['tensor'] = createTensorAttr(2);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -328,7 +327,7 @@ describe('control', () => {
node.inputParams['tensor'] = createTensorAttr(1);
node.inputParams['lengths'] = createNumericArrayAttrFromIndex(2);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand Down Expand Up @@ -356,7 +355,7 @@ describe('control', () => {
node.inputParams['tensorArrayId'] = createNumberAttrFromIndex(0);
node.attrParams['dtype'] = createDtypeAttr('int32');

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -381,7 +380,7 @@ describe('control', () => {
node.op = 'TensorArraySizeV3';
node.inputParams['tensorArrayId'] = createNumberAttrFromIndex(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});

Expand All @@ -404,7 +403,7 @@ describe('control', () => {
node.op = 'TensorArrayCloseV3';
node.inputParams['tensorArrayId'] = createNumberAttrFromIndex(0);

expect(validateParam(node, control.json as OpMapper[])).toBeTruthy();
expect(validateParam(node, control.json)).toBeTruthy();
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {ExecutionContext} from '../../executor/execution_context';
import {Node} from '../types';

import {executeOp} from './convolution_executor';
// tslint:disable-next-line:max-line-length
import {createNumberAttr, createNumericArrayAttr, createStrArrayAttr, createStrAttr, createTensorAttr, createTensorsAttr} from './test_helper';

describe('convolution', () => {
Expand Down
Loading

0 comments on commit d65d13e

Please sign in to comment.