Skip to content

Commit

Permalink
Unblock LSC - Patch 2 - Fix initializer of instance members that refe…
Browse files Browse the repository at this point in the history
…rence 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 <73375917+frost-cy@users.noreply.github.com>
  • Loading branch information
rileyajones and frost-cy authored Aug 27, 2024
1 parent b56c655 commit b9ab242
Show file tree
Hide file tree
Showing 22 changed files with 745 additions and 622 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,87 +37,104 @@ export class ExecutionDataContainer {
@Input()
focusedExecutionIndex!: number;

readonly focusedExecutionData$ = this.store.pipe(
select(getFocusedExecutionData)
);
readonly focusedExecutionData$;

readonly tensorDebugMode$ = this.store.pipe(
select(
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
if (execution === null) {
return TensorDebugMode.UNSPECIFIED;
} else {
return execution.tensor_debug_mode;
}
})
)
);
readonly tensorDebugMode$;

readonly hasDebugTensorValues$ = this.store.pipe(
select(
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
if (execution === null || execution.debug_tensor_values === null) {
return false;
} else {
for (const singleDebugTensorValues of execution.debug_tensor_values) {
if (
singleDebugTensorValues !== null &&
singleDebugTensorValues.length > 0
) {
return true;
}
}
return false;
}
})
)
);
readonly hasDebugTensorValues$;

readonly debugTensorValues$;

readonly debugTensorValues$ = this.store.pipe(
select(
createSelector(getFocusedExecutionData, (execution: Execution | null) => {
if (execution === null) {
return null;
} else {
return execution.debug_tensor_values;
}
})
)
);
readonly debugTensorDtypes$;

readonly debugTensorDtypes$ = this.store.pipe(
select(
createSelector(
getFocusedExecutionData,
(execution: Execution | null): string[] | null => {
if (execution === null || execution.debug_tensor_values === null) {
return null;
constructor(private readonly store: Store<State>) {
this.focusedExecutionData$ = this.store.pipe(
select(getFocusedExecutionData)
);
this.tensorDebugMode$ = this.store.pipe(
select(
createSelector(
getFocusedExecutionData,
(execution: Execution | null) => {
if (execution === null) {
return TensorDebugMode.UNSPECIFIED;
} else {
return execution.tensor_debug_mode;
}
}
if (
execution.tensor_debug_mode !== TensorDebugMode.FULL_HEALTH &&
execution.tensor_debug_mode !== TensorDebugMode.SHAPE
) {
// TODO(cais): Add logic for other TensorDebugModes with dtype info.
return null;
)
)
);
this.hasDebugTensorValues$ = this.store.pipe(
select(
createSelector(
getFocusedExecutionData,
(execution: Execution | null) => {
if (execution === null || execution.debug_tensor_values === null) {
return false;
} else {
for (const singleDebugTensorValues of execution.debug_tensor_values) {
if (
singleDebugTensorValues !== null &&
singleDebugTensorValues.length > 0
) {
return true;
}
}
return false;
}
}
const dtypes: string[] = [];
for (const tensorValue of execution.debug_tensor_values) {
if (tensorValue === null) {
dtypes.push(UNKNOWN_DTYPE_NAME);
)
)
);
this.debugTensorValues$ = this.store.pipe(
select(
createSelector(
getFocusedExecutionData,
(execution: Execution | null) => {
if (execution === null) {
return null;
} else {
const dtypeEnum = String(
execution.tensor_debug_mode === TensorDebugMode.FULL_HEALTH
? tensorValue[2] // tensor_debug_mode: FULL_HEALTH
: tensorValue[1] // tensor_debug_mode: SHAPE
);
dtypes.push(DTYPE_ENUM_TO_NAME[dtypeEnum] || UNKNOWN_DTYPE_NAME);
return execution.debug_tensor_values;
}
}
return dtypes;
}
)
)
)
);

constructor(private readonly store: Store<State>) {}
);
this.debugTensorDtypes$ = this.store.pipe(
select(
createSelector(
getFocusedExecutionData,
(execution: Execution | null): string[] | null => {
if (execution === null || execution.debug_tensor_values === null) {
return null;
}
if (
execution.tensor_debug_mode !== TensorDebugMode.FULL_HEALTH &&
execution.tensor_debug_mode !== TensorDebugMode.SHAPE
) {
// TODO(cais): Add logic for other TensorDebugModes with dtype info.
return null;
}
const dtypes: string[] = [];
for (const tensorValue of execution.debug_tensor_values) {
if (tensorValue === null) {
dtypes.push(UNKNOWN_DTYPE_NAME);
} else {
const dtypeEnum = String(
execution.tensor_debug_mode === TensorDebugMode.FULL_HEALTH
? tensorValue[2] // tensor_debug_mode: FULL_HEALTH
: tensorValue[1] // tensor_debug_mode: SHAPE
);
dtypes.push(
DTYPE_ENUM_TO_NAME[dtypeEnum] || UNKNOWN_DTYPE_NAME
);
}
}
return dtypes;
}
)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ import {State} from '../../store/debugger_types';
`,
})
export class GraphContainer {
readonly opInfo$ = this.store.pipe(select(getFocusedGraphOpInfo));
readonly opInfo$;

readonly inputOps$ = this.store.pipe(select(getFocusedGraphOpInputs));
readonly inputOps$;

readonly consumerOps$ = this.store.pipe(select(getFocusedGraphOpConsumers));
readonly consumerOps$;

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

constructor(private readonly store: Store<State>) {}
constructor(private readonly store: Store<State>) {
this.opInfo$ = this.store.pipe(select(getFocusedGraphOpInfo));
this.inputOps$ = this.store.pipe(select(getFocusedGraphOpInputs));
this.consumerOps$ = this.store.pipe(select(getFocusedGraphOpConsumers));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ import {State as DebuggerState} from '../../store/debugger_types';
`,
})
export class SourceFilesContainer {
constructor(private readonly store: Store<DebuggerState & OtherAppState>) {}
constructor(private readonly store: Store<DebuggerState & OtherAppState>) {
this.focusedSourceFileContent$ = this.store.select(
getFocusedSourceFileContent
);
this.focusedSourceLineSpec$ = this.store.select(getFocusedSourceLineSpec);
this.useDarkMode$ = this.store.select(getDarkModeEnabled);
}

readonly focusedSourceFileContent$ = this.store.select(
getFocusedSourceFileContent
);
readonly focusedSourceFileContent$;

readonly focusedSourceLineSpec$ = this.store.select(getFocusedSourceLineSpec);
readonly focusedSourceLineSpec$;

readonly useDarkMode$: Observable<boolean> =
this.store.select(getDarkModeEnabled);
readonly useDarkMode$: Observable<boolean>;
}
Loading

0 comments on commit b9ab242

Please sign in to comment.