Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/datasets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/event_codec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/event_codec_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions mt3/inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,7 +68,7 @@ def write_inferences_to_file(
else:
encoding_spec = note_sequences.NoteEncodingWithTiesSpec

codec = vocabularies.build_codec(vocab_config)
codec = vocabularies.build_codec(vocab_config) # pyrefly: ignore[bad-argument-type]

targets = []
predictions = []
Expand Down
22 changes: 11 additions & 11 deletions mt3/layers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,7 +147,7 @@ def dot_product_attention(query: Array,
# corresponds to in positional dimensions here, assuming query dim.
dropout_shape = list(attn_weights.shape)
dropout_shape[-2] = 1
keep = random.bernoulli(dropout_rng, keep_prob, dropout_shape)
keep = random.bernoulli(dropout_rng, keep_prob, dropout_shape) # pyrefly: ignore[bad-argument-type]
keep = jnp.broadcast_to(keep, attn_weights.shape)
multiplier = (
keep.astype(attn_weights.dtype) / jnp.asarray(keep_prob, dtype=dtype))
Expand Down Expand Up @@ -357,7 +357,7 @@ def __call__(self,

def _normalize_axes(axes: Iterable[int], ndim: int) -> Tuple[int]:
# A tuple by convention. len(axes_tuple) then also gives the rank efficiently.
return tuple([ax if ax >= 0 else ndim + ax for ax in axes])
return tuple([ax if ax >= 0 else ndim + ax for ax in axes]) # pyrefly: ignore[bad-return]


def _canonicalize_tuple(x):
Expand Down Expand Up @@ -593,7 +593,7 @@ def __call__(self,
i = position_embedder_index.value
position_embedder_index.value = i + 1
return jax.lax.dynamic_slice(self.embedding, jnp.array((i, 0)),
np.array((1, self.features)))
np.array((1, self.features))) # pyrefly: ignore[bad-argument-type]

return jnp.take(self.embedding, inputs, axis=0)

Expand Down Expand Up @@ -700,15 +700,15 @@ def combine_masks(*masks: Optional[Array], dtype: DType = jnp.float32):
Returns:
Combined mask, reduced by logical and, returns None if no masks given.
"""
masks = [m for m in masks if m is not None]
masks = [m for m in masks if m is not None] # pyrefly: ignore[bad-assignment]
if not masks:
return None
assert all(map(lambda x: x.ndim == masks[0].ndim, masks)), (
assert all(map(lambda x: x.ndim == masks[0].ndim, masks)), ( # pyrefly: ignore[missing-attribute]
f'masks must have same rank: {tuple(map(lambda x: x.ndim, masks))}')
mask, *other_masks = masks
for other_mask in other_masks:
mask = jnp.logical_and(mask, other_mask)
return mask.astype(dtype)
mask = jnp.logical_and(mask, other_mask) # pyrefly: ignore[bad-argument-type]
return mask.astype(dtype) # pyrefly: ignore[missing-attribute]


def combine_biases(*masks: Optional[Array]):
Expand All @@ -720,14 +720,14 @@ def combine_biases(*masks: Optional[Array]):
Returns:
Combined mask, reduced by summation, returns None if no masks given.
"""
masks = [m for m in masks if m is not None]
masks = [m for m in masks if m is not None] # pyrefly: ignore[bad-assignment]
if not masks:
return None
assert all(map(lambda x: x.ndim == masks[0].ndim, masks)), (
assert all(map(lambda x: x.ndim == masks[0].ndim, masks)), ( # pyrefly: ignore[missing-attribute]
f'masks must have same rank: {tuple(map(lambda x: x.ndim, masks))}')
mask, *other_masks = masks
for other_mask in other_masks:
mask = mask + other_mask
mask = mask + other_mask # pyrefly: ignore[unsupported-operation]
return mask


Expand Down
2 changes: 1 addition & 1 deletion mt3/layers_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/metrics_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/metrics_utils_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions mt3/mixing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,10 +59,10 @@ def mix_transcription_examples(
Dataset containing mixed examples.
"""
if max_examples_per_mix is None:
return ds
return ds # pyrefly: ignore[bad-return]

# TODO(iansimon): is there a way to use seqio's seed?
ds = tf.data.Dataset.sample_from_datasets([
ds = tf.data.Dataset.sample_from_datasets([ # pyrefly: ignore[bad-argument-type]
ds.shuffle(
buffer_size=shuffle_buffer_size // max_examples_per_mix
).padded_batch(batch_size=i) for i in range(1, max_examples_per_mix + 1)
Expand Down
4 changes: 2 additions & 2 deletions mt3/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, module, input_vocabulary, output_vocabulary, optimizer_def,
input_vocabulary=input_vocabulary,
output_vocabulary=output_vocabulary,
optimizer_def=optimizer_def,
decode_fn=decode_fn,
decode_fn=decode_fn, # pyrefly: ignore[bad-argument-type]
label_smoothing=label_smoothing,
z_loss=z_loss,
loss_normalizing_factor=loss_normalizing_factor)
Expand Down
4 changes: 2 additions & 2 deletions mt3/network.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -344,7 +344,7 @@ def decode(
encoder_decoder_mask = layers.combine_masks(
encoder_decoder_mask,
layers.make_attention_mask(
decoder_segment_ids,
decoder_segment_ids, # pyrefly: ignore[bad-argument-type]
encoder_segment_ids,
jnp.equal,
dtype=cfg.dtype))
Expand Down
2 changes: 1 addition & 1 deletion mt3/note_sequences.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/note_sequences_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
22 changes: 11 additions & 11 deletions mt3/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,7 +64,7 @@ def _audio_to_frames(
"""Convert audio samples to non-overlapping frames and frame times."""
frame_size = spectrogram_config.hop_width
logging.info('Padding %d samples to multiple of %d', len(samples), frame_size)
samples = np.pad(samples,
samples = np.pad(samples, # pyrefly: ignore[bad-assignment]
[0, frame_size - len(samples) % frame_size],
mode='constant')

Expand Down Expand Up @@ -167,9 +167,9 @@ def tokenize(sequence, audio, sample_rate, example_id=None):
event_values=values,
encode_event_fn=note_sequences.note_event_data_to_events,
codec=codec,
frame_times=frame_times,
frame_times=frame_times, # pyrefly: ignore[bad-argument-type]
encoding_state_to_events_fn=(
note_sequences.note_encoding_state_to_events
note_sequences.note_encoding_state_to_events # pyrefly: ignore[bad-argument-type]
if include_ties else None)))

yield {
Expand All @@ -196,7 +196,7 @@ def process_record(input_record):
args.append(input_record[id_feature_key])

ds = tf.data.Dataset.from_generator(
tokenize,
tokenize, # pyrefly: ignore[bad-argument-type]
output_signature={
'inputs':
tf.TensorSpec(
Expand Down Expand Up @@ -339,9 +339,9 @@ def tokenize(sequences, inst_names, audio, example_id=None):
event_values=values,
encode_event_fn=note_sequences.note_event_data_to_events,
codec=codec,
frame_times=frame_times,
frame_times=frame_times, # pyrefly: ignore[bad-argument-type]
encoding_state_to_events_fn=(
note_sequences.note_encoding_state_to_events
note_sequences.note_encoding_state_to_events # pyrefly: ignore[bad-argument-type]
if include_ties else None)))

yield {
Expand All @@ -365,7 +365,7 @@ def process_record(input_record):
args.append(input_record[id_feature_key])

ds = tf.data.Dataset.from_generator(
tokenize,
tokenize, # pyrefly: ignore[bad-argument-type]
output_signature={
'inputs':
tf.TensorSpec(
Expand Down Expand Up @@ -556,9 +556,9 @@ def tokenize(sequences, samples, sample_rate, inst_names, example_id):
event_values=values,
encode_event_fn=note_sequences.note_event_data_to_events,
codec=codec,
frame_times=frame_times,
frame_times=frame_times, # pyrefly: ignore[bad-argument-type]
encoding_state_to_events_fn=(
note_sequences.note_encoding_state_to_events
note_sequences.note_encoding_state_to_events # pyrefly: ignore[bad-argument-type]
if include_ties else None)))

yield {
Expand All @@ -574,7 +574,7 @@ def tokenize(sequences, samples, sample_rate, inst_names, example_id):

def process_record(input_record):
ds = tf.data.Dataset.from_generator(
tokenize,
tokenize, # pyrefly: ignore[bad-argument-type]
output_signature={
'inputs':
tf.TensorSpec(
Expand Down
8 changes: 4 additions & 4 deletions mt3/run_length_encoding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -124,8 +124,8 @@ def fill_event_start_indices_to_cur_step():
while(len(event_start_indices) < len(frame_times) and
frame_times[len(event_start_indices)] <
cur_step / codec.steps_per_second):
event_start_indices.append(cur_event_idx)
state_event_indices.append(cur_state_event_idx)
event_start_indices.append(cur_event_idx) # pyrefly: ignore[missing-attribute]
state_event_indices.append(cur_state_event_idx) # pyrefly: ignore[missing-attribute]

for event_step, event_value in zip(event_steps, event_values):
while event_step > cur_step:
Expand Down Expand Up @@ -163,7 +163,7 @@ def fill_event_start_indices_to_cur_step():
event_end_indices = np.array(event_end_indices)
state_event_indices = np.array(state_event_indices)

return (events, event_start_indices, event_end_indices,
return (events, event_start_indices, event_end_indices, # pyrefly: ignore[bad-return]
state_events, state_event_indices)


Expand Down
2 changes: 1 addition & 1 deletion mt3/run_length_encoding_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/scripts/dump_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions mt3/scripts/extract_monophonic_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -240,7 +240,7 @@ def main(unused_argv):
continue
logging.info('processing %s...', filename)
for ex in process_wav_file(
os.path.join(_INPUT_DIR.value, filename), crepe, counters):
os.path.join(_INPUT_DIR.value, filename), crepe, counters): # pyrefly: ignore[no-matching-overload]
writer.write(ex.SerializeToString())
counters['wav_files_processed'] += 1
for k, v in counters.items():
Expand Down
2 changes: 1 addition & 1 deletion mt3/spectral_ops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion mt3/spectrograms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 The MT3 Authors.
# Copyright 2026 The MT3 Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading
Loading