Skip to content

Commit

Permalink
Replace deprecated jax.tree_* functions with jax.tree.*
Browse files Browse the repository at this point in the history
The top-level `jax.tree_*` aliases have long been deprecated, and will soon be removed. Alternate APIs are in `jax.tree_util`, with shorter aliases in the `jax.tree` submodule, added in JAX version 0.4.25.

PiperOrigin-RevId: 633966249
  • Loading branch information
Jake VanderPlas authored and Magenta Team committed May 21, 2024
1 parent a8bab04 commit 302c94b
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion music_spectrogram_diffusion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/audio_codecs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/beam/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 @@ -206,7 +206,7 @@ def process(self, id_examples):

tick = time.time()
if self._prediction_source == 'model':
pred_encoded, _ = jax.tree_map(
pred_encoded, _ = jax.tree.map(
np.asarray, self._synth_model.predict(batch))
elif self._prediction_source in ('gt_raw', 'gt_encoded'):
pred_encoded = batch['decoder_target_tokens']
Expand Down
2 changes: 1 addition & 1 deletion music_spectrogram_diffusion/datasets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/dump_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/event_codec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/event_codec_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/feature_converters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/layers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/layers_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/metrics_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/models/diffusion/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 @@ -178,7 +178,7 @@ def predict_batch_with_aux(
def pred_fn(z: jnp.ndarray,
time: jnp.ndarray,
include_conditioning: bool) -> jnp.ndarray:
step_encodings_and_masks = jax.tree_map(
step_encodings_and_masks = jax.tree.map(
lambda x: x * include_conditioning, encodings_and_masks)
return self.module.apply(
{
Expand Down Expand Up @@ -373,7 +373,7 @@ def predict_batch_with_aux(
def pred_fn(z: jnp.ndarray,
time: jnp.ndarray,
include_conditioning: bool) -> jnp.ndarray:
step_encodings_and_masks = jax.tree_map(
step_encodings_and_masks = jax.tree.map(
lambda x: x * include_conditioning, encodings_and_masks)
return self.module.apply(
{
Expand Down
2 changes: 1 addition & 1 deletion music_spectrogram_diffusion/models/diffusion/network.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/note_sequences.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/note_sequences_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/postprocessors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/run_length_encoding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/run_length_encoding_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/transcription_inference.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/vocabularies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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 music_spectrogram_diffusion/vocabularies_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 The Music Spectrogram Diffusion Authors.
# Copyright 2024 The Music Spectrogram Diffusion 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

0 comments on commit 302c94b

Please sign in to comment.