-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
198 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/layer/merge/MergedLayer.js → src/layer/abstract/MergedLayer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,52 @@ | ||
import { MergedLayer3d } from "../abstract/MergedLayer3d"; | ||
|
||
function Concatenate(layerList) { | ||
|
||
let operatorType = "concatenate"; | ||
|
||
validate(layerList); | ||
|
||
} | ||
return createMergedLayer(layerList); | ||
|
||
function validate(layerList) { | ||
|
||
let depth; | ||
|
||
if (layerList.length > 0) { | ||
depth = layerList[0].layerDimension; | ||
} else { | ||
console.error("Merge Layer missing elements."); | ||
} | ||
|
||
for (let i = 0; i < layerList.length; i++) { | ||
|
||
if (layerList[i].layerDimension !== depth) { | ||
console.error("Can not add layer with different depth."); | ||
} | ||
|
||
} | ||
|
||
Concatenate.prototype = { | ||
} | ||
|
||
}; | ||
function createMergedLayer(layerList) { | ||
|
||
if (layerList[0].layerDimension === 1) { | ||
|
||
} else if (layerList[0].layerDimension === 2) { | ||
|
||
} else if (layerList[0].layerDimension === 3) { | ||
|
||
return new MergedLayer3d({ | ||
operator: operatorType, | ||
mergedElements: layerList | ||
}); | ||
|
||
} else { | ||
console.error("Do not support layer concatenate operation more than 4 dimension."); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
export { Concatenate }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
function Concatenate3d(mergedElements) { | ||
|
||
this.mergedElements = mergedElements; | ||
this.layerIndex = undefined; | ||
|
||
} | ||
|
||
Concatenate3d.prototype = { | ||
|
||
setLayerIndex: function(layerIndex) { | ||
this.layerIndex = layerIndex; | ||
}, | ||
|
||
validate: function() { | ||
|
||
let inputShape = this.mergedElements[0].outputShape; | ||
|
||
for (let i = 0; i < this.mergedElements.length; i++) { | ||
|
||
let layerShape = this.mergedElements[i].outputShape; | ||
if (layerShape[0] !== inputShape[0] || layerShape[1] !== inputShape[1]) { | ||
return false; | ||
} | ||
|
||
} | ||
|
||
return true; | ||
|
||
}, | ||
|
||
getShape: function() { | ||
|
||
let width = this.mergedElements[0].outputShape[0]; | ||
let height = this.mergedElements[0].outputShape[1]; | ||
|
||
let depth = 0; | ||
for (let i = 0; i < this.mergedElements.length; i++) { | ||
|
||
depth += this.mergedElements[i].outputShape[2]; | ||
|
||
} | ||
|
||
return [width, height, depth]; | ||
|
||
}, | ||
|
||
getRelativeElements: function(selectedElement) { | ||
|
||
let curveElements = []; | ||
let straightElements = []; | ||
|
||
if (selectedElement.elementType === "aggregationElement") { | ||
|
||
let request = { | ||
all: true | ||
}; | ||
|
||
for (let i = 0; i < this.mergedElements.length; i++) { | ||
let relativeResult = this.mergedElements[i].provideRelativeElements(request); | ||
let relativeElements = relativeResult.elementList; | ||
if (this.mergedElements[i].layerIndex === this.layerIndex - 1) { | ||
|
||
for (let j = 0; j < relativeElements.length; j++) { | ||
straightElements.push(relativeElements[j]); | ||
} | ||
|
||
} else { | ||
|
||
if (relativeResult.isOpen) { | ||
for (let j = 0; j < relativeElements.length; j++) { | ||
straightElements.push(relativeElements[j]); | ||
} | ||
} else { | ||
for (let j = 0; j < relativeElements.length; j++) { | ||
curveElements.push(relativeElements[j]); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} else if (selectedElement.elementType === "featureMap") { | ||
|
||
let fmIndex = selectedElement.fmIndex; | ||
|
||
let relativeLayer; | ||
|
||
for (let i = 0; i < this.mergedElements.length; i++) { | ||
|
||
let layerDepth = this.mergedElements[i].outputShape[2]; | ||
if (layerDepth >= fmIndex) { | ||
relativeLayer = this.mergedElements[i]; | ||
break; | ||
} else { | ||
fmIndex -= layerDepth; | ||
} | ||
|
||
} | ||
|
||
let request = { | ||
index: fmIndex | ||
}; | ||
|
||
let relativeResult = relativeLayer.provideRelativeElements(request); | ||
let relativeElements = relativeResult.elementList; | ||
if (relativeLayer.layerIndex === this.layerIndex - 1) { | ||
|
||
for (let i = 0; i < relativeElements.length; i++) { | ||
straightElements.push(relativeElements[i]); | ||
} | ||
|
||
} else { | ||
|
||
if (relativeResult.isOpen) { | ||
for (let i = 0; i < relativeElements.length; i++) { | ||
straightElements.push(relativeElements[i]); | ||
} | ||
} else { | ||
for (let i = 0; i < relativeElements.length; i++) { | ||
curveElements.push(relativeElements[i]); | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
return { | ||
straight: straightElements, | ||
curve: curveElements | ||
}; | ||
|
||
} | ||
|
||
}; | ||
|
||
export { Concatenate3d }; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters