Skip to content

Commit 8efdabd

Browse files
authored
support empty list for numerical array params (#411)
1 parent ed0267d commit 8efdabd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/operations/operation_mapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function getNumericArrayParam(
373373
def: number[]): number[] {
374374
const param = attrs[name];
375375
if (param) {
376-
return ((param.list.f && param.list.f.length ? param.list.f : param.list.i))
376+
return ((param.list.f && param.list.f.length ? param.list.f : param.list.i) || [])
377377
.map(
378378
v => (typeof v === 'number') ? v :
379379
parseInt(v as string, 10)) as

src/operations/operation_mapper_test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ const SIMPLE_MODEL: tensorflow.IGraphDef = {
117117
input: ['BiasAdd'],
118118
attr: {squeeze_dims: {list: {i: ['1', '2']}}}
119119
},
120+
{
121+
name: 'Squeeze2',
122+
op: 'Squeeze',
123+
input: ['BiasAdd'],
124+
attr: {squeeze_dims: {list: {}}}
125+
},
120126
{
121127
name: 'Split',
122128
op: 'Split',
@@ -163,7 +169,7 @@ describe('operationMapper', () => {
163169

164170
it('should find the graph output nodes', () => {
165171
expect(convertedGraph.outputs.map(node => node.name)).toEqual([
166-
'Fill', 'Squeeze', 'Split', 'LogicalNot', 'FusedBatchNorm'
172+
'Fill', 'Squeeze', 'Squeeze2', 'Split', 'LogicalNot', 'FusedBatchNorm'
167173
]);
168174
});
169175

@@ -176,7 +182,8 @@ describe('operationMapper', () => {
176182
it('should convert nodes', () => {
177183
expect(Object.keys(convertedGraph.nodes)).toEqual([
178184
'image_placeholder', 'Const', 'Shape', 'Value', 'Fill', 'Conv2D',
179-
'BiasAdd', 'Squeeze', 'Split', 'LogicalNot', 'FusedBatchNorm'
185+
'BiasAdd', 'Squeeze', 'Squeeze2', 'Split', 'LogicalNot',
186+
'FusedBatchNorm'
180187
]);
181188
});
182189
});
@@ -214,6 +221,9 @@ describe('operationMapper', () => {
214221
expect(
215222
convertedGraph.nodes['FusedBatchNorm'].attrParams['epsilon'].value)
216223
.toEqual(0.0001);
224+
expect(
225+
convertedGraph.nodes['Squeeze2'].attrParams['axis'].value)
226+
.toEqual([]);
217227
});
218228

219229
it('should map the placeholder attribute params', () => {

0 commit comments

Comments
 (0)