Skip to content

Commit b9ab242

Browse files
Unblock LSC - Patch 2 - Fix initializer of instance members that reference identifiers declared in the constructor (#6901)
## Motivation for features / changes There is an ongoing LSC cl/652971829 which changes how instance methods are set. The change is blocked because of our split codebase. This PR is intended as a replacement for go/tbpr/6883 --------- Co-authored-by: Chinthoorie <[email protected]>
1 parent b56c655 commit b9ab242

22 files changed

+745
-622
lines changed

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/execution_data/execution_data_container.ts

Lines changed: 90 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -37,87 +37,104 @@ export class ExecutionDataContainer {
3737
@Input()
3838
focusedExecutionIndex!: number;
3939

40-
readonly focusedExecutionData$ = this.store.pipe(
41-
select(getFocusedExecutionData)
42-
);
40+
readonly focusedExecutionData$;
4341

44-
readonly tensorDebugMode$ = this.store.pipe(
45-
select(
46-
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
47-
if (execution === null) {
48-
return TensorDebugMode.UNSPECIFIED;
49-
} else {
50-
return execution.tensor_debug_mode;
51-
}
52-
})
53-
)
54-
);
42+
readonly tensorDebugMode$;
5543

56-
readonly hasDebugTensorValues$ = this.store.pipe(
57-
select(
58-
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
59-
if (execution === null || execution.debug_tensor_values === null) {
60-
return false;
61-
} else {
62-
for (const singleDebugTensorValues of execution.debug_tensor_values) {
63-
if (
64-
singleDebugTensorValues !== null &&
65-
singleDebugTensorValues.length > 0
66-
) {
67-
return true;
68-
}
69-
}
70-
return false;
71-
}
72-
})
73-
)
74-
);
44+
readonly hasDebugTensorValues$;
45+
46+
readonly debugTensorValues$;
7547

76-
readonly debugTensorValues$ = this.store.pipe(
77-
select(
78-
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
79-
if (execution === null) {
80-
return null;
81-
} else {
82-
return execution.debug_tensor_values;
83-
}
84-
})
85-
)
86-
);
48+
readonly debugTensorDtypes$;
8749

