2018-11-17 18:03:33 -08:00
|
|
|
# Copyright 2018 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
|
|
|
|
#
|
|
|
|
# https://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.
|
|
|
|
|
2022-04-21 13:44:12 -07:00
|
|
|
from jax._src.public_test_util import (
|
2021-09-24 07:02:08 -07:00
|
|
|
check_grads as check_grads,
|
2021-10-14 11:55:11 -04:00
|
|
|
check_jvp as check_jvp,
|
|
|
|
check_vjp as check_vjp,
|
2020-02-05 17:35:46 +01:00
|
|
|
)
|
2022-02-17 14:58:58 -08:00
|
|
|
|
2022-04-21 12:12:40 -07:00
|
|
|
# TODO(jakevdp): remove everything below once downstream callers are fixed.
|
|
|
|
|
|
|
|
# Unconditionally import private test_util because it contains flag definitions.
|
|
|
|
# In bazel, jax._src.test_util requires its own BUILD target so it may not be present.
|
|
|
|
# pytype: disable=import-error
|
2022-04-04 14:39:43 -07:00
|
|
|
try:
|
2022-04-21 12:12:40 -07:00
|
|
|
import jax._src.test_util as _private_test_util
|
2022-08-18 11:38:31 -07:00
|
|
|
except ImportError:
|
2022-04-04 14:39:43 -07:00
|
|
|
pass
|
2022-04-21 12:12:40 -07:00
|
|
|
else:
|
|
|
|
del _private_test_util
|
|
|
|
|
|
|
|
# Use module-level getattr to add warnings to imports of deprecated names.
|
|
|
|
# pylint: disable=import-outside-toplevel
|
|
|
|
def __getattr__(attr):
|
|
|
|
try:
|
|
|
|
from jax._src import test_util
|
2022-08-18 11:38:31 -07:00
|
|
|
except ImportError:
|
2022-04-21 12:12:40 -07:00
|
|
|
raise AttributeError(f"module {__name__} has no attribute {attr}")
|
|
|
|
if attr in ['cases_from_list', 'check_close', 'check_eq', 'device_under_test',
|
|
|
|
'format_shape_dtype_string', 'rand_uniform', 'skip_on_devices',
|
|
|
|
'with_config', 'xla_bridge', '_default_tolerance']:
|
|
|
|
import warnings
|
|
|
|
warnings.warn(f"jax.test_util.{attr} is deprecated and will soon be removed.", FutureWarning)
|
|
|
|
return getattr(test_util, attr)
|
|
|
|
else:
|
|
|
|
raise AttributeError(f"module {__name__} has no attribute {attr}")
|