ttnn-visualizer 0.53.0__py3-none-any.whl → 0.55.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@
4
4
 
5
5
  import csv
6
6
  import json
7
+ import logging
7
8
  import os
8
9
  import tempfile
9
10
  from io import StringIO
@@ -16,6 +17,8 @@ from tt_perf_report import perf_report
16
17
  from ttnn_visualizer.exceptions import DataFormatError
17
18
  from ttnn_visualizer.models import Instance
18
19
 
20
+ logger = logging.getLogger(__name__)
21
+
19
22
 
20
23
  class LocalCSVQueryRunner:
21
24
  def __init__(self, file_path: str, offset: int = 0):
@@ -432,7 +435,7 @@ class OpsPerformanceReportQueries:
432
435
  }
433
436
 
434
437
  DEFAULT_SIGNPOST = None
435
- DEFAULT_IGNORE_SIGNPOSTS = None
438
+ DEFAULT_IGNORE_SIGNPOSTS = True
436
439
  DEFAULT_MIN_PERCENTAGE = 0.5
437
440
  DEFAULT_ID_RANGE = None
438
441
  DEFAULT_NO_ADVICE = False
@@ -443,19 +446,26 @@ class OpsPerformanceReportQueries:
443
446
  DEFAULT_NO_STACK_BY_IN0 = True
444
447
 
445
448
  @classmethod
446
- def generate_report(cls, instance):
449
+ def generate_report(cls, instance, **kwargs):
447
450
  raw_csv = OpsPerformanceQueries.get_raw_csv(instance)
448
451
  csv_file = StringIO(raw_csv)
449
452
  csv_output_file = tempfile.mktemp(suffix=".csv")
450
453
  csv_stacked_output_file = tempfile.mktemp(suffix=".csv")
454
+ signpost = kwargs.get("signpost", cls.DEFAULT_SIGNPOST)
455
+ ignore_signposts = cls.DEFAULT_IGNORE_SIGNPOSTS
456
+ stack_by_in0 = kwargs.get("stack_by_in0", cls.DEFAULT_NO_STACK_BY_IN0)
457
+
458
+ if signpost:
459
+ ignore_signposts = False
460
+
451
461
  # perf_report currently generates a PNG alongside the CSV using the same temp name - we'll just delete it afterwards
452
462
  stacked_png_file = os.path.splitext(csv_output_file)[0] + ".png"
453
463
 
454
464
  try:
455
465
  perf_report.generate_perf_report(
456
466
  csv_file,
457
- cls.DEFAULT_SIGNPOST,
458
- cls.DEFAULT_IGNORE_SIGNPOSTS,
467
+ signpost,
468
+ ignore_signposts,
459
469
  cls.DEFAULT_MIN_PERCENTAGE,
460
470
  cls.DEFAULT_ID_RANGE,
461
471
  csv_output_file,
@@ -464,10 +474,11 @@ class OpsPerformanceReportQueries:
464
474
  cls.DEFAULT_RAW_OP_CODES,
465
475
  cls.DEFAULT_NO_HOST_OPS,
466
476
  cls.DEFAULT_NO_STACKED_REPORT,
467
- cls.DEFAULT_NO_STACK_BY_IN0,
477
+ stack_by_in0,
468
478
  csv_stacked_output_file,
469
479
  )
470
480
  except Exception as e:
481
+ logger.error(f"Error generating performance report: {e}")
471
482
  raise DataFormatError(f"Error generating performance report: {e}") from e
472
483
 
473
484
  ops_perf_results = []
@@ -476,56 +487,89 @@ class OpsPerformanceReportQueries:
476
487
  for row in ops_perf_results_reader:
477
488
  ops_perf_results.append(row)
478
489
 
490
+ # Returns a list of unique signposts in the order they appear
491
+ # TODO: Signpost names are not unique but tt-perf-report treats them as such
492
+ captured_signposts = set()
493
+ signposts = []
494
+ for index, row in enumerate(ops_perf_results):
495
+ if row.get("OP TYPE") == "signpost":
496
+ op_code = row["OP CODE"]
497
+ op_id = index + 2 # Match IDs with row numbers in ops perf results csv
498
+ if not any(s["op_code"] == op_code for s in signposts):
499
+ captured_signposts.add(op_code)
500
+ signposts.append({"id": op_id, "op_code": op_code})
501
+
479
502
  report = []
480
503
 
