Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def model_fn(
update_batch_norm: bool,
use_running_average_bn: Optional[bool] = None,
dropout_rate: Optional[float] = models.DROPOUT_RATE,
) -> Tuple[spec.Tensor, spec.ModelAuxiliaryState]:
) -> Tuple[Tuple[spec.Tensor, spec.Tensor], spec.ModelAuxiliaryState]:
variables = {'params': params, **model_state}
inputs, input_paddings = augmented_and_preprocessed_input_batch['inputs']
is_train_mode = mode == spec.ForwardPassMode.TRAIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def model_fn(
rng: spec.RandomState,
update_batch_norm: bool,
dropout_rate: float = models.DROPOUT_RATE,
) -> Tuple[spec.Tensor, spec.ModelAuxiliaryState]:
) -> Tuple[Tuple[spec.Tensor, spec.Tensor], spec.ModelAuxiliaryState]:
del model_state
del rng

Expand Down
30 changes: 30 additions & 0 deletions tests/test_model_fn_annotations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import ast
from pathlib import Path

import pytest


@pytest.mark.parametrize(
'workload_path',
[
Path(
'algoperf/workloads/librispeech_conformer/librispeech_jax/workload.py'
),
Path(
'algoperf/workloads/librispeech_conformer/librispeech_pytorch/workload.py'
),
],
)
def test_librispeech_conformer_model_fn_return_annotation(
workload_path: Path,
):
module = ast.parse(workload_path.read_text(encoding='utf-8'))
model_fn = next(
node
for node in ast.walk(module)
if isinstance(node, ast.FunctionDef) and node.name == 'model_fn'
)

assert ast.unparse(model_fn.returns) == (
'Tuple[Tuple[spec.Tensor, spec.Tensor], spec.ModelAuxiliaryState]'
)
Loading