@@ -19,6 +19,7 @@ view.View = class {
19
19
} ;
20
20
this . _options = { ...this . _defaultOptions } ;
21
21
this . _model = null ;
22
+ this . _metrics = new metrics . Metrics ( ) ;
22
23
this . _stack = [ ] ;
23
24
this . _selection = [ ] ;
24
25
this . _sidebar = new view . Sidebar ( this . _host ) ;
@@ -287,6 +288,10 @@ view.View = class {
287
288
return this . _model ;
288
289
}
289
290
291
+ get metrics ( ) {
292
+ return this . _metrics ;
293
+ }
294
+
290
295
get options ( ) {
291
296
return this . _options ;
292
297
}
@@ -715,6 +720,13 @@ view.View = class {
715
720
}
716
721
}
717
722
723
+ async attach ( context ) {
724
+ if ( this . _model && await this . _metrics . open ( context ) ) {
725
+ return true ;
726
+ }
727
+ return false ;
728
+ }
729
+
718
730
async _updateActiveTarget ( stack ) {
719
731
this . _sidebar . close ( ) ;
720
732
if ( this . _model ) {
@@ -2836,6 +2848,13 @@ view.NodeSidebar = class extends view.ObjectSidebar {
2836
2848
this . addArgument ( entry . name , entry , 'attribute' ) ;
2837
2849
}
2838
2850
}
2851
+ const metrics = this . _view . metrics . node ( node ) ;
2852
+ if ( Array . isArray ( metrics ) && metrics . length > 0 ) {
2853
+ this . addSection ( 'Metrics' ) ;
2854
+ for ( const metric of metrics ) {
2855
+ this . addArgument ( metric . name , metric ) ;
2856
+ }
2857
+ }
2839
2858
}
2840
2859
2841
2860
addArgument ( name , argument , source ) {
@@ -3502,6 +3521,13 @@ view.ConnectionSidebar = class extends view.ObjectSidebar {
3502
3521
this . addProperty ( metadata . name , metadata . value ) ;
3503
3522
}
3504
3523
}
3524
+ const metrics = this . _view . metrics . value ( value ) ;
3525
+ if ( Array . isArray ( metrics ) && metrics . length > 0 ) {
3526
+ this . addSection ( 'Metrics' ) ;
3527
+ for ( const argument of metrics ) {
3528
+ this . addProperty ( argument . name , argument . value ) ;
3529
+ }
3530
+ }
3505
3531
}
3506
3532
3507
3533
addNodeList ( name , list ) {
@@ -3604,11 +3630,12 @@ view.TensorSidebar = class extends view.ObjectSidebar {
3604
3630
this . _tensor = new base . Tensor ( tensor ) ;
3605
3631
if ( ! this . _tensor . empty ) {
3606
3632
if ( ! this . _metrics ) {
3607
- this . _metrics = new metrics . Tensor ( this . _tensor ) ;
3633
+ const tensor = new metrics . Tensor ( this . _tensor ) ;
3634
+ this . _metrics = this . _view . metrics . tensor ( tensor ) ;
3608
3635
}
3609
- if ( this . _metrics . metrics . length > 0 ) {
3636
+ if ( this . _metrics . length > 0 ) {
3610
3637
this . addSection ( 'Metrics' ) ;
3611
- for ( const metric of this . _metrics . metrics ) {
3638
+ for ( const metric of this . _metrics ) {
3612
3639
const value = metric . type === 'percentage' ? `${ ( metric . value * 100 ) . toFixed ( 1 ) } %` : metric . value ;
3613
3640
this . addProperty ( metric . name , [ value ] ) ;
3614
3641
}
@@ -3674,7 +3701,7 @@ view.ModelSidebar = class extends view.ObjectSidebar {
3674
3701
this . addProperty ( argument . name , argument . value ) ;
3675
3702
}
3676
3703
}
3677
- const metrics = model . metrics ;
3704
+ const metrics = this . _view . metrics . model ( model ) ;
3678
3705
if ( Array . isArray ( metrics ) && metrics . length > 0 ) {
3679
3706
this . addSection ( 'Metrics' ) ;
3680
3707
for ( const argument of metrics ) {
@@ -3740,7 +3767,7 @@ view.TargetSidebar = class extends view.ObjectSidebar {
3740
3767
this . addProperty ( argument . name , argument . value ) ;
3741
3768
}
3742
3769
}
3743
- const metrics = target . metrics ;
3770
+ const metrics = this . _view . metrics . graph ( target ) ;
3744
3771
if ( Array . isArray ( metrics ) && metrics . length > 0 ) {
3745
3772
this . addSection ( 'Metrics' ) ;
3746
3773
for ( const argument of metrics ) {
@@ -5301,6 +5328,67 @@ markdown.Generator = class {
5301
5328
}
5302
5329
} ;
5303
5330
5331
+ metrics . Metrics = class {
5332
+
5333
+ constructor ( ) {
5334
+ this . _metrics = new Map ( ) ;
5335
+ }
5336
+
5337
+ async open ( context ) {
5338
+ const content = new view . Context ( context ) ;
5339
+ if ( content . identifier . toLowerCase ( ) . endsWith ( '.metrics.json' ) ) {
5340
+ const data = await content . peek ( 'json' ) ;
5341
+ if ( data && data . signature === 'metrics' && Array . isArray ( data . metrics ) ) {
5342
+ this . _metrics . clear ( ) ;
5343
+ for ( const metric of data . metrics ) {
5344
+ if ( metric . kind && 'target' in metric ) {
5345
+ const key = `${ metric . kind } ::${ metric . target } ` ;
5346
+ if ( ! this . _metrics . has ( key ) ) {
5347
+ this . _metrics . set ( key , new Map ( ) ) ;
5348
+ }
5349
+ const entries = this . _metrics . get ( key ) ;
5350
+ entries . set ( metric . name , { value : metric . value , type : metric . type } ) ;
5351
+ }
5352
+ }
5353
+ return true ;
5354
+ }
5355
+ }
5356
+ return false ;
5357
+ }
5358
+
5359
+ metrics ( entries , type , name ) {
5360
+ const result = new Map ( entries . map ( ( metric ) => [ metric . name , metric ] ) ) ;
5361
+ const key = `${ type } ::${ name } ` ;
5362
+ if ( this . _metrics . has ( key ) ) {
5363
+ for ( const [ name , metric ] of this . _metrics . get ( key ) ) {
5364
+ result . set ( name , new metrics . Argument ( name , metric . value , metric . type || 'attribute' ) ) ;
5365
+ }
5366
+ }
5367
+ return Array . from ( result . values ( ) ) ;
5368
+ }
5369
+
5370
+ model ( value ) {
5371
+ return this . metrics ( value . metrics || [ ] , 'model' , '' ) ;
5372
+ }
5373
+
5374
+ graph ( value ) {
5375
+ return this . metrics ( value . metrics || [ ] , 'graph' , value . name || '' ) ;
5376
+ }
5377
+
5378
+ node ( value ) {
5379
+ return this . metrics ( value . metrics || [ ] , 'node' , value . name ) ;
5380
+ }
5381
+
5382
+ value ( value ) {
5383
+ const name = ( value . name || '' ) . split ( '\n' ) . shift ( ) ;
5384
+ return this . metrics ( value . metrics || [ ] , 'value' , name ) ;
5385
+ }
5386
+
5387
+ tensor ( value ) {
5388
+ return this . metrics ( value . metrics || [ ] , 'tensor' , value . name ) ;
5389
+ }
5390
+ } ;
5391
+
5304
5392
metrics . Argument = class {
5305
5393
5306
5394
constructor ( name , value , type ) {
@@ -5317,6 +5405,10 @@ metrics.Tensor = class {
5317
5405
this . _metrics = null ;
5318
5406
}
5319
5407
5408
+ get name ( ) {
5409
+ return this . _tensor . name || '' ;
5410
+ }
5411
+
5320
5412
get metrics ( ) {
5321
5413
if ( this . _metrics === null ) {
5322
5414
this . _metrics = [ ] ;
@@ -6026,6 +6118,7 @@ view.ModelFactoryService = class {
6026
6118
{ name : 'Netron metadata' , tags : [ '[].name' , '[].category' ] } ,
6027
6119
{ name : 'Netron test data' , tags : [ '[].type' , '[].target' , '[].source' , '[].format' , '[].link' ] } ,
6028
6120
{ name : 'Netron configuration' , tags : [ 'recents' , 'consent' ] } ,
6121
+ { name : 'Netron metrics data' , tags : [ 'signature' , 'metrics' ] } ,
6029
6122
{ name : 'Darkflow metadata' , tags : [ 'net' , 'type' , 'model' ] } ,
6030
6123
{ name : 'keras-yolo2 configuration' , tags : [ 'model' , 'train' , 'valid' ] } ,
6031
6124
{ name : 'Vulkan SwiftShader ICD manifest' , tags : [ 'file_format_version' , 'ICD' ] } ,
@@ -6063,7 +6156,7 @@ view.ModelFactoryService = class {
6063
6156
{ name : 'Jupyter Notebook data' , tags : [ 'cells' , 'nbformat' ] } ,
6064
6157
{ name : 'Kaggle credentials' , tags : [ 'username' , 'key' ] } ,
6065
6158
{ name : '.NET runtime configuration' , tags : [ 'runtimeOptions.configProperties' ] } ,
6066
- { name : '.NET dependency manifest' , tags : [ 'runtimeTarget' , 'targets' , 'libraries' ] }
6159
+ { name : '.NET dependency manifest' , tags : [ 'runtimeTarget' , 'targets' , 'libraries' ] } ,
6067
6160
] ;
6068
6161
const match = ( obj , tag ) => {
6069
6162
if ( tag . startsWith ( '[].' ) ) {
0 commit comments