-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EdgeTpu] Add EdgeTpuConfigSetting.ts to separate config
This commit Add EdgeTpuConfigSetting.ts to separate ConfigObject logic of EdgeTpu Config ONE-vscode-DCO-1.0-Signed-off-by: Seongwon Im <[email protected]>
- Loading branch information
Showing
4 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
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,103 @@ | ||
import * as vscode from "vscode"; | ||
|
||
import { Locator, LocatorRunner } from "./ArtifactLocator"; | ||
|
||
// export type OneCfg = { | ||
// "one-import-tflite": CfgOneImportTflite; | ||
// "one-import-onnx": CfgOneImportOnnx; | ||
// "one-import-tf": CfgOneImportTf; | ||
// }; | ||
// type CfgOneImportTflite = any; | ||
// type CfgOneImportOnnx = any; | ||
// type CfgOneImportTf = any; | ||
|
||
export class EdgeTpuConfigSetting { | ||
static baseModelsLocatorRunner: LocatorRunner; | ||
static productsLocatorRunner: LocatorRunner; | ||
// TODO: make sections for updateBaseModelField method | ||
|
||
static getBaseModelsLocatorRunner(): LocatorRunner { | ||
if (!this.baseModelsLocatorRunner) { | ||
this._initBaseModelsLocatorRunner(); | ||
} | ||
return this.baseModelsLocatorRunner; | ||
} | ||
|
||
static getProductsLocatorRunner(): LocatorRunner { | ||
if (!this.productsLocatorRunner) { | ||
this._initProductsLocatorRunner(); | ||
} | ||
return this.productsLocatorRunner; | ||
} | ||
|
||
private static _initBaseModelsLocatorRunner() { | ||
let locatorRunner = new LocatorRunner(); | ||
|
||
locatorRunner.register({ | ||
artifactAttr: { | ||
ext: ".tflite", | ||
icon: new vscode.ThemeIcon("symbol-variable"), | ||
}, | ||
locator: new Locator((value: string) => { | ||
value += ""; | ||
const filterd = value | ||
.split(" ") | ||
.filter((val) => !val.endsWith("_edgetpu.tflite")); | ||
value = filterd.join(" "); | ||
return LocatorRunner.searchWithExt(".tflite", value); | ||
}), | ||
}); | ||
|
||
this.baseModelsLocatorRunner = locatorRunner; | ||
} | ||
|
||
private static _initProductsLocatorRunner() { | ||
let locatorRunner = new LocatorRunner(); | ||
|
||
/** | ||
* ABOUT ORDERING | ||
* | ||
* The registration order determines the order in the tree view | ||
*/ | ||
|
||
// NOTE | ||
// Shows <model>_edgetpu.tflite | ||
// <model>_edgetpu.tflite generated by <model>.tflite is product type | ||
locatorRunner.register({ | ||
artifactAttr: { | ||
ext: ".tflite", | ||
icon: new vscode.ThemeIcon("symbol-variable"), | ||
}, | ||
locator: new Locator((value: string) => { | ||
value += ""; | ||
const filterd = value | ||
.split(" ") | ||
.filter((val) => val.endsWith("_edgetpu.tflite")); | ||
value = filterd.join(" "); | ||
return LocatorRunner.searchWithExt(".tflite", value); | ||
}), | ||
}); | ||
|
||
locatorRunner.register({ | ||
// 'default' view type is 'text editor' (vscode.openWith) | ||
artifactAttr: { | ||
ext: ".log", | ||
openViewType: "default", | ||
icon: vscode.ThemeIcon.File, | ||
canHide: true, | ||
}, | ||
locator: new Locator((value: string) => { | ||
value += ""; | ||
const filterd = value | ||
.split(" ") | ||
.filter((val) => val.endsWith("_edgetpu.tflite")); | ||
value = filterd.join(" "); | ||
return LocatorRunner.searchWithExt(".tflite", value).map((filepath) => | ||
filepath.replace(".tflite", ".log") | ||
); | ||
}), | ||
}); | ||
|
||
this.productsLocatorRunner = locatorRunner; | ||
} | ||
} |
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