Skip to content

Commit

Permalink
Fix: Make proxy layer compatible with empty functional model
Browse files Browse the repository at this point in the history
  • Loading branch information
syt123450 committed Apr 20, 2019
1 parent b90869b commit 7fd32f5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
50 changes: 47 additions & 3 deletions src/layer/intermediate/Reshape.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,22 @@ function Reshape( config ) {
this.actualHeight = undefined;
this.actualDepth = undefined;

this.depth = undefined;

this.layerDimension = undefined;
this.openFmCenters = undefined;

this.lastLayer = undefined;

if ( config !== undefined &&
( config.targetShape !== undefined || config.shape !== undefined ) ) {

this.setReshapeType();
this.createActualLayer();
this.updateLayerMetric();

}

}

Reshape.prototype = {
Expand Down Expand Up @@ -114,10 +127,14 @@ Reshape.prototype = {
this.actualHeight = this.actualLayer.actualHeight;
this.actualDepth = this.actualLayer.actualDepth;

this.depth = this.actualLayer.depth;

this.layerDimension = this.actualLayer.layerDimension;

this.openFmCenters = this.actualLayer.openFmCenters;

this.lastLayer = this.actualLayer.lastLayer;

},

/**
Expand Down Expand Up @@ -166,6 +183,13 @@ Reshape.prototype = {

setEnvironment: function( context, model ) {

if ( this.actualLayer === undefined ) {

this.createActualLayer();
this.updateLayerMetric();

}

this.actualLayer.setEnvironment( context, model );

},
Expand Down Expand Up @@ -212,6 +236,20 @@ Reshape.prototype = {

},

translateLayer: function( targetCenter, translateTime ) {

this.actualLayer.translateLayer( targetCenter, translateTime );

},

apply: function( lastLayer ) {

this.actualLayer.apply( lastLayer );

this.updateLayerMetric();

},

setShape: function( shape ) {

// Based on shape dimension, update proxy states.
Expand Down Expand Up @@ -246,6 +284,15 @@ Reshape.prototype = {

assemble: function() {

this.setReshapeType();

this.actualLayer.assemble();
this.updateLayerMetric();

},

setReshapeType: function() {

// If "setShape" has been called before, there is no need to check "shape" attribute or "targetShape" attribute in config.

if ( this.reshapeType === undefined ) {
Expand Down Expand Up @@ -308,9 +355,6 @@ Reshape.prototype = {

}

this.actualLayer.assemble();
this.updateLayerMetric();

}

};
Expand Down
18 changes: 18 additions & 0 deletions src/merge/proxy/MergeProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function MergeProxy( operatorType, layerList, config ) {
this.actualHeight = undefined;
this.actualDepth = undefined;

this.depth = undefined;

this.layerDimension = undefined;

this.openFmCenters = undefined;
Expand Down Expand Up @@ -89,6 +91,8 @@ MergeProxy.prototype = {
this.actualHeight = this.actualLayer.actualHeight;
this.actualDepth = this.actualLayer.actualDepth;

this.depth = this.actualLayer.depth;

this.layerDimension = this.actualLayer.layerDimension;

this.openFmCenters = this.actualLayer.openFmCenters;
Expand Down Expand Up @@ -136,6 +140,14 @@ MergeProxy.prototype = {

setEnvironment: function( context, model ) {

if ( this.actualLayer === undefined ) {

MergeValidator.validateDimension( this.layerList );
this.createActualLayer();
this.updateLayerMetric();

}

this.actualLayer.setEnvironment( context, model );

},
Expand Down Expand Up @@ -188,6 +200,12 @@ MergeProxy.prototype = {

},

translateLayer: function( targetCenter, translateTime ) {

this.actualLayer.translateLayer( targetCenter, translateTime );

},

setShape: function( shape ) {

// make sure the input elements have the same dimension.
Expand Down

0 comments on commit 7fd32f5

Please sign in to comment.