481
- try:
482
- with open(csv_output_file, newline="") as csvfile:
483
- reader = csv.reader(csvfile, delimiter=",")
484
- next(reader, None)
485
- for row in reader:
486
- processed_row = {
487
- column: row[index]
488
- for index, column in enumerate(cls.REPORT_COLUMNS)
489
- if index < len(row)
490
- }
491
- if "advice" in processed_row and processed_row["advice"]:
492
- processed_row["advice"] = processed_row["advice"].split(" • ")
493
- else:
494
- processed_row["advice"] = []
495
-
496
- for key, value in cls.PASSTHROUGH_COLUMNS.items():
497
- op_id = int(row[0])
498
- idx = (
499
- op_id - 2
500
- ) # IDs in result column one correspond to row numbers in ops perf results csv
501
- processed_row[key] = ops_perf_results[idx][value]
502
-
503
- report.append(processed_row)
504
- except csv.Error as e:
505
- raise DataFormatError() from e
506
- finally:
507
- os.unlink(csv_output_file)
504
+ if os.path.exists(csv_output_file):
505
+ try:
506
+ with open(csv_output_file, newline="") as csvfile:
507
+ reader = csv.reader(csvfile, delimiter=",")
508
+ next(reader, None)
509
+ for row in reader:
510
+ processed_row = {
511
+ column: row[index]
512
+ for index, column in enumerate(cls.REPORT_COLUMNS)
513
+ if index < len(row)
514
+ }
515
+ if "advice" in processed_row and processed_row["advice"]:
516
+ processed_row["advice"] = processed_row["advice"].split(
517
+ " "
518
+ )
519
+ else:
520
+ processed_row["advice"] = []
521
+
522
+ # Get the op type from the raw file for this row as it is not returned from tt-perf-report
523
+ op_id = int(row[0])
524
+ raw_idx = op_id - 2
525
+ if 0 <= raw_idx < len(ops_perf_results):
526
+ processed_row["op_type"] = ops_perf_results[
527
+ raw_idx
528
+ ].get("OP TYPE")
529
+ else:
530
+ processed_row["op_type"] = None
531
+
532
+ report.append(processed_row)
533
+ except csv.Error as e:
534
+ raise DataFormatError() from e
535
+ finally:
536
+ os.unlink(csv_output_file)
508
537
 
509
538
  stacked_report = []
510
539
 
511
- try:
512
- with open(csv_stacked_output_file, newline="") as csvfile:
513
- reader = csv.reader(csvfile, delimiter=",")
514
- next(reader, None)
515
-
516
- for row in reader:
517
- processed_row = {
518
- column: row[index]
519
- for index, column in enumerate(cls.STACKED_REPORT_COLUMNS)
520
- if index < len(row)
521
- }
540
+ if os.path.exists(csv_stacked_output_file):
541
+ try:
542
+ with open(csv_stacked_output_file, newline="") as csvfile:
543
+ reader = csv.reader(csvfile, delimiter=",")
544
+ next(reader, None)
545
+
546
+ for row in reader:
547
+ processed_row = {
548
+ column: row[index]
549
+ for index, column in enumerate(cls.STACKED_REPORT_COLUMNS)
550
+ if index < len(row)
551
+ }
552
+
553
+ if "op_code" in processed_row and any(
554
+ processed_row["op_code"] in signpost["op_code"]
555
+ for signpost in signposts
556
+ ):
557
+ processed_row["op_type"] = "signpost"
558
+ else:
559
+ processed_row["op_type"] = "unknown"
560
+
561
+ stacked_report.append(processed_row)
562
+ except csv.Error as e:
563
+ raise DataFormatError() from e
564
+ finally:
565
+ os.unlink(csv_stacked_output_file)
566
+ if os.path.exists(stacked_png_file):
567
+ os.unlink(stacked_png_file)
522
568
 
523
569
  stacked_report.append(processed_row)
524
- except csv.Error as e:
525
- raise DataFormatError() from e
526
- finally:
527
- os.unlink(csv_stacked_output_file)
528
- if os.path.exists(stacked_png_file):
529
- os.unlink(stacked_png_file)
530
-
531
- return {"report": report, "stacked_report": stacked_report}
570
+
571
+ return {
572
+ "report": report,
573
+ "stacked_report": stacked_report,
574
+ "signposts": signposts,
575
+ }
@@ -1 +1 @@
1
- import{I as s}from"./index-CnPrfHYh.js";import{I as r}from"./index-Cnc1EkDo.js";import{p as n,I as c}from"./index-ASyuPW18.js";function p(t,a){const o=n(t);return a===c.STANDARD?s[o]:r[o]}export{s as IconSvgPaths16,r as IconSvgPaths20,p as getIconPaths};
1
+ import{I as s}from"./index-CnPrfHYh.js";import{I as r}from"./index-Cnc1EkDo.js";import{p as n,I as c}from"./index-BvcHTS9m.js";function p(t,a){const o=n(t);return a===c.STANDARD?s[o]:r[o]}export{s as IconSvgPaths16,r as IconSvgPaths20,p as getIconPaths};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/allPaths-BmK4MbG-.js","assets/index-CnPrfHYh.js","assets/index-Cnc1EkDo.js","assets/index-BvcHTS9m.js","assets/index-BLaRkCu7.css"])))=>i.map(i=>d[i]);
2
+ import{_ as e}from"./index-BvcHTS9m.js";const s=async(t,a)=>{const{getIconPaths:o}=await e(async()=>{const{getIconPaths:r}=await import("./allPaths-BmK4MbG-.js");return{getIconPaths:r}},__vite__mapDeps([0,1,2,3,4]));return o(t,a)};export{s as allPathsLoader};