# Path: flaxformer/activation_partitioning.py
# def global_mesh_defined():
# def with_sharding(x, partitioning_dims: int):
# def with_sharding_migration(
#     x: T,
#     activation_partitioning_dims: Optional[int],
#     logical_axis_names: Tuple[str, ...],
# ) -> T:
# T = TypeVar('T')


from unittest import mock
from absl.testing import absltest
from absl.testing import parameterized
from flax.linen import partitioning as flax_partitioning
from jax import numpy as jnp
from flaxformer import activation_partitioning
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for activation_partitioning."""





class ActivationPartitioningTest(parameterized.TestCase):

  def test_with_sharding_migration_dims_unset(self):
    x = jnp.array([1, 2, 3])
    with mock.patch.object(
        flax_partitioning,
        "with_sharding_constraint",
        autospec=True,
    ) as mock_wsc:

# Path: flaxformer/activation_partitioning.py
# def global_mesh_defined():
# def with_sharding(x, partitioning_dims: int):
# def with_sharding_migration(
#     x: T,
#     activation_partitioning_dims: Optional[int],
#     logical_axis_names: Tuple[str, ...],
# ) -> T:
# T = TypeVar('T')


# Path: flaxformer/activation_partitioning_test.py
from unittest import mock
from absl.testing import absltest
from absl.testing import parameterized
from flax.linen import partitioning as flax_partitioning
from jax import numpy as jnp
from flaxformer import activation_partitioning

# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for activation_partitioning."""





class ActivationPartitioningTest(parameterized.TestCase):

  def test_with_sharding_migration_dims_unset(self):
    x = jnp.array([1, 2, 3])
    with mock.patch.object(
        flax_partitioning,
        "with_sharding_constraint",
        autospec=True,
    ) as mock_wsc:

      activation_partitioning.with_sharding_migration(