88-
readonly debugTensorDtypes$ = this.store.pipe(
89-
select(
90-
createSelector(
91-
getFocusedExecutionData,
92-
(execution: Execution | null): string[] | null => {
93-
if (execution === null || execution.debug_tensor_values === null) {
94-
return null;
50+
constructor(private readonly store: Store<State>) {
51+
this.focusedExecutionData$ = this.store.pipe(
52+
select(getFocusedExecutionData)
53+
);
54+
this.tensorDebugMode$ = this.store.pipe(
55+
select(
56+
createSelector(
57+
getFocusedExecutionData,
58+
(execution: Execution | null) => {
59+
if (execution === null) {
60+
return TensorDebugMode.UNSPECIFIED;
61+
} else {
62+
return execution.tensor_debug_mode;
63+
}
9564
}
96-
if (
97-
execution.tensor_debug_mode !== TensorDebugMode.FULL_HEALTH &&
98-
execution.tensor_debug_mode !== TensorDebugMode.SHAPE
99-
) {
100-
// TODO(cais): Add logic for other TensorDebugModes with dtype info.
101-
return null;
65+
)
66+
)
67+
);
68+
this.hasDebugTensorValues$ = this.store.pipe(
69+
select(
70+
createSelector(
71+
getFocusedExecutionData,
72+
(execution: Execution | null) => {
73+
if (execution === null || execution.debug_tensor_values === null) {
74+
return false;
75+
} else {
76+
for (const singleDebugTensorValues of execution.debug_tensor_values) {
77+
if (
78+
singleDebugTensorValues !== null &&
79+
singleDebugTensorValues.length > 0
80+
) {
81+
return true;
82+
}
83+
}
84+
return false;
85+
}
10286
}
103-
const dtypes: string[] = [];
104-
for (const tensorValue of execution.debug_tensor_values) {
105-
if (tensorValue === null) {
106-
dtypes.push(UNKNOWN_DTYPE_NAME);
87+
)
88+
)
89+
);
90+
this.debugTensorValues$ = this.store.pipe(
91+
select(
92+
createSelector(
93+
getFocusedExecutionData,
94+
(execution: Execution | null) => {
95+
if (execution === null) {
96+
return null;
10797
} else {
108-
const dtypeEnum = String(
109-
execution.tensor_debug_mode === TensorDebugMode.FULL_HEALTH
110-
? tensorValue[2] // tensor_debug_mode: FULL_HEALTH
111-
: tensorValue[1] // tensor_debug_mode: SHAPE
112-
);
113-
dtypes.push(DTYPE_ENUM_TO_NAME[dtypeEnum] || UNKNOWN_DTYPE_NAME);
98+
return execution.debug_tensor_values;
11499
}
115100
}
116-
return dtypes;
117-
}
101+
)
118102
)
119-
)
120-
);
121-
122-
constructor(private readonly store: Store<State>) {}
103+
);
104+
this.debugTensorDtypes$ = this.store.pipe(
105+
select(
106+
createSelector(
107+
getFocusedExecutionData,
108+
(execution: Execution | null): string[] | null => {
109+
if (execution === null || execution.debug_tensor_values === null) {
110+
return null;
111+
}
112+
if (
113+
execution.tensor_debug_mode !== TensorDebugMode.FULL_HEALTH &&
114+
execution.tensor_debug_mode !== TensorDebugMode.SHAPE
115+
) {
116+
// TODO(cais): Add logic for other TensorDebugModes with dtype info.
117+
return null;
118+
}
119+
const dtypes: string[] = [];
120+
for (const tensorValue of execution.debug_tensor_values) {
121+
if (tensorValue === null) {
122+
dtypes.push(UNKNOWN_DTYPE_NAME);
123+
} else {
124+
const dtypeEnum = String(
125+
execution.tensor_debug_mode === TensorDebugMode.FULL_HEALTH
126+
? tensorValue[2] // tensor_debug_mode: FULL_HEALTH
127+
: tensorValue[1] // tensor_debug_mode: SHAPE
128+
);
129+
dtypes.push(
130+
DTYPE_ENUM_TO_NAME[dtypeEnum] || UNKNOWN_DTYPE_NAME
131+
);
132+
}
133+
}
134+
return dtypes;
135+
}
136+
)
137+
)
138+
);
139+
}
123140
}

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/graph/graph_container.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ import {State} from '../../store/debugger_types';
3434
`,
3535
})
3636
export class GraphContainer {
37-
readonly opInfo$ = this.store.pipe(select(getFocusedGraphOpInfo));
37+
readonly opInfo$;
3838

39-
readonly inputOps$ = this.store.pipe(select(getFocusedGraphOpInputs));
39+
readonly inputOps$;
4040

41-
readonly consumerOps$ = this.store.pipe(select(getFocusedGraphOpConsumers));
41+
readonly consumerOps$;
4242

4343
onGraphOpNavigate(event: {graph_id: string; op_name: string}) {
4444
this.store.dispatch(graphOpFocused(event));
4545
}
4646

47-
constructor(private readonly store: Store<State>) {}
47+
constructor(private readonly store: Store<State>) {
48+
this.opInfo$ = this.store.pipe(select(getFocusedGraphOpInfo));
49+
this.inputOps$ = this.store.pipe(select(getFocusedGraphOpInputs));
50+
this.consumerOps$ = this.store.pipe(select(getFocusedGraphOpConsumers));
51+
}
4852
}

tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/views/source_files/source_files_container.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ import {State as DebuggerState} from '../../store/debugger_types';
3434
`,
3535
})
3636
export class SourceFilesContainer {
37-
constructor(private readonly store: Store<DebuggerState & OtherAppState>) {}
37+
constructor(private readonly store: Store<DebuggerState & OtherAppState>) {
38+
this.focusedSourceFileContent$ = this.store.select(
39+
getFocusedSourceFileContent
40+
);
41+
this.focusedSourceLineSpec$ = this.store.select(getFocusedSourceLineSpec);
42+
this.useDarkMode$ = this.store.select(getDarkModeEnabled);
43+
}
3844

39-
readonly focusedSourceFileContent$ = this.store.select(
40-
getFocusedSourceFileContent
41-
);
45+
readonly focusedSourceFileContent$;
4246

43-
readonly focusedSourceLineSpec$ = this.store.select(getFocusedSourceLineSpec);
47+
readonly focusedSourceLineSpec$;
4448

45-
readonly useDarkMode$: Observable<boolean> =
46-
this.store.select(getDarkModeEnabled);
49+
readonly useDarkMode$: Observable<boolean>;
4750
}

0 commit comments

Comments
 (0)