Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lezwon committed Oct 27, 2020
1 parent 0fcd27e commit 7283d25
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/utilities/test_xla_device_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# 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.
import math
import time

import pytest

import pytorch_lightning.utilities.xla_device_utils as utils
import pytorch_lightning.utilities.xla_device_utils as xla_utils
from tests.base.develop_utils import pl_multi_process_test

try:
Expand All @@ -30,13 +29,13 @@
@pytest.mark.skipif(XLA_AVAILABLE, reason="test requires torch_xla to be absent")
def test_tpu_device_absence():
"""Check tpu_device_exists returns None when torch_xla is not available"""
assert utils.XLADeviceUtils.tpu_device_exists() is None
assert xla_utils.XLADeviceUtils.tpu_device_exists() is None


@pytest.mark.skipif(not XLA_AVAILABLE, reason="test requires torch_xla to be installed")
def test_tpu_device_presence():
"""Check tpu_device_exists returns True when TPU is available"""
assert utils.XLADeviceUtils.tpu_device_exists() is True
assert xla_utils.XLADeviceUtils.tpu_device_exists() is True


@pytest.mark.skipif(not XLA_AVAILABLE, reason="test requires torch_xla to be installed")
Expand All @@ -52,8 +51,8 @@ def test_result_returns_within_10_seconds():
"""Check that pl_multi_process returns within 10 seconds"""

start = time.time()
result = utils.pl_multi_process(time.sleep)(25)
result = xla_utils.pl_multi_process(time.sleep)(25)
end = time.time()
elapsed_time = math.floor(end - start)
elapsed_time = int(end - start)
assert elapsed_time <= 10
assert result is False

0 comments on commit 7283d25

Please sign in to comment.