14 | Note: Showing active memory allocations at peak usage within the profiling window. To avoid
15 | sluggishness, only the allocations with size over 1MiB are shown in the table below.
16 |
6 |
--------------------------------------------------------------------------------
/frontend/app/components/roofline_model/program_level_analysis/program_level_analysis.scss:
--------------------------------------------------------------------------------
1 | .row {
2 | display: flex;
3 | }
4 |
--------------------------------------------------------------------------------
/frontend/app/components/roofline_model/program_level_analysis/program_level_analysis_module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {ChartModule} from 'org_xprof/frontend/app/components/chart/chart';
3 | import {TableModule} from 'org_xprof/frontend/app/components/chart/table/table_module';
4 | import {CategoryFilterModule} from 'org_xprof/frontend/app/components/controls/category_filter/category_filter_module';
5 |
6 | import {ProgramLevelAnalysis} from './program_level_analysis';
7 |
8 | @NgModule({
9 | declarations: [ProgramLevelAnalysis],
10 | imports: [CategoryFilterModule, TableModule, ChartModule],
11 | exports: [ProgramLevelAnalysis],
12 | })
13 | export class ProgramLevelAnalysisModule {}
14 |
--------------------------------------------------------------------------------
/frontend/app/components/roofline_model/roofline_model.scss:
--------------------------------------------------------------------------------
1 | .section-container {
2 | margin: 20px 20px 0px;
3 | }
4 |
5 | .block-content {
6 | padding: 5px;
7 | }
8 |
9 | .row {
10 | display: flex;
11 | }
12 |
13 | .flex-space {
14 | flex: 1;
15 | }
16 |
17 | .description {
18 | font-size: 14px;
19 | }
20 |
21 | .tableHeaderCell {
22 | word-wrap: break-word;
23 | background-color: azure; //!to hide the scrolled-up text.
24 | }
25 |
26 | .tableTableCell {
27 | word-break: break-all;
28 | }
29 |
30 | .opColumnClass {
31 | max-height: 200px;
32 | overflow-y: auto;
33 | }
34 |
35 | .errorMessage {
36 | border: 2px solid;
37 | background-color: #ffcccb;
38 | color: red;
39 | }
40 |
--------------------------------------------------------------------------------
/frontend/app/components/sidenav/sidenav.scss:
--------------------------------------------------------------------------------
1 | /** CSS for a side navigation component. */
2 |
3 | @import 'frontend/app/styles/common';
4 |
5 | .button-container {
6 | padding: 20px;
7 | }
8 |
9 | .item-container {
10 | padding: 20px 20px 0 20px;
11 | }
12 |
13 | .mat-subheading-2 {
14 | margin-bottom: 0;
15 | }
16 |
--------------------------------------------------------------------------------
/frontend/app/components/sidenav/sidenav_module.ts:
--------------------------------------------------------------------------------
1 | import {CommonModule} from '@angular/common';
2 | import {NgModule} from '@angular/core';
3 | import {MatOptionModule} from '@angular/material/core';
4 | import {MatFormFieldModule} from '@angular/material/form-field';
5 | import {MatSelectModule} from '@angular/material/select';
6 | import {CaptureProfileModule} from 'org_xprof/frontend/app/components/capture_profile/capture_profile_module';
7 | import {BufferDetailsModule} from 'org_xprof/frontend/app/components/memory_viewer/buffer_details/buffer_details_module';
8 | import {OpDetailsModule} from 'org_xprof/frontend/app/components/op_profile/op_details/op_details_module';
9 | import {PodViewerDetailsModule} from 'org_xprof/frontend/app/components/pod_viewer/pod_viewer_details/pod_viewer_details_module';
10 |
11 | import {SideNav} from './sidenav';
12 |
13 | /** A side navigation module. */
14 | @NgModule({
15 | declarations: [SideNav],
16 | imports: [
17 | CommonModule,
18 | MatFormFieldModule,
19 | MatSelectModule,
20 | MatOptionModule,
21 | BufferDetailsModule,
22 | CaptureProfileModule,
23 | OpDetailsModule,
24 | PodViewerDetailsModule,
25 | ],
26 | exports: [SideNav]
27 | })
28 | export class SideNavModule {
29 | }
30 |
--------------------------------------------------------------------------------
/frontend/app/components/trace_viewer/BUILD:
--------------------------------------------------------------------------------
1 | load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
2 | load("//defs:defs.bzl", "xprof_ng_module")
3 |
4 | package(default_visibility = ["//frontend:internal"])
5 |
6 | xprof_ng_module(
7 | name = "trace_viewer",
8 | srcs = [
9 | "trace_viewer.ts",
10 | "trace_viewer_module.ts",
11 | ],
12 | assets = [
13 | ":trace_viewer_css",
14 | "trace_viewer.ng.html",
15 | ],
16 | deps = [
17 | "@npm//@angular/common",
18 | "@npm//@angular/core",
19 | "@npm//@angular/router",
20 | "@npm//rxjs",
21 | "@org_xprof//frontend/app/common/angular:angular_common_http",
22 | "@org_xprof//frontend/app/common/constants",
23 | "@org_xprof//frontend/app/common/interfaces",
24 | "@org_xprof//frontend/app/pipes",
25 | "@org_xprof//frontend/app/services/communication_service",
26 | ],
27 | )
28 |
29 | sass_binary(
30 | name = "trace_viewer_css",
31 | src = "trace_viewer.scss",
32 | # stack = False,
33 | sourcemap = False,
34 | )
35 |
--------------------------------------------------------------------------------
/frontend/app/components/trace_viewer/trace_viewer.ng.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/frontend/app/components/trace_viewer/trace_viewer.scss:
--------------------------------------------------------------------------------
1 | /** CSS for a trace viewer component. */
2 |
3 | iframe {
4 | position: absolute;
5 | width: 100%;
6 | height: 100%;
7 | box-sizing: border-box;
8 | border-style: unset;
9 | }
10 |
--------------------------------------------------------------------------------
/frontend/app/components/trace_viewer/trace_viewer_module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {PipesModule} from 'org_xprof/frontend/app/pipes/pipes_module';
3 |
4 | import {TraceViewer} from './trace_viewer';
5 |
6 | /** A trace viewer module. */
7 | @NgModule({
8 | declarations: [TraceViewer],
9 | imports: [PipesModule],
10 | exports: [TraceViewer]
11 | })
12 | export class TraceViewerModule {
13 | }
14 |
--------------------------------------------------------------------------------
/frontend/app/pipes/BUILD:
--------------------------------------------------------------------------------
1 | load("//defs:defs.bzl", "xprof_ng_module")
2 |
3 | package(default_visibility = ["//frontend:internal"])
4 |
5 | xprof_ng_module(
6 | name = "pipes",
7 | srcs = [
8 | "pipes_module.ts",
9 | "safe_pipe.ts",
10 | ],
11 | deps = [
12 | "@npm//@angular/common",
13 | "@npm//@angular/core",
14 | "@npm//@angular/platform-browser",
15 | ],
16 | )
17 |
--------------------------------------------------------------------------------
/frontend/app/pipes/pipes_module.ts:
--------------------------------------------------------------------------------
1 | import {CommonModule} from '@angular/common'
2 | import {NgModule} from '@angular/core';
3 | import {SafePipe} from './safe_pipe';
4 |
5 | @NgModule(
6 | {imports: [CommonModule], declarations: [SafePipe], exports: [SafePipe]})
7 | export class PipesModule {
8 | }
9 |
--------------------------------------------------------------------------------
/frontend/app/pipes/safe_pipe.ts:
--------------------------------------------------------------------------------
1 | import {Pipe, PipeTransform} from '@angular/core';
2 | import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser';
3 |
4 | @Pipe({name: 'safe'})
5 | export class SafePipe implements PipeTransform {
6 | constructor(private readonly sanitizer: DomSanitizer) {}
7 |
8 | transform(url: any): SafeResourceUrl {
9 | return this.sanitizer.bypassSecurityTrustResourceUrl(url);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/app/services/communication_service/BUILD:
--------------------------------------------------------------------------------
1 | load("//defs:defs.bzl", "xprof_ng_module")
2 |
3 | package(default_visibility = ["//frontend:internal"])
4 |
5 | xprof_ng_module(
6 | name = "communication_service",
7 | srcs = [
8 | "communication_service.ts",
9 | ],
10 | deps = [
11 | "@npm//@angular/core",
12 | "@org_xprof//frontend/app/common/interfaces",
13 | ],
14 | )
15 |
--------------------------------------------------------------------------------
/frontend/app/services/communication_service/communication_service.ts:
--------------------------------------------------------------------------------
1 | import {EventEmitter, Injectable, Output} from '@angular/core';
2 | import {NavigationEvent} from 'org_xprof/frontend/app/common/interfaces/navigation_event';
3 |
4 | /**
5 | * The query parameter object for route navigation excluding run, tag, host
6 | * for example, opName for Graph Viewer
7 | */
8 | export type ToolQueryParams = NavigationEvent;
9 |
10 | /**
11 | * (OSS) The communication service class that emits events across components
12 | * Provide the service dependency at the application root level for angular to
13 | * create a shared instance of this service - Needed for unit tests to run
14 | */
15 | @Injectable({providedIn: 'root'})
16 | export class CommunicationService {
17 | @Output() readonly navigationReady = new EventEmitter();
18 | @Output() readonly toolQueryParamsChange = new EventEmitter();
19 |
20 | // Show a navigating status when populating navigation chains
21 | // eg. tools for selected run
22 | onNavigateReady(navigationEvent: NavigationEvent) {
23 | this.navigationReady.emit(navigationEvent);
24 | }
25 |
26 | onToolQueryParamsChange(queryParams: ToolQueryParams) {
27 | this.toolQueryParamsChange.emit(queryParams);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/frontend/app/services/data_service/BUILD:
--------------------------------------------------------------------------------
1 | load("@npm//@bazel/concatjs:index.bzl", "ts_library")
2 | load("//defs:defs.bzl", "xprof_ng_module")
3 |
4 | package(default_visibility = ["//frontend:internal"])
5 |
6 | xprof_ng_module(
7 | name = "data_service",
8 | srcs = [
9 | "data_service.ts",
10 | ],
11 | deps = [
12 | ":mock_data",
13 | "@npm//@angular/common",
14 | "@npm//@angular/core",
15 | "@npm//@ngrx/store",
16 | "@npm//rxjs",
17 | "@org_xprof//frontend/app/common/angular:angular_common_http",
18 | "@org_xprof//frontend/app/common/constants",
19 | "@org_xprof//frontend/app/common/interfaces",
20 | "@org_xprof//frontend/app/store",
21 | ],
22 | )
23 |
24 | ts_library(
25 | name = "mock_data",
26 | srcs = [
27 | "mock_data.ts",
28 | ],
29 | )
30 |
--------------------------------------------------------------------------------
/frontend/app/store/BUILD:
--------------------------------------------------------------------------------
1 | load("@npm//@bazel/concatjs:index.bzl", "ts_library")
2 | load("//defs:defs.bzl", "xprof_ng_module")
3 |
4 | package(default_visibility = ["//frontend:internal"])
5 |
6 | xprof_ng_module(
7 | name = "store",
8 | srcs = [
9 | "actions.ts",
10 | "reducers.ts",
11 | "selectors.ts",
12 | "state.ts",
13 | "store_module.ts",
14 | ],
15 | deps = [
16 | ":types",
17 | "@npm//@angular/core",
18 | "@npm//@ngrx/store",
19 | "@npm//rxjs",
20 | "@org_xprof//frontend/app/common/constants",
21 | "@org_xprof//frontend/app/common/interfaces",
22 | "@org_xprof//frontend/app/common/interfaces:op_profile_proto_defs",
23 | "@org_xprof//frontend/app/store/common_data_store",
24 | "@org_xprof//frontend/app/store/framework_op_stats",
25 | ],
26 | )
27 |
28 | ts_library(
29 | name = "types",
30 | srcs = [
31 | "types.ts",
32 | ],
33 | deps = [
34 | "@npm//@ngrx/store",
35 | ],
36 | )
37 |
--------------------------------------------------------------------------------
/frontend/app/store/common_data_store/BUILD:
--------------------------------------------------------------------------------
1 | load("//defs:defs.bzl", "xprof_ng_module")
2 |
3 | package(default_visibility = ["//frontend:internal"])
4 |
5 | xprof_ng_module(
6 | name = "common_data_store",
7 | srcs = [
8 | "actions.ts",
9 | "reducers.ts",
10 | "selectors.ts",
11 | "state.ts",
12 | ],
13 | deps = [
14 | "@npm//@angular/core",
15 | "@npm//@ngrx/store",
16 | "@npm//rxjs",
17 | "@org_xprof//frontend/app/common/interfaces",
18 | "@org_xprof//frontend/app/store:types",
19 | ],
20 | )
21 |
--------------------------------------------------------------------------------
/frontend/app/store/common_data_store/actions.ts:
--------------------------------------------------------------------------------
1 | import {createAction, props} from '@ngrx/store';
2 | import {SimpleDataTable} from 'org_xprof/frontend/app/common/interfaces/data_table';
3 | import {ActionCreatorAny} from 'org_xprof/frontend/app/store/types';
4 |
5 | /** Action to set kernel stats data property */
6 | export const setKernelStatsDataAction: ActionCreatorAny = createAction(
7 | '[Kernel Stats] Set data property',
8 | props<{kernelStatsData: SimpleDataTable | null}>(),
9 | );
10 |
--------------------------------------------------------------------------------
/frontend/app/store/common_data_store/reducers.ts:
--------------------------------------------------------------------------------
1 | import {Action, ActionReducer, createReducer, on} from '@ngrx/store';
2 | import {ActionCreatorAny} from 'org_xprof/frontend/app/store/types';
3 |
4 | import * as actions from './actions';
5 | import {CommonDataStoreState, INIT_COMMON_DATA_STORE_STATE} from './state';
6 |
7 | /** Reduce functions of common data store. */
8 | export const reducer: ActionReducer =
9 | createReducer(
10 | INIT_COMMON_DATA_STORE_STATE,
11 | on(
12 | actions.setKernelStatsDataAction,
13 | (state: CommonDataStoreState, action: ActionCreatorAny) => {
14 | return {
15 | ...state,
16 | kernelStatsData: action.kernelStatsData,
17 | };
18 | },
19 | ),
20 | );
21 |
22 | /** Common Data Store reducer */
23 | export function commonDataStoreReducer(
24 | state: CommonDataStoreState|undefined, action: Action) {
25 | return reducer(state, action);
26 | }
27 |
--------------------------------------------------------------------------------
/frontend/app/store/common_data_store/selectors.ts:
--------------------------------------------------------------------------------
1 | import {createFeatureSelector, createSelector} from '@ngrx/store';
2 | import {MemoizedSelectorAny} from 'org_xprof/frontend/app/store/types';
3 |
4 | import {COMMON_DATA_STORE_KEY, CommonDataStoreState} from './state';
5 |
6 | const commonDataStoreState =
7 | createFeatureSelector(COMMON_DATA_STORE_KEY);
8 |
9 | /** Selector for kernel stats data property */
10 | export const getKernelStatsDataState: MemoizedSelectorAny = createSelector(
11 | commonDataStoreState,
12 | (commonDataStoreState: CommonDataStoreState) =>
13 | commonDataStoreState.kernelStatsData);
14 |
--------------------------------------------------------------------------------
/frontend/app/store/common_data_store/state.ts:
--------------------------------------------------------------------------------
1 | import {SimpleDataTable} from 'org_xprof/frontend/app/common/interfaces/data_table';
2 |
3 | /** State of common data store */
4 | export interface CommonDataStoreState {
5 | kernelStatsData: SimpleDataTable|null;
6 | }
7 |
8 | /** Initial state object */
9 | export const INIT_COMMON_DATA_STORE_STATE: CommonDataStoreState = {
10 | kernelStatsData: null,
11 | };
12 |
13 | /** Feature key for store */
14 | export const COMMON_DATA_STORE_KEY = 'common_data_store';
15 |
--------------------------------------------------------------------------------
/frontend/app/store/framework_op_stats/BUILD:
--------------------------------------------------------------------------------
1 | load("//defs:defs.bzl", "xprof_ng_module")
2 |
3 | package(default_visibility = ["//frontend:internal"])
4 |
5 | xprof_ng_module(
6 | name = "framework_op_stats",
7 | srcs = [
8 | "actions.ts",
9 | "reducers.ts",
10 | "selectors.ts",
11 | "state.ts",
12 | ],
13 | deps = [
14 | "@npm//@angular/core",
15 | "@npm//@ngrx/store",
16 | "@npm//rxjs",
17 | "@org_xprof//frontend/app/common/interfaces",
18 | "@org_xprof//frontend/app/store:types",
19 | ],
20 | )
21 |
--------------------------------------------------------------------------------
/frontend/app/store/framework_op_stats/state.ts:
--------------------------------------------------------------------------------
1 | import {FrameworkOpStatsData} from 'org_xprof/frontend/app/common/interfaces/data_table';
2 |
3 | /** State of tensorflow stats */
4 | export interface FrameworkOpStatsState {
5 | data: FrameworkOpStatsData[];
6 | diffData: FrameworkOpStatsData[];
7 | hasDiff: boolean;
8 | showPprofLink: boolean;
9 | showFlopRateChart: boolean;
10 | showModelProperties: boolean;
11 | title: string;
12 | }
13 |
14 | /** Initial state object */
15 | export const INIT_FRAMEWORK_OP_STATS_STATE: FrameworkOpStatsState = {
16 | data: [],
17 | diffData: [],
18 | hasDiff: false,
19 | showPprofLink: false,
20 | showFlopRateChart: false,
21 | showModelProperties: false,
22 | title: '',
23 | };
24 |
25 | /** Feature key for store */
26 | export const FRAMEWORK_OP_STATS_STORE_KEY = 'framework_op_stats';
27 |
--------------------------------------------------------------------------------
/frontend/app/store/store_module.ts:
--------------------------------------------------------------------------------
1 | import {NgModule} from '@angular/core';
2 | import {StoreModule} from '@ngrx/store';
3 | import {commonDataStoreReducer} from 'org_xprof/frontend/app/store/common_data_store/reducers';
4 | import {COMMON_DATA_STORE_KEY} from 'org_xprof/frontend/app/store/common_data_store/state';
5 | import {frameworkOpStatsReducer} from 'org_xprof/frontend/app/store/framework_op_stats/reducers';
6 | import {FRAMEWORK_OP_STATS_STORE_KEY} from 'org_xprof/frontend/app/store/framework_op_stats/state';
7 |
8 | import {rootReducer} from './reducers';
9 | import {STORE_KEY} from './state';
10 |
11 | @NgModule({
12 | imports: [
13 | StoreModule.forFeature(STORE_KEY, rootReducer),
14 | StoreModule.forFeature(COMMON_DATA_STORE_KEY, commonDataStoreReducer),
15 | StoreModule.forFeature(
16 | FRAMEWORK_OP_STATS_STORE_KEY, frameworkOpStatsReducer),
17 | StoreModule.forRoot({}),
18 | ],
19 | })
20 | export class RootStoreModule {
21 | }
22 |
--------------------------------------------------------------------------------
/frontend/app/store/types.ts:
--------------------------------------------------------------------------------
1 | import {ActionCreator, MemoizedSelector} from '@ngrx/store';
2 |
3 | /** Action type. */
4 | // tslint:disable-next-line:no-any
5 | export type ActionCreatorAny = ActionCreator;
6 |
7 | /** Selector type. */
8 | // tslint:disable-next-line:no-any
9 | export type MemoizedSelectorAny = MemoizedSelector;
10 |
--------------------------------------------------------------------------------
/frontend/app/styles/BUILD:
--------------------------------------------------------------------------------
1 | load("@io_bazel_rules_sass//:defs.bzl", "sass_library")
2 |
3 | package(default_visibility = ["//frontend:internal"])
4 |
5 | sass_library(
6 | name = "common",
7 | srcs = ["common.scss"],
8 | )
9 |
--------------------------------------------------------------------------------
/frontend/main.ts:
--------------------------------------------------------------------------------
1 | // Angular 9+ using Ivy apps that potentially do i18n, even transitively, must
2 | // import this module, which adds a global symbol at runtime.
3 | // https://angular.io/guide/migration-localize
4 | import '@angular/localize/init';
5 | import {enableProdMode} from '@angular/core';
6 | import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
7 |
8 | import {AppModule} from './app/app_module';
9 |
10 | enableProdMode();
11 |
12 | platformBrowserDynamic().bootstrapModule(AppModule)
13 | .catch(err => console.error(err));
14 |
--------------------------------------------------------------------------------
/frontend/server.py:
--------------------------------------------------------------------------------
1 | """SimpleHTTPServer with IPv6 suport to run on TAP which will be IPV6 only.
2 |
3 | Also provides /healthz support so that test can wait for the server to start.
4 | """
5 |
6 | from __future__ import print_function
7 |
8 | import http.server
9 | import os
10 | import socketserver
11 |
12 | PORT = 4200
13 |
14 | Handler = http.server.SimpleHTTPRequestHandler
15 |
16 | with socketserver.TCPServer(("", PORT), Handler) as httpd:
17 | os.chdir(os.getcwd() + "/frontend")
18 | print("Listening on port %s" % PORT)
19 | httpd.serve_forever()
20 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Entry point for the TensorBoard plugin package for performance profiling.
16 |
17 | Public submodules:
18 | summary: Summary-writing ops.
19 | Private submodules:
20 | metadata: Global constants and the like.
21 | plugin: TensorBoard backend plugin.
22 | """
23 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/build_utils/BUILD:
--------------------------------------------------------------------------------
1 | load("//tools/build_defs/testing:bzl_library.bzl", "bzl_library")
2 |
3 | visibility = ["//plugin:internal"]
4 |
5 | package(
6 | default_visibility = visibility,
7 | licenses = ["notice"], # Apache 2.0
8 | )
9 |
10 | bzl_library(
11 | name = "strict_default_bzl",
12 | srcs = ["strict.default.bzl"],
13 | parse_tests = False,
14 | visibility = ["//visibility:private"],
15 | )
16 |
17 | bzl_library(
18 | name = "pytype_default_bzl",
19 | srcs = ["pytype.default.bzl"],
20 | parse_tests = False,
21 | visibility = ["//visibility:private"],
22 | )
23 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/build_utils/profiler_test.bzl:
--------------------------------------------------------------------------------
1 | """Module defining test target to run on multiple platforms"""
2 |
3 | def profiler_test(name, **kwargs):
4 | kwargs.pop("platforms")
5 | native.py_test(name = name, **kwargs)
6 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/build_utils/pytype.default.bzl:
--------------------------------------------------------------------------------
1 | """Default (OSS) build versions of Python pytype rules."""
2 |
3 | # Placeholder to use until bazel supports pytype_library.
4 | def pytype_library(name, **kwargs):
5 | native.py_library(name = name, **kwargs)
6 |
7 | # Placeholder to use until bazel supports pytype_strict_binary.
8 | def pytype_strict_binary(name, **kwargs):
9 | native.py_binary(name = name, **kwargs)
10 |
11 | # Placeholder to use until bazel supports pytype_strict_library.
12 | def pytype_strict_library(name, **kwargs):
13 | native.py_library(name = name, **kwargs)
14 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/build_utils/strict.default.bzl:
--------------------------------------------------------------------------------
1 | """Default (OSS) build versions of Python strict rules."""
2 |
3 | # Placeholder to use until bazel supports py_strict_binary.
4 | def py_strict_binary(name, **kwargs):
5 | native.py_binary(name = name, **kwargs)
6 |
7 | # Placeholder to use until bazel supports py_strict_library.
8 | def py_strict_library(name, **kwargs):
9 | native.py_library(name = name, **kwargs)
10 |
11 | # Placeholder to use until bazel supports py_strict_test.
12 | def py_strict_test(name, **kwargs):
13 | native.py_test(name = name, **kwargs)
14 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/convert/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Converter from protobuf to gviz/json format."""
16 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/demo/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Demos for TensorBoard profile plugin."""
16 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/demo/data/profile_demo.input_pipeline.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/plugin/tensorboard_plugin_profile/demo/data/profile_demo.input_pipeline.pb
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/demo/data/profile_demo.overview_page.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/plugin/tensorboard_plugin_profile/demo/data/profile_demo.overview_page.pb
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/demo/data/profile_demo.tensorflow_stats.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/plugin/tensorboard_plugin_profile/demo/data/profile_demo.tensorflow_stats.pb
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/integration_tests/BUILD:
--------------------------------------------------------------------------------
1 | load("//plugin/tensorboard_plugin_profile/build_utils:pytype.default.bzl", "pytype_strict_library")
2 |
3 | visibility = ["//plugin:internal"]
4 |
5 | package(
6 | default_visibility = visibility,
7 | licenses = ["notice"], # Apache 2.0
8 | )
9 |
10 | pytype_strict_library(
11 | name = "tf_mnist",
12 | srcs = ["tf_mnist.py"],
13 | visibility = visibility,
14 | deps = [],
15 | )
16 |
17 | pytype_strict_library(
18 | name = "tf_profiler_session",
19 | srcs = ["tf_profiler_session.py"],
20 | visibility = visibility,
21 | deps = [],
22 | )
23 |
24 | filegroup(
25 | name = "resources",
26 | srcs = [
27 | "__init__.py",
28 | ],
29 | )
30 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/integration_tests/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Integration tests for TensorBoard profile plugin."""
16 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/integration_tests/tpu/tensorflow/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Integration tests for Tensorflow on Cloud TPU."""
16 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Protobufs used by TensorBoard profile plugin."""
16 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/diagnostics.proto:
--------------------------------------------------------------------------------
1 | // This proto describes the diagnostics for debugging profiling issues of
2 | // the TensorFlow profiler.
3 | syntax = "proto3";
4 |
5 | package tensorflow.profiler;
6 |
7 | message Diagnostics {
8 | repeated string info = 1;
9 | repeated string warnings = 2;
10 | repeated string errors = 3;
11 | }
12 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/hardware_types.proto:
--------------------------------------------------------------------------------
1 | // This proto describes the types of hardware profiled by the TensorFlow
2 | // profiler.
3 | syntax = "proto3";
4 |
5 | package tensorflow.profiler;
6 |
7 | // Types of hardware profiled.
8 | enum HardwareType {
9 | // Unknown hardware.
10 | UNKNOWN_HARDWARE = 0;
11 | // CPU only without any hardware accelerator.
12 | CPU_ONLY = 1;
13 | // GPU.
14 | GPU = 2;
15 | // TPU.
16 | TPU = 3;
17 | }
18 |
19 | message GPUComputeCapability {
20 | uint32 major = 1;
21 | uint32 minor = 2;
22 | }
23 |
24 | message DeviceCapabilities {
25 | double clock_rate_in_ghz = 1;
26 | uint32 num_cores = 2;
27 | uint64 memory_size_in_bytes = 3;
28 | uint64 memory_bandwidth = 4; // Bytes/s.
29 | GPUComputeCapability compute_capability = 5;
30 | string device_vendor = 6;
31 | }
32 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/kernel_stats.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package tensorflow.profiler;
4 |
5 | // Next ID: 15
6 | message KernelReport {
7 | // Name of the kernel.
8 | string name = 1;
9 | // Registers per thread.
10 | uint32 registers_per_thread = 2;
11 | // Static shared memory in bytes.
12 | uint32 static_shmem_bytes = 3;
13 | // Dynamic shared memory in bytes.
14 | uint32 dynamic_shmem_bytes = 4;
15 | // Block dimensions.
16 | repeated uint32 block_dim = 5;
17 | // Grid dimensions.
18 | repeated uint32 grid_dim = 6;
19 | // Total duration of this kernel.
20 | uint64 total_duration_ns = 7;
21 | // Min duration of kernel in nanoseconds.
22 | uint64 min_duration_ns = 8;
23 | // Max duration of kernel in nanoseconds.
24 | uint64 max_duration_ns = 9;
25 | // Kernel utilizes TensorCore instructions.
26 | bool is_kernel_using_tensor_core = 10;
27 | // Operation is eligible to use TensorCores.
28 | bool is_op_tensor_core_eligible = 11;
29 | // TF operation name.
30 | string op_name = 12;
31 | // Number of occurrences.
32 | uint32 occurrences = 13;
33 | // Occupancy pct.
34 | float occupancy_pct = 14;
35 | }
36 |
37 | message KernelStatsDb {
38 | // A list of kernels aggregated by name.
39 | repeated KernelReport reports = 1;
40 | }
41 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/power_metrics.proto:
--------------------------------------------------------------------------------
1 | // LINT: LEGACY_NAMES
2 |
3 | syntax = "proto3";
4 |
5 | package tensorflow.profiler;
6 |
7 | message PowerComponentMetrics {
8 | // power rail or component name, e.g. HBM, Core.
9 | string component_name = 1;
10 | // maximum watts monitored.
11 | double max_power = 2;
12 | // average watts monitored.
13 | double avg_power = 3;
14 | // (SPI sampler only) maximum watts of moving average power over a time window
15 | // of 100us.
16 | double max_moving_avg_power_100us = 4;
17 | // (SPI sampler only) maximum watts of moving average power over a time window
18 | // of 1ms.
19 | double max_moving_avg_power_1ms = 5;
20 | // (SPI sampler only) maximum watts of moving average power over a time window
21 | // of 10ms.
22 | double max_moving_avg_power_10ms = 6;
23 | // (FW only) The timescale in us to compute moving averages.
24 | uint32 timescale_us = 7;
25 | // The number of samples.
26 | uint64 sample_count = 8;
27 | // (SPI sampler only) maximum watts of moving average power over a time window
28 | // of 1s.
29 | double max_moving_avg_power_1s = 9;
30 | }
31 |
32 | message PowerMetrics {
33 | repeated PowerComponentMetrics power_component_metrics = 1;
34 | }
35 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/source_info.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package tensorflow.profiler;
4 |
5 | message SourceInfo {
6 | string file_name = 1;
7 |
8 | int32 line_number = 2; // could be `-1`
9 |
10 | string stack_frame = 3; // One stack frame per line.
11 | }
12 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/protobuf/tfstreamz.proto:
--------------------------------------------------------------------------------
1 | // This proto describes the format of the output profile file from
2 | // the TF-stats tool.
3 | syntax = "proto3";
4 |
5 | package tensorflow.profiler.tfstreamz;
6 |
7 | // A proxy proto to serialize tensorflow::monitoring::Percentiles
8 |
9 | enum UnitOfMeasure {
10 | NUMBER = 0;
11 | TIME = 1;
12 | BYTES = 2;
13 | }
14 |
15 | message PercentilePoint {
16 | // In the [0, 100] range.
17 | double percentile = 1;
18 | double value = 2;
19 | }
20 |
21 | message Percentiles {
22 | UnitOfMeasure unit_of_measure = 1;
23 | uint64 start_nstime = 2;
24 | uint64 end_nstime = 3;
25 | double min_value = 4;
26 | double max_value = 5;
27 | double mean = 6;
28 | double stddev = 7;
29 | uint64 num_samples = 8;
30 | uint64 total_samples = 9;
31 | double accumulator = 10;
32 | repeated PercentilePoint points = 11;
33 | }
34 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/standalone/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Utilities for xprof to be used without TensorBoard.
16 |
17 | """
18 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/standalone/context.py:
--------------------------------------------------------------------------------
1 | # Copyright 2025 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """A standalone version of Tensorboard's context and utils."""
16 |
17 |
18 | class RequestContext:
19 | """Overload of tensorboard/context.py:RequestContext."""
20 |
21 | def __init__(self):
22 | pass
23 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/static/index.js:
--------------------------------------------------------------------------------
1 | export async function render() {
2 | document.location.href = 'index.html';
3 | }
4 |
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/static/materialicons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/plugin/tensorboard_plugin_profile/static/materialicons.woff2
--------------------------------------------------------------------------------
/plugin/tensorboard_plugin_profile/version.py:
--------------------------------------------------------------------------------
1 | # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Version information for tensorboard-plugin-profile."""
16 |
17 | __version__ = "2.19.9"
18 |
--------------------------------------------------------------------------------
/plugin/third_party/tracing/BUILD:
--------------------------------------------------------------------------------
1 | licenses(["notice"])
2 |
3 | genrule(
4 | name = "trace_viewer_full",
5 | srcs = ["trace_viewer_full.html.gz"],
6 | outs = ["trace_viewer_full.html"],
7 | cmd = "gzip -d -c $(SRCS) > $(OUTS)",
8 | visibility = [
9 | "//plugin:__subpackages__",
10 | ],
11 | )
12 |
13 | # Catapult Trace Viewer (chrome://tracing):
14 | # git clone https://chromium.googlesource.com/catapult
15 | # cd catapult
16 | # git checkout 0d1854ab10b0950252ac4346e867639cec0ab6d2
17 | # tracing/bin/vulcanize_trace_viewer
18 | # gzip tracing/bin/trace_viewer_full.html
19 | exports_files(["trace_viewer_full.html.gz"])
20 |
--------------------------------------------------------------------------------
/plugin/third_party/tracing/trace_viewer_full.html.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/plugin/third_party/tracing/trace_viewer_full.html.gz
--------------------------------------------------------------------------------
/plugin/third_party/webcomponentsjs/BUILD:
--------------------------------------------------------------------------------
1 | licenses(["notice"])
2 |
3 | filegroup(
4 | name = "webcomponentsjs",
5 | srcs = ["webcomponents.js"],
6 | visibility = ["//plugin:__subpackages__"],
7 | )
8 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/BUILD:
--------------------------------------------------------------------------------
1 | load("@org_tensorflow_tensorboard//tensorboard/defs:web.bzl", "tb_combine_html", "tf_web_library")
2 |
3 | package(default_visibility = ["//plugin:internal"])
4 |
5 | licenses(["notice"])
6 |
7 | tf_web_library(
8 | name = "trace_viewer",
9 | srcs = ["trace_viewer.html"],
10 | path = "/",
11 | deps = [
12 | "@npm//@polymer/polymer",
13 | "@org_xprof//plugin/trace_viewer/tf_trace_viewer",
14 | "@org_xprof//plugin/trace_viewer/webcomponentsjs_polyfill",
15 | ],
16 | )
17 |
18 | tb_combine_html(
19 | name = "trace_viewer_index",
20 | input_path = "/trace_viewer.html",
21 | js_path = "/trace_viewer_index.js",
22 | output_path = "/trace_viewer_index.html",
23 | deps = [":trace_viewer"],
24 | )
25 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/tf_trace_viewer/BUILD:
--------------------------------------------------------------------------------
1 | load("@org_tensorflow_tensorboard//tensorboard/defs:web.bzl", "tf_web_library")
2 |
3 | package(default_visibility = ["//plugin:internal"])
4 |
5 | licenses(["notice"])
6 |
7 | tf_web_library(
8 | name = "tf_trace_viewer",
9 | srcs = [
10 | "tf-trace-viewer.html",
11 | "@org_xprof//plugin/third_party/tracing:trace_viewer_full.html",
12 | ],
13 | path = "/tf-trace-viewer",
14 | deps = [
15 | ":tf-trace-viewer-helper",
16 | ],
17 | )
18 |
19 | tf_web_library(
20 | name = "demo",
21 | srcs = ["demo.html"],
22 | path = "/tf-trace-viewer",
23 | deps = [
24 | ":tf_trace_viewer",
25 | "@org_xprof//plugin/trace_viewer/tf_trace_viewer/data",
26 | ],
27 | )
28 |
29 | tf_web_library(
30 | name = "tf-trace-viewer-helper",
31 | srcs = [
32 | "tf-trace-viewer-helper.js",
33 | ],
34 | path = "/tf-trace-viewer",
35 | )
36 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/tf_trace_viewer/data/BUILD:
--------------------------------------------------------------------------------
1 | load("@io_bazel_rules_closure//closure:defs.bzl", "web_library")
2 |
3 | package(default_visibility = ["//plugin:internal"])
4 |
5 | licenses(["notice"])
6 |
7 | web_library(
8 | name = "data",
9 | srcs = glob(["*.json"]),
10 | path = "/tf-trace-viewer/data/plugin/profile",
11 | )
12 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/tf_trace_viewer/demo.html:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 | Trace Viewer Demo
21 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/webcomponentsjs_polyfill/BUILD:
--------------------------------------------------------------------------------
1 | load("@org_tensorflow_tensorboard//tensorboard/defs:web.bzl", "tf_web_library")
2 |
3 | package(default_visibility = ["//plugin:internal"])
4 |
5 | licenses(["notice"])
6 |
7 | tf_web_library(
8 | name = "webcomponentsjs_polyfill",
9 | srcs = [
10 | "webcomponentsjs_polyfill.html",
11 | "@org_xprof//plugin/third_party/webcomponentsjs",
12 | ],
13 | path = "/webcomponentsjs_polyfill",
14 | )
15 |
--------------------------------------------------------------------------------
/plugin/trace_viewer/webcomponentsjs_polyfill/webcomponentsjs_polyfill.html:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
--------------------------------------------------------------------------------
/requirements.in:
--------------------------------------------------------------------------------
1 | absl-py >= 2.1.0
2 | gviz_api >= 1.10.0
3 | setuptools <= 71.0.0
4 | fsspec[gcs] >= 2024.10.0
5 | cheroot >= 10.0.1
6 | etils[epath] >= 1.0.0
7 | werkzeug >= 0.11.15
8 | protobuf >= 3.19.6
9 | six >= 1.10.0
10 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | const {nodeResolve} = require('@rollup/plugin-node-resolve');
2 | const commonjs = require('@rollup/plugin-commonjs');
3 |
4 | module.exports = {
5 | plugins: [
6 | nodeResolve({
7 | mainFields: ['browser', 'es2015', 'module', 'jsnext:main', 'main'],
8 | }),
9 | commonjs(),
10 | ],
11 | output: {
12 | // Name field is required for iife|umd file format
13 | name: 'tbp',
14 | strict: false,
15 | format: 'iife',
16 | sourcemap: false,
17 | },
18 | onwarn: (warning, warn) => {
19 | // Typescript decorator transpiled code checks `this` in case there are
20 | // global decorator. Rollup warns `this` is undefined.
21 | // This is safe to ignore.
22 | if (warning.code === 'THIS_IS_UNDEFINED') {
23 | return;
24 | }
25 | warn(warning);
26 | }
27 | };
28 |
--------------------------------------------------------------------------------
/third_party/BUILD:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/third_party/BUILD
--------------------------------------------------------------------------------
/third_party/tensorboard.patch:
--------------------------------------------------------------------------------
1 | diff --git a/tensorboard/defs/protos.bzl b/tensorboard/defs/protos.bzl
2 | index e1dbe485d..6b0afc5ff 100644
3 | --- a/tensorboard/defs/protos.bzl
4 | +++ b/tensorboard/defs/protos.bzl
5 | @@ -53,8 +53,8 @@ def tb_proto_library(
6 | proto_gen(
7 | name = name + "_genproto",
8 | srcs = srcs,
9 | - deps = [s + "_genproto" for s in deps] + [protoc_runtime_genproto],
10 | - includes = [],
11 | + deps = [s + "_genproto" for s in deps] + ["@com_google_protobuf//:well_known_types_py_pb2_genproto"],
12 | + includes = [],
13 | protoc = protoc,
14 | gen_py = True,
15 | outs = outs_all,
16 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "lib": ["dom", "es2018"],
4 | "moduleResolution": "node",
5 | "strict": false,
6 | "inlineSourceMap": true,
7 | "experimentalDecorators": true,
8 | "baseUrl": "./"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/xprof/BUILD:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/xprof/BUILD
--------------------------------------------------------------------------------
/xprof/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/xprof/__init__.py
--------------------------------------------------------------------------------
/xprof/convert/executor.h:
--------------------------------------------------------------------------------
1 | #ifndef THIRD_PARTY_XPROF_CONVERT_EXECUTOR_H_
2 | #define THIRD_PARTY_XPROF_CONVERT_EXECUTOR_H_
3 |
4 | #include
5 |
6 | namespace tensorflow {
7 | namespace profiler {
8 |
9 | // Interface for abstracting execution mechanisms like thread pools.
10 | class Executor {
11 | public:
12 | virtual ~Executor() = default;
13 |
14 | // Executes the given function, potentially in parallel.
15 | // The execution might happen asynchronously.
16 | virtual void Execute(std::function fn) = 0;
17 |
18 | // Waits for all previously scheduled functions via Execute() to complete.
19 | virtual void JoinAll() = 0;
20 | };
21 |
22 | } // namespace profiler
23 | } // namespace tensorflow
24 |
25 | #endif // THIRD_PARTY_XPROF_CONVERT_EXECUTOR_H_
26 |
--------------------------------------------------------------------------------
/xprof/convert/inference_stats_combiner.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 |
16 | #ifndef XPROF_CONVERT_INFERENCE_STATS_COMBINER_H_
17 | #define XPROF_CONVERT_INFERENCE_STATS_COMBINER_H_
18 | #include "plugin/tensorboard_plugin_profile/protobuf/inference_stats.pb.h"
19 |
20 | namespace tensorflow::profiler {
21 | void CombineInferenceStatsResult(int src_host_id, const InferenceStats& src,
22 | InferenceStats* dst);
23 | } // namespace tensorflow::profiler
24 |
25 | #endif // XPROF_CONVERT_INFERENCE_STATS_COMBINER_H_
26 |
--------------------------------------------------------------------------------
/xprof/convert/op_stats_to_pod_stats.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 |
16 | #ifndef XPROF_CONVERT_OP_STATS_TO_POD_STATS_H_
17 | #define XPROF_CONVERT_OP_STATS_TO_POD_STATS_H_
18 |
19 | #include "plugin/tensorboard_plugin_profile/protobuf/op_stats.pb.h"
20 | #include "plugin/tensorboard_plugin_profile/protobuf/pod_stats.pb.h"
21 |
22 | namespace tensorflow {
23 | namespace profiler {
24 |
25 | PodStatsDatabase ConvertOpStatsToPodStats(const OpStats& op_stats);
26 |
27 | } // namespace profiler
28 | } // namespace tensorflow
29 |
30 | #endif // XPROF_CONVERT_OP_STATS_TO_POD_STATS_H_
31 |
--------------------------------------------------------------------------------
/xprof/convert/op_stats_to_pod_viewer.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 |
16 | #ifndef XPROF_CONVERT_OP_STATS_TO_POD_VIEWER_H_
17 | #define XPROF_CONVERT_OP_STATS_TO_POD_VIEWER_H_
18 |
19 | #include "plugin/tensorboard_plugin_profile/protobuf/op_stats.pb.h"
20 | #include "plugin/tensorboard_plugin_profile/protobuf/pod_viewer.pb.h"
21 |
22 | namespace tensorflow {
23 | namespace profiler {
24 |
25 | PodViewerDatabase ConvertOpStatsToPodViewer(const OpStats& op_stats);
26 |
27 | } // namespace profiler
28 | } // namespace tensorflow
29 |
30 | #endif // XPROF_CONVERT_OP_STATS_TO_POD_VIEWER_H_
31 |
--------------------------------------------------------------------------------
/xprof/convert/oss/BUILD:
--------------------------------------------------------------------------------
1 | exports_files(
2 | ["tpu_input_pipeline_analysis_constants.cc"],
3 | visibility = ["@org_xprof//xprof/convert:__pkg__"],
4 | )
5 |
--------------------------------------------------------------------------------
/xprof/convert/oss/tpu_input_pipeline_analysis_constants.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 | #include "xprof/convert/tpu_input_pipeline_analysis_constants.h"
16 |
17 | #include "absl/strings/string_view.h"
18 |
19 | namespace tensorflow {
20 | namespace profiler {
21 |
22 | constexpr absl::string_view kProfileAllHostsDoc =
23 | "https://cloud.google.com/tpu/docs/troubleshooting/troubleshoot-multislice";
24 | constexpr absl::string_view kSparseCoreV0Name = "SparseCoreV0";
25 |
26 | } // namespace profiler
27 | } // namespace tensorflow
28 |
--------------------------------------------------------------------------------
/xprof/convert/process_megascale_dcn.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 | #ifndef XPROF_CONVERT_PROCESS_MEGASCALE_DCN_H_
16 | #define XPROF_CONVERT_PROCESS_MEGASCALE_DCN_H_
17 |
18 | #include "tsl/profiler/protobuf/xplane.pb.h"
19 |
20 | namespace tensorflow {
21 | namespace profiler {
22 |
23 | // Process Dcn Megascale TraceMe info.
24 | void ProcessMegascaleDcn(XSpace* space);
25 |
26 | } // namespace profiler
27 | } // namespace tensorflow
28 |
29 | #endif // XPROF_CONVERT_PROCESS_MEGASCALE_DCN_H_
30 |
--------------------------------------------------------------------------------
/xprof/convert/tpu_input_pipeline_analysis_constants.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2024 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 | #ifndef XPROF_CONVERT_TPU_INPUT_PIPELINE_ANALYSIS_CONSTANTS_H_
16 | #define XPROF_CONVERT_TPU_INPUT_PIPELINE_ANALYSIS_CONSTANTS_H_
17 |
18 | #include "absl/strings/string_view.h"
19 | #include "xla/tsl/platform/macros.h"
20 |
21 | namespace tensorflow {
22 | namespace profiler {
23 |
24 | TF_CONST_INIT extern const absl::string_view kProfileAllHostsDoc;
25 | TF_CONST_INIT extern const absl::string_view kSparseCoreV0Name;
26 |
27 | } // namespace profiler
28 | } // namespace tensorflow
29 |
30 | #endif // XPROF_CONVERT_TPU_INPUT_PIPELINE_ANALYSIS_CONSTANTS_H_
31 |
--------------------------------------------------------------------------------
/xprof/pywrap/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openxla/xprof/c1f0728bb0df61f52e843e00a96586af02f99dbe/xprof/pywrap/__init__.py
--------------------------------------------------------------------------------
/xprof/pywrap/_pywrap_profiler_plugin.pyi:
--------------------------------------------------------------------------------
1 | # Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 |
16 | def monitor(arg0: str, arg1: int, arg2: int, arg3: bool) -> str: ...
17 | def trace(arg0: str, arg1: str, arg2: str, arg3: bool, arg4: int, arg5: int, arg6: dict) -> None: ...
18 | def xspace_to_tools_data(arg0: list, arg1: str, arg2: dict = ...) -> tuple: ...
19 | def xspace_to_tools_data_from_byte_string(arg0: list, arg1: list, arg2: str, arg3: dict) -> tuple: ...
20 |
--------------------------------------------------------------------------------
/xprof/pywrap/profiler_wrapper_test.py:
--------------------------------------------------------------------------------
1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Tests for profiler_wrapper.cc pybind methods."""
16 |
17 | from absl.testing import absltest
18 | from xprof.pywrap import _pywrap_profiler_plugin as profiler_wrapper_plugin
19 |
20 |
21 | class ProfilerSessionTest(absltest.TestCase):
22 |
23 | def test_xspace_to_tools_data_default_options(self):
24 | # filenames only used for `hlo_proto` tool.
25 | profiler_wrapper_plugin.xspace_to_tools_data([], 'trace_viewer')
26 |
27 | if __name__ == '__main__':
28 | absltest.main()
29 |
--------------------------------------------------------------------------------
/xprof/utils/device_caps_utils.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | ==============================================================================*/
15 |
16 | #ifndef XPROF_UTILS_DEVICE_CAPS_UTILS_H_
17 | #define XPROF_UTILS_DEVICE_CAPS_UTILS_H_
18 |
19 | #include "tsl/profiler/protobuf/xplane.pb.h"
20 | #include "plugin/tensorboard_plugin_profile/protobuf/hardware_types.pb.h"
21 |
22 | namespace tensorflow {
23 | namespace profiler {
24 |
25 | void SetDeviceCaps(const DeviceCapabilities& caps, XPlane* plane);
26 | DeviceCapabilities GetDeviceCaps(const XPlane& plane);
27 |
28 | } // namespace profiler
29 | } // namespace tensorflow
30 |
31 | #endif // XPROF_UTILS_DEVICE_CAPS_UTILS_H_
32 |
--------------------------------------------------------------------------------
/xprof/utils/roofline_model_utils.cc:
--------------------------------------------------------------------------------
1 | #include "xprof/utils/roofline_model_utils.h"
2 |
3 | #include "xla/tsl/profiler/utils/math_utils.h"
4 |
5 | namespace tensorflow {
6 | namespace profiler {
7 |
8 | double RidgePoint(double peak_gigaflops_per_second,
9 | double peak_gibibytes_per_second) {
10 | return tsl::profiler::SafeDivide(
11 | peak_gigaflops_per_second,
12 | tsl::profiler::GibiToGiga(peak_gibibytes_per_second));
13 | }
14 |
15 | } // namespace profiler
16 | } // namespace tensorflow
17 |
--------------------------------------------------------------------------------
/xprof/utils/roofline_model_utils.h:
--------------------------------------------------------------------------------
1 | #ifndef THIRD_PARTY_XPROF_UTILS_ROOFLINE_MODEL_UTILS_H_
2 | #define THIRD_PARTY_XPROF_UTILS_ROOFLINE_MODEL_UTILS_H_
3 |
4 | namespace tensorflow {
5 | namespace profiler {
6 |
7 | // Takes flops as Gflops and BW as GiB.
8 | double RidgePoint(double peak_gigaflops_per_second,
9 | double peak_gibibytes_per_second);
10 |
11 | } // namespace profiler
12 | } // namespace tensorflow
13 |
14 | #endif // THIRD_PARTY_XPROF_UTILS_ROOFLINE_MODEL_UTILS_H_
15 |
--------------------------------------------------------------------------------
/xprof_pypi_package/xprof/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright 2025 The XProf Authors. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the 'License');
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an 'AS IS' BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | # ==============================================================================
15 | """Passthrough __init__.py pointing to tensorboard_plugin_profile."""
16 |
17 | from tensorboard_plugin_profile import profile_plugin
18 | from tensorboard_plugin_profile import profile_plugin_loader
19 | from tensorboard_plugin_profile import server
20 | from tensorboard_plugin_profile import version
21 |
--------------------------------------------------------------------------------