From 24f578cd66bfc3ec35017fc77e136e43c4b74742 Mon Sep 17 00:00:00 2001 From: Gaurav Jain <gjn@google.com> Date: Thu, 29 Nov 2018 15:30:12 -0800 Subject: [PATCH] Add @run_deprecated_v1 annotation to tests failing in v2 PiperOrigin-RevId: 223422907 --- tensorflow/examples/adding_an_op/fact_test.py | 2 + .../examples/adding_an_op/zero_out_1_test.py | 2 + .../examples/adding_an_op/zero_out_2_test.py | 5 + .../examples/adding_an_op/zero_out_3_test.py | 5 + .../autograph/integration_tests/keras_test.py | 2 + .../examples/speech_commands/freeze_test.py | 4 + .../speech_commands/input_data_test.py | 9 + .../examples/speech_commands/models_test.py | 6 + .../speech_commands/wav_to_features_test.py | 2 + .../autograph/converters/asserts_test.py | 2 + .../converters/builtin_functions_test.py | 4 + .../autograph/converters/control_flow_test.py | 13 + .../converters/function_scopes_test.py | 5 + .../converters/logical_expressions_test.py | 4 + .../converters/side_effect_guards_test.py | 3 + .../python/autograph/core/errors_test.py | 4 + .../autograph/core/function_wrapping_test.py | 2 + tensorflow/python/autograph/impl/api_test.py | 10 + .../autograph/operators/control_flow_test.py | 6 + .../operators/data_structures_test.py | 4 + .../autograph/operators/exceptions_test.py | 3 + .../autograph/operators/logical_test.py | 3 + .../autograph/operators/py_builtins_test.py | 4 + .../python/autograph/utils/misc_test.py | 3 + .../autograph/utils/tensor_list_test.py | 3 + .../python/autograph/utils/type_check_test.py | 1 + .../python/client/session_partial_run_test.py | 24 ++ tensorflow/python/client/timeline_test.py | 1 + .../kernel_tests/copy_to_device_test.py | 10 + .../experimental/kernel_tests/counter_test.py | 2 + .../dense_to_sparse_batch_test.py | 5 + .../directed_interleave_dataset_test.py | 4 + .../kernel_tests/enumerate_dataset_test.py | 2 + .../function_buffering_resource_test.py | 4 + .../kernel_tests/get_single_element_test.py | 2 + .../kernel_tests/group_by_reducer_test.py | 6 + .../kernel_tests/group_by_window_test.py | 11 + .../kernel_tests/ignore_errors_test.py | 4 + .../kernel_tests/indexed_dataset_ops_test.py | 3 + .../make_batched_features_dataset_test.py | 2 + .../kernel_tests/make_csv_dataset_test.py | 9 + .../kernel_tests/map_and_batch_test.py | 13 + .../kernel_tests/matching_files_test.py | 7 + .../kernel_tests/override_threadpool_test.py | 3 + .../parse_example_dataset_test.py | 4 + .../kernel_tests/prefetch_to_device_test.py | 5 + .../kernel_tests/rejection_resample_test.py | 4 + .../kernel_tests/restructured_dataset_test.py | 2 + .../experimental/kernel_tests/scan_test.py | 3 + .../checkpoint_input_pipeline_hook_test.py | 4 + .../kernel_tests/shuffle_and_repeat_test.py | 7 + .../experimental/kernel_tests/sleep_test.py | 2 + .../kernel_tests/stats_dataset_ops_test.py | 17 ++ .../experimental/kernel_tests/unbatch_test.py | 10 + .../experimental/kernel_tests/unique_test.py | 3 + .../python/data/kernel_tests/flat_map_test.py | 1 + .../data/kernel_tests/from_generator_test.py | 17 ++ .../from_sparse_tensor_slices_test.py | 1 + .../data/kernel_tests/from_tensors_test.py | 1 + .../python/data/kernel_tests/iterator_test.py | 17 ++ .../data/kernel_tests/list_files_test.py | 1 + .../python/data/kernel_tests/optional_test.py | 3 + .../data/kernel_tests/padded_batch_test.py | 3 + .../python/data/kernel_tests/reduce_test.py | 1 + .../python/data/kernel_tests/shuffle_test.py | 1 + tensorflow/python/data/util/convert_test.py | 2 + tensorflow/python/data/util/sparse_test.py | 3 + tensorflow/python/data/util/structure_test.py | 2 + .../python/debug/cli/analyzer_cli_test.py | 33 +++ .../python/debug/cli/cli_shared_test.py | 11 + .../debug/cli/profile_analyzer_cli_test.py | 5 + tensorflow/python/debug/lib/common_test.py | 3 + .../python/debug/lib/debug_gradients_test.py | 14 ++ .../python/debug/lib/debug_utils_test.py | 10 + .../debug/lib/session_debug_file_test.py | 2 + .../python/debug/lib/source_utils_test.py | 1 + .../python/distribute/all_reduce_test.py | 5 + .../python/distribute/device_util_test.py | 3 + .../python/distribute/input_ops_test.py | 12 + .../python/eager/function_gradients_test.py | 1 + tensorflow/python/eager/function_test.py | 1 + .../python/eager/graph_only_ops_test.py | 2 + .../feature_column/feature_column_test.py | 130 ++++++++++ .../feature_column/feature_column_v2_test.py | 141 +++++++++++ .../python/framework/file_system_test.py | 2 + .../framework/function_def_to_graph_test.py | 3 + tensorflow/python/framework/function_test.py | 26 ++ .../python/framework/graph_util_test.py | 2 + .../python/framework/meta_graph_test.py | 17 ++ tensorflow/python/framework/ops_test.py | 57 +++++ .../python/framework/smart_cond_test.py | 5 + .../python/framework/sparse_tensor_test.py | 2 + tensorflow/python/framework/subscribe_test.py | 10 + .../python/framework/tensor_spec_test.py | 4 + .../python/framework/tensor_util_test.py | 12 + tensorflow/python/framework/test_util_test.py | 5 + .../python/grappler/cost_analyzer_test.py | 4 + tensorflow/python/grappler/item_test.py | 2 + .../python/grappler/layout_optimizer_test.py | 3 + .../python/grappler/memory_optimizer_test.py | 3 + .../python/grappler/model_analyzer_test.py | 3 + .../python/grappler/tf_optimizer_test.py | 4 + tensorflow/python/keras/activations_test.py | 4 + tensorflow/python/keras/backend_test.py | 8 + tensorflow/python/keras/callbacks_test.py | 10 + tensorflow/python/keras/engine/saving_test.py | 8 + .../python/keras/engine/sequential_test.py | 2 + .../python/keras/engine/topology_test.py | 10 + .../keras/engine/training_dataset_test.py | 1 + .../python/keras/engine/training_test.py | 10 + tensorflow/python/keras/initializers_test.py | 11 + tensorflow/python/keras/integration_test.py | 8 + tensorflow/python/keras/layers/local_test.py | 4 + tensorflow/python/keras/layers/lstm_test.py | 4 + tensorflow/python/keras/layers/merge_test.py | 1 + .../python/keras/layers/normalization_test.py | 1 + .../python/keras/layers/simplernn_test.py | 3 + .../python/keras/layers/unified_rnn_test.py | 2 + .../python/keras/layers/wrappers_test.py | 4 + .../python/keras/model_subclassing_test.py | 4 + tensorflow/python/keras/models_test.py | 10 + .../keras/optimizer_v2/adadelta_test.py | 1 + .../python/keras/optimizer_v2/adagrad_test.py | 7 + .../python/keras/optimizer_v2/adam_test.py | 6 + .../python/keras/optimizer_v2/adamax_test.py | 5 + .../python/keras/optimizer_v2/ftrl_test.py | 14 ++ .../optimizer_v2/gradient_descent_test.py | 9 + .../python/keras/optimizer_v2/nadam_test.py | 5 + .../python/keras/optimizer_v2/rmsprop_test.py | 5 + tensorflow/python/keras/optimizers_test.py | 9 + tensorflow/python/keras/regularizers_test.py | 2 + .../python/kernel_tests/accumulate_n_test.py | 4 + .../python/kernel_tests/ackermann_test.py | 2 + .../python/kernel_tests/aggregate_ops_test.py | 3 + .../python/kernel_tests/argmax_op_test.py | 3 + .../python/kernel_tests/array_ops_test.py | 52 ++++ .../python/kernel_tests/as_string_op_test.py | 7 + .../python/kernel_tests/atrous_conv2d_test.py | 6 + .../python/kernel_tests/barrier_ops_test.py | 18 ++ .../python/kernel_tests/basic_gpu_test.py | 3 + .../kernel_tests/batch_gather_op_test.py | 4 + .../kernel_tests/batch_scatter_ops_test.py | 4 + .../kernel_tests/batchtospace_op_test.py | 21 ++ .../python/kernel_tests/bcast_ops_test.py | 6 + .../python/kernel_tests/betainc_op_test.py | 8 + .../python/kernel_tests/bias_op_test.py | 12 + .../python/kernel_tests/bincount_op_test.py | 7 + .../python/kernel_tests/bitcast_op_test.py | 2 + .../boosted_trees/prediction_ops_test.py | 15 ++ .../boosted_trees/quantile_ops_test.py | 4 + .../boosted_trees/resource_ops_test.py | 3 + .../boosted_trees/stats_ops_test.py | 1 + .../boosted_trees/training_ops_test.py | 10 + .../kernel_tests/broadcast_to_ops_test.py | 11 + .../python/kernel_tests/bucketize_op_test.py | 2 + .../candidate_sampler_ops_test.py | 3 + .../python/kernel_tests/cast_op_test.py | 9 + .../python/kernel_tests/check_ops_test.py | 45 ++++ .../kernel_tests/checkpoint_ops_test.py | 10 + .../python/kernel_tests/cholesky_op_test.py | 9 + .../python/kernel_tests/clip_ops_test.py | 10 + .../python/kernel_tests/concat_op_test.py | 26 ++ .../python/kernel_tests/cond_v2_test.py | 8 + .../conditional_accumulator_test.py | 24 ++ .../kernel_tests/confusion_matrix_test.py | 23 ++ .../python/kernel_tests/constant_op_test.py | 40 ++++ .../kernel_tests/control_flow_ops_py_test.py | 55 +++++ .../conv2d_backprop_filter_grad_test.py | 2 + .../kernel_tests/conv2d_transpose_test.py | 2 + .../conv3d_backprop_filter_v2_grad_test.py | 2 + .../kernel_tests/conv3d_transpose_test.py | 3 + .../python/kernel_tests/conv_ops_3d_test.py | 17 ++ .../python/kernel_tests/cross_grad_test.py | 2 + .../kernel_tests/ctc_decoder_ops_test.py | 3 + .../python/kernel_tests/ctc_loss_op_test.py | 23 ++ .../kernel_tests/cwise_ops_binary_test.py | 73 ++++++ .../python/kernel_tests/cwise_ops_test.py | 15 ++ .../kernel_tests/cwise_ops_unary_test.py | 8 + .../kernel_tests/decode_compressed_op_test.py | 3 + .../kernel_tests/decode_image_op_test.py | 4 + .../python/kernel_tests/decode_raw_op_test.py | 7 + .../python/kernel_tests/denormal_test.py | 3 + .../dense_update_ops_no_tsan_test.py | 5 + .../kernel_tests/dense_update_ops_test.py | 5 + .../kernel_tests/depthtospace_op_test.py | 17 ++ .../python/kernel_tests/diag_op_test.py | 26 ++ .../distributions/bernoulli_test.py | 5 + .../distributions/bijector_test.py | 2 + .../distributions/categorical_test.py | 17 ++ .../dirichlet_multinomial_test.py | 13 + .../distributions/identity_bijector_test.py | 2 + .../distributions/kullback_leibler_test.py | 2 + .../kernel_tests/distributions/normal_test.py | 1 + .../distributions/special_math_test.py | 9 + .../kernel_tests/distributions/util_test.py | 48 ++++ .../python/kernel_tests/duplicate_op_test.py | 2 + .../kernel_tests/dynamic_partition_op_test.py | 8 + .../kernel_tests/dynamic_stitch_op_test.py | 8 + .../python/kernel_tests/embedding_ops_test.py | 44 ++++ .../extract_image_patches_grad_test.py | 3 + .../fractional_avg_pool_op_test.py | 5 + .../fractional_max_pool_op_test.py | 5 + .../kernel_tests/functional_ops_test.py | 33 +++ .../python/kernel_tests/gather_nd_op_test.py | 11 + .../python/kernel_tests/gather_op_test.py | 8 + .../kernel_tests/gradient_correctness_test.py | 11 + .../kernel_tests/identity_n_op_py_test.py | 4 + .../kernel_tests/identity_op_py_test.py | 5 + .../python/kernel_tests/init_ops_test.py | 59 +++++ .../python/kernel_tests/inplace_ops_test.py | 7 + tensorflow/python/kernel_tests/io_ops_test.py | 3 + .../linalg/linear_operator_addition_test.py | 13 + .../linalg/linear_operator_circulant_test.py | 20 ++ .../linear_operator_composition_test.py | 4 + .../linalg/linear_operator_diag_test.py | 4 + .../linear_operator_full_matrix_test.py | 2 + .../linalg/linear_operator_identity_test.py | 15 ++ .../linalg/linear_operator_kronecker_test.py | 2 + .../linalg/linear_operator_test.py | 9 + .../linalg/linear_operator_util_test.py | 25 ++ .../linalg/linear_operator_zeros_test.py | 7 + .../python/kernel_tests/linalg_grad_test.py | 2 + .../python/kernel_tests/linalg_ops_test.py | 5 + .../python/kernel_tests/list_ops_test.py | 15 ++ .../python/kernel_tests/logging_ops_test.py | 4 + .../python/kernel_tests/lookup_ops_test.py | 64 +++++ tensorflow/python/kernel_tests/losses_test.py | 62 +++++ tensorflow/python/kernel_tests/lrn_op_test.py | 4 + .../python/kernel_tests/manip_ops_test.py | 12 + .../python/kernel_tests/map_stage_op_test.py | 13 + .../python/kernel_tests/matmul_op_test.py | 4 + .../matrix_exponential_op_test.py | 4 + .../kernel_tests/matrix_solve_ls_op_test.py | 4 + .../kernel_tests/matrix_solve_op_test.py | 6 + .../matrix_triangular_solve_op_test.py | 7 + .../python/kernel_tests/metrics_test.py | 226 ++++++++++++++++++ .../kernel_tests/morphological_ops_test.py | 3 + .../neon_depthwise_conv_op_test.py | 3 + .../kernel_tests/nth_element_op_test.py | 8 + .../python/kernel_tests/numerics_test.py | 5 + tensorflow/python/kernel_tests/pad_op_test.py | 12 + .../parameterized_truncated_normal_op_test.py | 11 + .../parse_single_example_op_test.py | 7 + .../python/kernel_tests/parsing_ops_test.py | 18 ++ .../partitioned_variables_test.py | 13 + tensorflow/python/kernel_tests/pool_test.py | 4 + .../kernel_tests/pooling_ops_3d_test.py | 19 ++ .../python/kernel_tests/pooling_ops_test.py | 12 + .../python/kernel_tests/py_func_test.py | 2 + tensorflow/python/kernel_tests/qr_op_test.py | 2 + .../random/multinomial_op_big_test.py | 2 + .../random/multinomial_op_test.py | 3 + .../kernel_tests/random/random_crop_test.py | 3 + .../kernel_tests/random/random_gamma_test.py | 6 + .../kernel_tests/random/random_grad_test.py | 11 + .../kernel_tests/random/random_ops_test.py | 22 ++ .../random/random_poisson_test.py | 6 + .../random/stateless_random_ops_test.py | 6 + .../python/kernel_tests/reader_ops_test.py | 25 ++ .../python/kernel_tests/record_input_test.py | 4 + .../kernel_tests/reduce_join_op_test.py | 6 + .../python/kernel_tests/reduction_ops_test.py | 57 +++++ .../kernel_tests/regex_full_match_op_test.py | 7 + .../kernel_tests/regex_replace_op_test.py | 9 + .../python/kernel_tests/relu_op_test.py | 21 ++ .../python/kernel_tests/reshape_op_test.py | 4 + .../resource_variable_ops_test.py | 19 ++ .../kernel_tests/reverse_sequence_op_test.py | 3 + tensorflow/python/kernel_tests/rnn_test.py | 10 + .../kernel_tests/save_restore_ops_test.py | 3 + .../python/kernel_tests/scan_ops_test.py | 24 ++ .../kernel_tests/scatter_nd_ops_test.py | 29 +++ .../python/kernel_tests/scatter_ops_test.py | 28 +++ .../segment_reduction_ops_test.py | 32 +++ tensorflow/python/kernel_tests/sets_test.py | 16 ++ .../python/kernel_tests/shape_ops_test.py | 21 ++ .../kernel_tests/signal/dct_ops_test.py | 2 + .../kernel_tests/signal/fft_ops_test.py | 16 ++ .../kernel_tests/signal/mel_ops_test.py | 4 + .../kernel_tests/signal/mfcc_ops_test.py | 4 + .../signal/reconstruction_ops_test.py | 5 + .../kernel_tests/signal/shape_ops_test.py | 12 + .../kernel_tests/signal/window_ops_test.py | 3 + .../python/kernel_tests/slice_op_test.py | 8 + .../python/kernel_tests/softmax_op_test.py | 3 + .../python/kernel_tests/softplus_op_test.py | 5 + .../python/kernel_tests/softsign_op_test.py | 3 + .../kernel_tests/spacetobatch_op_test.py | 36 +++ .../kernel_tests/spacetodepth_op_test.py | 11 + .../python/kernel_tests/sparse_add_op_test.py | 3 + .../kernel_tests/sparse_concat_op_test.py | 5 + .../sparse_conditional_accumulator_test.py | 24 ++ .../kernel_tests/sparse_cross_op_test.py | 18 ++ .../kernel_tests/sparse_matmul_op_test.py | 7 + .../python/kernel_tests/sparse_ops_test.py | 32 +++ .../kernel_tests/sparse_reorder_op_test.py | 4 + .../kernel_tests/sparse_reshape_op_test.py | 18 ++ .../sparse_serialization_ops_test.py | 25 ++ .../kernel_tests/sparse_slice_op_test.py | 8 + .../kernel_tests/sparse_split_op_test.py | 8 + .../sparse_tensor_dense_matmul_grad_test.py | 2 + .../sparse_tensor_dense_matmul_op_test.py | 4 + .../sparse_tensors_map_ops_test.py | 6 + .../sparse_to_dense_op_py_test.py | 18 ++ .../kernel_tests/sparse_xent_op_test.py | 10 +- .../python/kernel_tests/sparsemask_op_test.py | 2 + .../python/kernel_tests/split_op_test.py | 7 + .../python/kernel_tests/stack_op_test.py | 17 ++ .../python/kernel_tests/stack_ops_test.py | 15 ++ .../python/kernel_tests/stage_op_test.py | 8 + .../kernel_tests/string_join_op_test.py | 2 + .../kernel_tests/string_length_op_test.py | 3 + .../kernel_tests/string_split_op_test.py | 5 + .../string_to_hash_bucket_op_test.py | 5 + .../kernel_tests/string_to_number_op_test.py | 5 + .../python/kernel_tests/substr_op_test.py | 9 + .../kernel_tests/summary_v1_image_op_test.py | 3 + .../kernel_tests/summary_v1_ops_test.py | 2 + .../python/kernel_tests/template_test.py | 5 + .../kernel_tests/tensor_array_ops_test.py | 42 ++++ .../python/kernel_tests/topk_op_test.py | 4 + .../python/kernel_tests/trace_op_test.py | 2 + .../kernel_tests/unicode_decode_op_test.py | 4 + .../kernel_tests/unicode_script_op_test.py | 3 + .../kernel_tests/unicode_transcode_op_test.py | 7 + .../python/kernel_tests/unstack_op_test.py | 6 + .../python/kernel_tests/variable_ops_test.py | 22 ++ .../kernel_tests/variable_scope_test.py | 14 ++ .../python/kernel_tests/variables_test.py | 27 +++ .../kernel_tests/weights_broadcast_test.py | 31 +++ .../python/kernel_tests/where_op_test.py | 17 ++ .../python/kernel_tests/while_v2_test.py | 15 ++ .../python/kernel_tests/xent_op_test.py | 7 + .../python/kernel_tests/zero_division_test.py | 1 + tensorflow/python/layers/base_test.py | 4 + .../python/layers/convolutional_test.py | 56 +++++ tensorflow/python/layers/core_test.py | 19 ++ .../python/layers/normalization_test.py | 37 +++ tensorflow/python/layers/pooling_test.py | 4 + tensorflow/python/ops/bitwise_ops_test.py | 6 + tensorflow/python/ops/clip_ops_test.py | 2 + tensorflow/python/ops/collective_ops_test.py | 5 + .../python/ops/gradient_checker_test.py | 14 ++ tensorflow/python/ops/histogram_ops_test.py | 4 + tensorflow/python/ops/image_grad_test.py | 12 + tensorflow/python/ops/image_ops_test.py | 92 +++++++ tensorflow/python/ops/losses/util_test.py | 2 + tensorflow/python/ops/math_grad_test.py | 26 ++ tensorflow/python/ops/math_ops_test.py | 24 ++ tensorflow/python/ops/nn_batchnorm_test.py | 14 ++ tensorflow/python/ops/nn_grad_test.py | 2 + tensorflow/python/ops/nn_test.py | 20 ++ tensorflow/python/ops/nn_xent_test.py | 6 + ...vert_to_tensor_or_ragged_tensor_op_test.py | 2 + .../ops/ragged/ragged_batch_gather_op_test.py | 3 + .../ops/ragged/ragged_boolean_mask_op_test.py | 2 + .../ops/ragged/ragged_concat_op_test.py | 5 + .../python/ops/ragged/ragged_const_op_test.py | 2 + .../ops/ragged/ragged_elementwise_ops_test.py | 1 + .../ops/ragged/ragged_expand_dims_op_test.py | 1 + .../ops/ragged/ragged_from_sparse_op_test.py | 5 + .../ops/ragged/ragged_from_tensor_op_test.py | 5 + .../ops/ragged/ragged_gather_nd_op_test.py | 3 + .../ops/ragged/ragged_gather_op_test.py | 10 + .../ops/ragged/ragged_map_fn_op_test.py | 5 + .../ragged/ragged_map_inner_values_op_test.py | 13 + .../ops/ragged/ragged_operators_test.py | 3 + .../python/ops/ragged/ragged_range_op_test.py | 9 + .../ops/ragged/ragged_reduce_op_test.py | 4 + .../ops/ragged/ragged_row_lengths_op_test.py | 1 + ...agged_row_splits_to_segment_ids_op_test.py | 3 + ...agged_segment_ids_to_row_splits_op_test.py | 4 + .../ops/ragged/ragged_segment_op_test.py | 5 + .../python/ops/ragged/ragged_stack_op_test.py | 2 + .../python/ops/ragged/ragged_tensor_test.py | 33 +++ .../python/ops/ragged/ragged_tile_op_test.py | 2 + .../ops/ragged/ragged_to_sparse_op_test.py | 7 + .../ops/ragged/ragged_to_tensor_op_test.py | 3 + .../python/ops/ragged/ragged_where_op_test.py | 1 + tensorflow/python/ops/sort_ops_test.py | 10 + .../python/ops/special_math_ops_test.py | 7 + .../profiler/internal/run_metadata_test.py | 3 + .../python/profiler/pprof_profiler_test.py | 2 + .../python/profiler/profile_context_test.py | 4 + tensorflow/python/profiler/profiler_test.py | 3 + tensorflow/python/saved_model/loader_test.py | 7 + tensorflow/python/saved_model/save_test.py | 1 + .../python/saved_model/saved_model_test.py | 31 +++ .../saved_model/signature_def_utils_test.py | 9 + .../python/saved_model/simple_save_test.py | 2 + tensorflow/python/summary/summary_test.py | 13 + .../python/summary/writer/writer_test.py | 15 ++ tensorflow/python/tools/freeze_graph_test.py | 2 + .../tools/optimize_for_inference_test.py | 5 + tensorflow/python/training/adadelta_test.py | 1 + tensorflow/python/training/adagrad_da_test.py | 7 + tensorflow/python/training/adagrad_test.py | 9 + tensorflow/python/training/adam_test.py | 6 + .../python/training/basic_loops_test.py | 4 + .../training/basic_session_run_hooks_test.py | 9 + .../training/checkpoint_management_test.py | 5 + .../python/training/device_setter_test.py | 11 + tensorflow/python/training/ftrl_test.py | 14 ++ .../python/training/gradient_descent_test.py | 10 + tensorflow/python/training/input_test.py | 108 +++++++++ .../training/learning_rate_decay_test.py | 2 + .../training/learning_rate_decay_v2_test.py | 1 + tensorflow/python/training/momentum_test.py | 6 + .../python/training/monitored_session_test.py | 27 +++ .../python/training/moving_averages_test.py | 23 ++ tensorflow/python/training/optimizer_test.py | 4 + .../python/training/proximal_adagrad_test.py | 9 + .../proximal_gradient_descent_test.py | 8 + .../python/training/quantize_training_test.py | 2 + .../python/training/queue_runner_test.py | 16 ++ tensorflow/python/training/rmsprop_test.py | 6 + tensorflow/python/training/saver_test.py | 35 +++ .../server_lib_multiple_containers_test.py | 2 + ...lib_same_variables_clear_container_test.py | 2 + .../server_lib_same_variables_clear_test.py | 2 + ...server_lib_same_variables_no_clear_test.py | 2 + .../training/server_lib_sparse_job_test.py | 2 + .../python/training/session_manager_test.py | 15 ++ .../python/training/slot_creator_test.py | 8 + tensorflow/python/training/supervisor_test.py | 12 + .../python/training/training_ops_test.py | 8 + .../python/training/training_util_test.py | 3 + tensorflow/python/util/deprecation_test.py | 16 ++ tensorflow/python/util/nest_test.py | 1 + tensorflow/python/util/tf_should_use_test.py | 7 + .../tools/api/tests/api_compatibility_test.py | 3 + 431 files changed, 4673 insertions(+), 1 deletion(-) diff --git a/tensorflow/examples/adding_an_op/fact_test.py b/tensorflow/examples/adding_an_op/fact_test.py index 11163e7ba5c..46beaebe0cc 100644 --- a/tensorflow/examples/adding_an_op/fact_test.py +++ b/tensorflow/examples/adding_an_op/fact_test.py @@ -19,10 +19,12 @@ from __future__ import division from __future__ import print_function import tensorflow as tf +from tensorflow.python.framework import test_util class FactTest(tf.test.TestCase): + @test_util.run_deprecated_v1 def test(self): with self.cached_session(): print(tf.user_ops.my_fact().eval()) diff --git a/tensorflow/examples/adding_an_op/zero_out_1_test.py b/tensorflow/examples/adding_an_op/zero_out_1_test.py index 342d3a020cc..459ac2dc279 100644 --- a/tensorflow/examples/adding_an_op/zero_out_1_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_1_test.py @@ -23,10 +23,12 @@ import os.path import tensorflow as tf from tensorflow.examples.adding_an_op import zero_out_op_1 +from tensorflow.python.framework import test_util class ZeroOut1Test(tf.test.TestCase): + @test_util.run_deprecated_v1 def test(self): with self.cached_session(): result = zero_out_op_1.zero_out([5, 4, 3, 2, 1]) diff --git a/tensorflow/examples/adding_an_op/zero_out_2_test.py b/tensorflow/examples/adding_an_op/zero_out_2_test.py index 45045978176..650fd9546b5 100644 --- a/tensorflow/examples/adding_an_op/zero_out_2_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_2_test.py @@ -24,20 +24,24 @@ import tensorflow as tf from tensorflow.examples.adding_an_op import zero_out_grad_2 # pylint: disable=unused-import from tensorflow.examples.adding_an_op import zero_out_op_2 +from tensorflow.python.framework import test_util class ZeroOut2Test(tf.test.TestCase): + @test_util.run_deprecated_v1 def test(self): with self.cached_session(): result = zero_out_op_2.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0]) + @test_util.run_deprecated_v1 def test_2d(self): with self.cached_session(): result = zero_out_op_2.zero_out([[6, 5, 4], [3, 2, 1]]) self.assertAllEqual(result.eval(), [[6, 0, 0], [0, 0, 0]]) + @test_util.run_deprecated_v1 def test_grad(self): with self.cached_session(): shape = (5,) @@ -46,6 +50,7 @@ class ZeroOut2Test(tf.test.TestCase): err = tf.test.compute_gradient_error(x, shape, y, shape) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def test_grad_2d(self): with self.cached_session(): shape = (2, 3) diff --git a/tensorflow/examples/adding_an_op/zero_out_3_test.py b/tensorflow/examples/adding_an_op/zero_out_3_test.py index 2327e7cd8fa..8cbe2b6793a 100644 --- a/tensorflow/examples/adding_an_op/zero_out_3_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_3_test.py @@ -21,26 +21,31 @@ from __future__ import print_function import tensorflow as tf from tensorflow.examples.adding_an_op import zero_out_op_3 +from tensorflow.python.framework import test_util class ZeroOut3Test(tf.test.TestCase): + @test_util.run_deprecated_v1 def test(self): with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0]) + @test_util.run_deprecated_v1 def testAttr(self): with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=3) self.assertAllEqual(result.eval(), [0, 0, 0, 2, 0]) + @test_util.run_deprecated_v1 def testNegative(self): with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=-1) with self.assertRaisesOpError("Need preserve_index >= 0, got -1"): self.evaluate(result) + @test_util.run_deprecated_v1 def testLarge(self): with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=17) diff --git a/tensorflow/examples/autograph/integration_tests/keras_test.py b/tensorflow/examples/autograph/integration_tests/keras_test.py index fc0b0736965..3fe33df920d 100644 --- a/tensorflow/examples/autograph/integration_tests/keras_test.py +++ b/tensorflow/examples/autograph/integration_tests/keras_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import tensorflow as tf from tensorflow.python import autograph +from tensorflow.python.framework import test_util class MinimalKeras(tf.keras.Model): @@ -84,6 +85,7 @@ class KerasTest(tf.test.TestCase): model = ModelWithStaticConditional(True) self.assertEqual(model.call(), 25) + @test_util.run_deprecated_v1 def test_recursive_true(self): with self.assertRaisesRegexp(NotImplementedError, 'Object conversion is not yet supported.'): diff --git a/tensorflow/examples/speech_commands/freeze_test.py b/tensorflow/examples/speech_commands/freeze_test.py index 0c7ca9bc011..9ed9050035b 100644 --- a/tensorflow/examples/speech_commands/freeze_test.py +++ b/tensorflow/examples/speech_commands/freeze_test.py @@ -19,11 +19,13 @@ from __future__ import division from __future__ import print_function from tensorflow.examples.speech_commands import freeze +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class FreezeTest(test.TestCase): + @test_util.run_deprecated_v1 def testCreateInferenceGraphWithMfcc(self): with self.cached_session() as sess: freeze.create_inference_graph( @@ -43,6 +45,7 @@ class FreezeTest(test.TestCase): ops = [node.op for node in sess.graph_def.node] self.assertEqual(1, ops.count('Mfcc')) + @test_util.run_deprecated_v1 def testCreateInferenceGraphWithoutMfcc(self): with self.cached_session() as sess: freeze.create_inference_graph( @@ -62,6 +65,7 @@ class FreezeTest(test.TestCase): ops = [node.op for node in sess.graph_def.node] self.assertEqual(0, ops.count('Mfcc')) + @test_util.run_deprecated_v1 def testFeatureBinCount(self): with self.cached_session() as sess: freeze.create_inference_graph( diff --git a/tensorflow/examples/speech_commands/input_data_test.py b/tensorflow/examples/speech_commands/input_data_test.py index 33b58b9d09b..9269bb6c0bc 100644 --- a/tensorflow/examples/speech_commands/input_data_test.py +++ b/tensorflow/examples/speech_commands/input_data_test.py @@ -26,6 +26,7 @@ import tensorflow as tf from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio from tensorflow.examples.speech_commands import input_data from tensorflow.examples.speech_commands import models +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -96,6 +97,7 @@ class InputDataTest(test.TestCase): input_data.which_set("foo_nohash_0.wav", 10, 10), input_data.which_set("foo_nohash_1.wav", 10, 10)) + @test_util.run_deprecated_v1 def testPrepareDataIndex(self): tmp_dir = self.get_temp_dir() self._saveWavFolders(tmp_dir, ["a", "b", "c"], 100) @@ -125,6 +127,7 @@ class InputDataTest(test.TestCase): 10, self._model_settings(), tmp_dir) self.assertTrue("Expected to find" in str(e.exception)) + @test_util.run_deprecated_v1 def testPrepareBackgroundData(self): tmp_dir = self.get_temp_dir() background_dir = os.path.join(tmp_dir, "_background_noise_") @@ -156,6 +159,7 @@ class InputDataTest(test.TestCase): self.assertIsNotNone(loaded_data) self.assertEqual(16000, len(loaded_data)) + @test_util.run_deprecated_v1 def testPrepareProcessingGraph(self): tmp_dir = self.get_temp_dir() wav_dir = os.path.join(tmp_dir, "wavs") @@ -186,15 +190,19 @@ class InputDataTest(test.TestCase): self.assertIsNotNone(audio_processor.background_volume_placeholder_) self.assertIsNotNone(audio_processor.output_) + @test_util.run_deprecated_v1 def testGetDataAverage(self): self._runGetDataTest("average", 10) + @test_util.run_deprecated_v1 def testGetDataAverageLongWindow(self): self._runGetDataTest("average", 30) + @test_util.run_deprecated_v1 def testGetDataMfcc(self): self._runGetDataTest("mfcc", 30) + @test_util.run_deprecated_v1 def testGetUnprocessedData(self): tmp_dir = self.get_temp_dir() wav_dir = os.path.join(tmp_dir, "wavs") @@ -216,6 +224,7 @@ class InputDataTest(test.TestCase): self.assertEqual(10, len(result_data)) self.assertEqual(10, len(result_labels)) + @test_util.run_deprecated_v1 def testGetFeaturesForWav(self): tmp_dir = self.get_temp_dir() wav_dir = os.path.join(tmp_dir, "wavs") diff --git a/tensorflow/examples/speech_commands/models_test.py b/tensorflow/examples/speech_commands/models_test.py index 04478c09626..cb9304eab8d 100644 --- a/tensorflow/examples/speech_commands/models_test.py +++ b/tensorflow/examples/speech_commands/models_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import tensorflow as tf from tensorflow.examples.speech_commands import models +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -47,6 +48,7 @@ class ModelsTest(test.TestCase): feature_bin_count=40, preprocess="mfcc")) + @test_util.run_deprecated_v1 def testCreateModelConvTraining(self): model_settings = self._modelSettings() with self.cached_session() as sess: @@ -58,6 +60,7 @@ class ModelsTest(test.TestCase): self.assertIsNotNone(sess.graph.get_tensor_by_name(logits.name)) self.assertIsNotNone(sess.graph.get_tensor_by_name(dropout_prob.name)) + @test_util.run_deprecated_v1 def testCreateModelConvInference(self): model_settings = self._modelSettings() with self.cached_session() as sess: @@ -67,6 +70,7 @@ class ModelsTest(test.TestCase): self.assertIsNotNone(logits) self.assertIsNotNone(sess.graph.get_tensor_by_name(logits.name)) + @test_util.run_deprecated_v1 def testCreateModelLowLatencyConvTraining(self): model_settings = self._modelSettings() with self.cached_session() as sess: @@ -78,6 +82,7 @@ class ModelsTest(test.TestCase): self.assertIsNotNone(sess.graph.get_tensor_by_name(logits.name)) self.assertIsNotNone(sess.graph.get_tensor_by_name(dropout_prob.name)) + @test_util.run_deprecated_v1 def testCreateModelFullyConnectedTraining(self): model_settings = self._modelSettings() with self.cached_session() as sess: @@ -98,6 +103,7 @@ class ModelsTest(test.TestCase): "bad_architecture", True) self.assertTrue("not recognized" in str(e.exception)) + @test_util.run_deprecated_v1 def testCreateModelTinyConvTraining(self): model_settings = self._modelSettings() with self.cached_session() as sess: diff --git a/tensorflow/examples/speech_commands/wav_to_features_test.py b/tensorflow/examples/speech_commands/wav_to_features_test.py index cb8ea912fa2..6234490b267 100644 --- a/tensorflow/examples/speech_commands/wav_to_features_test.py +++ b/tensorflow/examples/speech_commands/wav_to_features_test.py @@ -24,6 +24,7 @@ import tensorflow as tf from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio from tensorflow.examples.speech_commands import wav_to_features +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -49,6 +50,7 @@ class WavToFeaturesTest(test.TestCase): file_path = os.path.join(dir_name, "some_audio_%d.wav" % i) self._saveTestWavFile(file_path, wav_data) + @test_util.run_deprecated_v1 def testWavToFeatures(self): tmp_dir = self.get_temp_dir() wav_dir = os.path.join(tmp_dir, "wavs") diff --git a/tensorflow/python/autograph/converters/asserts_test.py b/tensorflow/python/autograph/converters/asserts_test.py index 803b6a06dab..9ae448892a0 100644 --- a/tensorflow/python/autograph/converters/asserts_test.py +++ b/tensorflow/python/autograph/converters/asserts_test.py @@ -23,12 +23,14 @@ from tensorflow.python.autograph.converters import side_effect_guards from tensorflow.python.autograph.core import converter_testing from tensorflow.python.framework import constant_op from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_control_flow_ops from tensorflow.python.platform import test class AssertsTest(converter_testing.TestCase): + @test_util.run_deprecated_v1 def test_basic(self): def test_fn(a): diff --git a/tensorflow/python/autograph/converters/builtin_functions_test.py b/tensorflow/python/autograph/converters/builtin_functions_test.py index 30cfb13233a..2683be16ec7 100644 --- a/tensorflow/python/autograph/converters/builtin_functions_test.py +++ b/tensorflow/python/autograph/converters/builtin_functions_test.py @@ -24,12 +24,14 @@ from tensorflow.python.autograph.converters import builtin_functions from tensorflow.python.autograph.core import converter_testing from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test class BuiltinFunctionsTest(converter_testing.TestCase): + @test_util.run_deprecated_v1 def test_len(self): def test_fn(a): @@ -41,6 +43,7 @@ class BuiltinFunctionsTest(converter_testing.TestCase): ops = result.test_fn(p) self.assertEqual(sess.run(ops, {p: [0, 0, 0]}), 3) + @test_util.run_deprecated_v1 def test_print(self): if six.PY2: @@ -54,6 +57,7 @@ class BuiltinFunctionsTest(converter_testing.TestCase): with self.assertPrints('a\n'): sess.run(result.test_fn('a')) + @test_util.run_deprecated_v1 def test_print_multiple_values(self): if six.PY2: diff --git a/tensorflow/python/autograph/converters/control_flow_test.py b/tensorflow/python/autograph/converters/control_flow_test.py index 03fdfc804e4..034fcbe3865 100644 --- a/tensorflow/python/autograph/converters/control_flow_test.py +++ b/tensorflow/python/autograph/converters/control_flow_test.py @@ -23,6 +23,7 @@ from tensorflow.python.autograph.core import converter_testing from tensorflow.python.autograph.pyct import transformer from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -36,6 +37,7 @@ class ControlFlowTest(converter_testing.TestCase): with self.cached_session() as sess: self.assertEqual(sess.run(result.test_fn(*inputs)), expected) + @test_util.run_deprecated_v1 def test_while_basic(self): def test_fn(n): @@ -48,6 +50,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(5), (10, 5, 5)) + @test_util.run_deprecated_v1 def test_while_nested(self): def test_fn(n): @@ -66,6 +69,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(5), (25, 5, 0, 5)) + @test_util.run_deprecated_v1 def test_while_single_output(self): def test_fn(n): @@ -86,6 +90,7 @@ class ControlFlowTest(converter_testing.TestCase): with self.assertRaises(NameError): control_flow.transform(node, ctx) + @test_util.run_deprecated_v1 def test_if_basic(self): def test_fn(n): @@ -100,6 +105,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(1), (-1, 0)) self.assertTransformedResult(test_fn, constant_op.constant(-1), (0, -2)) + @test_util.run_deprecated_v1 def test_if_complex_outputs(self): class TestClass(object): @@ -124,6 +130,7 @@ class ControlFlowTest(converter_testing.TestCase): res_obj = result.test_fn(constant_op.constant(-1), TestClass(0, 0)) self.assertEqual(sess.run((res_obj.a, res_obj.b)), (0, -2)) + @test_util.run_deprecated_v1 def test_if_single_output(self): def test_fn(n): @@ -133,6 +140,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(1), -1) + @test_util.run_deprecated_v1 def test_if_semi(self): def test_fn(n): @@ -143,6 +151,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(2), 3) self.assertTransformedResult(test_fn, constant_op.constant(-3), -3) + @test_util.run_deprecated_v1 def test_if_local_var(self): def test_fn(n): @@ -154,6 +163,7 @@ class ControlFlowTest(converter_testing.TestCase): self.assertTransformedResult(test_fn, constant_op.constant(1), 5) self.assertTransformedResult(test_fn, constant_op.constant(-1), -1) + @test_util.run_deprecated_v1 def test_if_no_outputs(self): def test_fn(n): @@ -177,6 +187,7 @@ class ControlFlowTest(converter_testing.TestCase): with self.assertRaises(transformer.AutographParseError): control_flow.transform(node, ctx) + @test_util.run_deprecated_v1 def test_simple_for(self): def test_fn(l): @@ -191,6 +202,7 @@ class ControlFlowTest(converter_testing.TestCase): empty_vector = constant_op.constant([], shape=(0,), dtype=dtypes.int32) self.assertTransformedResult(test_fn, empty_vector, (0, 0)) + @test_util.run_deprecated_v1 def test_for_single_output(self): def test_fn(l): @@ -235,6 +247,7 @@ class ControlFlowTest(converter_testing.TestCase): with self.assertRaises(NameError): control_flow.transform(node, ctx) + @test_util.run_deprecated_v1 def test_for_tuple_unpacking(self): def test_fn(x_list): z = tf.constant(0) # pylint:disable=undefined-variable diff --git a/tensorflow/python/autograph/converters/function_scopes_test.py b/tensorflow/python/autograph/converters/function_scopes_test.py index e5ce03a1090..5a1248c8015 100644 --- a/tensorflow/python/autograph/converters/function_scopes_test.py +++ b/tensorflow/python/autograph/converters/function_scopes_test.py @@ -22,11 +22,13 @@ from tensorflow.python.autograph.converters import function_scopes from tensorflow.python.autograph.core import converter_testing from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class FunctionBodyTransformerTest(converter_testing.TestCase): + @test_util.run_deprecated_v1 def test_basic(self): def test_fn(l): @@ -40,6 +42,7 @@ class FunctionBodyTransformerTest(converter_testing.TestCase): self.assertIn('test_fn/', result_op.op.name) self.assertEqual('Docstring.', result.test_fn.__doc__) + @test_util.run_deprecated_v1 def test_multiline_docstring(self): tf = None @@ -58,6 +61,7 @@ class FunctionBodyTransformerTest(converter_testing.TestCase): self.assertIn('First sentence.', result.test_fn.__doc__) self.assertIn('Second sentence.', result.test_fn.__doc__) + @test_util.run_deprecated_v1 def test_nested_functions(self): def test_fn(l): @@ -74,6 +78,7 @@ class FunctionBodyTransformerTest(converter_testing.TestCase): self.assertNotIn('inner_fn', first.op.name) self.assertIn('test_fn/inner_fn/', second.op.name) + @test_util.run_deprecated_v1 def test_method(self): class TestClass(object): diff --git a/tensorflow/python/autograph/converters/logical_expressions_test.py b/tensorflow/python/autograph/converters/logical_expressions_test.py index 99db04a7751..687412750e0 100644 --- a/tensorflow/python/autograph/converters/logical_expressions_test.py +++ b/tensorflow/python/autograph/converters/logical_expressions_test.py @@ -21,11 +21,13 @@ from __future__ import print_function from tensorflow.python.autograph.converters import logical_expressions from tensorflow.python.autograph.core import converter_testing from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class LogicalExpressionTest(converter_testing.TestCase): + @test_util.run_deprecated_v1 def test_equals(self): def test_fn(a, b): @@ -36,6 +38,7 @@ class LogicalExpressionTest(converter_testing.TestCase): self.assertTrue(sess.run(result.test_fn(constant_op.constant(1), 1))) self.assertFalse(sess.run(result.test_fn(constant_op.constant(1), 2))) + @test_util.run_deprecated_v1 def test_bool_ops(self): def test_fn(a, b, c): @@ -48,6 +51,7 @@ class LogicalExpressionTest(converter_testing.TestCase): self.assertFalse( sess.run(result.test_fn(constant_op.constant(True), False, True))) + @test_util.run_deprecated_v1 def test_comparison(self): def test_fn(a, b, c, d): diff --git a/tensorflow/python/autograph/converters/side_effect_guards_test.py b/tensorflow/python/autograph/converters/side_effect_guards_test.py index f6d0f73b5b9..645267e5600 100644 --- a/tensorflow/python/autograph/converters/side_effect_guards_test.py +++ b/tensorflow/python/autograph/converters/side_effect_guards_test.py @@ -23,6 +23,7 @@ from tensorflow.python.autograph.core import converter_testing from tensorflow.python.framework import constant_op from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import state_ops from tensorflow.python.ops import variable_scope @@ -34,6 +35,7 @@ tf = None # Will be replaced by a mock. class SideEffectGuardsTest(converter_testing.TestCase): + @test_util.run_deprecated_v1 def test_side_effect_on_return_only_variable(self): def test_fn(a): @@ -75,6 +77,7 @@ class SideEffectGuardsTest(converter_testing.TestCase): # Right now it's 3 or 4 based on whether the read is synchronized. self.assertEqual(3, self.evaluate(v)) + @test_util.run_deprecated_v1 def test_side_effect_on_tensor(self): def test_fn(a): diff --git a/tensorflow/python/autograph/core/errors_test.py b/tensorflow/python/autograph/core/errors_test.py index 00c8a726eda..845a28a5222 100644 --- a/tensorflow/python/autograph/core/errors_test.py +++ b/tensorflow/python/autograph/core/errors_test.py @@ -22,6 +22,7 @@ from tensorflow.python.autograph.core import errors from tensorflow.python.autograph.pyct import origin_info from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors as tf_errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test from tensorflow.python.util import tf_inspect @@ -47,6 +48,7 @@ class RuntimeErrorsTest(test.TestCase): 'test_comment') return loc, origin + @test_util.run_deprecated_v1 def test_improved_errors_basic(self): loc, origin = self.fake_origin(zero_div, 2) zero_div_caller.ag_source_map = {loc: origin} @@ -62,6 +64,7 @@ class RuntimeErrorsTest(test.TestCase): self.assertNotEqual('zero_div', function_name) self.assertIn(origin.as_frame(), set(cm.exception.custom_traceback)) + @test_util.run_deprecated_v1 def test_improved_errors_no_matching_lineno(self): loc, origin = self.fake_origin(zero_div, -1) zero_div_caller.ag_source_map = {loc: origin} @@ -79,6 +82,7 @@ class RuntimeErrorsTest(test.TestCase): self.assertNotEqual('test_function_name', function_name) self.assertIn('zero_div', all_function_names) + @test_util.run_deprecated_v1 def test_improved_errors_failures(self): loc, _ = self.fake_origin(zero_div, 2) zero_div_caller.ag_source_map = {loc: 'bogus object'} diff --git a/tensorflow/python/autograph/core/function_wrapping_test.py b/tensorflow/python/autograph/core/function_wrapping_test.py index 5e217055c71..7e21b979dbc 100644 --- a/tensorflow/python/autograph/core/function_wrapping_test.py +++ b/tensorflow/python/autograph/core/function_wrapping_test.py @@ -20,11 +20,13 @@ from __future__ import print_function from tensorflow.python.autograph.core import function_wrapping from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class FunctionWrappingTest(test.TestCase): + @test_util.run_deprecated_v1 def test_function_scope_name(self): with function_wrapping.function_scope('test_name'): t = constant_op.constant(1) diff --git a/tensorflow/python/autograph/impl/api_test.py b/tensorflow/python/autograph/impl/api_test.py index a0fa501fb83..66edda51193 100644 --- a/tensorflow/python/autograph/impl/api_test.py +++ b/tensorflow/python/autograph/impl/api_test.py @@ -29,6 +29,7 @@ from tensorflow.python.autograph.impl import api from tensorflow.python.autograph.pyct import parser from tensorflow.python.autograph.utils import py_func from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.keras.engine import sequential from tensorflow.python.keras.layers import core from tensorflow.python.ops import variables @@ -44,6 +45,7 @@ class TestResource(str): class ApiTest(test.TestCase): + @test_util.run_deprecated_v1 def test_decorator_recurses(self): class TestClass(object): @@ -66,6 +68,7 @@ class ApiTest(test.TestCase): constant_op.constant(-2)) self.assertListEqual([0, 1], self.evaluate(x).tolist()) + @test_util.run_deprecated_v1 def test_decorator_does_not_recurse(self): class TestClass(object): @@ -86,6 +89,7 @@ class ApiTest(test.TestCase): constant_op.constant(-2)) self.assertListEqual([0, 1], self.evaluate(x).tolist()) + @test_util.run_deprecated_v1 def test_decorator_calls_unconverted_graph(self): class TestClass(object): @@ -107,6 +111,7 @@ class ApiTest(test.TestCase): constant_op.constant(-2)) self.assertListEqual([0, 1], self.evaluate(x).tolist()) + @test_util.run_deprecated_v1 def test_decorator_calls_unconverted_py_func(self): class TestClass(object): @@ -133,6 +138,7 @@ class ApiTest(test.TestCase): constant_op.constant(-2)) self.assertListEqual([0, 1], self.evaluate(x).tolist()) + @test_util.run_deprecated_v1 def test_decorator_calls_decorated(self): class TestClass(object): @@ -172,6 +178,7 @@ class ApiTest(test.TestCase): list(tf_inspect.getfullargspec(tc.called_member)), list(tf_inspect.getfullargspec(tc.called_member_converted))) + @test_util.run_deprecated_v1 def test_convert_call_site_decorator(self): class TestClass(object): @@ -326,6 +333,7 @@ class ApiTest(test.TestCase): constant_op.constant(0)) self.assertTrue(self.evaluate(x)) + @test_util.run_deprecated_v1 def test_converted_call_no_user_code(self): def f(x): @@ -400,6 +408,7 @@ class ApiTest(test.TestCase): self.evaluate(variables.global_variables_initializer()) self.assertAllEqual(True, self.evaluate(x)) + @test_util.run_deprecated_v1 def test_to_graph_basic(self): def test_fn(x, s): @@ -413,6 +422,7 @@ class ApiTest(test.TestCase): x = compiled_fn(constant_op.constant([4, 8]), 4) self.assertListEqual([1, 2], self.evaluate(x).tolist()) + @test_util.run_deprecated_v1 def test_to_graph_with_defaults(self): foo = 4 diff --git a/tensorflow/python/autograph/operators/control_flow_test.py b/tensorflow/python/autograph/operators/control_flow_test.py index 05b5660941d..0a7d4b64022 100644 --- a/tensorflow/python/autograph/operators/control_flow_test.py +++ b/tensorflow/python/autograph/operators/control_flow_test.py @@ -22,12 +22,14 @@ from tensorflow.python.autograph.operators import control_flow from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.platform import test class ForLoopTest(test.TestCase): + @test_util.run_deprecated_v1 def test_tensor(self): s = control_flow.for_stmt( constant_op.constant([1, 2, 3, 4]), @@ -45,6 +47,7 @@ class ForLoopTest(test.TestCase): init_state=(0,)) self.assertEqual(10, s) + @test_util.run_deprecated_v1 def test_dataset(self): to_int32 = lambda i: math_ops.cast(i, dtypes.int32) s = control_flow.for_stmt( @@ -58,6 +61,7 @@ class ForLoopTest(test.TestCase): class WhileLoopTest(test.TestCase): + @test_util.run_deprecated_v1 def test_tensor(self): n = constant_op.constant(5) results = control_flow.while_stmt( @@ -87,6 +91,7 @@ class IfStmtTest(test.TestCase): return control_flow.if_stmt( cond=cond, body=lambda: (1, 2), orelse=lambda: (-1, -2)) + @test_util.run_deprecated_v1 def test_tensor(self): with self.cached_session() as sess: t = self.single_return_if_stmt(constant_op.constant(True)) @@ -98,6 +103,7 @@ class IfStmtTest(test.TestCase): self.assertEqual(1, self.single_return_if_stmt(True)) self.assertEqual(-1, self.single_return_if_stmt(False)) + @test_util.run_deprecated_v1 def test_tensor_multiple_returns(self): with self.cached_session() as sess: t = self.multi_return_if_stmt(constant_op.constant(True)) diff --git a/tensorflow/python/autograph/operators/data_structures_test.py b/tensorflow/python/autograph/operators/data_structures_test.py index 0433e3f130c..9397b9acb82 100644 --- a/tensorflow/python/autograph/operators/data_structures_test.py +++ b/tensorflow/python/autograph/operators/data_structures_test.py @@ -22,6 +22,7 @@ from tensorflow.python.autograph.operators import data_structures from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import list_ops from tensorflow.python.ops import tensor_array_ops from tensorflow.python.platform import test @@ -59,6 +60,7 @@ class ListTest(test.TestCase): with self.cached_session() as sess: self.assertAllEqual(self.evaluate(t), [3, 4, 5]) + @test_util.run_deprecated_v1 def test_tf_tensor_list_new_illegal_input(self): with self.assertRaises(ValueError): data_structures.tf_tensor_list_new([3, 4.0]) @@ -104,6 +106,7 @@ class ListTest(test.TestCase): with self.cached_session() as sess: self.assertAllEqual(self.evaluate(t), [[1, 2, 3]]) + @test_util.run_deprecated_v1 def test_append_tensorarray(self): l = tensor_array_ops.TensorArray(dtypes.int32, size=0, dynamic_size=True) l1 = data_structures.list_append(l, 1) @@ -154,6 +157,7 @@ class ListTest(test.TestCase): t = data_structures.list_stack(l, opts) self.assertAllEqual(self.evaluate(t), self.evaluate(initial_list)) + @test_util.run_deprecated_v1 def test_stack_tensor_list_empty(self): l = list_ops.empty_tensor_list( element_shape=None, element_dtype=dtypes.variant) diff --git a/tensorflow/python/autograph/operators/exceptions_test.py b/tensorflow/python/autograph/operators/exceptions_test.py index 24d3f1bd35f..21ba76bb952 100644 --- a/tensorflow/python/autograph/operators/exceptions_test.py +++ b/tensorflow/python/autograph/operators/exceptions_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.autograph.operators import exceptions from tensorflow.python.framework import constant_op from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -32,6 +33,7 @@ class ExceptionsTest(test.TestCase): constant_op.constant(True), lambda: constant_op.constant('ignored')) self.evaluate(t) + @test_util.run_deprecated_v1 def test_assert_tf_triggered(self): with self.cached_session() as sess: t = exceptions.assert_stmt( @@ -42,6 +44,7 @@ class ExceptionsTest(test.TestCase): 'test message'): self.evaluate(t) + @test_util.run_deprecated_v1 def test_assert_tf_multiple_printed_values(self): two_tensors = [ constant_op.constant('test message'), diff --git a/tensorflow/python/autograph/operators/logical_test.py b/tensorflow/python/autograph/operators/logical_test.py index ebf6458f01e..e22f39932d1 100644 --- a/tensorflow/python/autograph/operators/logical_test.py +++ b/tensorflow/python/autograph/operators/logical_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.autograph.operators import logical from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -42,6 +43,7 @@ class LogicalOperatorsTest(test.TestCase): self.assertFalse(logical.and_(lambda: False, lambda: True)) self.assertFalse(logical.and_(lambda: False, self.assertNotCalled)) + @test_util.run_deprecated_v1 def test_and_tf(self): with self.cached_session() as sess: t = logical.and_(self._tf_true, self._tf_true) @@ -60,6 +62,7 @@ class LogicalOperatorsTest(test.TestCase): self.assertTrue(logical.or_(lambda: False, lambda: True)) self.assertTrue(logical.or_(lambda: True, self.assertNotCalled)) + @test_util.run_deprecated_v1 def test_or_tf(self): with self.cached_session() as sess: t = logical.or_(self._tf_false, self._tf_true) diff --git a/tensorflow/python/autograph/operators/py_builtins_test.py b/tensorflow/python/autograph/operators/py_builtins_test.py index 4d9eec77c38..c856e39d141 100644 --- a/tensorflow/python/autograph/operators/py_builtins_test.py +++ b/tensorflow/python/autograph/operators/py_builtins_test.py @@ -27,6 +27,7 @@ from tensorflow.python.autograph.operators import py_builtins from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import tensor_array_ops from tensorflow.python.platform import test @@ -81,6 +82,7 @@ class PyBuiltinsTest(test.TestCase): with self.assertRaises(ValueError): py_builtins.len_(constant_op.constant(1)) + @test_util.run_deprecated_v1 def test_len_dynamic_shape(self): with self.cached_session() as sess: p = array_ops.placeholder(dtype=dtypes.int32, shape=None) @@ -91,6 +93,7 @@ class PyBuiltinsTest(test.TestCase): t = py_builtins.len_(p) sess.run(t, {p: 1}) + @test_util.run_deprecated_v1 def test_print_tensors(self): try: out_capturer = six.StringIO() @@ -101,6 +104,7 @@ class PyBuiltinsTest(test.TestCase): finally: sys.stdout = sys.__stdout__ + @test_util.run_deprecated_v1 def test_print_complex(self): try: out_capturer = six.StringIO() diff --git a/tensorflow/python/autograph/utils/misc_test.py b/tensorflow/python/autograph/utils/misc_test.py index c813e0f5c96..c78df48d626 100644 --- a/tensorflow/python/autograph/utils/misc_test.py +++ b/tensorflow/python/autograph/utils/misc_test.py @@ -19,6 +19,7 @@ from __future__ import division from __future__ import print_function from tensorflow.python.autograph.utils.misc import alias_tensors +from tensorflow.python.framework import test_util from tensorflow.python.framework.constant_op import constant from tensorflow.python.ops.variables import Variable from tensorflow.python.platform import test @@ -26,6 +27,7 @@ from tensorflow.python.platform import test class MiscTest(test.TestCase): + @test_util.run_deprecated_v1 def test_alias_single_tensor(self): a = constant(1) @@ -34,6 +36,7 @@ class MiscTest(test.TestCase): with self.cached_session() as sess: self.assertEqual(1, self.evaluate(new_a)) + @test_util.run_deprecated_v1 def test_alias_tensors(self): a = constant(1) v = Variable(2) diff --git a/tensorflow/python/autograph/utils/tensor_list_test.py b/tensorflow/python/autograph/utils/tensor_list_test.py index c655f773b00..0bd30072497 100644 --- a/tensorflow/python/autograph/utils/tensor_list_test.py +++ b/tensorflow/python/autograph/utils/tensor_list_test.py @@ -23,6 +23,7 @@ from tensorflow.python.client.session import Session from tensorflow.python.eager import context from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.framework.constant_op import constant from tensorflow.python.ops import list_ops from tensorflow.python.ops import tensor_array_ops @@ -34,6 +35,7 @@ class TensorListTest(test.TestCase): def _shape(self, shape_tuple): return constant(shape_tuple, dtypes.int32) + @test_util.run_deprecated_v1 def test_dynamic_list_append(self): l = [] l = tl.dynamic_list_append(l, 1) @@ -80,6 +82,7 @@ class TensorListTest(test.TestCase): l[0] = ops.convert_to_tensor(b) self.assertEqual(l[0].numpy(), b.numpy()) + @test_util.run_deprecated_v1 def test_list_append_tf(self): a = constant(3.0) l = tl.TensorList(a.shape, a.dtype) diff --git a/tensorflow/python/autograph/utils/type_check_test.py b/tensorflow/python/autograph/utils/type_check_test.py index b3d1304e16f..2521dc9f925 100644 --- a/tensorflow/python/autograph/utils/type_check_test.py +++ b/tensorflow/python/autograph/utils/type_check_test.py @@ -28,6 +28,7 @@ from tensorflow.python.platform import test class TypeCheckTest(test.TestCase): + @test_util.run_deprecated_v1 def test_checks(self): self.assertTrue(type_check.is_tensor(constant_op.constant([1, 2, 3]))) self.assertTrue( diff --git a/tensorflow/python/client/session_partial_run_test.py b/tensorflow/python/client/session_partial_run_test.py index a9bd5ab7e08..a97930635af 100644 --- a/tensorflow/python/client/session_partial_run_test.py +++ b/tensorflow/python/client/session_partial_run_test.py @@ -188,6 +188,7 @@ class PartialRunTest(test_util.TensorFlowTestCase): r = sess.partial_run(h, [b], {}) self.assertEqual([6.0], r) + @test_util.run_deprecated_v1 def testInvalidPartialRunSetup(self): sess = session.Session() x = array_ops.placeholder(dtypes.float32, shape=[]) @@ -196,6 +197,7 @@ class PartialRunTest(test_util.TensorFlowTestCase): 'specify at least one target to fetch or execute.'): sess.partial_run_setup(fetches=[], feeds=[x]) + @test_util.run_deprecated_v1 def testPartialRunSetupNoFeedsPassed(self): sess = session.Session() r1 = constant_op.constant([6.0]) @@ -204,80 +206,102 @@ class PartialRunTest(test_util.TensorFlowTestCase): result1 = sess.partial_run(h, r1) self.assertEqual([6.0], result1) + @test_util.run_deprecated_v1 def testPartialRunDirect(self): self.RunTestPartialRun(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunIncompleteDirect(self): self.RunTestPartialRunIncomplete(session.Session()) + @test_util.run_deprecated_v1 def testConcurrentPartialRunDirect(self): self.RunTestConcurrentPartialRun(session.Session()) + @test_util.run_deprecated_v1 def testManyPartialRunDirect(self): self.RunTestManyPartialRun(session.Session()) + @test_util.run_deprecated_v1 def testRunAndPartialRunDirect(self): self.RunTestRunAndPartialRun(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunMissingPlaceholderFeedExceptionDirect(self): self.RunTestPartialRunMissingPlaceholderFeedException(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunUnspecifiedFeedDirect(self): self.RunTestPartialRunUnspecifiedFeed(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunUnspecifiedFetchDirect(self): self.RunTestPartialRunUnspecifiedFetch(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunAlreadyFedDirect(self): self.RunTestPartialRunAlreadyFed(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunAlreadyFetchedDirect(self): self.RunTestPartialRunAlreadyFetched(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunEmptyFetchesDirect(self): self.RunTestPartialRunEmptyFetches(session.Session()) + @test_util.run_deprecated_v1 def testPartialRunDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRun(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunIncompleteDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunIncomplete(session.Session(server.target)) + @test_util.run_deprecated_v1 def testConcurrentPartialRunDist(self): server = server_lib.Server.create_local_server() self.RunTestConcurrentPartialRun(session.Session(server.target)) + @test_util.run_deprecated_v1 def testManyPartialRunDist(self): server = server_lib.Server.create_local_server() self.RunTestManyPartialRun(session.Session(server.target)) + @test_util.run_deprecated_v1 def testRunAndPartialRunDist(self): server = server_lib.Server.create_local_server() self.RunTestRunAndPartialRun(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunMissingPlaceholderFeedExceptionDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunMissingPlaceholderFeedException( session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunUnspecifiedFeedDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunUnspecifiedFeed(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunUnspecifiedFetchDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunUnspecifiedFetch(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunAlreadyFedDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunAlreadyFed(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunAlreadyFetchedDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunAlreadyFetched(session.Session(server.target)) + @test_util.run_deprecated_v1 def testPartialRunEmptyFetchesDist(self): server = server_lib.Server.create_local_server() self.RunTestPartialRunEmptyFetches(session.Session(server.target)) diff --git a/tensorflow/python/client/timeline_test.py b/tensorflow/python/client/timeline_test.py index f9bd50957a7..61c0da01b83 100644 --- a/tensorflow/python/client/timeline_test.py +++ b/tensorflow/python/client/timeline_test.py @@ -57,6 +57,7 @@ class TimelineTest(test.TestCase): ctf = tl.generate_chrome_trace_format() self._validateTrace(ctf) + @test_util.run_deprecated_v1 def testTimelineCpu(self): run_options = config_pb2.RunOptions( trace_level=config_pb2.RunOptions.FULL_TRACE) diff --git a/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py b/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py index 7edaab81f4c..b0516573f5f 100644 --- a/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/copy_to_device_test.py @@ -35,6 +35,7 @@ from tensorflow.python.util import compat as util_compat class CopyToDeviceTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testCopyToDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -61,6 +62,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyToDeviceInt32(self): host_dataset = dataset_ops.Dataset.from_tensors([0, 1, 2, 3]) device_dataset = host_dataset.apply( @@ -86,6 +88,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyToSameDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -112,6 +115,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyToDeviceWithPrefetch(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -138,6 +142,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyDictToDevice(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -164,6 +169,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyDictToDeviceWithPrefetch(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -190,6 +196,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopySparseTensorsToDevice(self): def make_tensor(i): @@ -224,6 +231,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopySparseTensorsToDeviceWithPrefetch(self): def make_tensor(i): @@ -426,6 +434,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyToDeviceWithReInit(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -456,6 +465,7 @@ class CopyToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testCopyToDeviceWithReInitAndPrefetch(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( diff --git a/tensorflow/python/data/experimental/kernel_tests/counter_test.py b/tensorflow/python/data/experimental/kernel_tests/counter_test.py index d1dd07a8794..b370e0029e9 100644 --- a/tensorflow/python/data/experimental/kernel_tests/counter_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/counter_test.py @@ -20,11 +20,13 @@ from __future__ import print_function from tensorflow.python.data.experimental.ops import counter from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class CounterTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testCounter(self): """Test dataset construction using `count`.""" iterator = (counter.Counter(start=3, step=4) diff --git a/tensorflow/python/data/experimental/kernel_tests/dense_to_sparse_batch_test.py b/tensorflow/python/data/experimental/kernel_tests/dense_to_sparse_batch_test.py index d9bbfb9c994..4b84446be8a 100644 --- a/tensorflow/python/data/experimental/kernel_tests/dense_to_sparse_batch_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/dense_to_sparse_batch_test.py @@ -24,12 +24,14 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test class DenseToSparseBatchTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testDenseToSparseBatchDataset(self): components = np.random.randint(12, size=(100,)).astype(np.int32) iterator = ( @@ -58,6 +60,7 @@ class DenseToSparseBatchTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testDenseToSparseBatchDatasetWithUnknownShape(self): components = np.random.randint(5, size=(40,)).astype(np.int32) iterator = ( @@ -91,12 +94,14 @@ class DenseToSparseBatchTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testDenseToSparseBatchDatasetWithInvalidShape(self): input_tensor = array_ops.constant([[1]]) with self.assertRaisesRegexp(ValueError, "Dimension -2 must be >= 0"): dataset_ops.Dataset.from_tensors(input_tensor).apply( batching.dense_to_sparse_batch(4, [-2])).make_initializable_iterator() + @test_util.run_deprecated_v1 def testDenseToSparseBatchDatasetShapeErrors(self): input_tensor = array_ops.placeholder(dtypes.int32) iterator = ( diff --git a/tensorflow/python/data/experimental/kernel_tests/directed_interleave_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/directed_interleave_dataset_test.py index 768a8d774b1..269c27dde29 100644 --- a/tensorflow/python/data/experimental/kernel_tests/directed_interleave_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/directed_interleave_dataset_test.py @@ -24,11 +24,13 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import errors from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class DirectedInterleaveDatasetTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testBasic(self): selector_dataset = dataset_ops.Dataset.range(10).repeat(100) input_datasets = [ @@ -77,6 +79,7 @@ class DirectedInterleaveDatasetTest(test_base.DatasetTestBase): return freqs + @test_util.run_deprecated_v1 def testSampleFromDatasets(self): random_seed.set_random_seed(1619) num_samples = 5000 @@ -96,6 +99,7 @@ class DirectedInterleaveDatasetTest(test_base.DatasetTestBase): freqs = self._testSampleFromDatasetsHelper(probs_ds, classes, num_samples) self.assertLess(self._chi2(probs, freqs / num_samples), 1e-2) + @test_util.run_deprecated_v1 def testSelectFromDatasets(self): words = [b"foo", b"bar", b"baz"] datasets = [dataset_ops.Dataset.from_tensors(w).repeat() for w in words] diff --git a/tensorflow/python/data/experimental/kernel_tests/enumerate_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/enumerate_dataset_test.py index f32d1d0a6fc..3c2e1bb7f3d 100644 --- a/tensorflow/python/data/experimental/kernel_tests/enumerate_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/enumerate_dataset_test.py @@ -24,11 +24,13 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class EnumerateDatasetTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testEnumerateDataset(self): components = (["a", "b"], [1, 2], [37.0, 38]) start = constant_op.constant(20, dtype=dtypes.int64) diff --git a/tensorflow/python/data/experimental/kernel_tests/function_buffering_resource_test.py b/tensorflow/python/data/experimental/kernel_tests/function_buffering_resource_test.py index 860442571eb..a78fb4d229d 100644 --- a/tensorflow/python/data/experimental/kernel_tests/function_buffering_resource_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/function_buffering_resource_test.py @@ -107,11 +107,13 @@ class FunctionBufferingResourceTest(test_base.DatasetTestBase): self.assertEqual(elem, [5.0]) self.evaluate(destroy_op) + @test_util.run_deprecated_v1 def testSameDeviceCPU(self): self._prefetch_fn_helper_one_shot("same_device_cpu", "/job:localhost/replica:0/task:0/cpu:0", "/job:localhost/replica:0/task:0/cpu:0") + @test_util.run_deprecated_v1 def testDifferentDeviceCPU(self): self._prefetch_fn_helper_one_shot("diff_device_cpu", "/job:localhost/replica:0/task:0/cpu:0", @@ -125,6 +127,7 @@ class FunctionBufferingResourceTest(test_base.DatasetTestBase): "/job:localhost/replica:0/task:0/cpu:0", "/job:localhost/replica:0/task:0/gpu:0") + @test_util.run_deprecated_v1 def testReinitialization(self): worker_config = config_pb2.ConfigProto(device_count={"CPU": 2}) @@ -165,6 +168,7 @@ class FunctionBufferingResourceTest(test_base.DatasetTestBase): self.assertEqual(elem, [5.0]) self.evaluate(destroy_op) + @test_util.run_deprecated_v1 def testReinitializationOutOfRange(self): worker_config = config_pb2.ConfigProto(device_count={"CPU": 2}) diff --git a/tensorflow/python/data/experimental/kernel_tests/get_single_element_test.py b/tensorflow/python/data/experimental/kernel_tests/get_single_element_test.py index 0147988c595..ef576563a15 100644 --- a/tensorflow/python/data/experimental/kernel_tests/get_single_element_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/get_single_element_test.py @@ -25,6 +25,7 @@ from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test @@ -39,6 +40,7 @@ class GetSingleElementTest(test_base.DatasetTestBase, parameterized.TestCase): ("MoreThanOne", 0, 2, errors.InvalidArgumentError, "Dataset had more than one element."), ) + @test_util.run_deprecated_v1 def testGetSingleElement(self, skip, take, error=None, error_msg=None): skip_t = array_ops.placeholder(dtypes.int64, shape=[]) take_t = array_ops.placeholder(dtypes.int64, shape=[]) diff --git a/tensorflow/python/data/experimental/kernel_tests/group_by_reducer_test.py b/tensorflow/python/data/experimental/kernel_tests/group_by_reducer_test.py index f9856500c5c..c7366f66411 100644 --- a/tensorflow/python/data/experimental/kernel_tests/group_by_reducer_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/group_by_reducer_test.py @@ -27,6 +27,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -44,6 +45,7 @@ class GroupByReducerTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testSum(self): reducer = grouping.Reducer( init_func=lambda _: np.int64(0), @@ -55,6 +57,7 @@ class GroupByReducerTest(test_base.DatasetTestBase): self.checkResults( dataset, shapes=tensor_shape.scalar(), values=[(i - 1) * i, i * i]) + @test_util.run_deprecated_v1 def testAverage(self): def reduce_fn(x, y): @@ -72,6 +75,7 @@ class GroupByReducerTest(test_base.DatasetTestBase): self.checkResults( dataset, shapes=tensor_shape.scalar(), values=[i - 1, i]) + @test_util.run_deprecated_v1 def testConcat(self): components = np.array(list("abcdefghijklmnopqrst")).view(np.chararray) reducer = grouping.Reducer( @@ -88,6 +92,7 @@ class GroupByReducerTest(test_base.DatasetTestBase): shapes=tensor_shape.scalar(), values=[b"acegikmoqs" [:i], b"bdfhjlnprt" [:i]]) + @test_util.run_deprecated_v1 def testSparseSum(self): def _sparse(i): return sparse_tensor.SparseTensorValue( @@ -105,6 +110,7 @@ class GroupByReducerTest(test_base.DatasetTestBase): self.checkResults( dataset, shapes=tensor_shape.scalar(), values=[(i - 1) * i, i * i]) + @test_util.run_deprecated_v1 def testChangingStateShape(self): def reduce_fn(x, _): diff --git a/tensorflow/python/data/experimental/kernel_tests/group_by_window_test.py b/tensorflow/python/data/experimental/kernel_tests/group_by_window_test.py index d5a36e7cb15..1e54091c7db 100644 --- a/tensorflow/python/data/experimental/kernel_tests/group_by_window_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/group_by_window_test.py @@ -27,6 +27,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import string_ops @@ -49,6 +50,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): 32, (tensor_shape.TensorShape([]), tensor_shape.TensorShape( [None]), tensor_shape.TensorShape([3]))))) + @test_util.run_deprecated_v1 def testSingleBucket(self): def _map_fn(v): @@ -84,6 +86,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertAllEqual(expected_unk_int64, bucketed_values[1]) self.assertAllEqual(expected_vec3_str, bucketed_values[2]) + @test_util.run_deprecated_v1 def testEvenOddBuckets(self): def _map_fn(v): @@ -141,6 +144,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertAllEqual(expected_unk_int64, bucketed_values_odd[1]) self.assertAllEqual(expected_vec3_str, bucketed_values_odd[2]) + @test_util.run_deprecated_v1 def testEvenOddBucketsFilterOutAllOdd(self): def _map_fn(v): @@ -188,6 +192,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertAllEqual( np.arange(64, 128, 2, dtype=np.int64), bucketed_values_even1["x"]) + @test_util.run_deprecated_v1 def testDynamicWindowSize(self): components = np.arange(100).astype(np.int64) @@ -221,6 +226,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertEqual(batches, 15) + @test_util.run_deprecated_v1 def testSimple(self): components = np.random.randint(100, size=(200,)).astype(np.int64) iterator = ( @@ -248,6 +254,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertGreaterEqual(num_full_batches, 24) self.assertTrue(all(c == 4 for c in counts[:num_full_batches])) + @test_util.run_deprecated_v1 def testImmediateOutput(self): components = np.array( [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 2, 2, 0, 0], dtype=np.int64) @@ -270,6 +277,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertAllEqual([2, 2, 2, 2], self.evaluate(get_next)) self.assertAllEqual([0, 0, 0, 0], self.evaluate(get_next)) + @test_util.run_deprecated_v1 def testSmallGroups(self): components = np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0], dtype=np.int64) iterator = ( @@ -288,6 +296,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): self.assertAllEqual([0, 0, 0], self.evaluate(get_next)) self.assertAllEqual([1], self.evaluate(get_next)) + @test_util.run_deprecated_v1 def testEmpty(self): iterator = ( dataset_ops.Dataset.range(4).apply( @@ -303,6 +312,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): "Window size must be greater than zero, but got 0."): print(self.evaluate(get_next)) + @test_util.run_deprecated_v1 def testReduceFuncError(self): components = np.random.randint(100, size=(200,)).astype(np.int64) @@ -327,6 +337,7 @@ class GroupByWindowTest(test_base.DatasetTestBase): with self.assertRaises(errors.InvalidArgumentError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testConsumeWindowDatasetMoreThanOnce(self): components = np.random.randint(50, size=(200,)).astype(np.int64) diff --git a/tensorflow/python/data/experimental/kernel_tests/ignore_errors_test.py b/tensorflow/python/data/experimental/kernel_tests/ignore_errors_test.py index 522b1960606..bd323592e44 100644 --- a/tensorflow/python/data/experimental/kernel_tests/ignore_errors_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/ignore_errors_test.py @@ -25,6 +25,7 @@ from tensorflow.python.data.experimental.ops import error_ops from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import io_ops from tensorflow.python.platform import test @@ -35,6 +36,7 @@ _NUMPY_RANDOM_SEED = 42 class IgnoreErrorsTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testMapIgnoreError(self): components = np.array([1., 2., 3., np.nan, 5.]).astype(np.float32) @@ -53,6 +55,7 @@ class IgnoreErrorsTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testParallelMapIgnoreError(self): components = np.array([1., 2., 3., np.nan, 5.]).astype(np.float32) @@ -71,6 +74,7 @@ class IgnoreErrorsTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next) + @test_util.run_deprecated_v1 def testReadFileIgnoreError(self): def write_string_to_file(value, filename): diff --git a/tensorflow/python/data/experimental/kernel_tests/indexed_dataset_ops_test.py b/tensorflow/python/data/experimental/kernel_tests/indexed_dataset_ops_test.py index 0a436034a8c..c3c4ccd0770 100644 --- a/tensorflow/python/data/experimental/kernel_tests/indexed_dataset_ops_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/indexed_dataset_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_experimental_dataset_ops as ged_ops from tensorflow.python.platform import test @@ -31,6 +32,7 @@ from tensorflow.python.platform import test class IndexedDatasetOpsTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testLowLevelIndexedDatasetOps(self): identity = ged_ops.experimental_identity_indexed_dataset( ops.convert_to_tensor(16, dtype=dtypes.uint64)) @@ -49,6 +51,7 @@ class IndexedDatasetOpsTest(test_base.DatasetTestBase): self.evaluate(materialize) self.assertEqual([3], sess.run(get_op, feed_dict={index: 3})) + @test_util.run_deprecated_v1 def testIdentityIndexedDataset(self): ds = indexed_dataset_ops.IdentityIndexedDataset(16) materialized = ds.materialize() diff --git a/tensorflow/python/data/experimental/kernel_tests/make_batched_features_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/make_batched_features_dataset_test.py index 109b3696b84..48916471b35 100644 --- a/tensorflow/python/data/experimental/kernel_tests/make_batched_features_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/make_batched_features_dataset_test.py @@ -26,6 +26,7 @@ from tensorflow.python.data.util import nest from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import io_ops from tensorflow.python.ops import parsing_ops from tensorflow.python.platform import test @@ -98,6 +99,7 @@ class MakeBatchedFeaturesDatasetTest( with self.assertRaises(errors.OutOfRangeError): self._next_actual_batch(sess) + @test_util.run_deprecated_v1 def testReadWithEquivalentDataset(self): features = { "file": parsing_ops.FixedLenFeature([], dtypes.int64), diff --git a/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py index 1f509384d72..bcbaf1a7c49 100644 --- a/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py @@ -30,6 +30,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -127,6 +128,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): self._verify_output(sess, dataset, batch_size, num_epochs, label_name, expected_output, expected_keys) + @test_util.run_deprecated_v1 def testMakeCSVDataset(self): """Tests making a CSV dataset with keys and defaults provided.""" record_defaults = [ @@ -158,6 +160,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): column_defaults=record_defaults, ) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withBatchSizeAndEpochs(self): """Tests making a CSV dataset with keys and defaults provided.""" record_defaults = [ @@ -189,6 +192,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): column_defaults=record_defaults, ) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withCompressionType(self): """Tests `compression_type` argument.""" record_defaults = [ @@ -257,6 +261,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): label_name="not_a_real_label", column_names=column_names) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withNoLabel(self): """Tests making a CSV dataset with no label provided.""" record_defaults = [ @@ -286,6 +291,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): column_defaults=record_defaults, ) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withNoHeader(self): """Tests that datasets can be created from CSV files with no header line. """ @@ -347,6 +353,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): column_defaults=record_defaults, ) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withNoColNames(self): """Tests that datasets can be created when column names are not specified. @@ -451,6 +458,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): header=True, ) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withSelectCols(self): record_defaults = [ constant_op.constant([], dtypes.int32), @@ -557,6 +565,7 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): label_name=None, select_columns=["invalid_col_name"]) + @test_util.run_deprecated_v1 def testMakeCSVDataset_withShuffle(self): record_defaults = [ constant_op.constant([], dtypes.int32), diff --git a/tensorflow/python/data/experimental/kernel_tests/map_and_batch_test.py b/tensorflow/python/data/experimental/kernel_tests/map_and_batch_test.py index 8449c0651de..fc97f63358a 100644 --- a/tensorflow/python/data/experimental/kernel_tests/map_and_batch_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/map_and_batch_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops @@ -48,6 +49,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("ParallelCallsNUMA", 2, None, True), ("ParallelBatchesNUMA", None, 10, True), ) + @test_util.run_deprecated_v1 def testMapAndBatch(self, num_parallel_calls, num_parallel_batches, numa_aware): """Test a dataset that maps a TF function across its input elements.""" @@ -132,6 +134,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("EvenNUMA", False, True), ("UnevenNUMA", True, True), ) + @test_util.run_deprecated_v1 def testMapAndBatchPartialBatch(self, drop_remainder, numa_aware): dataset = ( dataset_ops.Dataset.range(10).apply( @@ -163,6 +166,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchYieldsPartialBatch(self, numa_aware): dataset = ( dataset_ops.Dataset.range(10).apply( @@ -187,6 +191,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchParallelGetNext(self, numa_aware): dataset = dataset_ops.Dataset.range(50000).apply( batching.map_and_batch(lambda x: x, batch_size=100)) @@ -214,6 +219,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchParallelGetNextDropRemainder(self, numa_aware): dataset = dataset_ops.Dataset.range(49999).apply( batching.map_and_batch( @@ -243,6 +249,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchSparse(self, numa_aware): def _sparse(i): @@ -277,6 +284,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchFails(self, numa_aware): """Test a dataset that maps a TF function across its input elements.""" dataset = dataset_ops.Dataset.from_tensors( @@ -299,6 +307,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchShapeMismatch(self, numa_aware): """Test a dataset that maps a TF function across its input elements.""" @@ -370,6 +379,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("5NUMA", 95, True), ("6NUMA", 99, True), ) + @test_util.run_deprecated_v1 def testMapAndBatchOutOfRangeError(self, threshold, numa_aware): def raising_py_fn(i): @@ -452,6 +462,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Swap", (None, None), lambda x, y: (y, x), None), ("Project", (None, None), lambda x, y: x, None), ) + @test_util.run_deprecated_v1 def testShortCircuit(self, structure, map_fn, num_parallel_calls): dataset = self.structuredDataset(structure).repeat().apply( batching.map_and_batch(map_fn, batch_size=10)) @@ -466,6 +477,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): sess.run(self.structuredElement(structure, shape=[10]))) self.assertAllEqual(expected, self.evaluate(get_next)) + @test_util.run_deprecated_v1 def testShortCircuitCapturedInput(self): captured_t = array_ops.placeholder(dtypes.int64, shape=[]) dataset = self.structuredDataset(None).repeat().apply( @@ -481,6 +493,7 @@ class MapAndBatchTest(test_base.DatasetTestBase, parameterized.TestCase): ("Normal", False), ("NUMA", True), ) + @test_util.run_deprecated_v1 def testMapAndBatchControlFlow(self, numa_aware): def map_fn(x): diff --git a/tensorflow/python/data/experimental/kernel_tests/matching_files_test.py b/tensorflow/python/data/experimental/kernel_tests/matching_files_test.py index 938dd4aff4a..787a7a91a4b 100644 --- a/tensorflow/python/data/experimental/kernel_tests/matching_files_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/matching_files_test.py @@ -24,6 +24,7 @@ import tempfile from tensorflow.python.data.experimental.ops import matching_files from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.util import compat @@ -40,6 +41,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): for filename in filenames: open(os.path.join(self.tmp_dir, filename), 'a').close() + @test_util.run_deprecated_v1 def testNonExistingDirectory(self): """Test the MatchingFiles dataset with a non-existing directory.""" @@ -51,6 +53,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): with self.assertRaises(errors.NotFoundError): sess.run(next_element) + @test_util.run_deprecated_v1 def testEmptyDirectory(self): """Test the MatchingFiles dataset with an empty directory.""" @@ -61,6 +64,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): with self.assertRaises(errors.NotFoundError): sess.run(next_element) + @test_util.run_deprecated_v1 def testSimpleDirectory(self): """Test the MatchingFiles dataset with a simple directory.""" @@ -83,6 +87,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(next_element) + @test_util.run_deprecated_v1 def testFileSuffixes(self): """Test the MatchingFiles dataset using the suffixes of filename.""" @@ -104,6 +109,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(next_element) + @test_util.run_deprecated_v1 def testFileMiddles(self): """Test the MatchingFiles dataset using the middles of filename.""" @@ -125,6 +131,7 @@ class MatchingFilesTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(next_element) + @test_util.run_deprecated_v1 def testNestedDirectories(self): """Test the MatchingFiles dataset with nested directories.""" diff --git a/tensorflow/python/data/experimental/kernel_tests/override_threadpool_test.py b/tensorflow/python/data/experimental/kernel_tests/override_threadpool_test.py index 1dfe854f188..7116e7549f9 100644 --- a/tensorflow/python/data/experimental/kernel_tests/override_threadpool_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/override_threadpool_test.py @@ -29,6 +29,7 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import script_ops from tensorflow.python.platform import test @@ -81,6 +82,7 @@ class OverrideThreadpoolTest(test_base.DatasetTestBase, ("8", 4, 1), ("9", 4, 4), ) + @test_util.run_deprecated_v1 def testNumThreadsDeprecated(self, num_threads, max_intra_op_parallelism): def override_threadpool_fn(dataset): @@ -107,6 +109,7 @@ class OverrideThreadpoolTest(test_base.DatasetTestBase, ("11", 4, 4), ("12", None, None), ) + @test_util.run_deprecated_v1 def testNumThreads(self, num_threads, max_intra_op_parallelism): def override_threadpool_fn(dataset): diff --git a/tensorflow/python/data/experimental/kernel_tests/parse_example_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/parse_example_dataset_test.py index c74f754fefb..76e0d4d72a6 100644 --- a/tensorflow/python/data/experimental/kernel_tests/parse_example_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/parse_example_dataset_test.py @@ -144,6 +144,7 @@ class ParseExampleDatasetTest(test_base.DatasetTestBase): expected_values=expected_output, create_iterator_twice=True) + @test_util.run_deprecated_v1 def testEmptySerializedWithoutDefaultsShouldFail(self): input_features = { "st_a": @@ -177,6 +178,7 @@ class ParseExampleDatasetTest(test_base.DatasetTestBase): expected_err=(errors_impl.InvalidArgumentError, "Feature: c \\(data type: float\\) is required")) + @test_util.run_deprecated_v1 def testDenseNotMatchingShapeShouldFail(self): original = [ example(features=features({ @@ -669,6 +671,7 @@ class ParseExampleDatasetTest(test_base.DatasetTestBase): for batch_size in (1, 10, 20, 100, 256): self._testSerializedContainingVarLenDenseLargerBatch(batch_size) + @test_util.run_deprecated_v1 def testSkipEagerSerializedShapeMismatch(self): aname = "a" bname = "b" @@ -706,6 +709,7 @@ class ParseExampleDatasetTest(test_base.DatasetTestBase): expected_err=(ValueError, "Cannot reshape a tensor with 0 elements to shape")) + @test_util.run_deprecated_v1 def testSerializedContainingVarLenDense(self): aname = "a" bname = "b" diff --git a/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py b/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py index 8fc18e1ccd3..56befc9e7dc 100644 --- a/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/prefetch_to_device_test.py @@ -31,6 +31,7 @@ from tensorflow.python.platform import test class PrefetchToDeviceTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testPrefetchToDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -61,6 +62,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testPrefetchToSameDevice(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( @@ -91,6 +93,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testPrefetchDictToDevice(self): host_dataset = dataset_ops.Dataset.range(10).map(lambda x: {"a": x}) device_dataset = host_dataset.apply( @@ -121,6 +124,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testPrefetchSparseTensorsToDevice(self): def make_tensor(i): return sparse_tensor.SparseTensorValue( @@ -174,6 +178,7 @@ class PrefetchToDeviceTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testPrefetchToDeviceWithReInit(self): host_dataset = dataset_ops.Dataset.range(10) device_dataset = host_dataset.apply( diff --git a/tensorflow/python/data/experimental/kernel_tests/rejection_resample_test.py b/tensorflow/python/data/experimental/kernel_tests/rejection_resample_test.py index 4c879dbae68..675209d1899 100644 --- a/tensorflow/python/data/experimental/kernel_tests/rejection_resample_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/rejection_resample_test.py @@ -28,6 +28,7 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import string_ops @@ -63,6 +64,7 @@ class RejectionResampleTest(test_base.DatasetTestBase, parameterized.TestCase): @parameterized.named_parameters( ("InitialDistributionKnown", True), ("InitialDistributionUnknown", False)) + @test_util.run_deprecated_v1 def testDistribution(self, initial_known): classes = np.random.randint(5, size=(20000,)) # Uniformly sampled target_dist = [0.9, 0.05, 0.05, 0.0, 0.0] @@ -97,6 +99,7 @@ class RejectionResampleTest(test_base.DatasetTestBase, parameterized.TestCase): @parameterized.named_parameters( ("OnlyInitial", True), ("NotInitial", False)) + @test_util.run_deprecated_v1 def testEdgeCasesSampleFromInitialDataset(self, only_initial_dist): init_dist = [0.5, 0.5] target_dist = [0.5, 0.5] if only_initial_dist else [0.0, 1.0] @@ -122,6 +125,7 @@ class RejectionResampleTest(test_base.DatasetTestBase, parameterized.TestCase): while True: returned.append(sess.run(get_next)) + @test_util.run_deprecated_v1 def testRandomClasses(self): init_dist = [0.25, 0.25, 0.25, 0.25] target_dist = [0.0, 0.0, 0.0, 1.0] diff --git a/tensorflow/python/data/experimental/kernel_tests/restructured_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/restructured_dataset_test.py index 516e489d043..658e6120cf9 100644 --- a/tensorflow/python/data/experimental/kernel_tests/restructured_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/restructured_dataset_test.py @@ -22,12 +22,14 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.data.util import nest from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test class RestructuredDatasetTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testRestructureDataset(self): components = (array_ops.placeholder(dtypes.int32), (array_ops.placeholder(dtypes.int32, shape=[None]), diff --git a/tensorflow/python/data/experimental/kernel_tests/scan_test.py b/tensorflow/python/data/experimental/kernel_tests/scan_test.py index dc8a7bca270..43a765b9e02 100644 --- a/tensorflow/python/data/experimental/kernel_tests/scan_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/scan_test.py @@ -40,6 +40,7 @@ class ScanTest(test_base.DatasetTestBase): return dataset_ops.Dataset.from_tensors(0).repeat().apply( scan_ops.scan(start, scan_fn)) + @test_util.run_deprecated_v1 def testCount(self): def make_scan_fn(step): return lambda state, _: (state + step, state) @@ -83,6 +84,7 @@ class ScanTest(test_base.DatasetTestBase): self.assertEqual(5, self.evaluate(next_element())) self.assertEqual(8, self.evaluate(next_element())) + @test_util.run_deprecated_v1 def testSparseCount(self): def _sparse(i): return sparse_tensor.SparseTensorValue( @@ -114,6 +116,7 @@ class ScanTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testChangingStateShape(self): # Test the fixed-point shape invariant calculations: start with # initial values with known shapes, and use a scan function that diff --git a/tensorflow/python/data/experimental/kernel_tests/serialization/checkpoint_input_pipeline_hook_test.py b/tensorflow/python/data/experimental/kernel_tests/serialization/checkpoint_input_pipeline_hook_test.py index 94393d6d4ba..140ed517ef5 100644 --- a/tensorflow/python/data/experimental/kernel_tests/serialization/checkpoint_input_pipeline_hook_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/serialization/checkpoint_input_pipeline_hook_test.py @@ -26,6 +26,7 @@ from tensorflow.python.estimator import model_fn from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -68,6 +69,7 @@ class CheckpointInputPipelineHookTest(test_base.DatasetTestBase): def _build_iterator_saver_hook(self, est): return iterator_ops.CheckpointInputPipelineHook(est) + @test_util.run_deprecated_v1 def testReturnDatasetFromInputFn(self): def _input_fn(): @@ -80,6 +82,7 @@ class CheckpointInputPipelineHookTest(test_base.DatasetTestBase): est.train(_input_fn, steps=2, hooks=[self._build_iterator_saver_hook(est)]) self.assertSequenceEqual(self._read_vars(est.model_dir), (4, 3)) + @test_util.run_deprecated_v1 def testBuildIteratorInInputFn(self): def _input_fn(): @@ -94,6 +97,7 @@ class CheckpointInputPipelineHookTest(test_base.DatasetTestBase): est.train(_input_fn, steps=2, hooks=[self._build_iterator_saver_hook(est)]) self.assertSequenceEqual(self._read_vars(est.model_dir), (4, 3)) + @test_util.run_deprecated_v1 def testDoNotRestore(self): def _input_fn(): diff --git a/tensorflow/python/data/experimental/kernel_tests/shuffle_and_repeat_test.py b/tensorflow/python/data/experimental/kernel_tests/shuffle_and_repeat_test.py index 2e8b93feaf0..ce63da6bf98 100644 --- a/tensorflow/python/data/experimental/kernel_tests/shuffle_and_repeat_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/shuffle_and_repeat_test.py @@ -24,6 +24,7 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -44,6 +45,7 @@ class ShuffleAndRepeatTest(test_base.DatasetTestBase): self.evaluate(get_next) return outputs + @test_util.run_deprecated_v1 def testCorrectOutput(self): output = self._gen_outputs(lambda: self._build_ds(10), 100) self.assertSequenceEqual( @@ -52,6 +54,7 @@ class ShuffleAndRepeatTest(test_base.DatasetTestBase): for i in range(5): self.assertSequenceEqual(sorted(output[i * 20:(i + 1) * 20]), range(20)) + @test_util.run_deprecated_v1 def testReshuffling(self): # Check that the output orders of different epochs are indeed different. output = self._gen_outputs(lambda: self._build_ds(10), 100) @@ -60,17 +63,20 @@ class ShuffleAndRepeatTest(test_base.DatasetTestBase): epoch2 = output[(i + 1) * 20:(i + 2) * 20] self.assertNotEqual(epoch1, epoch2) + @test_util.run_deprecated_v1 def testSameOrderForSameSeeds(self): output1 = self._gen_outputs(lambda: self._build_ds(10), 100) output2 = self._gen_outputs(lambda: self._build_ds(10), 100) self.assertEqual(output1, output2) + @test_util.run_deprecated_v1 def testDifferentOrderForDifferentSeeds(self): output1 = self._gen_outputs(lambda: self._build_ds(10), 100) output2 = self._gen_outputs(lambda: self._build_ds(20), 100) self.assertNotEqual(output1, output2) self.assertEqual(sorted(output1), sorted(output2)) + @test_util.run_deprecated_v1 def testCountNone(self): output1 = self._gen_outputs( lambda: self._build_ds(10, count=None), 100, verify_exhausted=False) @@ -79,6 +85,7 @@ class ShuffleAndRepeatTest(test_base.DatasetTestBase): self.assertNotEqual(output1, output2) self.assertEqual(sorted(output1), sorted(output2)) + @test_util.run_deprecated_v1 def testCountMinusOne(self): output1 = self._gen_outputs( lambda: self._build_ds(10, count=-1), 100, verify_exhausted=False) diff --git a/tensorflow/python/data/experimental/kernel_tests/sleep_test.py b/tensorflow/python/data/experimental/kernel_tests/sleep_test.py index 1a6d5522ef4..8c9e8225d68 100644 --- a/tensorflow/python/data/experimental/kernel_tests/sleep_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/sleep_test.py @@ -23,6 +23,7 @@ from tensorflow.python.data.experimental.ops import sleep from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.platform import test _NUMPY_RANDOM_SEED = 42 @@ -30,6 +31,7 @@ _NUMPY_RANDOM_SEED = 42 class SleepTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testSleep(self): sleep_microseconds = 100 dataset = dataset_ops.Dataset.range(10).apply( diff --git a/tensorflow/python/data/experimental/kernel_tests/stats_dataset_ops_test.py b/tensorflow/python/data/experimental/kernel_tests/stats_dataset_ops_test.py index e8160069333..b89aa20432a 100644 --- a/tensorflow/python/data/experimental/kernel_tests/stats_dataset_ops_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/stats_dataset_ops_test.py @@ -30,6 +30,7 @@ from tensorflow.python.data.experimental.ops import stats_options from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -59,6 +60,7 @@ def function_apply_options(dataset, aggregator, prefix="", counter_prefix=""): ) class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): + @test_util.run_deprecated_v1 def testBytesProduced(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).map( @@ -85,6 +87,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount(summary_str, "bytes_produced", 100.0) self._assertSummaryHasSum(summary_str, "bytes_produced", expected_sum) + @test_util.run_deprecated_v1 def testLatencyStats(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -105,6 +108,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount( self.evaluate(summary_t), "record_latency", 100.0) + @test_util.run_deprecated_v1 def testPrefetchBufferUtilization(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).map( @@ -132,6 +136,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount(summary_str, "Prefetch::buffer_utilization", 100) + @test_util.run_deprecated_v1 def testPrefetchBufferScalars(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(10).map( @@ -154,6 +159,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testFilteredElementsStats(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(101).filter( @@ -180,6 +186,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasScalarValue( self.evaluate(summary_t), "Filter::filtered_elements", 34.0) + @test_util.run_deprecated_v1 def testMapBufferUtilization(self, dataset_transformation): def dataset_fn(): @@ -194,6 +201,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): dataset_transformation, function_processing_time=True) + @test_util.run_deprecated_v1 def testMapAutoTuneBufferUtilization(self, dataset_transformation): def dataset_fn(): @@ -211,6 +219,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): dataset_transformation, function_processing_time=True) + @test_util.run_deprecated_v1 def testInterleaveAutoTuneBufferUtilization(self, dataset_transformation): def dataset_fn(): @@ -227,6 +236,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._testParallelCallsStats(dataset_fn, "ParallelInterleaveV2", 10, dataset_transformation) + @test_util.run_deprecated_v1 def testMapAndBatchAutoTuneBufferUtilization(self, dataset_transformation): def dataset_fn(): @@ -248,6 +258,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): check_elements=False, function_processing_time=True) + @test_util.run_deprecated_v1 def testReinitialize(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -270,6 +281,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount( self.evaluate(summary_t), "record_latency", (j + 1) * 100.0) + @test_util.run_deprecated_v1 def testNoAggregatorRegistered(self, dataset_transformation): dataset = dataset_ops.Dataset.range(100).apply( stats_ops.latency_stats("record_latency")) @@ -283,6 +295,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testMultipleTags(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -308,6 +321,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount( self.evaluate(summary_t), "record_latency_2", 100.0) + @test_util.run_deprecated_v1 def testRepeatedTags(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -329,6 +343,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount( self.evaluate(summary_t), "record_latency", 200.0) + @test_util.run_deprecated_v1 def testMultipleIteratorsSameAggregator(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -350,6 +365,7 @@ class StatsDatasetTest(stats_dataset_test_base.StatsDatasetTestBase): self._assertSummaryHasCount( self.evaluate(summary_t), "record_latency", 200.0) + @test_util.run_deprecated_v1 def testMultipleDatasetWithPrefixes(self, dataset_transformation): aggregator = stats_aggregator.StatsAggregator() dataset = dataset_ops.Dataset.range(100).apply( @@ -390,6 +406,7 @@ class FeatureStatsDatasetTest( stats_dataset_test_base.StatsDatasetTestBase, reader_dataset_ops_test_base.MakeBatchedFeaturesDatasetTestBase): + @test_util.run_deprecated_v1 def testFeaturesStats(self, dataset_transformation): num_epochs = 5 total_records = num_epochs * self._num_records diff --git a/tensorflow/python/data/experimental/kernel_tests/unbatch_test.py b/tensorflow/python/data/experimental/kernel_tests/unbatch_test.py index cb94bb41443..9c6830d9934 100644 --- a/tensorflow/python/data/experimental/kernel_tests/unbatch_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/unbatch_test.py @@ -28,6 +28,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import string_ops @@ -37,6 +38,7 @@ from tensorflow.python.util import compat class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testUnbatchWithUnknownRankInput(self): placeholder = array_ops.placeholder(dtypes.int32) dataset = dataset_ops.Dataset.from_tensors(placeholder).apply( @@ -51,6 +53,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_elem) + @test_util.run_deprecated_v1 def testUnbatchScalarDataset(self): data = tuple([math_ops.range(10) for _ in range(3)]) data = dataset_ops.Dataset.from_tensor_slices(data) @@ -70,6 +73,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(op) + @test_util.run_deprecated_v1 def testUnbatchDatasetWithStrings(self): data = tuple([math_ops.range(10) for _ in range(3)]) data = dataset_ops.Dataset.from_tensor_slices(data) @@ -90,6 +94,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(op) + @test_util.run_deprecated_v1 def testUnbatchDatasetWithSparseTensor(self): st = sparse_tensor.SparseTensorValue( indices=[[i, i] for i in range(10)], @@ -111,6 +116,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testUnbatchDatasetWithDenseAndSparseTensor(self): st = sparse_tensor.SparseTensorValue( indices=[[i, i] for i in range(10)], @@ -133,6 +139,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testUnbatchSingleElementTupleDataset(self): data = tuple([(math_ops.range(10),) for _ in range(3)]) data = dataset_ops.Dataset.from_tensor_slices(data) @@ -152,6 +159,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(op) + @test_util.run_deprecated_v1 def testUnbatchMultiElementTupleDataset(self): data = tuple([(math_ops.range(10 * i, 10 * i + 10), array_ops.fill([10], "hi")) for i in range(3)]) @@ -173,6 +181,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(op) + @test_util.run_deprecated_v1 def testUnbatchEmpty(self): data = dataset_ops.Dataset.from_tensors( (constant_op.constant([]), constant_op.constant([], shape=[0, 4]), @@ -191,6 +200,7 @@ class UnbatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(ValueError): data.apply(batching.unbatch()) + @test_util.run_deprecated_v1 def testUnbatchDynamicShapeMismatch(self): ph1 = array_ops.placeholder(dtypes.int32, shape=[None]) ph2 = array_ops.placeholder(dtypes.int32, shape=None) diff --git a/tensorflow/python/data/experimental/kernel_tests/unique_test.py b/tensorflow/python/data/experimental/kernel_tests/unique_test.py index 91f4bc84e99..ddec968858a 100644 --- a/tensorflow/python/data/experimental/kernel_tests/unique_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/unique_test.py @@ -22,6 +22,7 @@ from tensorflow.python.data.kernel_tests import test_base from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.util import compat @@ -57,6 +58,7 @@ class UniqueTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testSimpleInt(self): for dtype in [dtypes.int32, dtypes.int64]: self._testSimpleHelper(dtype, [ @@ -69,6 +71,7 @@ class UniqueTest(test_base.DatasetTestBase): ([[1, 1], [1, 1], [2, 2], [3, 3], [1, 1]], [[1, 1], [2, 2], [3, 3]]), ]) + @test_util.run_deprecated_v1 def testSimpleString(self): self._testSimpleHelper(dtypes.string, [ ([], []), diff --git a/tensorflow/python/data/kernel_tests/flat_map_test.py b/tensorflow/python/data/kernel_tests/flat_map_test.py index 5f11c2e3a7f..ff52821b107 100644 --- a/tensorflow/python/data/kernel_tests/flat_map_test.py +++ b/tensorflow/python/data/kernel_tests/flat_map_test.py @@ -60,6 +60,7 @@ class FlatMapTest(test_base.DatasetTestBase): self.assertDatasetProduces(dataset, expected_output=expected_output) # Note: no eager mode coverage, session specific test. + @test_util.run_deprecated_v1 def testSkipEagerSharedResourceNestedFlatMapDataset(self): repeats = [[1, 2], [3, 4], [5, 0], [1, 7]] components = np.array(repeats, dtype=np.int64) diff --git a/tensorflow/python/data/kernel_tests/from_generator_test.py b/tensorflow/python/data/kernel_tests/from_generator_test.py index 4d82c2111c3..d58e3c2364d 100644 --- a/tensorflow/python/data/kernel_tests/from_generator_test.py +++ b/tensorflow/python/data/kernel_tests/from_generator_test.py @@ -27,6 +27,7 @@ from tensorflow.python.data.ops import dataset_ops from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import script_ops from tensorflow.python.platform import test @@ -69,6 +70,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorUsingFunction(self): def generator(): for i in range(1, 100): @@ -79,18 +81,21 @@ class FromGeneratorTest(test_base.DatasetTestBase): self._testFromGeneratorOneShot(generator, elem_sequence, 1) self._testFromGeneratorOneShot(generator, elem_sequence, 5) + @test_util.run_deprecated_v1 def testFromGeneratorUsingList(self): generator = lambda: [[i] * i for i in range(1, 100)] elem_sequence = list(generator()) self._testFromGenerator(generator, elem_sequence, 1) self._testFromGenerator(generator, elem_sequence, 5) + @test_util.run_deprecated_v1 def testFromGeneratorUsingNdarray(self): generator = lambda: np.arange(100, dtype=np.int64) elem_sequence = list(generator()) self._testFromGenerator(generator, elem_sequence, 1, output_types=np.int64) self._testFromGenerator(generator, elem_sequence, 5, output_types=np.int64) + @test_util.run_deprecated_v1 def testFromGeneratorUsingGeneratorExpression(self): # NOTE(mrry): Generator *expressions* are not repeatable (or in # general reusable), because they eagerly evaluate the `for` @@ -102,6 +107,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): self._testFromGenerator(generator, elem_sequence, 1) self._testFromGenerator(generator, elem_sequence, 5) + @test_util.run_deprecated_v1 def testFromMultipleConcurrentGenerators(self): num_inner_repeats = 5 num_outer_repeats = 100 @@ -199,6 +205,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorImplicitConversion(self): def generator(): yield [1] @@ -223,6 +230,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorString(self): def generator(): yield "foo" @@ -243,6 +251,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorTypeError(self): def generator(): yield np.array([1, 2, 3], dtype=np.int64) @@ -266,6 +275,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorShapeError(self): def generator(): yield np.array([1, 2, 3], dtype=np.int64) @@ -289,6 +299,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorStructureError(self): def generator(): yield 1, 2 @@ -317,6 +328,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorHeterogeneous(self): def generator(): yield 1 @@ -335,6 +347,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorStopShort(self): def generator(): @@ -353,6 +366,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): self.assertAllEqual(0, sess.run(get_next)) self.assertAllEqual(1, sess.run(get_next)) + @test_util.run_deprecated_v1 def testFromGeneratorDestructorCalled(self): # Use an `Event` to signal that the generator has been deleted. event = threading.Event() @@ -387,6 +401,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): # iterator terminates (and the generator iterator is deleted). self.assertTrue(event.is_set()) + @test_util.run_deprecated_v1 def testFromGeneratorWithArgs(self): def flat_map_fn(elem): @@ -414,6 +429,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testFromGeneratorWithTwoArgs(self): def flat_map_fn(elem, message): @@ -446,6 +462,7 @@ class FromGeneratorTest(test_base.DatasetTestBase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testGeneratorDatasetFinalizeFunctionCalled(self): # NOTE(mrry): This test tests the internal `_GeneratorDataset`, # which affords more control over what the finalize function can do than diff --git a/tensorflow/python/data/kernel_tests/from_sparse_tensor_slices_test.py b/tensorflow/python/data/kernel_tests/from_sparse_tensor_slices_test.py index d23ac0ebe9c..80ed26e7fbc 100644 --- a/tensorflow/python/data/kernel_tests/from_sparse_tensor_slices_test.py +++ b/tensorflow/python/data/kernel_tests/from_sparse_tensor_slices_test.py @@ -32,6 +32,7 @@ from tensorflow.python.platform import test @test_util.run_all_in_graph_and_eager_modes class FromSparseTensorSlicesTest(test_base.DatasetTestBase): + @test_util.run_deprecated_v1 def testSkipEagerFromSparseTensorSlices(self): """Test a dataset based on slices of a `tf.SparseTensor`.""" st = array_ops.sparse_placeholder(dtypes.float64) diff --git a/tensorflow/python/data/kernel_tests/from_tensors_test.py b/tensorflow/python/data/kernel_tests/from_tensors_test.py index 2857817e14e..ce706375724 100644 --- a/tensorflow/python/data/kernel_tests/from_tensors_test.py +++ b/tensorflow/python/data/kernel_tests/from_tensors_test.py @@ -154,6 +154,7 @@ class FromTensorsTest(test_base.DatasetTestBase): self.assertEquals(([], ([], []), []), dataset.output_shapes) # TODO(b/117581999): more specific shapes in eager mode. + @test_util.run_deprecated_v1 def testSkipEagerNestedStructure(self): components = (np.array([1, 2, 3], dtype=np.int64), (np.array([4., 5.]), np.array([6., 7.])), diff --git a/tensorflow/python/data/kernel_tests/iterator_test.py b/tensorflow/python/data/kernel_tests/iterator_test.py index de95a53e576..b836a6aecf1 100644 --- a/tensorflow/python/data/kernel_tests/iterator_test.py +++ b/tensorflow/python/data/kernel_tests/iterator_test.py @@ -55,6 +55,7 @@ from tensorflow.python.util import compat class IteratorTest(test.TestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testNoGradients(self): component = constant_op.constant([1.]) side = constant_op.constant(0.) @@ -65,6 +66,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): self.assertIsNone(gradients_impl.gradients(value, side)[0]) self.assertIsNone(gradients_impl.gradients(value, [component, side])[0]) + @test_util.run_deprecated_v1 def testCapturingStateInOneShotRaisesException(self): var = variables.Variable(37.0, name="myvar") dataset = ( @@ -75,6 +77,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): "datasets that capture stateful objects.+myvar"): dataset.make_one_shot_iterator() + @test_util.run_deprecated_v1 def testOneShotIterator(self): components = (np.arange(7), np.array([[1, 2, 3]]) * np.arange(7)[:, np.newaxis], @@ -100,6 +103,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testOneShotIteratorCaptureByValue(self): components = (np.arange(7), np.array([[1, 2, 3]]) * np.arange(7)[:, np.newaxis], @@ -162,6 +166,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testOneShotIteratorNonBlocking(self): dataset = dataset_ops.Dataset.from_tensors([1, 2, 3]).map(lambda x: x * x) iterator = dataset.make_one_shot_iterator() @@ -200,6 +205,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): len([None for r in results if r is None])) self.assertAllEqual([[1, 4, 9]], [r for r in results if r is not None]) + @test_util.run_deprecated_v1 def testOneShotIteratorInitializerFails(self): # Define a dataset whose initialization will always fail. dataset = dataset_ops.Dataset.from_tensors( @@ -280,6 +286,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testNotInitializedError(self): components = (np.array(1), np.array([1, 2, 3]), np.array(37.0)) iterator = ( @@ -292,6 +299,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): "iterator has not been initialized"): sess.run(get_next) + @test_util.run_deprecated_v1 def testReinitializableIterator(self): dataset_3 = dataset_ops.Dataset.from_tensors( constant_op.constant([1, 2, 3])) @@ -331,6 +339,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) + @test_util.run_deprecated_v1 def testReinitializableIteratorWithFunctions(self): def g(): @@ -390,6 +399,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): (constant_op.constant([1, 2, 3], dtype=dtypes.int64), constant_op.constant([4., 5., 6., 7.], dtype=dtypes.float64)))) + @test_util.run_deprecated_v1 def testIteratorStringHandle(self): dataset_3 = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) dataset_4 = dataset_ops.Dataset.from_tensor_slices([10, 20, 30, 40]) @@ -445,6 +455,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): sess.run( next_element, feed_dict={handle_placeholder: iterator_4_handle}) + @test_util.run_deprecated_v1 def testIteratorStringHandleFuture(self): with forward_compat.forward_compatibility_horizon(2018, 8, 4): dataset_3 = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) @@ -508,6 +519,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): sess.run( next_element, feed_dict={handle_placeholder: iterator_4_handle}) + @test_util.run_deprecated_v1 def testIteratorStringHandleReuseTensorObject(self): dataset = dataset_ops.Dataset.from_tensor_slices([1, 2, 3]) one_shot_iterator = dataset.make_one_shot_iterator() @@ -536,6 +548,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): self.assertEqual("foo_1", handle_with_same_name.op.name) self.assertIsNot(handle_with_name, handle_with_same_name) + @test_util.run_deprecated_v1 def testIteratorStringHandleError(self): dataset_int_scalar = ( dataset_ops.Dataset.from_tensor_slices([1, 2, 3]).repeat()) @@ -576,6 +589,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): feedable_int_vector.get_next(), feed_dict={handle_placeholder: handle_float_vector})) + @test_util.run_deprecated_v1 def testRemoteIteratorUsingRemoteCallOpDirectSession(self): worker_config = config_pb2.ConfigProto() worker_config.device_count["CPU"] = 3 @@ -632,6 +646,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): target_placeholder: "/job:localhost/replica:0/task:0/cpu:1" }) + @test_util.run_deprecated_v1 def testRemoteIteratorUsingRemoteCallOpMultiWorkers(self): s1 = server_lib.Server.create_local_server() s2 = server_lib.Server.create_local_server() @@ -739,6 +754,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): target_placeholder: "/job:localhost/replica:0/task:0/cpu:0" }) + @test_util.run_deprecated_v1 def testIncorrectIteratorRestore(self): def _path(): @@ -797,6 +813,7 @@ class IteratorTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.InvalidArgumentError): sess.run(restore_op) + @test_util.run_deprecated_v1 def testRepeatedGetNextWarning(self): iterator = dataset_ops.Dataset.range(10).make_one_shot_iterator() warnings.simplefilter("always") diff --git a/tensorflow/python/data/kernel_tests/list_files_test.py b/tensorflow/python/data/kernel_tests/list_files_test.py index 26c536086bc..789f1ab6de7 100644 --- a/tensorflow/python/data/kernel_tests/list_files_test.py +++ b/tensorflow/python/data/kernel_tests/list_files_test.py @@ -44,6 +44,7 @@ class ListFilesTest(test_base.DatasetTestBase): open(path.join(self.tmp_dir, filename), 'a').close() # Note: eager mode fails in assertion error same as initializer in graph mode. + @test_util.run_deprecated_v1 def testSkipEagerEmptyDirectory(self): dataset = dataset_ops.Dataset.list_files(path.join(self.tmp_dir, '*')) self.assertDatasetProduces(dataset, expected_output=[]) diff --git a/tensorflow/python/data/kernel_tests/optional_test.py b/tensorflow/python/data/kernel_tests/optional_test.py index 864013171d8..c2c62e9423e 100644 --- a/tensorflow/python/data/kernel_tests/optional_test.py +++ b/tensorflow/python/data/kernel_tests/optional_test.py @@ -74,6 +74,7 @@ class OptionalTest(test_base.DatasetTestBase, parameterized.TestCase): self.assertAllEqual(expected.dense_shape, self.evaluate(actual.dense_shape)) + @test_util.run_deprecated_v1 def testFromNone(self): value_structure = structure.TensorStructure(dtypes.float32, []) opt = optional_ops.Optional.none_from_structure(value_structure) @@ -267,6 +268,7 @@ class OptionalTest(test_base.DatasetTestBase, parameterized.TestCase): optional_ops.OptionalStructure( structure.TensorStructure(dtypes.float32, []))), ) + @test_util.run_deprecated_v1 def testSkipEagerOptionalStructure(self, tf_value_fn, expected_value_structure): tf_value = tf_value_fn() @@ -322,6 +324,7 @@ class OptionalTest(test_base.DatasetTestBase, parameterized.TestCase): indices=[[0, 1], [1, 0]], values=[37.0, 42.0], dense_shape=[2, 2])}, False), ) + @test_util.run_deprecated_v1 def testSkipEagerIteratorGetNextAsOptional(self, np_value, tf_value_fn, works_on_gpu): if not works_on_gpu and test.is_gpu_available(): diff --git a/tensorflow/python/data/kernel_tests/padded_batch_test.py b/tensorflow/python/data/kernel_tests/padded_batch_test.py index 5f20d7b4240..dcfb2f507bf 100644 --- a/tensorflow/python/data/kernel_tests/padded_batch_test.py +++ b/tensorflow/python/data/kernel_tests/padded_batch_test.py @@ -93,6 +93,7 @@ class PaddedBatchTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next()) + @test_util.run_deprecated_v1 def testPaddedBatchShortPadding(self): dataset = ( dataset_ops.Dataset.from_tensor_slices( @@ -155,6 +156,7 @@ class PaddedBatchTest(test_base.DatasetTestBase, parameterized.TestCase): next_element = self.getNext(padded_dataset) self.evaluate(next_element()) + @test_util.run_deprecated_v1 def testSkipEagerPaddedBatchDatasetShapeSpecifications(self): int_placeholder = array_ops.placeholder(dtypes.int32) float_placeholder = array_ops.placeholder(dtypes.float32) @@ -226,6 +228,7 @@ class PaddedBatchTest(test_base.DatasetTestBase, parameterized.TestCase): _ = dataset_ops.Dataset.range(10).padded_batch( 5, padded_shapes=shape_as_tensor) + @test_util.run_deprecated_v1 def testSkipEagerPaddedBatchShapeError(self): with self.assertRaisesRegexp( ValueError, diff --git a/tensorflow/python/data/kernel_tests/reduce_test.py b/tensorflow/python/data/kernel_tests/reduce_test.py index d7b653961d6..14bbc0bf72c 100644 --- a/tensorflow/python/data/kernel_tests/reduce_test.py +++ b/tensorflow/python/data/kernel_tests/reduce_test.py @@ -68,6 +68,7 @@ class ReduceTest(test_base.DatasetTestBase, parameterized.TestCase): self.assertEqual(((i + 1) * i) // 2, s) self.assertEqual(i, c) + @test_util.run_deprecated_v1 def testSkipEagerSquareUsingPlaceholder(self): delta = array_ops.placeholder(dtype=dtypes.int64) diff --git a/tensorflow/python/data/kernel_tests/shuffle_test.py b/tensorflow/python/data/kernel_tests/shuffle_test.py index 49460a1a4ed..05d5d814c01 100644 --- a/tensorflow/python/data/kernel_tests/shuffle_test.py +++ b/tensorflow/python/data/kernel_tests/shuffle_test.py @@ -115,6 +115,7 @@ class ShuffleTest(test_base.DatasetTestBase, parameterized.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(get_next()) + @test_util.run_deprecated_v1 def testSkipEagerSeedZero(self): """Test for same behavior when the seed is a Python or Tensor zero.""" iterator = ( diff --git a/tensorflow/python/data/util/convert_test.py b/tensorflow/python/data/util/convert_test.py index 3058e2b3f60..78ca6e95139 100644 --- a/tensorflow/python/data/util/convert_test.py +++ b/tensorflow/python/data/util/convert_test.py @@ -22,6 +22,7 @@ from tensorflow.python.data.util import convert from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.util import compat @@ -60,6 +61,7 @@ class ConvertTest(test.TestCase): convert.partial_shape_to_tensor( constant_op.constant([1], dtype=dtypes.int64)))) + @test_util.run_deprecated_v1 def testPartialShapeToTensorUnknownDimension(self): self.assertAllEqual([-1], self.evaluate( diff --git a/tensorflow/python/data/util/sparse_test.py b/tensorflow/python/data/util/sparse_test.py index 4ba314f06a4..06acf55ab9d 100644 --- a/tensorflow/python/data/util/sparse_test.py +++ b/tensorflow/python/data/util/sparse_test.py @@ -25,6 +25,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -296,6 +297,7 @@ class SparseTest(test.TestCase): self.assertAllEqual(a.eval().values, self.evaluate(b).values) self.assertAllEqual(a.eval().dense_shape, self.evaluate(b).dense_shape) + @test_util.run_deprecated_v1 def testSerializeDeserialize(self): test_cases = ( (), @@ -325,6 +327,7 @@ class SparseTest(test.TestCase): for a, e in zip(nest.flatten(actual), nest.flatten(expected)): self.assertSparseValuesEqual(a, e) + @test_util.run_deprecated_v1 def testSerializeManyDeserialize(self): test_cases = ( (), diff --git a/tensorflow/python/data/util/structure_test.py b/tensorflow/python/data/util/structure_test.py index 65a41a50f11..e9e2f5be0ae 100644 --- a/tensorflow/python/data/util/structure_test.py +++ b/tensorflow/python/data/util/structure_test.py @@ -28,6 +28,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -115,6 +116,7 @@ class StructureTest(test.TestCase, parameterized.TestCase): indices=[[0], [1], [2]], values=[4, 5, 6], dense_shape=[3]) }, (constant_op.constant(15.0), constant_op.constant([4, 5, 6]))]), ) + @test_util.run_deprecated_v1 def testIsCompatibleWithStructure( self, original_value_fn, compatible_values_fn, incompatible_values_fn): original_value = original_value_fn() diff --git a/tensorflow/python/debug/cli/analyzer_cli_test.py b/tensorflow/python/debug/cli/analyzer_cli_test.py index 5aa7d1bb4c3..322ecf94667 100644 --- a/tensorflow/python/debug/cli/analyzer_cli_test.py +++ b/tensorflow/python/debug/cli/analyzer_cli_test.py @@ -645,6 +645,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertEqual(len("Size (B)") + 1, dump_size_col_width) self.assertEqual(len("Op type") + 1, op_type_col_width) + @test_util.run_deprecated_v1 def testMeasureTensorListColumnWidthsGivesRightAnswerForData(self): dump = self._debug_dump.dumped_tensor_data[0] self.assertLess(dump.dump_size_bytes, 1000) @@ -660,6 +661,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): # column should be determined by the length of "VariableV2". self.assertEqual(len("VariableV2") + 1, op_type_col_width) + @test_util.run_deprecated_v1 def testListTensors(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", []) @@ -673,6 +675,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): # Check the main menu. check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInReverseTimeOrderWorks(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", ["-s", "timestamp", "-r"]) @@ -688,6 +691,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): reverse=True) check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInDumpSizeOrderWorks(self): out = self._registry.dispatch_command("lt", ["-s", "dump_size"]) assert_listed_tensors( @@ -701,6 +705,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): sort_by="dump_size") check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInReverseDumpSizeOrderWorks(self): out = self._registry.dispatch_command("lt", ["-s", "dump_size", "-r"]) assert_listed_tensors( @@ -720,6 +725,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertIn("ValueError: Unsupported key to sort tensors by: foobar", out.lines) + @test_util.run_deprecated_v1 def testListTensorsInOpTypeOrderWorks(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", ["-s", "op_type"]) @@ -735,6 +741,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): reverse=False) check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInReverseOpTypeOrderWorks(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", ["-s", "op_type", "-r"]) @@ -750,6 +757,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): reverse=True) check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInTensorNameOrderWorks(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", ["-s", "tensor_name"]) @@ -765,6 +773,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): reverse=False) check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsInReverseTensorNameOrderWorks(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", ["-s", "tensor_name", "-r"]) @@ -780,6 +789,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): reverse=True) check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorsFilterByNodeNameRegex(self): out = self._registry.dispatch_command("list_tensors", ["--node_name_filter", ".*read.*"]) @@ -793,6 +803,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): assert_listed_tensors(self, out, [], [], node_name_regex="^read") check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorFilterByOpTypeRegex(self): out = self._registry.dispatch_command("list_tensors", ["--op_type_filter", "Identity"]) @@ -821,6 +832,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): op_type_regex="(Add|MatMul)") check_main_menu(self, out, list_tensors_enabled=False) + @test_util.run_deprecated_v1 def testListTensorWithFilterAndNodeNameExclusionWorks(self): # First, create and register the filter. def is_2x1_vector(datum, tensor): @@ -877,6 +889,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): out = self._registry.dispatch_command("list_tensors", ["--bar"]) check_syntax_error_output(self, out, "list_tensors") + @test_util.run_deprecated_v1 def testNodeInfoByNodeName(self): node_name = "simple_mul_add/matmul" out = self._registry.dispatch_command("node_info", [node_name]) @@ -901,6 +914,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): [(len(out.lines[0]) - len(node_name), len(out.lines[0]), "bold")], out.font_attr_segs[0]) + @test_util.run_deprecated_v1 def testNodeInfoShowAttributes(self): node_name = "simple_mul_add/matmul" out = self._registry.dispatch_command("node_info", ["-a", node_name]) @@ -924,6 +938,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): print_tensor_node_name=node_name, list_outputs_node_name=node_name) + @test_util.run_deprecated_v1 def testNodeInfoShowDumps(self): node_name = "simple_mul_add/matmul" out = self._registry.dispatch_command("node_info", ["-d", node_name]) @@ -948,6 +963,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): len(out.lines[16]) - len(out.lines[16].strip()), len(out.lines[16]), "pt %s:0 -n 0" % node_name) + @test_util.run_deprecated_v1 def testNodeInfoShowStackTraceUnavailableIsIndicated(self): self._debug_dump.set_python_graph(None) @@ -971,6 +987,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): print_tensor_node_name=node_name, list_outputs_node_name=node_name) + @test_util.run_deprecated_v1 def testNodeInfoShowStackTraceAvailableWorks(self): self._debug_dump.set_python_graph(self._sess.graph) @@ -994,6 +1011,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): print_tensor_node_name=node_name, list_outputs_node_name=node_name) + @test_util.run_deprecated_v1 def testNodeInfoByTensorName(self): node_name = "simple_mul_add/u/read" tensor_name = node_name + ":0" @@ -1363,6 +1381,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): break return index + @test_util.run_deprecated_v1 def testPrintSourceForOpNamesWholeFileWorks(self): self._debug_dump.set_python_graph(self._sess.graph) out = self._registry.dispatch_command( @@ -1415,6 +1434,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertEqual("pt simple_mul_add/add", out.font_attr_segs[index + 1][0][2].content) + @test_util.run_deprecated_v1 def testPrintSourceForTensorNamesWholeFileWorks(self): self._debug_dump.set_python_graph(self._sess.graph) out = self._registry.dispatch_command( @@ -1435,6 +1455,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertEqual("pt simple_mul_add/u:0", out.font_attr_segs[index + 2][0][2].content) + @test_util.run_deprecated_v1 def testPrintSourceForOpNamesStartingAtSpecifiedLineWorks(self): self._debug_dump.set_python_graph(self._sess.graph) out = self._registry.dispatch_command( @@ -1461,6 +1482,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertEqual("pt simple_mul_add/u/read", out.font_attr_segs[index + 3][0][2].content) + @test_util.run_deprecated_v1 def testPrintSourceForOpNameSettingMaximumElementCountWorks(self): self._debug_dump.set_python_graph(self._sess.graph) out = self._registry.dispatch_command( @@ -1505,6 +1527,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase): self.assertTrue(cli_shared.COLOR_GRAY in attr_seg[2] or attr_seg[2] == cli_shared.COLOR_GRAY) + @test_util.run_deprecated_v1 def testListSourceWithNodeNameFilterWithMatchesWorks(self): self._debug_dump.set_python_graph(self._sess.graph) out = self._registry.dispatch_command("list_source", ["-n", ".*/read"]) @@ -1719,6 +1742,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): # Tear down temporary dump directory. shutil.rmtree(cls._dump_root) + @test_util.run_deprecated_v1 def testNodeInfoWithControlDependencies(self): # Call node_info on a node with control inputs. out = self._registry.dispatch_command("node_info", @@ -1759,6 +1783,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): len(out.lines[z_line]), "ni -a -d -t control_deps/ctrl_dep_z") + @test_util.run_deprecated_v1 def testListInputsNonRecursiveNoControl(self): """List inputs non-recursively, without any control inputs.""" @@ -1801,6 +1826,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): len(out.lines[3]) - len("control_deps/ctrl_dep_y"), len(out.lines[3]), "li -c -r control_deps/ctrl_dep_y") + @test_util.run_deprecated_v1 def testListInputsNonRecursiveNoControlUsingTensorName(self): """List inputs using the name of an output tensor of the node.""" @@ -1829,6 +1855,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): len(out.lines[3]) - len("control_deps/ctrl_dep_y"), len(out.lines[3]), "li -c -r control_deps/ctrl_dep_y") + @test_util.run_deprecated_v1 def testListInputsNonRecursiveWithControls(self): """List inputs non-recursively, with control inputs.""" node_name = "control_deps/ctrl_dep_z" @@ -1859,6 +1886,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): len(out.lines[5]) - len("control_deps/x"), len(out.lines[5]), "li -c -r control_deps/x") + @test_util.run_deprecated_v1 def testListInputsRecursiveWithControls(self): """List inputs recursively, with control inputs.""" node_name = "control_deps/ctrl_dep_z" @@ -1904,6 +1932,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): len(out.lines[18]) - len("control_deps/x"), len(out.lines[18]), "li -c -r control_deps/x") + @test_util.run_deprecated_v1 def testListInputsRecursiveWithControlsWithDepthLimit(self): """List inputs recursively, with control inputs and a depth limit.""" node_name = "control_deps/ctrl_dep_z" @@ -1963,6 +1992,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase): "ERROR: There is no node named \"control_deps/z/foo\" in the " "partition graphs"], out.lines) + @test_util.run_deprecated_v1 def testListRecipientsRecursiveWithControlsWithDepthLimit(self): """List recipients recursively, with control inputs and a depth limit.""" @@ -2034,6 +2064,7 @@ class AnalyzerCLIWhileLoopTest(test_util.TensorFlowTestCase): # Tear down temporary dump directory. shutil.rmtree(cls._dump_root) + @test_util.run_deprecated_v1 def testMultipleDumpsPrintTensorNoNumber(self): output = self._registry.dispatch_command("pt", ["while/Identity:0"]) @@ -2051,6 +2082,7 @@ class AnalyzerCLIWhileLoopTest(test_util.TensorFlowTestCase): self.assertEqual("For example:", output.lines[-2]) self.assertEqual(" print_tensor while/Identity:0 -n 0", output.lines[-1]) + @test_util.run_deprecated_v1 def testMultipleDumpsPrintTensorWithNumber(self): for i in xrange(5): output = self._registry.dispatch_command( @@ -2064,6 +2096,7 @@ class AnalyzerCLIWhileLoopTest(test_util.TensorFlowTestCase): self.assertTrue(output.lines[4].startswith("array(%d" % i)) self.assertTrue(output.lines[4].endswith(")")) + @test_util.run_deprecated_v1 def testMultipleDumpsPrintTensorInvalidNumber(self): output = self._registry.dispatch_command("pt", ["while/Identity:0", "-n", "10"]) diff --git a/tensorflow/python/debug/cli/cli_shared_test.py b/tensorflow/python/debug/cli/cli_shared_test.py index 07b364db9f2..d191a234fde 100644 --- a/tensorflow/python/debug/cli/cli_shared_test.py +++ b/tensorflow/python/debug/cli/cli_shared_test.py @@ -118,6 +118,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): def tearDown(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testSingleFetchNoFeeds(self): run_start_intro = cli_shared.get_run_start_intro(12, self.const_a, None, {}) @@ -181,6 +182,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): run_start_intro = cli_shared.get_run_start_intro(1, self.sparse_d, None, {}) self.assertEqual(str(self.sparse_d), run_start_intro.lines[4].strip()) + @test_util.run_deprecated_v1 def testTwoFetchesListNoFeeds(self): fetches = [self.const_a, self.const_b] run_start_intro = cli_shared.get_run_start_intro(1, fetches, None, {}) @@ -197,6 +199,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): description = cli_shared.get_run_short_description(1, fetches, None) self.assertEqual("run #1: 2 fetches; 0 feeds", description) + @test_util.run_deprecated_v1 def testNestedListAsFetches(self): fetches = [self.const_c, [self.const_a, self.const_b]] run_start_intro = cli_shared.get_run_start_intro(1, fetches, None, {}) @@ -210,6 +213,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): description = cli_shared.get_run_short_description(1, fetches, None) self.assertEqual("run #1: 3 fetches; 0 feeds", description) + @test_util.run_deprecated_v1 def testNestedDictAsFetches(self): fetches = {"c": self.const_c, "ab": {"a": self.const_a, "b": self.const_b}} run_start_intro = cli_shared.get_run_start_intro(1, fetches, None, {}) @@ -227,6 +231,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): description = cli_shared.get_run_short_description(1, fetches, None) self.assertEqual("run #1: 3 fetches; 0 feeds", description) + @test_util.run_deprecated_v1 def testTwoFetchesAsTupleNoFeeds(self): fetches = (self.const_a, self.const_b) run_start_intro = cli_shared.get_run_start_intro(1, fetches, None, {}) @@ -243,6 +248,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): description = cli_shared.get_run_short_description(1, fetches, None) self.assertEqual("run #1: 2 fetches; 0 feeds", description) + @test_util.run_deprecated_v1 def testTwoFetchesAsNamedTupleNoFeeds(self): fetches_namedtuple = namedtuple("fetches", "x y") fetches = fetches_namedtuple(self.const_b, self.const_c) @@ -260,6 +266,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): description = cli_shared.get_run_short_description(1, fetches, None) self.assertEqual("run #1: 2 fetches; 0 feeds", description) + @test_util.run_deprecated_v1 def testWithFeedDict(self): feed_dict = { self.const_a: 10.0, @@ -283,6 +290,7 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): feed_dict) self.assertEqual("run #1: 1 fetch (c:0); 2 feeds", description) + @test_util.run_deprecated_v1 def testTensorFilters(self): feed_dict = {self.const_a: 10.0} tensor_filters = { @@ -313,11 +321,13 @@ class GetRunStartIntroAndDescriptionTest(test_util.TensorFlowTestCase): command_set.add(annot[2].content) self.assertEqual({"run -f filter_a", "run -f filter_b"}, command_set) + @test_util.run_deprecated_v1 def testGetRunShortDescriptionWorksForTensorFeedKey(self): short_description = cli_shared.get_run_short_description( 1, self.const_a, {self.const_a: 42.0}) self.assertEqual("run #1: 1 fetch (a:0); 1 feed (a:0)", short_description) + @test_util.run_deprecated_v1 def testGetRunShortDescriptionWorksForUnicodeFeedKey(self): short_description = cli_shared.get_run_short_description( 1, self.const_a, {u"foo": 42.0}) @@ -332,6 +342,7 @@ class GetErrorIntroTest(test_util.TensorFlowTestCase): def tearDown(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testShapeError(self): tf_error = errors.OpError(None, self.var_a.initializer, "foo description", None) diff --git a/tensorflow/python/debug/cli/profile_analyzer_cli_test.py b/tensorflow/python/debug/cli/profile_analyzer_cli_test.py index 60b60479707..effcd500c70 100644 --- a/tensorflow/python/debug/cli/profile_analyzer_cli_test.py +++ b/tensorflow/python/debug/cli/profile_analyzer_cli_test.py @@ -348,6 +348,7 @@ class ProfileAnalyzerPrintSourceTest(test_util.TensorFlowTestCase): ops.reset_default_graph() super(ProfileAnalyzerPrintSourceTest, self).tearDown() + @test_util.run_deprecated_v1 def testPrintSourceForWhileLoop(self): prof_output = self.prof_analyzer.print_source([__file__]) @@ -361,6 +362,7 @@ class ProfileAnalyzerPrintSourceTest(test_util.TensorFlowTestCase): r"\[(\|)+(\s)*\] .*us .*7\(55\) .*L%d.*(\S)+" % self.loop_lineno, prof_output.lines) + @test_util.run_deprecated_v1 def testPrintSourceOutputContainsClickableLinks(self): prof_output = self.prof_analyzer.print_source([__file__]) any_match, line_index = _at_least_one_line_matches( @@ -377,6 +379,7 @@ class ProfileAnalyzerPrintSourceTest(test_util.TensorFlowTestCase): break self.assertTrue(any_menu_item_match) + @test_util.run_deprecated_v1 def testPrintSourceWithNonDefaultTimeUnit(self): prof_output = self.prof_analyzer.print_source([ __file__, "--time_unit", "ms"]) @@ -391,6 +394,7 @@ class ProfileAnalyzerPrintSourceTest(test_util.TensorFlowTestCase): r"\[(\|)+(\s)*\] .*ms .*7\(55\) .*L%d.*(\S)+" % self.loop_lineno, prof_output.lines) + @test_util.run_deprecated_v1 def testPrintSourceWithNodeNameFilter(self): prof_output = self.prof_analyzer.print_source([ __file__, "--node_name_filter", "x$"]) @@ -423,6 +427,7 @@ class ProfileAnalyzerPrintSourceTest(test_util.TensorFlowTestCase): break self.assertTrue(any_menu_item_match) + @test_util.run_deprecated_v1 def testPrintSourceWithOpTypeFilter(self): prof_output = self.prof_analyzer.print_source([ __file__, "--op_type_filter", "Less"]) diff --git a/tensorflow/python/debug/lib/common_test.py b/tensorflow/python/debug/lib/common_test.py index 5af0dafcf9f..f6413f6b7b3 100644 --- a/tensorflow/python/debug/lib/common_test.py +++ b/tensorflow/python/debug/lib/common_test.py @@ -27,6 +27,7 @@ from tensorflow.python.platform import googletest class CommonTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testOnFeedOneFetch(self): a = constant_op.constant(10.0, name="a") b = constant_op.constant(20.0, name="b") @@ -35,6 +36,7 @@ class CommonTest(test_util.TensorFlowTestCase): self.assertItemsEqual(["a:0"], loaded[0]) self.assertItemsEqual(["b:0"], loaded[1]) + @test_util.run_deprecated_v1 def testGetRunKeyFlat(self): a = constant_op.constant(10.0, name="a") b = constant_op.constant(20.0, name="b") @@ -43,6 +45,7 @@ class CommonTest(test_util.TensorFlowTestCase): self.assertItemsEqual(["a:0"], loaded[0]) self.assertItemsEqual(["a:0", "b:0"], loaded[1]) + @test_util.run_deprecated_v1 def testGetRunKeyNestedFetches(self): a = constant_op.constant(10.0, name="a") b = constant_op.constant(20.0, name="b") diff --git a/tensorflow/python/debug/lib/debug_gradients_test.py b/tensorflow/python/debug/lib/debug_gradients_test.py index 01867fc69d0..1c531478638 100644 --- a/tensorflow/python/debug/lib/debug_gradients_test.py +++ b/tensorflow/python/debug/lib/debug_gradients_test.py @@ -54,6 +54,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): ops.reset_default_graph() debug_gradients.clear_gradient_debuggers() + @test_util.run_deprecated_v1 def testIdentifyGradientGivesCorrectTensorObjectWithoutContextManager(self): grad_debugger = debug_gradients.GradientsDebugger() id_grad_w = grad_debugger.identify_gradient(self.w) @@ -84,6 +85,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertIsInstance(w_grad, ops.Tensor) self.assertAllClose(1.0, self.sess.run(w_grad)) + @test_util.run_deprecated_v1 def testIdentifyGradientGivesCorrectTensorObjectWithTfGradients(self): grad_debugger = debug_gradients.GradientsDebugger() id_grad_w = grad_debugger.identify_gradient(self.w) @@ -115,6 +117,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertIsInstance(w_grad, ops.Tensor) self.assertAllClose(1.0, self.sess.run(w_grad)) + @test_util.run_deprecated_v1 def testCallingIdentifyGradientTwiceWithTheSameGradientsDebuggerErrors(self): grad_debugger = debug_gradients.GradientsDebugger() grad_debugger.identify_gradient(self.w) @@ -122,6 +125,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): "The graph already contains an op named .*"): grad_debugger.identify_gradient(self.w) + @test_util.run_deprecated_v1 def testIdentifyGradientWorksOnMultipleLosses(self): grad_debugger_1 = debug_gradients.GradientsDebugger() grad_debugger_2 = debug_gradients.GradientsDebugger() @@ -150,6 +154,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertAllClose(2.0 * 5.0, self.sess.run(dz1_dy)) self.assertAllClose(0.5 * (5.0**-0.5), self.sess.run(dz2_dy)) + @test_util.run_deprecated_v1 def testIdentifyGradientRaisesLookupErrorForUnknownXTensor(self): grad_debugger_1 = debug_gradients.GradientsDebugger() grad_debugger_2 = debug_gradients.GradientsDebugger() @@ -170,6 +175,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): r"This GradientsDebugger has not received any gradient tensor for "): grad_debugger_2.gradient_tensor(self.w) + @test_util.run_deprecated_v1 def testIdentifyGradientRaisesTypeErrorForNonTensorOrTensorNameInput(self): grad_debugger = debug_gradients.GradientsDebugger() with self.assertRaisesRegexp( @@ -178,6 +184,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): r"has type .*Operation.*"): grad_debugger.gradient_tensor(variables.global_variables_initializer()) + @test_util.run_deprecated_v1 def testIdentifyGradientTensorWorksWithGradientDescentOptimizer(self): grad_debugger = debug_gradients.GradientsDebugger() id_grad_w = grad_debugger.identify_gradient(self.w) @@ -193,6 +200,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertIsInstance(w_grad, ops.Tensor) self.assertAllClose(1.0, self.sess.run(w_grad)) + @test_util.run_deprecated_v1 def testWatchGradientsByXTensorNamesWorks(self): y = math_ops.add(self.w, -1.0, name="y") @@ -219,6 +227,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertIsInstance(w_grad, ops.Tensor) self.assertAllClose(1.0, self.sess.run(w_grad)) + @test_util.run_deprecated_v1 def testWatchGradientsByXTensorNamesWorksWithoutContextManager(self): y = math_ops.add(self.w, -1.0, name="y") @@ -245,6 +254,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertIsInstance(w_grad, ops.Tensor) self.assertAllClose(1.0, self.sess.run(w_grad)) + @test_util.run_deprecated_v1 def testWatchGradientsWorksOnRefTensor(self): y = math_ops.add(self.w, -1.0, name="y") @@ -263,6 +273,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertAllClose(3.0, self.sess.run( grad_debugger.gradient_tensor("u:0"))) + @test_util.run_deprecated_v1 def testWatchGradientsWorksOnMultipleTensors(self): y = math_ops.add(self.w, -1.0, name="y") @@ -283,6 +294,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertAllClose(3.0, self.sess.run( grad_debugger.gradient_tensor("u:0"))) + @test_util.run_deprecated_v1 def testWatchGradientsByXTensorsWorks(self): y = math_ops.add(self.w, -1.0, name="foo/y") z = math_ops.square(y, name="foo/z") @@ -305,6 +317,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertAllClose(10.0, self.sess.run(w_grad)) self.assertAllClose(30.0, self.sess.run(u_grad)) + @test_util.run_deprecated_v1 def testWatchGradientsByTensorCanWorkOnMultipleLosses(self): y = math_ops.add(self.w, -1.0, name="y") z1 = math_ops.square(y, name="z1") @@ -330,6 +343,7 @@ class IdentifyGradientTest(test_util.TensorFlowTestCase): self.assertAllClose(2.0 * 5.0, self.sess.run(dz1_dy)) self.assertAllClose(0.5 * (5.0**-0.5), self.sess.run(dz2_dy)) + @test_util.run_deprecated_v1 def testGradientsValuesFromDumpWorks(self): y = math_ops.add(self.w, -1.0, name="y") z = math_ops.square(y, name="z") diff --git a/tensorflow/python/debug/lib/debug_utils_test.py b/tensorflow/python/debug/lib/debug_utils_test.py index 23ab98444cd..cf59b30e3da 100644 --- a/tensorflow/python/debug/lib/debug_utils_test.py +++ b/tensorflow/python/debug/lib/debug_utils_test.py @@ -185,6 +185,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): self.assertEqual(["file:///tmp/tfdbg_1", "file:///tmp/tfdbg_2"], watch_0.debug_urls) + @test_util.run_deprecated_v1 def testWatchGraph_allNodes(self): debug_utils.watch_graph( self._run_options, @@ -216,6 +217,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): self.assertTrue("p1" in node_names) self.assertTrue("s" in node_names) + @test_util.run_deprecated_v1 def testWatchGraph_nodeNameWhitelist(self): debug_utils.watch_graph( self._run_options, @@ -230,6 +232,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): sorted(["a1_init", "a1", "a1/Assign", "a1/read", "p1"]), sorted(node_names)) + @test_util.run_deprecated_v1 def testWatchGraph_opTypeWhitelist(self): debug_utils.watch_graph( self._run_options, @@ -255,6 +258,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): ["DebugIdentity"], ["file:///tmp/tfdbg_1"]) self.assertEqual(["p1"], node_names) + @test_util.run_deprecated_v1 def testWatchGraph_tensorDTypeWhitelist(self): debug_utils.watch_graph( self._run_options, @@ -267,6 +271,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): ["DebugIdentity"], ["file:///tmp/tfdbg_1"]) self.assertItemsEqual(["a1", "a1/Assign", "b", "b/Assign"], node_names) + @test_util.run_deprecated_v1 def testWatchGraph_nodeNameAndTensorDTypeWhitelists(self): debug_utils.watch_graph( self._run_options, @@ -280,6 +285,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): ["DebugIdentity"], ["file:///tmp/tfdbg_1"]) self.assertItemsEqual(["a1", "a1/Assign"], node_names) + @test_util.run_deprecated_v1 def testWatchGraph_nodeNameBlacklist(self): debug_utils.watch_graph_with_blacklists( self._run_options, @@ -294,6 +300,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): sorted(["b_init", "b", "b/Assign", "b/read", "c", "s"]), sorted(node_names)) + @test_util.run_deprecated_v1 def testWatchGraph_opTypeBlacklist(self): debug_utils.watch_graph_with_blacklists( self._run_options, @@ -306,6 +313,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): ["DebugIdentity"], ["file:///tmp/tfdbg_1"]) self.assertEqual(sorted(["p1", "s"]), sorted(node_names)) + @test_util.run_deprecated_v1 def testWatchGraph_nodeNameAndOpTypeBlacklists(self): debug_utils.watch_graph_with_blacklists( self._run_options, @@ -319,6 +327,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): ["DebugIdentity"], ["file:///tmp/tfdbg_1"]) self.assertEqual(["s"], node_names) + @test_util.run_deprecated_v1 def testWatchGraph_tensorDTypeBlacklists(self): debug_utils.watch_graph_with_blacklists( self._run_options, @@ -335,6 +344,7 @@ class DebugUtilsTest(test_util.TensorFlowTestCase): self.assertNotIn("b/Assign", node_names) self.assertIn("s", node_names) + @test_util.run_deprecated_v1 def testWatchGraph_nodeNameAndTensorDTypeBlacklists(self): debug_utils.watch_graph_with_blacklists( self._run_options, diff --git a/tensorflow/python/debug/lib/session_debug_file_test.py b/tensorflow/python/debug/lib/session_debug_file_test.py index 1874160dd63..f5f9ba29ab5 100644 --- a/tensorflow/python/debug/lib/session_debug_file_test.py +++ b/tensorflow/python/debug/lib/session_debug_file_test.py @@ -28,6 +28,7 @@ from tensorflow.python.debug.lib import debug_utils from tensorflow.python.debug.lib import session_debug_testlib from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables from tensorflow.python.platform import googletest @@ -44,6 +45,7 @@ class SessionDebugFileTest(session_debug_testlib.SessionDebugTestBase): else: return os.path.join(self._dump_root, "run_%d" % run_number) + @test_util.run_deprecated_v1 def testAllowsDifferentWatchesOnDifferentRuns(self): """Test watching different tensors on different runs of the same graph.""" diff --git a/tensorflow/python/debug/lib/source_utils_test.py b/tensorflow/python/debug/lib/source_utils_test.py index a16d68329a3..9083297fdbb 100644 --- a/tensorflow/python/debug/lib/source_utils_test.py +++ b/tensorflow/python/debug/lib/source_utils_test.py @@ -65,6 +65,7 @@ class GuessIsTensorFlowLibraryTest(test_util.TensorFlowTestCase): self.assertTrue( source_utils.guess_is_tensorflow_py_library(source_utils.__file__)) + @test_util.run_deprecated_v1 def testFileInPythonKernelsPathReturnsTrue(self): x = constant_op.constant(42.0, name="x") self.assertTrue( diff --git a/tensorflow/python/distribute/all_reduce_test.py b/tensorflow/python/distribute/all_reduce_test.py index 5bf983a1b20..2c6b853124c 100644 --- a/tensorflow/python/distribute/all_reduce_test.py +++ b/tensorflow/python/distribute/all_reduce_test.py @@ -37,6 +37,7 @@ from tensorflow.python.platform import tf_logging class AllReduceTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testFlattenTensorsShapesDefined(self): x = array_ops.placeholder(types_pb2.DT_FLOAT, [None]) with self.assertRaisesRegexp(ValueError, @@ -100,6 +101,7 @@ class AllReduceTest(test_util.TensorFlowTestCase): input_tensors.append(array_ops.identity(t8)) return input_tensors, device_names + @test_util.run_deprecated_v1 def testBuildRingGatherPassStructure(self): # 1 worker, 1 device input_tensors, device_names = self._buildInput(1, 1) @@ -170,6 +172,7 @@ class AllReduceTest(test_util.TensorFlowTestCase): "subdiv=%d elapsed=%f" % (num_workers, num_gpus, shape, subdiv, elapsed)) + @test_util.run_deprecated_v1 def testRingAllReduce(self): self._testRingAllReduce(1, 2, [], 1) self._testRingAllReduce(1, 2, [8], 1) @@ -199,6 +202,7 @@ class AllReduceTest(test_util.TensorFlowTestCase): tf_logging.info("ShuffleAllReduce num_workers=%d num_gpus=%d shape=%s " "elapsed=%f" % (num_workers, num_gpus, shape, elapsed)) + @test_util.run_deprecated_v1 def testShuffleAllReduce(self): self._testShuffleAllReduce(1, 2, [], 1) self._testShuffleAllReduce(1, 2, [8], 1) @@ -225,6 +229,7 @@ class AllReduceTest(test_util.TensorFlowTestCase): "shape=%s elapsed=%f" % (num_workers, num_gpus, shape, elapsed)) + @test_util.run_deprecated_v1 def testRecursiveHDAllReduce(self): self._testRecursiveHDAllReduce(1, 2, [8]) self._testRecursiveHDAllReduce(1, 2, [4, 4]) diff --git a/tensorflow/python/distribute/device_util_test.py b/tensorflow/python/distribute/device_util_test.py index baecd43c8e4..2f0d7ed3b31 100644 --- a/tensorflow/python/distribute/device_util_test.py +++ b/tensorflow/python/distribute/device_util_test.py @@ -21,11 +21,13 @@ from __future__ import print_function from tensorflow.python.distribute import device_util from tensorflow.python.eager import context from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test class DeviceUtilTest(test.TestCase): + @test_util.run_deprecated_v1 def testCurrentDeviceWithGlobalGraph(self): with ops.device("/cpu:0"): self.assertEqual(device_util.current(), "/device:CPU:0") @@ -49,6 +51,7 @@ class DeviceUtilTest(test.TestCase): self.assertEqual(device_util.current(), "/job:localhost/replica:0/task:0/device:CPU:0") + @test_util.run_deprecated_v1 def testCanonicalizeWithoutDefaultDevice(self): self.assertEqual( device_util.canonicalize("/cpu:0"), diff --git a/tensorflow/python/distribute/input_ops_test.py b/tensorflow/python/distribute/input_ops_test.py index d5f41b70931..dcf946ba477 100644 --- a/tensorflow/python/distribute/input_ops_test.py +++ b/tensorflow/python/distribute/input_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.data.ops import dataset_ops from tensorflow.python.data.ops import readers from tensorflow.python.distribute import input_ops from tensorflow.python.framework import errors +from tensorflow.python.framework import test_util from tensorflow.python.lib.io import python_io from tensorflow.python.platform import test from tensorflow.python.util import compat @@ -96,6 +97,7 @@ class AutoShardDatasetTest(test.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testTFRecordDataset(self): dataset = readers.TFRecordDataset(self._createTFRecordFiles()) dataset = input_ops.auto_shard_dataset( @@ -103,6 +105,7 @@ class AutoShardDatasetTest(test.TestCase): self._verifySimpleShardingOutput(dataset, self._record) + @test_util.run_deprecated_v1 def testFlatMap(self): dataset = dataset_ops.Dataset.from_tensor_slices( self._createTFRecordFiles()) @@ -112,6 +115,7 @@ class AutoShardDatasetTest(test.TestCase): self._verifySimpleShardingOutput(dataset, self._record) + @test_util.run_deprecated_v1 def testInterleave(self): dataset = dataset_ops.Dataset.from_tensor_slices( self._createTFRecordFiles()) @@ -124,6 +128,7 @@ class AutoShardDatasetTest(test.TestCase): # contain records in order of files. self._verifySimpleShardingOutput(dataset, self._record) + @test_util.run_deprecated_v1 def testListfiles(self): filenames = self._createTFRecordFiles() file_pattern = filenames[0].rsplit(os.sep, 1)[0] + "/tf_record.*.txt" @@ -144,6 +149,7 @@ class AutoShardDatasetTest(test.TestCase): self.evaluate(next_element) self.assertAllEqual(expected, actual) + @test_util.run_deprecated_v1 def testComplexPipeline(self): # Setup a complex input pipeline. batch_size = 2 @@ -183,6 +189,7 @@ class AutoShardDatasetTest(test.TestCase): self.assertAllEqual(sorted(expected), sorted(actual)) + @test_util.run_deprecated_v1 def testZip(self): dataset1 = readers.TFRecordDataset(self._createTFRecordFiles()) dataset2 = readers.TextLineDataset(self._createTextFiles()) @@ -193,6 +200,7 @@ class AutoShardDatasetTest(test.TestCase): record_fn = lambda r, f: (self._record(r, f), self._text_line(r, f)) self._verifySimpleShardingOutput(dataset, record_fn) + @test_util.run_deprecated_v1 def testConcat(self): dataset1 = readers.TFRecordDataset(self._createTFRecordFiles()) dataset2 = readers.TextLineDataset(self._createTextFiles()) @@ -213,6 +221,7 @@ class AutoShardDatasetTest(test.TestCase): with self.assertRaises(errors.OutOfRangeError): self.evaluate(next_element) + @test_util.run_deprecated_v1 def testTextLineReader(self): dataset = readers.TextLineDataset(self._createTextFiles()) dataset = input_ops.auto_shard_dataset( @@ -220,6 +229,7 @@ class AutoShardDatasetTest(test.TestCase): self._verifySimpleShardingOutput(dataset, self._text_line) + @test_util.run_deprecated_v1 def testTextLineReaderWithFlatMap(self): dataset = dataset_ops.Dataset.from_tensor_slices(self._createTextFiles()) dataset = dataset.flat_map(readers.TextLineDataset) @@ -228,6 +238,7 @@ class AutoShardDatasetTest(test.TestCase): self._verifySimpleShardingOutput(dataset, self._text_line) + @test_util.run_deprecated_v1 def testFixedLengthReader(self): dataset = readers.FixedLengthRecordDataset( self._createFixedLengthRecordFiles(), self._record_bytes) @@ -236,6 +247,7 @@ class AutoShardDatasetTest(test.TestCase): self._verifySimpleShardingOutput(dataset, self._fixed_length_record) + @test_util.run_deprecated_v1 def testFixedLengthReaderWithFlatMap(self): dataset = dataset_ops.Dataset.from_tensor_slices( self._createFixedLengthRecordFiles()) diff --git a/tensorflow/python/eager/function_gradients_test.py b/tensorflow/python/eager/function_gradients_test.py index 1ba596573f9..9b83f57089a 100644 --- a/tensorflow/python/eager/function_gradients_test.py +++ b/tensorflow/python/eager/function_gradients_test.py @@ -187,6 +187,7 @@ class FunctionGradientsTest(test.TestCase, parameterized.TestCase): self.assertAllEqual(2, g(constant_op.constant(2.))) + @test_util.run_deprecated_v1 def testGraphModeEagerGradError(self): with context.graph_mode(): def f(): diff --git a/tensorflow/python/eager/function_test.py b/tensorflow/python/eager/function_test.py index a206b1f7911..e47c5083a39 100644 --- a/tensorflow/python/eager/function_test.py +++ b/tensorflow/python/eager/function_test.py @@ -1283,6 +1283,7 @@ class FunctionTest(test.TestCase, parameterized.TestCase): defined.get_concrete_function( tensor_spec.TensorSpec(shape=(3,), dtype=dtypes.float32)) + @test_util.run_deprecated_v1 def testInputSignatureForFunctionWithNonTensorInputsNotAllowed(self): def foo(a, training=True): diff --git a/tensorflow/python/eager/graph_only_ops_test.py b/tensorflow/python/eager/graph_only_ops_test.py index 3aedf5fee1c..914b4d9a95a 100644 --- a/tensorflow/python/eager/graph_only_ops_test.py +++ b/tensorflow/python/eager/graph_only_ops_test.py @@ -29,12 +29,14 @@ from tensorflow.python.platform import test class GraphOnlyOpsTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testGraphZerosLike(self): x = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.int32) z_tf = graph_only_ops.graph_zeros_like(x) with self.cached_session(): self.assertAllClose(np.zeros((2, 3)), self.evaluate(z_tf)) + @test_util.run_deprecated_v1 def testGraphPlaceholder(self): x_tf = graph_only_ops.graph_placeholder(dtypes.int32, shape=(1,)) y_tf = math_ops.square(x_tf) diff --git a/tensorflow/python/feature_column/feature_column_test.py b/tensorflow/python/feature_column/feature_column_test.py index 2c70d668103..daa0a3b3a4b 100644 --- a/tensorflow/python/feature_column/feature_column_test.py +++ b/tensorflow/python/feature_column/feature_column_test.py @@ -170,6 +170,7 @@ class LazyColumnTest(test.TestCase): TypeError, '"key" must be either a "str" or "_FeatureColumn".'): builder.get(NotAFeatureColumn()) + @test_util.run_deprecated_v1 def test_expand_dim_rank_1_sparse_tensor_empty_batch(self): # empty 1-D sparse tensor: builder = _LazyBuilder(features={'a': sparse_tensor.SparseTensor( @@ -185,6 +186,7 @@ class LazyColumnTest(test.TestCase): class NumericColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): a = fc._numeric_column('aaa') self.assertEqual('aaa', a.key) @@ -263,6 +265,7 @@ class NumericColumnTest(test.TestCase): 'aaa': parsing_ops.FixedLenFeature((2, 3), dtype=dtypes.int32) }, a._parse_example_spec) + @test_util.run_deprecated_v1 def test_parse_example_no_default_value(self): price = fc._numeric_column('price', shape=[2]) data = example_pb2.Example(features=feature_pb2.Features( @@ -278,6 +281,7 @@ class NumericColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual([[20., 110.]], features['price'].eval()) + @test_util.run_deprecated_v1 def test_parse_example_with_default_value(self): price = fc._numeric_column('price', shape=[2], default_value=11.) data = example_pb2.Example(features=feature_pb2.Features( @@ -304,6 +308,7 @@ class NumericColumnTest(test.TestCase): with self.assertRaisesRegexp(TypeError, 'must be a callable'): fc._numeric_column('price', normalizer_fn='NotACallable') + @test_util.run_deprecated_v1 def test_normalizer_fn_transform_feature(self): def _increment_two(input_tensor): @@ -314,6 +319,7 @@ class NumericColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual([[3., 4.], [7., 8.]], output[price].eval()) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): def _increment_two(input_tensor): @@ -333,6 +339,7 @@ class NumericColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'must be a Tensor'): price._transform_feature(builder) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc._numeric_column('aaa', shape=[1, 2], default_value=[[3., 2.]]) a_copy = copy.deepcopy(a) @@ -345,6 +352,7 @@ class NumericColumnTest(test.TestCase): 'aaa', shape=[1, 2], default_value=np.array([[3., 2.]])) self.assertEqual(a.default_value, ((3., 2.),)) + @test_util.run_deprecated_v1 def test_linear_model(self): price = fc._numeric_column('price') with ops.Graph().as_default(): @@ -359,6 +367,7 @@ class NumericColumnTest(test.TestCase): sess.run(price_var.assign([[10.]])) self.assertAllClose([[10.], [50.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): price = fc._numeric_column('price') with ops.Graph().as_default(): @@ -433,6 +442,7 @@ class BucketizedColumnTest(test.TestCase): # Column 'aaa` has shape [2] times three buckets -> num_buckets=6. self.assertEqual(6, b._num_buckets) + @test_util.run_deprecated_v1 def test_parse_example(self): price = fc._numeric_column('price', shape=[2]) bucketized_price = fc._bucketized_column(price, boundaries=[0, 50]) @@ -449,6 +459,7 @@ class BucketizedColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual([[20., 110.]], features['price'].eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): price = fc._numeric_column('price', shape=[2]) bucketized_price = fc._bucketized_column(price, boundaries=[0, 2, 4, 6]) @@ -531,6 +542,7 @@ class BucketizedColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'must be a Tensor'): bucketized_price._transform_feature(builder) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc._numeric_column('aaa', shape=[2]) a_bucketized = fc._bucketized_column(a, boundaries=[0, 1]) @@ -658,6 +670,7 @@ class BucketizedColumnTest(test.TestCase): class HashedCategoricalColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): a = fc._categorical_column_with_hash_bucket('aaa', 10) self.assertEqual('aaa', a.name) @@ -685,6 +698,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be string or integer'): fc._categorical_column_with_hash_bucket('aaa', 10, dtype=dtypes.float32) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc._categorical_column_with_hash_bucket('aaa', 10) for column in (original, copy.deepcopy(original)): @@ -705,6 +719,7 @@ class HashedCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, a._parse_example_spec) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_hash_bucket('aaa', 10) data = example_pb2.Example(features=feature_pb2.Features( @@ -726,6 +741,7 @@ class HashedCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_strings_should_be_hashed(self): hashed_sparse = fc._categorical_column_with_hash_bucket('wire', 10) wire_tensor = sparse_tensor.SparseTensor( @@ -781,6 +797,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be compatible'): builder.get(hashed_sparse) + @test_util.run_deprecated_v1 def test_ints_should_be_hashed(self): hashed_sparse = fc._categorical_column_with_hash_bucket( 'wire', 10, dtype=dtypes.int64) @@ -795,6 +812,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual(expected_values, output.values.eval()) + @test_util.run_deprecated_v1 def test_int32_64_is_compatible(self): hashed_sparse = fc._categorical_column_with_hash_bucket( 'wire', 10, dtype=dtypes.int64) @@ -809,6 +827,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual(expected_values, output.values.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): hashed_sparse = fc._categorical_column_with_hash_bucket('wire', 10) builder = _LazyBuilder({ @@ -837,6 +856,7 @@ class HashedCategoricalColumnTest(test.TestCase): [], ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)) self.assertItemsEqual([], ops.get_collection('my_weights')) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): hashed_sparse = fc._categorical_column_with_hash_bucket('wire', 10) builder = _LazyBuilder({'wire': (('omar', ''), ('stringer', 'marlo'))}) @@ -844,6 +864,7 @@ class HashedCategoricalColumnTest(test.TestCase): self.assertIsNone(id_weight_pair.weight_tensor) self.assertEqual(builder.get(hashed_sparse), id_weight_pair.id_tensor) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc._categorical_column_with_hash_bucket('wire', 4) self.assertEqual(4, wire_column._num_buckets) @@ -866,6 +887,7 @@ class HashedCategoricalColumnTest(test.TestCase): # 'skywalker' -> 2, 'omar' -> 2: wire_var[2] + wire_var[2] = 3+3 = 6 self.assertAllClose(((4.,), (6.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): wire_column = fc._categorical_column_with_hash_bucket('wire', 4) self.assertEqual(4, wire_column._num_buckets) @@ -975,6 +997,7 @@ class CrossedColumnTest(test.TestCase): crossed = fc._crossed_column([b, 'c'], 15) self.assertEqual(15, crossed._num_buckets) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc._numeric_column('a', dtype=dtypes.int32) b = fc._bucketized_column(a, boundaries=[0, 1]) @@ -985,6 +1008,7 @@ class CrossedColumnTest(test.TestCase): self.assertEqual(15, crossed2_copy.hash_bucket_size) self.assertEqual(5, crossed2_copy.hash_key) + @test_util.run_deprecated_v1 def test_parse_example(self): price = fc._numeric_column('price', shape=[2]) bucketized_price = fc._bucketized_column(price, boundaries=[0, 50]) @@ -1011,6 +1035,7 @@ class CrossedColumnTest(test.TestCase): self.assertAllEqual([b'omar', b'stringer'], wire_sparse.values.eval()) self.assertAllEqual([1, 2], wire_sparse.dense_shape.eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): price = fc._numeric_column('price', shape=[2]) bucketized_price = fc._bucketized_column(price, boundaries=[0, 50]) @@ -1034,6 +1059,7 @@ class CrossedColumnTest(test.TestCase): self.assertIn(val, list(range(hash_bucket_size))) self.assertAllEqual([2, 4], output_val.dense_shape) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): a = fc._numeric_column('a', dtype=dtypes.int32, shape=(2,)) b = fc._bucketized_column(a, boundaries=(0, 1)) @@ -1101,6 +1127,7 @@ class CrossedColumnTest(test.TestCase): self.assertAllEqual(expected_values, id_tensor_eval.values) self.assertAllEqual((2, 4), id_tensor_eval.dense_shape) + @test_util.run_deprecated_v1 def test_linear_model(self): """Tests linear_model. @@ -1182,6 +1209,7 @@ class CrossedColumnTest(test.TestCase): dense_shape=(2, 2)), }, (crossed,)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): """Tests _LinearModel. @@ -1854,6 +1882,7 @@ class LinearModelTest(test.TestCase): features['price2']: [[1.], [5.]], }) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): price = fc._numeric_column('price') price_buckets = fc._bucketized_column( @@ -1889,6 +1918,7 @@ class LinearModelTest(test.TestCase): self.assertAllClose([[10 - 1000 + 5.], [1000 - 10 + 5.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): price = fc._numeric_column('price') price_buckets = fc._bucketized_column( @@ -1936,6 +1966,7 @@ class LinearModelTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): price = fc._numeric_column('price') features = { @@ -2488,6 +2519,7 @@ class _LinearModelTest(test.TestCase): features['price2']: [[1.], [5.]], }) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): price = fc._numeric_column('price') price_buckets = fc._bucketized_column( @@ -2529,6 +2561,7 @@ class _LinearModelTest(test.TestCase): self.assertAllClose([[10 - 1000 + 5.], [1000 - 10 + 5.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): price = fc._numeric_column('price') price_buckets = fc._bucketized_column( @@ -2575,6 +2608,7 @@ class _LinearModelTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): price = fc._numeric_column('price') features = { @@ -2815,6 +2849,7 @@ class FunctionalInputLayerTest(test.TestCase): variables_lib.Variable) self.assertAllEqual(cols_to_vars[some_embedding_column][0].shape, [5, 10]) + @test_util.run_deprecated_v1 def test_fills_cols_to_vars_shared_embedding(self): # Provide 5 DenseColumn's to input_layer: a NumericColumn, a # BucketizedColumn, an EmbeddingColumn, two SharedEmbeddingColumns. The @@ -3012,6 +3047,7 @@ class FunctionalInputLayerTest(test.TestCase): expected_var_names, [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_multiple_layers_with_same_shared_embedding_column(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -3045,6 +3081,7 @@ class FunctionalInputLayerTest(test.TestCase): ['input_layer/aaa_bbb_shared_embedding/embedding_weights:0'], [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_multiple_layers_with_same_shared_embedding_column_diff_graphs(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -3096,6 +3133,7 @@ class FunctionalInputLayerTest(test.TestCase): ['input_layer/aaa_bbb_shared_embedding/embedding_weights:0'], [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): embedding_values = ( (1., 2., 3., 4., 5.), # id 0 @@ -3146,6 +3184,7 @@ class FunctionalInputLayerTest(test.TestCase): [1., 0., 0., 1., 2., 3., 4., 5., 12.]], sess.run(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): embedding_values = ( (1., 2.), # id 0 @@ -3205,6 +3244,7 @@ class FunctionalInputLayerTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): # price has 1 dimension in input_layer price = fc._numeric_column('price') @@ -3335,6 +3375,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): 'python/feature_column/testdata/wire_vocabulary.txt') self._wire_vocabulary_size = 3 + @test_util.run_deprecated_v1 def test_defaults(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='path_to_file', vocabulary_size=3) @@ -3351,6 +3392,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): fc._categorical_column_with_vocabulary_file( key=('aaa',), vocabulary_file='path_to_file', vocabulary_size=3) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3363,6 +3405,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, column._parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3387,6 +3430,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): fc._categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='', vocabulary_size=3) + @test_util.run_deprecated_v1 def test_invalid_vocabulary_file(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='file_does_not_exist', vocabulary_size=10) @@ -3411,6 +3455,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): vocabulary_file=self._wire_vocabulary_file_name, vocabulary_size=0) + @test_util.run_deprecated_v1 def test_too_large_vocabulary_size(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3477,6 +3522,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be compatible'): column._get_sparse_tensors(_LazyBuilder({'aaa': inputs})) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='path_to_file', vocabulary_size=3) @@ -3499,6 +3545,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3519,6 +3566,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_none_vocabulary_size(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', vocabulary_file=self._wire_vocabulary_file_name) @@ -3537,6 +3585,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3573,6 +3622,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): [], ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)) self.assertItemsEqual([], ops.get_collection('my_weights')) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3592,6 +3642,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=(2, 2)), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_default_value_in_vocabulary(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3613,6 +3664,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_oov_buckets(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3634,6 +3686,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_small_vocabulary_size(self): # 'marlo' is the last entry in our vocabulary file, so be setting # `vocabulary_size` to 1 less than number of entries in file, we take @@ -3657,6 +3710,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3678,6 +3732,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_dense_input(self): default_value = -100 column = fc._categorical_column_with_vocabulary_file( @@ -3700,6 +3755,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=(3, 3)), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_with_oov_buckets(self): column = fc._categorical_column_with_vocabulary_file( key='aaa', @@ -3722,6 +3778,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc._categorical_column_with_vocabulary_file( key='wire', @@ -3748,6 +3805,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): # 'skywalker' -> 3, 'omar' -> 0: wire_var[3] + wire_var[0] = 4+1 = 5 self.assertAllClose(((3.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): wire_column = fc._categorical_column_with_vocabulary_file( key='wire', @@ -3805,6 +3863,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, column._parse_example_spec) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -3816,6 +3875,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, column._parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=(12, 24, 36), dtype=dtypes.int32) @@ -3904,6 +3964,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be compatible'): column._get_sparse_tensors(_LazyBuilder({'aaa': inputs})) + @test_util.run_deprecated_v1 def test_parse_example_string(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -3926,6 +3987,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_parse_example_int(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=(11, 21, 31)) @@ -3948,6 +4010,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -3966,6 +4029,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -3998,6 +4062,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): [], ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)) self.assertItemsEqual([], ops.get_collection('my_weights')) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -4015,6 +4080,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=(2, 2)), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_default_value_in_vocabulary(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4035,6 +4101,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_oov_buckets(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4055,6 +4122,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4075,6 +4143,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_dense_input(self): default_value = -100 column = fc._categorical_column_with_vocabulary_list( @@ -4098,6 +4167,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=(3, 3)), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_with_oov_buckets(self): column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4119,6 +4189,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4144,6 +4215,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): # 'skywalker' -> 3, 'omar' -> 0: wire_var[3] + wire_var[0] = 4+1 = 5 self.assertAllClose(((3.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): wire_column = fc._categorical_column_with_vocabulary_list( key='aaa', @@ -4187,6 +4259,7 @@ class IdentityCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'key must be a string.'): fc._categorical_column_with_identity(key=('aaa',), num_buckets=3) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc._categorical_column_with_identity(key='aaa', num_buckets=3) for column in (original, copy.deepcopy(original)): @@ -4223,6 +4296,7 @@ class IdentityCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'Invalid input, not integer'): column._get_sparse_tensors(_LazyBuilder({'aaa': inputs})) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_identity(key='aaa', num_buckets=30) data = example_pb2.Example(features=feature_pb2.Features( @@ -4244,6 +4318,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -4261,6 +4336,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -4291,6 +4367,7 @@ class IdentityCategoricalColumnTest(test.TestCase): [], ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)) self.assertItemsEqual([], ops.get_collection('my_weights')) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) id_weight_pair = column._get_sparse_tensors( @@ -4307,6 +4384,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=(2, 2)), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_inputs_too_small(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -4320,6 +4398,7 @@ class IdentityCategoricalColumnTest(test.TestCase): errors.OpError, 'assert_greater_or_equal_0'): id_weight_pair.id_tensor.eval() + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_inputs_too_big(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -4333,6 +4412,7 @@ class IdentityCategoricalColumnTest(test.TestCase): errors.OpError, 'assert_less_than_num_buckets'): id_weight_pair.id_tensor.eval() + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_default_value(self): column = fc._categorical_column_with_identity( key='aaa', num_buckets=4, default_value=3) @@ -4351,6 +4431,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), id_weight_pair.id_tensor.eval()) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_default_value_and_placeholder_inputs(self): column = fc._categorical_column_with_identity( key='aaa', num_buckets=4, default_value=3) @@ -4376,6 +4457,7 @@ class IdentityCategoricalColumnTest(test.TestCase): input_shape: (2, 2), })) + @test_util.run_deprecated_v1 def test_linear_model(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) self.assertEqual(3, column._num_buckets) @@ -4397,6 +4479,7 @@ class IdentityCategoricalColumnTest(test.TestCase): # weight_var[2] + weight_var[1] = 3+2 = 5 self.assertAllClose(((1.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): column = fc._categorical_column_with_identity(key='aaa', num_buckets=3) self.assertEqual(3, column._num_buckets) @@ -4548,6 +4631,7 @@ class IndicatorColumnTest(test.TestCase): with self.cached_session(): self.assertAllEqual([[0., 1., 1., 0.]], self.evaluate(output)) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc._categorical_column_with_hash_bucket('a', 4) column = fc._indicator_column(a) @@ -4556,6 +4640,7 @@ class IndicatorColumnTest(test.TestCase): self.assertEqual(column.name, 'a_indicator') self.assertEqual(column._variable_shape, [1, 4]) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -4579,6 +4664,7 @@ class IndicatorColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_transform(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -4594,6 +4680,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[0, 0, 1], [1, 0, 0]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_weighted_column(self): # Github issue 12557 ids = fc._categorical_column_with_vocabulary_list( @@ -4608,6 +4695,7 @@ class IndicatorColumnTest(test.TestCase): with _initialized_session(): self.assertAllEqual([[6., 4., 3.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_missing_value_in_weighted_column(self): # Github issue 12583 ids = fc._categorical_column_with_vocabulary_list( @@ -4622,6 +4710,7 @@ class IndicatorColumnTest(test.TestCase): with _initialized_session(): self.assertAllEqual([[0., 4., 2.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_missing_value_in_categorical_column(self): # Github issue 12583 ids = fc._categorical_column_with_vocabulary_list( @@ -4634,6 +4723,7 @@ class IndicatorColumnTest(test.TestCase): with _initialized_session(): self.assertAllEqual([[0., 1., 1.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_linear_model(self): animal = fc._indicator_column( fc._categorical_column_with_identity('animal', num_buckets=4)) @@ -4653,6 +4743,7 @@ class IndicatorColumnTest(test.TestCase): weight_var.assign([[1.], [2.], [3.], [4.]]).eval() self.assertAllClose([[2. + 3.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): animal = fc._indicator_column( fc._categorical_column_with_identity('animal', num_buckets=4)) @@ -4672,6 +4763,7 @@ class IndicatorColumnTest(test.TestCase): weight_var.assign([[1.], [2.], [3.], [4.]]).eval() self.assertAllClose([[2. + 3.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_input_layer(self): animal = fc._indicator_column( fc._categorical_column_with_identity('animal', num_buckets=4)) @@ -4688,6 +4780,7 @@ class IndicatorColumnTest(test.TestCase): class EmbeddingColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): categorical_column = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -4709,6 +4802,7 @@ class EmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column._parse_example_spec) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): categorical_column = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -4737,6 +4831,7 @@ class EmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column._parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): categorical_column = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -4770,6 +4865,7 @@ class EmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column._parse_example_spec) + @test_util.run_deprecated_v1 def test_invalid_initializer(self): categorical_column = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -4777,6 +4873,7 @@ class EmbeddingColumnTest(test.TestCase): fc._embedding_column( categorical_column, dimension=2, initializer='not_fn') + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -4800,6 +4897,7 @@ class EmbeddingColumnTest(test.TestCase): dense_shape=[1, 2]), features['aaa'].eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): a = fc._categorical_column_with_identity(key='aaa', num_buckets=3) a_embedded = fc._embedding_column(a, dimension=2) @@ -4816,6 +4914,7 @@ class EmbeddingColumnTest(test.TestCase): _assert_sparse_tensor_value(self, self.evaluate(output_a), self.evaluate(output_embedded)) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): # Inputs. vocabulary_size = 3 @@ -4875,6 +4974,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, global_vars[0].eval()) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_3d(self): # Inputs. vocabulary_size = 4 @@ -4936,6 +5036,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, global_vars[0].eval()) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_weight_collections(self): sparse_input = sparse_tensor.SparseTensorValue( # example 0, ids [2] @@ -4965,6 +5066,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertItemsEqual( ('embedding_weights:0',), tuple([v.name for v in my_vars])) + @test_util.run_deprecated_v1 def test_get_dense_tensor_placeholder_inputs(self): # Inputs. vocabulary_size = 3 @@ -5036,6 +5138,7 @@ class EmbeddingColumnTest(test.TestCase): input_shape: sparse_input.dense_shape, })) + @test_util.run_deprecated_v1 def test_get_dense_tensor_restore_from_ckpt(self): # Inputs. vocabulary_size = 3 @@ -5094,6 +5197,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, global_vars[0].eval()) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_linear_model(self): # Inputs. batch_size = 4 @@ -5173,6 +5277,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllClose(((94.,), (29.,), (0.,), (42.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): # Inputs. batch_size = 4 @@ -5252,6 +5357,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllClose(((94.,), (29.,), (0.,), (42.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_input_layer(self): # Inputs. vocabulary_size = 3 @@ -5313,6 +5419,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, trainable_vars[0].eval()) self.assertAllEqual(expected_lookups, self.evaluate(input_layer)) + @test_util.run_deprecated_v1 def test_input_layer_not_trainable(self): # Inputs. vocabulary_size = 3 @@ -5376,6 +5483,7 @@ class EmbeddingColumnTest(test.TestCase): class SharedEmbeddingColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5420,6 +5528,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'bbb': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_b._parse_example_spec) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5471,6 +5580,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'bbb': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_b._parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5509,6 +5619,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_a._parse_example_spec) + @test_util.run_deprecated_v1 def test_invalid_initializer(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5520,6 +5631,7 @@ class SharedEmbeddingColumnTest(test.TestCase): dimension=2, initializer='not_fn') + @test_util.run_deprecated_v1 def test_incompatible_column_type(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5535,6 +5647,7 @@ class SharedEmbeddingColumnTest(test.TestCase): [categorical_column_a, categorical_column_b, categorical_column_c], dimension=2) + @test_util.run_deprecated_v1 def test_weighted_categorical_column_ok(self): categorical_column_a = fc._categorical_column_with_identity( key='aaa', num_buckets=3) @@ -5552,6 +5665,7 @@ class SharedEmbeddingColumnTest(test.TestCase): [weighted_categorical_column_a, weighted_categorical_column_b], dimension=2) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5589,6 +5703,7 @@ class SharedEmbeddingColumnTest(test.TestCase): dense_shape=[1, 2]), features['bbb'].eval()) + @test_util.run_deprecated_v1 def test_transform_feature(self): a = fc._categorical_column_with_identity(key='aaa', num_buckets=3) b = fc._categorical_column_with_identity(key='bbb', num_buckets=3) @@ -5615,6 +5730,7 @@ class SharedEmbeddingColumnTest(test.TestCase): _assert_sparse_tensor_value(self, self.evaluate(output_b), self.evaluate(output_b_embedded)) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): # Inputs. vocabulary_size = 3 @@ -5683,6 +5799,7 @@ class SharedEmbeddingColumnTest(test.TestCase): self.assertAllEqual(expected_lookups_a, self.evaluate(embedding_lookup_a)) self.assertAllEqual(expected_lookups_b, self.evaluate(embedding_lookup_b)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_weight_collections(self): # Inputs. vocabulary_size = 3 @@ -5735,6 +5852,7 @@ class SharedEmbeddingColumnTest(test.TestCase): ('input_layer/aaa_bbb_shared_embedding/embedding_weights:0',), tuple(v.name for v in my_vars)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_placeholder_inputs(self): # Inputs. vocabulary_size = 3 @@ -5791,6 +5909,7 @@ class SharedEmbeddingColumnTest(test.TestCase): with _initialized_session() as sess: sess.run([embedding_lookup_a, embedding_lookup_b], feed_dict=feed_dict) + @test_util.run_deprecated_v1 def test_linear_model(self): # Inputs. batch_size = 2 @@ -5881,6 +6000,7 @@ class SharedEmbeddingColumnTest(test.TestCase): # = [3*1 + 5*2, 3*0 +5*0] = [13, 0] self.assertAllClose([[94. + 13.], [29.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): # Inputs. batch_size = 2 @@ -6048,15 +6168,18 @@ class SharedEmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, shared_embedding_vars[0].eval()) self.assertAllEqual(expected_lookups, self.evaluate(input_layer)) + @test_util.run_deprecated_v1 def test_input_layer(self): self._test_input_layer() + @test_util.run_deprecated_v1 def test_input_layer_no_trainable(self): self._test_input_layer(trainable=False) class WeightedCategoricalColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( @@ -6070,6 +6193,7 @@ class WeightedCategoricalColumnTest(test.TestCase): 'values': parsing_ops.VarLenFeature(dtypes.float32) }, column._parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): """Tests deepcopy of categorical_column_with_hash_bucket.""" original = fc._weighted_categorical_column( @@ -6132,6 +6256,7 @@ class WeightedCategoricalColumnTest(test.TestCase): ValueError, 'values is not in features dictionary'): _transform_features({'ids': inputs}, (column,)) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc._categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -6167,6 +6292,7 @@ class WeightedCategoricalColumnTest(test.TestCase): dense_shape=[1, 2]), features['weights'].eval()) + @test_util.run_deprecated_v1 def test_transform_features(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( @@ -6198,6 +6324,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array(weights.values, dtype=np.float32), dense_shape=weights.dense_shape), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_transform_features_dense_input(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( @@ -6225,6 +6352,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array(weights.values, dtype=np.float32), dense_shape=weights.dense_shape), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_transform_features_dense_weights(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( @@ -6252,6 +6380,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array((.5, 1., .1), dtype=np.float32), dense_shape=(2, 2)), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_keras_linear_model(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( @@ -6354,6 +6483,7 @@ class WeightedCategoricalColumnTest(test.TestCase): # = 3*1 + 2*.1 = 3+.2 = 3.2 self.assertAllClose(((.5,), (3.2,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_linear_model(self): column = fc._weighted_categorical_column( categorical_column=fc._categorical_column_with_identity( diff --git a/tensorflow/python/feature_column/feature_column_v2_test.py b/tensorflow/python/feature_column/feature_column_v2_test.py index 3147754bee4..083cd526e46 100644 --- a/tensorflow/python/feature_column/feature_column_v2_test.py +++ b/tensorflow/python/feature_column/feature_column_v2_test.py @@ -218,6 +218,7 @@ class LazyColumnTest(test.TestCase): TypeError, '"key" must be either a "str" or "FeatureColumn".'): transformation_cache.get(NotAFeatureColumn(), None) + @test_util.run_deprecated_v1 def test_expand_dim_rank_1_sparse_tensor_empty_batch(self): # empty 1-D sparse tensor: transformation_cache = fc.FeatureTransformationCache( @@ -237,6 +238,7 @@ class LazyColumnTest(test.TestCase): class NumericColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): a = fc.numeric_column('aaa') self.assertEqual('aaa', a.key) @@ -315,6 +317,7 @@ class NumericColumnTest(test.TestCase): 'aaa': parsing_ops.FixedLenFeature((2, 3), dtype=dtypes.int32) }, a.parse_example_spec) + @test_util.run_deprecated_v1 def test_parse_example_no_default_value(self): price = fc.numeric_column('price', shape=[2]) data = example_pb2.Example( @@ -331,6 +334,7 @@ class NumericColumnTest(test.TestCase): self.assertAllEqual([[20., 110.]], self.evaluate(features['price'])) + @test_util.run_deprecated_v1 def test_parse_example_with_default_value(self): price = fc.numeric_column('price', shape=[2], default_value=11.) data = example_pb2.Example( @@ -360,6 +364,7 @@ class NumericColumnTest(test.TestCase): with self.assertRaisesRegexp(TypeError, 'must be a callable'): fc.numeric_column('price', normalizer_fn='NotACallable') + @test_util.run_deprecated_v1 def test_normalizer_fn_transform_feature(self): def _increment_two(input_tensor): @@ -372,6 +377,7 @@ class NumericColumnTest(test.TestCase): self.assertAllEqual([[3., 4.], [7., 8.]], self.evaluate(output[price])) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): def _increment_two(input_tensor): @@ -395,6 +401,7 @@ class NumericColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'must be a Tensor'): price.transform_feature(transformation_cache, None) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc.numeric_column('aaa', shape=[1, 2], default_value=[[3., 2.]]) a_copy = copy.deepcopy(a) @@ -407,6 +414,7 @@ class NumericColumnTest(test.TestCase): 'aaa', shape=[1, 2], default_value=np.array([[3., 2.]])) self.assertEqual(a.default_value, ((3., 2.),)) + @test_util.run_deprecated_v1 def test_linear_model(self): price = fc.numeric_column('price') with ops.Graph().as_default(): @@ -435,6 +443,7 @@ class NumericColumnTest(test.TestCase): sess.run(price_var.assign([[10.]])) self.assertAllClose([[10.], [50.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): def _increment_two(input_tensor): @@ -519,6 +528,7 @@ class BucketizedColumnTest(test.TestCase): # Column 'aaa` has shape [2] times three buckets -> num_buckets=6. self.assertEqual(6, b.num_buckets) + @test_util.run_deprecated_v1 def test_parse_example(self): price = fc.numeric_column('price', shape=[2]) bucketized_price = fc.bucketized_column(price, boundaries=[0, 50]) @@ -536,6 +546,7 @@ class BucketizedColumnTest(test.TestCase): self.assertAllEqual([[20., 110.]], self.evaluate(features['price'])) + @test_util.run_deprecated_v1 def test_transform_feature(self): price = fc.numeric_column('price', shape=[2]) bucketized_price = fc.bucketized_column(price, boundaries=[0, 2, 4, 6]) @@ -639,6 +650,7 @@ class BucketizedColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'must be a Tensor'): bucketized_price.transform_feature(transformation_cache, None) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc.numeric_column('aaa', shape=[2]) a_bucketized = fc.bucketized_column(a, boundaries=[0, 1]) @@ -789,6 +801,7 @@ class BucketizedColumnTest(test.TestCase): self.assertAllClose([[11.], [21.], [41.], [51.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): price = fc.numeric_column('price', shape=[2]) bucketized_price = fc.bucketized_column(price, boundaries=[0, 2, 4, 6]) @@ -821,6 +834,7 @@ class BucketizedColumnTest(test.TestCase): class HashedCategoricalColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): a = fc.categorical_column_with_hash_bucket('aaa', 10) self.assertEqual('aaa', a.name) @@ -848,6 +862,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be string or integer'): fc.categorical_column_with_hash_bucket('aaa', 10, dtype=dtypes.float32) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc.categorical_column_with_hash_bucket('aaa', 10) for column in (original, copy.deepcopy(original)): @@ -868,6 +883,7 @@ class HashedCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, a.parse_example_spec) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_hash_bucket('aaa', 10) data = example_pb2.Example( @@ -890,6 +906,7 @@ class HashedCategoricalColumnTest(test.TestCase): values=np.array([b'omar', b'stringer'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_strings_should_be_hashed(self): hashed_sparse = fc.categorical_column_with_hash_bucket('wire', 10) wire_tensor = sparse_tensor.SparseTensor( @@ -943,6 +960,7 @@ class HashedCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'dtype must be compatible'): transformation_cache.get(hashed_sparse, None) + @test_util.run_deprecated_v1 def test_ints_should_be_hashed(self): hashed_sparse = fc.categorical_column_with_hash_bucket( 'wire', 10, dtype=dtypes.int64) @@ -957,6 +975,7 @@ class HashedCategoricalColumnTest(test.TestCase): self.assertAllEqual(expected_values, self.evaluate(output.values)) + @test_util.run_deprecated_v1 def test_int32_64_is_compatible(self): hashed_sparse = fc.categorical_column_with_hash_bucket( 'wire', 10, dtype=dtypes.int64) @@ -971,6 +990,7 @@ class HashedCategoricalColumnTest(test.TestCase): self.assertAllEqual(expected_values, self.evaluate(output.values)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): hashed_sparse = fc.categorical_column_with_hash_bucket('wire', 10) transformation_cache = fc.FeatureTransformationCache({ @@ -986,6 +1006,7 @@ class HashedCategoricalColumnTest(test.TestCase): self.assertEqual( transformation_cache.get(hashed_sparse, None), id_weight_pair.id_tensor) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): hashed_sparse = fc.categorical_column_with_hash_bucket('wire', 10) transformation_cache = fc.FeatureTransformationCache({ @@ -997,6 +1018,7 @@ class HashedCategoricalColumnTest(test.TestCase): self.assertEqual( transformation_cache.get(hashed_sparse, None), id_weight_pair.id_tensor) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc.categorical_column_with_hash_bucket('wire', 4) self.assertEqual(4, wire_column.num_buckets) @@ -1047,6 +1069,7 @@ class HashedCategoricalColumnTest(test.TestCase): # 'skywalker' -> 2, 'omar' -> 2: wire_var[2] + wire_var[2] = 3+3 = 6 self.assertAllClose(((4.,), (6.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): wire_column = fc.categorical_column_with_hash_bucket('wire', 4) self.assertEqual(['wire'], wire_column.parents) @@ -1148,6 +1171,7 @@ class CrossedColumnTest(test.TestCase): crossed = fc.crossed_column([b, 'c'], 15) self.assertEqual(15, crossed.num_buckets) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc.numeric_column('a', dtype=dtypes.int32) b = fc.bucketized_column(a, boundaries=[0, 1]) @@ -1161,6 +1185,7 @@ class CrossedColumnTest(test.TestCase): self.assertEqual(15, crossed2_copy.hash_bucket_size) self.assertEqual(5, crossed2_copy.hash_key) + @test_util.run_deprecated_v1 def test_parse_example(self): price = fc.numeric_column('price', shape=[2]) bucketized_price = fc.bucketized_column(price, boundaries=[0, 50]) @@ -1190,6 +1215,7 @@ class CrossedColumnTest(test.TestCase): self.evaluate(wire_sparse.values)) self.assertAllEqual([1, 2], self.evaluate(wire_sparse.dense_shape)) + @test_util.run_deprecated_v1 def test_transform_feature(self): price = fc.numeric_column('price', shape=[2]) bucketized_price = fc.bucketized_column(price, boundaries=[0, 50]) @@ -1214,6 +1240,7 @@ class CrossedColumnTest(test.TestCase): self.assertIn(val, list(range(hash_bucket_size))) self.assertAllEqual([2, 4], output_val.dense_shape) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): a = fc.numeric_column('a', dtype=dtypes.int32, shape=(2,)) b = fc.bucketized_column(a, boundaries=(0, 1)) @@ -1285,6 +1312,7 @@ class CrossedColumnTest(test.TestCase): self.assertAllEqual(expected_values, id_tensor_eval.values) self.assertAllEqual((2, 4), id_tensor_eval.dense_shape) + @test_util.run_deprecated_v1 def test_linear_model(self): """Tests linear_model. @@ -1520,6 +1548,7 @@ class CrossedColumnTest(test.TestCase): sess.run(bias.assign((.1,))) self.assertAllClose(((3.1,), (14.1,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): a = fc.numeric_column('a', dtype=dtypes.int32, shape=(2,)) b = fc.bucketized_column(a, boundaries=(0, 1)) @@ -2077,6 +2106,7 @@ class LinearModelTest(test.TestCase): features['price2']: [[1.], [5.]], }) + @test_util.run_deprecated_v1 def test_with_numpy_input_fn(self): price = fc.numeric_column('price') price_buckets = fc.bucketized_column( @@ -2115,6 +2145,7 @@ class LinearModelTest(test.TestCase): coord.request_stop() coord.join(threads) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): price = fc.numeric_column('price') price_buckets = fc.bucketized_column( @@ -2154,6 +2185,7 @@ class LinearModelTest(test.TestCase): self.assertAllClose([[10 - 1000 + 5.], [1000 - 10 + 5.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): price = fc.numeric_column('price') price_buckets = fc.bucketized_column( @@ -2198,6 +2230,7 @@ class LinearModelTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): price = fc.numeric_column('price') features = { @@ -2835,6 +2868,7 @@ class OldLinearModelTest(test.TestCase): features['price2']: [[1.], [5.]], }) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): price = fc.numeric_column('price') price_buckets = fc.bucketized_column( @@ -2875,6 +2909,7 @@ class OldLinearModelTest(test.TestCase): self.assertAllClose([[10 - 1000 + 5.], [1000 - 10 + 5.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): price = fc.numeric_column('price') price_buckets = fc.bucketized_column( @@ -2920,6 +2955,7 @@ class OldLinearModelTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): price = fc.numeric_column('price') features = { @@ -2962,6 +2998,7 @@ class OldLinearModelTest(test.TestCase): sess.run(bias2.assign([5.])) self.assertAllClose([[25.], [105.]], self.evaluate(predictions2)) + @test_util.run_deprecated_v1 def test_linear_model_v1_shared_embedding_all_other_v2(self): price = fc.numeric_column('price') # v2 some_sparse_column = fc.categorical_column_with_hash_bucket( @@ -3001,6 +3038,7 @@ class OldLinearModelTest(test.TestCase): self.assertAllClose([0.], self.evaluate(bias)) + @test_util.run_deprecated_v1 def test_linear_model_v1_shared_embedding_with_v2_cat_all_other_v2(self): price = fc.numeric_column('price') # v2 some_sparse_column = fc.categorical_column_with_hash_bucket( @@ -3040,6 +3078,7 @@ class OldLinearModelTest(test.TestCase): self.assertAllClose([0.], self.evaluate(bias)) + @test_util.run_deprecated_v1 def test_linear_model_v1_v2_mix(self): price = fc.numeric_column('price') # v2 some_sparse_column = fc.categorical_column_with_hash_bucket( @@ -3079,6 +3118,7 @@ class OldLinearModelTest(test.TestCase): self.assertAllClose([0.], self.evaluate(bias)) + @test_util.run_deprecated_v1 def test_linear_model_v2_shared_embedding_all_other_v1(self): price = fc.numeric_column('price') # v1 some_sparse_column = fc.categorical_column_with_hash_bucket( @@ -3468,6 +3508,7 @@ class DenseFeaturesTest(test.TestCase): expected_var_names, [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_multiple_layers_with_same_shared_embedding_column(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -3501,6 +3542,7 @@ class DenseFeaturesTest(test.TestCase): ['aaa_bbb_shared_embedding:0'], [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_multiple_layers_with_same_shared_embedding_column_diff_graphs(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -3552,6 +3594,7 @@ class DenseFeaturesTest(test.TestCase): ['aaa_bbb_shared_embedding:0'], [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_with_numpy_input_fn(self): embedding_values = ( (1., 2., 3., 4., 5.), # id 0 @@ -3596,6 +3639,7 @@ class DenseFeaturesTest(test.TestCase): coord.request_stop() coord.join(threads) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): embedding_values = ( (1., 2., 3., 4., 5.), # id 0 @@ -3652,6 +3696,7 @@ class DenseFeaturesTest(test.TestCase): [1., 0., 0., 1., 2., 3., 4., 5., 12.]], sess.run(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): embedding_values = ( (1., 2.), # id 0 @@ -3710,6 +3755,7 @@ class DenseFeaturesTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): # price has 1 dimension in dense_features price = fc.numeric_column('price') @@ -3967,6 +4013,7 @@ class FunctionalInputLayerTest(test.TestCase): variables_lib.Variable) self.assertAllEqual(cols_to_vars[some_embedding_column][0].shape, [5, 10]) + @test_util.run_deprecated_v1 def test_fills_cols_to_vars_shared_embedding(self): # Provide 5 DenseColumn's to input_layer: a NumericColumn, a # BucketizedColumn, an EmbeddingColumn, two SharedEmbeddingColumns. The @@ -4167,6 +4214,7 @@ class FunctionalInputLayerTest(test.TestCase): expected_var_names, [v.name for v in ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)]) + @test_util.run_deprecated_v1 def test_with_1d_sparse_tensor(self): embedding_values = ( (1., 2., 3., 4., 5.), # id 0 @@ -4223,6 +4271,7 @@ class FunctionalInputLayerTest(test.TestCase): [1., 0., 0., 1., 2., 3., 4., 5., 12.]], sess.run(net)) + @test_util.run_deprecated_v1 def test_with_1d_unknown_shape_sparse_tensor(self): embedding_values = ( (1., 2.), # id 0 @@ -4281,6 +4330,7 @@ class FunctionalInputLayerTest(test.TestCase): features['country']: country_data })) + @test_util.run_deprecated_v1 def test_with_rank_0_feature(self): # price has 1 dimension in input_layer price = fc.numeric_column('price') @@ -4444,6 +4494,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): 'python/feature_column/testdata/wire_vocabulary.txt') self._wire_vocabulary_size = 3 + @test_util.run_deprecated_v1 def test_defaults(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='path_to_file', vocabulary_size=3) @@ -4460,6 +4511,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): fc.categorical_column_with_vocabulary_file( key=('aaa',), vocabulary_file='path_to_file', vocabulary_size=3) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4472,6 +4524,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, column.parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4496,6 +4549,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): fc.categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='', vocabulary_size=3) + @test_util.run_deprecated_v1 def test_invalid_vocabulary_file(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='file_does_not_exist', vocabulary_size=10) @@ -4522,6 +4576,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): vocabulary_file=self._wire_vocabulary_file_name, vocabulary_size=0) + @test_util.run_deprecated_v1 def test_too_large_vocabulary_size(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4596,6 +4651,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): 'aaa': inputs }), None) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_vocabulary_file( key='aaa', vocabulary_file='path_to_file', vocabulary_size=3) @@ -4619,6 +4675,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): values=np.array([b'omar', b'stringer'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4645,6 +4702,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_none_vocabulary_size(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', vocabulary_file=self._wire_vocabulary_file_name) @@ -4669,6 +4727,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4692,6 +4751,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): values=np.array((2, -1, 0), dtype=np.int64), dense_shape=inputs.dense_shape), self.evaluate(id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4713,6 +4773,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): values=np.array((2, -1, 0), dtype=np.int64), dense_shape=(2, 2)), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_default_value_in_vocabulary(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4740,6 +4801,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_oov_buckets(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4767,6 +4829,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_small_vocabulary_size(self): # 'marlo' is the last entry in our vocabulary file, so be setting # `vocabulary_size` to 1 less than number of entries in file, we take @@ -4796,6 +4859,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4823,6 +4887,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_dense_input(self): default_value = -100 column = fc.categorical_column_with_vocabulary_file( @@ -4847,6 +4912,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): values=np.array((2, default_value, 0, 4), dtype=np.int64), dense_shape=(3, 3)), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_with_oov_buckets(self): column = fc.categorical_column_with_vocabulary_file( key='aaa', @@ -4875,6 +4941,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc.categorical_column_with_vocabulary_file( key='wire', @@ -4933,6 +5000,7 @@ class VocabularyFileCategoricalColumnTest(test.TestCase): # 'skywalker' -> 3, 'omar' -> 0: wire_var[3] + wire_var[0] = 4+1 = 5 self.assertAllClose(((3.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): wire_column = fc.categorical_column_with_vocabulary_file( key='wire', @@ -4984,6 +5052,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, column.parse_example_spec) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -4995,6 +5064,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int32) }, column.parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=(12, 24, 36), dtype=dtypes.int32) @@ -5089,6 +5159,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): 'aaa': inputs }), None) + @test_util.run_deprecated_v1 def test_parse_example_string(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5112,6 +5183,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): values=np.array([b'omar', b'stringer'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_parse_example_int(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=(11, 21, 31)) @@ -5133,6 +5205,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): indices=[[0, 0], [0, 1]], values=[11, 21], dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5157,6 +5230,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5178,6 +5252,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): values=np.array((2, -1, 0), dtype=np.int64), dense_shape=inputs.dense_shape), self.evaluate(id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5197,6 +5272,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): values=np.array((2, -1, 0), dtype=np.int64), dense_shape=(2, 2)), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_default_value_in_vocabulary(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5223,6 +5299,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_oov_buckets(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5249,6 +5326,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5275,6 +5353,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_dense_input(self): default_value = -100 column = fc.categorical_column_with_vocabulary_list( @@ -5300,6 +5379,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): values=np.array((2, default_value, 0, 4), dtype=np.int64), dense_shape=(3, 3)), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_int32_with_oov_buckets(self): column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5327,6 +5407,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_linear_model(self): wire_column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5383,6 +5464,7 @@ class VocabularyListCategoricalColumnTest(test.TestCase): # 'skywalker' -> 3, 'omar' -> 0: wire_var[3] + wire_var[0] = 4+1 = 5 self.assertAllClose(((3.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): wire_column = fc.categorical_column_with_vocabulary_list( key='aaa', @@ -5420,6 +5502,7 @@ class IdentityCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'key must be a string.'): fc.categorical_column_with_identity(key=('aaa',), num_buckets=3) + @test_util.run_deprecated_v1 def test_deep_copy(self): original = fc.categorical_column_with_identity(key='aaa', num_buckets=3) for column in (original, copy.deepcopy(original)): @@ -5459,6 +5542,7 @@ class IdentityCategoricalColumnTest(test.TestCase): 'aaa': inputs }), None) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_identity(key='aaa', num_buckets=30) data = example_pb2.Example( @@ -5480,6 +5564,7 @@ class IdentityCategoricalColumnTest(test.TestCase): values=np.array([11, 21], dtype=np.int64), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_get_sparse_tensors(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -5501,6 +5586,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_transform_feature(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -5519,6 +5605,7 @@ class IdentityCategoricalColumnTest(test.TestCase): values=np.array((0, 1, 0), dtype=np.int64), dense_shape=inputs.dense_shape), self.evaluate(id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_dense_input(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) id_weight_pair = column.get_sparse_tensors( @@ -5537,6 +5624,7 @@ class IdentityCategoricalColumnTest(test.TestCase): values=np.array((0, 1, 0), dtype=np.int64), dense_shape=(2, 2)), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_inputs_too_small(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -5553,6 +5641,7 @@ class IdentityCategoricalColumnTest(test.TestCase): with self.assertRaisesRegexp(errors.OpError, 'assert_greater_or_equal_0'): self.evaluate(id_weight_pair.id_tensor) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_inputs_too_big(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) inputs = sparse_tensor.SparseTensorValue( @@ -5570,6 +5659,7 @@ class IdentityCategoricalColumnTest(test.TestCase): 'assert_less_than_num_buckets'): self.evaluate(id_weight_pair.id_tensor) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_default_value(self): column = fc.categorical_column_with_identity( key='aaa', num_buckets=4, default_value=3) @@ -5594,6 +5684,7 @@ class IdentityCategoricalColumnTest(test.TestCase): dense_shape=inputs.dense_shape), self.evaluate(id_weight_pair.id_tensor)) + @test_util.run_deprecated_v1 def test_get_sparse_tensors_with_default_value_and_placeholder_inputs(self): column = fc.categorical_column_with_identity( key='aaa', num_buckets=4, default_value=3) @@ -5624,6 +5715,7 @@ class IdentityCategoricalColumnTest(test.TestCase): input_shape: (2, 2), })) + @test_util.run_deprecated_v1 def test_linear_model(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) self.assertEqual(3, column.num_buckets) @@ -5674,6 +5766,7 @@ class IdentityCategoricalColumnTest(test.TestCase): # weight_var[2] + weight_var[1] = 3+2 = 5 self.assertAllClose(((1.,), (5.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): column = fc.categorical_column_with_identity(key='aaa', num_buckets=3) @@ -5827,6 +5920,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[0., 1., 1., 0.]], self.evaluate(output)) + @test_util.run_deprecated_v1 def test_deep_copy(self): a = fc.categorical_column_with_hash_bucket('a', 4) column = fc.indicator_column(a) @@ -5835,6 +5929,7 @@ class IndicatorColumnTest(test.TestCase): self.assertEqual(column.name, 'a_indicator') self.assertEqual(column.variable_shape, [1, 4]) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5859,6 +5954,7 @@ class IndicatorColumnTest(test.TestCase): values=np.array([b'omar', b'stringer'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_transform(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -5878,6 +5974,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[0, 0, 1], [1, 0, 0]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_weighted_column(self): # Github issue 12557 ids = fc.categorical_column_with_vocabulary_list( @@ -5896,6 +5993,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[6., 4., 3.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_missing_value_in_weighted_column(self): # Github issue 12583 ids = fc.categorical_column_with_vocabulary_list( @@ -5914,6 +6012,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[0., 4., 2.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_transform_with_missing_value_in_categorical_column(self): # Github issue 12583 ids = fc.categorical_column_with_vocabulary_list( @@ -5930,6 +6029,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllEqual([[0., 1., 1.]], self.evaluate(indicator_tensor)) + @test_util.run_deprecated_v1 def test_linear_model(self): animal = fc.indicator_column( fc.categorical_column_with_identity('animal', num_buckets=4)) @@ -5997,6 +6097,7 @@ class IndicatorColumnTest(test.TestCase): self.evaluate(weight_var.assign([[1.], [2.], [3.], [4.]])) self.assertAllClose([[2. + 3.]], self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_dense_features(self): animal = fc.indicator_column( fc.categorical_column_with_identity('animal', num_buckets=4)) @@ -6013,6 +6114,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllClose([[0., 1., 1., 0.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_input_layer(self): animal = fc.indicator_column( fc.categorical_column_with_identity('animal', num_buckets=4)) @@ -6045,6 +6147,7 @@ class IndicatorColumnTest(test.TestCase): self.assertAllClose([[0., 1., 1., 0.]], self.evaluate(net)) + @test_util.run_deprecated_v1 def test_serialization(self): parent = fc.categorical_column_with_identity('animal', num_buckets=4) animal = fc.indicator_column(parent) @@ -6114,6 +6217,7 @@ class _TestStateManager(fc.StateManager): class EmbeddingColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): categorical_column = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -6142,6 +6246,7 @@ class EmbeddingColumnTest(test.TestCase): categorical_column, dimension=embedding_dimension) self.assertFalse(embedding_column._is_v2_column) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): categorical_column = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -6168,6 +6273,7 @@ class EmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column.parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): categorical_column = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -6200,12 +6306,14 @@ class EmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column.parse_example_spec) + @test_util.run_deprecated_v1 def test_invalid_initializer(self): categorical_column = fc.categorical_column_with_identity( key='aaa', num_buckets=3) with self.assertRaisesRegexp(ValueError, 'initializer must be callable'): fc.embedding_column(categorical_column, dimension=2, initializer='not_fn') + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -6230,6 +6338,7 @@ class EmbeddingColumnTest(test.TestCase): values=np.array([b'omar', b'stringer'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['aaa'])) + @test_util.run_deprecated_v1 def test_transform_feature(self): a = fc.categorical_column_with_identity(key='aaa', num_buckets=3) a_embedded = fc.embedding_column(a, dimension=2) @@ -6250,6 +6359,7 @@ class EmbeddingColumnTest(test.TestCase): _assert_sparse_tensor_value(self, self.evaluate(output_a), self.evaluate(output_embedded)) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): # Inputs. vocabulary_size = 3 @@ -6315,6 +6425,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(global_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_old_categorical(self): # Inputs. vocabulary_size = 3 @@ -6378,6 +6489,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(global_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_3d(self): # Inputs. vocabulary_size = 4 @@ -6445,6 +6557,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(global_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_placeholder_inputs(self): # Inputs. vocabulary_size = 3 @@ -6524,6 +6637,7 @@ class EmbeddingColumnTest(test.TestCase): input_shape: sparse_input.dense_shape, })) + @test_util.run_deprecated_v1 def test_get_dense_tensor_restore_from_ckpt(self): # Inputs. vocabulary_size = 3 @@ -6587,6 +6701,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(global_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(embedding_lookup)) + @test_util.run_deprecated_v1 def test_linear_model(self): # Inputs. batch_size = 4 @@ -6668,6 +6783,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllClose(((94.,), (29.,), (0.,), (42.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_dense_features(self): # Inputs. vocabulary_size = 3 @@ -6734,6 +6850,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(trainable_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(dense_features)) + @test_util.run_deprecated_v1 def test_dense_features_not_trainable(self): # Inputs. vocabulary_size = 3 @@ -6799,6 +6916,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllEqual(embedding_values, self.evaluate(global_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(dense_features)) + @test_util.run_deprecated_v1 def test_input_layer(self): # Inputs. vocabulary_size = 3 @@ -7028,6 +7146,7 @@ class EmbeddingColumnTest(test.TestCase): self.assertAllClose(((94.,), (29.,), (0.,), (42.,)), self.evaluate(predictions)) + @test_util.run_deprecated_v1 def test_serialization(self): def _initializer(shape, dtype, partition_info): @@ -7081,6 +7200,7 @@ class EmbeddingColumnTest(test.TestCase): class SharedEmbeddingColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7105,6 +7225,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'bbb': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_b.parse_example_spec) + @test_util.run_deprecated_v1 def test_all_constructor_args(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7136,6 +7257,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'bbb': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_b.parse_example_spec) + @test_util.run_deprecated_v1 def test_deep_copy(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7167,6 +7289,7 @@ class SharedEmbeddingColumnTest(test.TestCase): 'aaa': parsing_ops.VarLenFeature(dtypes.int64) }, embedding_column_a.parse_example_spec) + @test_util.run_deprecated_v1 def test_invalid_initializer(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7178,6 +7301,7 @@ class SharedEmbeddingColumnTest(test.TestCase): dimension=2, initializer='not_fn') + @test_util.run_deprecated_v1 def test_incompatible_column_type(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7192,6 +7316,7 @@ class SharedEmbeddingColumnTest(test.TestCase): [categorical_column_a, categorical_column_b, categorical_column_c], dimension=2) + @test_util.run_deprecated_v1 def test_weighted_categorical_column_ok(self): categorical_column_a = fc.categorical_column_with_identity( key='aaa', num_buckets=3) @@ -7209,6 +7334,7 @@ class SharedEmbeddingColumnTest(test.TestCase): [weighted_categorical_column_a, weighted_categorical_column_b], dimension=2) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -7246,6 +7372,7 @@ class SharedEmbeddingColumnTest(test.TestCase): values=np.array([b'stringer', b'marlo'], dtype=np.object_), dense_shape=[1, 2]), self.evaluate(features['bbb'])) + @test_util.run_deprecated_v1 def test_transform_feature(self): a = fc.categorical_column_with_identity(key='aaa', num_buckets=3) b = fc.categorical_column_with_identity(key='bbb', num_buckets=3) @@ -7277,6 +7404,7 @@ class SharedEmbeddingColumnTest(test.TestCase): _assert_sparse_tensor_value(self, self.evaluate(output_b), self.evaluate(output_b_embedded)) + @test_util.run_deprecated_v1 def test_get_dense_tensor(self): # Inputs. vocabulary_size = 3 @@ -7348,6 +7476,7 @@ class SharedEmbeddingColumnTest(test.TestCase): self.assertAllEqual(expected_lookups_a, self.evaluate(embedding_lookup_a)) self.assertAllEqual(expected_lookups_b, self.evaluate(embedding_lookup_b)) + @test_util.run_deprecated_v1 def test_get_dense_tensor_placeholder_inputs(self): # Inputs. vocabulary_size = 3 @@ -7407,6 +7536,7 @@ class SharedEmbeddingColumnTest(test.TestCase): with _initialized_session() as sess: sess.run([embedding_lookup_a, embedding_lookup_b], feed_dict=feed_dict) + @test_util.run_deprecated_v1 def test_linear_model(self): # Inputs. batch_size = 2 @@ -7619,12 +7749,15 @@ class SharedEmbeddingColumnTest(test.TestCase): self.evaluate(shared_embedding_vars[0])) self.assertAllEqual(expected_lookups, self.evaluate(dense_features)) + @test_util.run_deprecated_v1 def test_dense_features(self): self._test_dense_features() + @test_util.run_deprecated_v1 def test_dense_features_no_trainable(self): self._test_dense_features(trainable=False) + @test_util.run_deprecated_v1 def test_serialization(self): def _initializer(shape, dtype, partition_info): @@ -7647,6 +7780,7 @@ class SharedEmbeddingColumnTest(test.TestCase): class WeightedCategoricalColumnTest(test.TestCase): + @test_util.run_deprecated_v1 def test_defaults(self): column = fc.weighted_categorical_column( categorical_column=fc.categorical_column_with_identity( @@ -7667,6 +7801,7 @@ class WeightedCategoricalColumnTest(test.TestCase): weight_feature_key='values') self.assertFalse(column._is_v2_column) + @test_util.run_deprecated_v1 def test_deep_copy(self): """Tests deepcopy of categorical_column_with_hash_bucket.""" original = fc.weighted_categorical_column( @@ -7732,6 +7867,7 @@ class WeightedCategoricalColumnTest(test.TestCase): 'values is not in features dictionary'): fc._transform_features_v2({'ids': inputs}, (column,), None) + @test_util.run_deprecated_v1 def test_parse_example(self): a = fc.categorical_column_with_vocabulary_list( key='aaa', vocabulary_list=('omar', 'stringer', 'marlo')) @@ -7766,6 +7902,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array([1., 10.], dtype=np.float32), dense_shape=[1, 2]), self.evaluate(features['weights'])) + @test_util.run_deprecated_v1 def test_transform_features(self): column = fc.weighted_categorical_column( categorical_column=fc.categorical_column_with_identity( @@ -7798,6 +7935,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array(weights.values, dtype=np.float32), dense_shape=weights.dense_shape), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_transform_features_dense_input(self): column = fc.weighted_categorical_column( categorical_column=fc.categorical_column_with_identity( @@ -7828,6 +7966,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array(weights.values, dtype=np.float32), dense_shape=weights.dense_shape), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_transform_features_dense_weights(self): column = fc.weighted_categorical_column( categorical_column=fc.categorical_column_with_identity( @@ -7856,6 +7995,7 @@ class WeightedCategoricalColumnTest(test.TestCase): values=np.array((.5, 1., .1), dtype=np.float32), dense_shape=(2, 2)), self.evaluate(weight_tensor)) + @test_util.run_deprecated_v1 def test_linear_model(self): column = fc.weighted_categorical_column( categorical_column=fc.categorical_column_with_identity( @@ -8106,6 +8246,7 @@ class WeightedCategoricalColumnTest(test.TestCase): # TODO(ptucker): Add test with embedding of weighted categorical. + @test_util.run_deprecated_v1 def test_serialization(self): categorical_column = fc.categorical_column_with_identity( key='ids', num_buckets=3) diff --git a/tensorflow/python/framework/file_system_test.py b/tensorflow/python/framework/file_system_test.py index 066d34e781c..8687bc5a785 100644 --- a/tensorflow/python/framework/file_system_test.py +++ b/tensorflow/python/framework/file_system_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import os from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.framework import load_library from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import io_ops @@ -36,6 +37,7 @@ class FileSystemTest(test.TestCase): "test_file_system.so") load_library.load_file_system_library(file_system_library) + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session() as sess: reader = io_ops.WholeFileReader("test_reader") diff --git a/tensorflow/python/framework/function_def_to_graph_test.py b/tensorflow/python/framework/function_def_to_graph_test.py index b2ef64f8730..ddf1a6e74d2 100644 --- a/tensorflow/python/framework/function_def_to_graph_test.py +++ b/tensorflow/python/framework/function_def_to_graph_test.py @@ -25,6 +25,7 @@ from tensorflow.python.framework import function_def_to_graph from tensorflow.python.framework import graph_to_function_def from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.framework import test_ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops @@ -52,6 +53,7 @@ class FunctionDefToGraphTest(test.TestCase): fdef.signature.name = "_whats_in_a_name" return fdef + @test_util.run_deprecated_v1 def testInputsAndOutputs(self): fdef = self._build_function_def() g = function_def_to_graph.function_def_to_graph(fdef) @@ -186,6 +188,7 @@ class FunctionDefToGraphDefTest(test.TestCase): self.assertEqual(g.node[0].attr["shape"].shape.unknown_rank, False) self.assertFalse("shape" in g.node[2].attr) + @test_util.run_deprecated_v1 def testFunctionCallsFromFunction(self): x = constant_op.constant(5.0) y = constant_op.constant(10.0) diff --git a/tensorflow/python/framework/function_test.py b/tensorflow/python/framework/function_test.py index 1a17a480502..d71f06ea528 100644 --- a/tensorflow/python/framework/function_test.py +++ b/tensorflow/python/framework/function_test.py @@ -35,6 +35,7 @@ from tensorflow.python.framework import function from tensorflow.python.framework import graph_to_function_def from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.framework.errors import InvalidArgumentError from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops @@ -104,6 +105,7 @@ class FunctionTest(test.TestCase): with session.Session() as sess: self.assertAllEqual([18.0], self.evaluate(call)) + @test_util.run_deprecated_v1 def testIdentityImplicitDeref(self): @function.Defun(dtypes.float32, func_name="MyIdentity") @@ -322,6 +324,7 @@ class FunctionTest(test.TestCase): self.assertEqual(x.get_shape(), dx.get_shape()) self.assertEqual(y.get_shape(), dy.get_shape()) + @test_util.run_deprecated_v1 def testSymGradAttr(self): @function.Defun(noinline=True) @@ -438,6 +441,7 @@ class FunctionTest(test.TestCase): "assertion failed.*-3"): self.assertAllEqual(Foo(constant_op.constant(-3.0)).eval(), 6.0) + @test_util.run_deprecated_v1 def testAssertWrapper(self): @function.Defun(dtypes.float32) @@ -452,6 +456,7 @@ class FunctionTest(test.TestCase): "assertion"): _ = MyFn(100.0).eval() + @test_util.run_deprecated_v1 def testWhileLoopCallsFunc(self): with self.session(use_gpu=True) as sess: @@ -471,6 +476,7 @@ class FunctionTest(test.TestCase): ans = self.evaluate(loop) self.assertAllClose(ans, 131072.) + @test_util.run_deprecated_v1 def testControlFlowStrictness(self): """Inlined functions must not execute in a untaken control flow branch.""" @@ -517,6 +523,7 @@ class FunctionTest(test.TestCase): "assertion"): sess.run(loop, {pred: True, x: 3}) + @test_util.run_deprecated_v1 def testVar(self): @function.Defun(dtypes.float32) @@ -532,6 +539,7 @@ class FunctionTest(test.TestCase): variables.global_variables_initializer().run() self.assertAllEqual(z.eval(), 101.) + @test_util.run_deprecated_v1 def testResourceVarAsImplicitInput(self): g = ops.Graph() with g.as_default(), ops.device("cpu:0"): @@ -707,6 +715,7 @@ class FunctionTest(test.TestCase): gdef = g.as_graph_def() self.assertEqual(0, len(gdef.library.function)) + @test_util.run_deprecated_v1 def testReduction(self): g = ops.Graph() @@ -735,6 +744,7 @@ class FunctionTest(test.TestCase): self.assertAllClose(vals[0], vals[1]) self.assertAllClose(vals[2], vals[3]) + @test_util.run_deprecated_v1 def testCapture(self): g = ops.Graph() with g.as_default(): @@ -781,6 +791,7 @@ class FunctionTest(test.TestCase): # NOTE: We still do not support capturing control deps. _ = Foo(x) + @test_util.run_deprecated_v1 def testCaptureInWhileLoop(self): g = ops.Graph() with g.as_default(): @@ -796,6 +807,7 @@ class FunctionTest(test.TestCase): with self.session(graph=g) as sess: self.assertEqual(self.evaluate(y), 10) + @test_util.run_deprecated_v1 def testCaptureInCond(self): g = ops.Graph() with g.as_default(): @@ -825,6 +837,7 @@ class FunctionTest(test.TestCase): self.assertEqual("Foo_aCYSbwBkR5A", Foo.instantiate([dtypes.float32] * 3).name) + @test_util.run_deprecated_v1 def testSignatureHash(self): # Foo.Inner and Bar.Inner have identical function body but have # different signatures. They should be treated as two different functions. @@ -877,6 +890,7 @@ class FunctionTest(test.TestCase): y = Bar(array_ops.zeros([1, 2, 3])) self.assertAllEqual(y.get_shape().as_list(), [1, 1, 2, 3]) + @test_util.run_deprecated_v1 def testVariableReuse(self): def LinearWithReuse(input_tensor, reuse=None): @@ -905,6 +919,7 @@ class FunctionTest(test.TestCase): output_op, feed_dict={input_op: np.random.rand(32, 100)}) self.assertEqual(output_val.shape, (32, 100)) + @test_util.run_deprecated_v1 def testFunctionCallInDifferentVariableScopes(self): @function.Defun(dtypes.float32) @@ -968,6 +983,7 @@ class FunctionTest(test.TestCase): self.assertAllClose( np.array([1.0, 0.0]).astype(np.float32), sess.run(dinp, {inp: x})) + @test_util.run_deprecated_v1 def testFunctionMarkedStateful(self): @function.Defun(dtypes.int32, dtypes.float32) @@ -995,6 +1011,7 @@ class FunctionTest(test.TestCase): self.assertEqual(100, self.evaluate(result_2)) self.assertEqual((4.0, 100), sess.run((result_1, result_2))) + @test_util.run_deprecated_v1 def testStatefulFunction(self): @function.Defun() @@ -1037,6 +1054,7 @@ class FunctionTest(test.TestCase): self.assertFalse(all(val3 == val1)) self.assertFalse(all(val4 == val2)) + @test_util.run_deprecated_v1 def testSameFunctionOnTwoDevices(self): @function.Defun(dtypes.float32) @@ -1056,6 +1074,7 @@ class FunctionTest(test.TestCase): self.assertEqual(44.0, self.evaluate(f_1)) self.assertEqual((42.0, 44.0), sess.run((f_0, f_1))) + @test_util.run_deprecated_v1 def testGuaranteedConstsAreCaptured(self): var = variables.Variable(1.0) const = array_ops.guarantee_const(var) @@ -1079,6 +1098,7 @@ class FunctionTest(test.TestCase): self.evaluate(var.initializer) _ = sess.run(CapturesGuaranteedConst(), {also_not_const: 1.0}) + @test_util.run_deprecated_v1 def testSameFunctionDifferentGrads(self): def PartOne(x): @@ -1150,6 +1170,7 @@ class FunctionsFromProtos(test.TestCase): self.assertEqual(func.declared_input_types, new_func.declared_input_types) self.assertEqual(func.captured_inputs, new_func.captured_inputs) + @test_util.run_deprecated_v1 def testBasic(self): @function.Defun(dtypes.float32, dtypes.float32) @@ -1359,6 +1380,7 @@ class FunctionsFromProtos(test.TestCase): class FunctionOverloadTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): @function.Defun() @@ -1411,6 +1433,7 @@ class FunctionOverloadTest(test.TestCase): class FunctionCaptureByValueTest(test.TestCase): + @test_util.run_deprecated_v1 def testCaptureByValue(self): g = ops.Graph() with g.as_default(): @@ -1634,6 +1657,7 @@ class FunctionInlineControlTest(test.TestCase): class ModuleFunctionTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): @function.Defun(*[dtypes.float32] * 3) @@ -1717,10 +1741,12 @@ class VariableHoistingTest(test.TestCase): self.assertAllEqual(db.shape, (64,)) self.assertAllClose(np.sum(db), 0.509, rtol=1e-2) + @test_util.run_deprecated_v1 def testBasic(self): self._testSimpleModel(True) self._testSimpleModel(False) + @test_util.run_deprecated_v1 def testBasicResource(self): self._testSimpleModel(True, use_resource=True) self._testSimpleModel(False, use_resource=True) diff --git a/tensorflow/python/framework/graph_util_test.py b/tensorflow/python/framework/graph_util_test.py index 10a01c71f2c..4e7408ad49f 100644 --- a/tensorflow/python/framework/graph_util_test.py +++ b/tensorflow/python/framework/graph_util_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import graph_util from tensorflow.python.framework import importer from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_state_ops from tensorflow.python.ops import math_ops # pylint: disable=unused-import from tensorflow.python.ops import math_ops as math_ops_lib @@ -102,6 +103,7 @@ class DeviceFunctionsTest(test.TestCase): self.assertDeviceEqual(var_5.device, "/device:GPU:0") self.assertDeviceEqual(var_6.device, "/device:CPU:0") + @test_util.run_deprecated_v1 def testNestedDeviceFunctions(self): with ops.Graph().as_default(): var_0 = variables.VariableV1(0) diff --git a/tensorflow/python/framework/meta_graph_test.py b/tensorflow/python/framework/meta_graph_test.py index cc93f8b1b87..46ce4616a50 100644 --- a/tensorflow/python/framework/meta_graph_test.py +++ b/tensorflow/python/framework/meta_graph_test.py @@ -63,6 +63,7 @@ def _TestDir(test_name): class SimpleMetaGraphTest(test.TestCase): + @test_util.run_deprecated_v1 def testNoVariables(self): test_dir = _TestDir("no_variables") filename = os.path.join(test_dir, "metafile") @@ -116,6 +117,7 @@ class SimpleMetaGraphTest(test.TestCase): {new_input_tensor: input_feed_value}) self.assertEqual(new_output_value, output_value) + @test_util.run_deprecated_v1 def testStrippedOpListNestedFunctions(self): with self.cached_session(): # Square two levels deep @@ -158,6 +160,7 @@ class SimpleMetaGraphTest(test.TestCase): op_list = meta_graph.stripped_op_list_for_graph(graph) self.assertEqual(["Const"], [op.name for op in op_list.op]) + @test_util.run_deprecated_v1 def testDefaultAttrStripping(self): """Verifies that default attributes are stripped from a graph def.""" @@ -210,6 +213,7 @@ class SimpleMetaGraphTest(test.TestCase): self.assertEqual(node_def.attr["Tout"].type, dtypes.complex128) self.assertTrue(meta_graph_def.meta_info_def.stripped_default_attrs) + @test_util.run_deprecated_v1 def testDefaultAttrStrippingNestedFunctions(self): """Verifies that default attributes are stripped from function node defs.""" with self.cached_session(): @@ -261,6 +265,7 @@ class SimpleMetaGraphTest(test.TestCase): self.assertEqual(node_def.attr["attr_1"].i, 1) self.assertTrue(meta_graph_def.meta_info_def.stripped_default_attrs) + @test_util.run_deprecated_v1 def testVariableObjectsAreSharedAmongCollections(self): with ops.Graph().as_default() as graph1: v = variables.Variable(3.0) @@ -454,6 +459,7 @@ class ScopedMetaGraphTest(test.TestCase): # Verifies that we can export the subgraph under each layer and import # them into new layers in a new graph. + @test_util.run_deprecated_v1 def testScopedExportAndImport(self): test_dir = _TestDir("scoped_export_import") filenames = [ @@ -522,6 +528,7 @@ class ScopedMetaGraphTest(test.TestCase): actual_grad_value = self.evaluate(grad) self.assertEqual(expected_grad_value, actual_grad_value) + @test_util.run_deprecated_v1 def testImportWhileLoopInWhileLoop(self): # Create a simple while loop. with ops.Graph().as_default(): @@ -547,6 +554,7 @@ class ScopedMetaGraphTest(test.TestCase): self.evaluate(variables.global_variables_initializer()) self.evaluate(x) + @test_util.run_deprecated_v1 def testScopedImportUnderNameScope(self): graph = ops.Graph() with graph.as_default(): @@ -562,6 +570,7 @@ class ScopedMetaGraphTest(test.TestCase): self.assertEqual(list(imported_variables.values())[0].name, "foo/bar/myvar:0") + @test_util.run_deprecated_v1 def testScopedImportUnderNameScopeNoVarScope(self): graph = ops.Graph() with graph.as_default(): @@ -590,6 +599,7 @@ class ScopedMetaGraphTest(test.TestCase): self.assertEqual(list(imported_variables.values())[0].name, "s" + suffix + "/v:0") + @test_util.run_deprecated_v1 def testScopedImportWithSelectedCollections(self): meta_graph_filename = os.path.join( _TestDir("selected_collections_import"), "meta_graph.pb") @@ -687,6 +697,7 @@ class ScopedMetaGraphTest(test.TestCase): # Verifies that we can export the subgraph containing a FIFOQueue under # "queue1" and import it into "new_queue1" in a new graph. + @test_util.run_deprecated_v1 def testScopedWithQueue(self): test_dir = _TestDir("scoped_with_queue") orig_meta_graph = self._testScopedExportWithQueue(test_dir, @@ -749,12 +760,15 @@ class ScopedMetaGraphTest(test.TestCase): for n, e in zip(nodes, expected): self.assertEqual([e], graph2.get_operation_by_name(n).get_attr("_class")) + @test_util.run_deprecated_v1 def testExportNestedNames(self): self.doTestExportNestedNames(use_resource=False) + @test_util.run_deprecated_v1 def testExportNestedNamesResource(self): self.doTestExportNestedNames(use_resource=True) + @test_util.run_deprecated_v1 def testPotentialCycle(self): graph1 = ops.Graph() with graph1.as_default(): @@ -783,6 +797,7 @@ class ScopedMetaGraphTest(test.TestCase): 4.0, shape=[2, 2]) }) + @test_util.run_deprecated_v1 def testClearDevices(self): graph1 = ops.Graph() with graph1.as_default(): @@ -842,6 +857,7 @@ class ScopedMetaGraphTest(test.TestCase): class MetaGraphWithVariableScopeTest(test.TestCase): + @test_util.run_deprecated_v1 def testMetricsCollection(self): def _enqueue_vector(sess, queue, values, shape=None): @@ -899,6 +915,7 @@ class MetaGraphWithVariableScopeTest(test.TestCase): class ExportImportAcrossScopesTest(test.TestCase): + @test_util.run_deprecated_v1 def testPartionedVariables(self): def make_graph_with_partitioned_variables(use_resource): diff --git a/tensorflow/python/framework/ops_test.py b/tensorflow/python/framework/ops_test.py index 9c9ef799f72..04a9ed05fd2 100644 --- a/tensorflow/python/framework/ops_test.py +++ b/tensorflow/python/framework/ops_test.py @@ -57,11 +57,13 @@ ops._set_call_cpp_shape_fn(common_shapes.call_cpp_shape_fn) class ResourceTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBuildGraph(self): with self.cached_session(): pt = test_ops.stub_resource_handle_op(container="a", shared_name="b") test_ops.resource_create_op(pt).run() + @test_util.run_deprecated_v1 def testInitialize(self): with self.cached_session(): handle = test_ops.stub_resource_handle_op(container="a", shared_name="b") @@ -106,6 +108,7 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase): c = a + b self.assertEqual([2, 3], c.shape) + @test_util.run_deprecated_v1 def testUnknownDim(self): with self.cached_session(): a = array_ops.placeholder(dtype=dtypes.float32, shape=[2, None, 3]) @@ -113,6 +116,7 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase): c = a + b self.assertEqual([2, None, 3], c.shape.as_list()) + @test_util.run_deprecated_v1 def testUnknownShape(self): with self.cached_session(): a = array_ops.placeholder(dtype=dtypes.float32, shape=None) @@ -120,6 +124,7 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase): c = a + b self.assertEqual(tensor_shape.unknown_shape(), c.shape) + @test_util.run_deprecated_v1 def testScalarShape(self): with self.cached_session(): a = array_ops.placeholder(dtype=dtypes.float32, shape=[]) @@ -127,6 +132,7 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase): c = a + b self.assertEqual(tensor_shape.scalar(), c.shape) + @test_util.run_deprecated_v1 def testShapeFunctionError(self): with self.cached_session(): a = array_ops.ones([1, 2, 3]) @@ -140,6 +146,7 @@ class TensorAndShapeTest(test_util.TensorFlowTestCase): class IndexedSlicesTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testToTensor(self): with self.cached_session(): values = constant_op.constant([2, 3, 5, 7], shape=[2, 2]) @@ -149,6 +156,7 @@ class IndexedSlicesTest(test_util.TensorFlowTestCase): tensor = ops.convert_to_tensor(x, name="tensor") self.assertAllEqual(tensor.eval(), [[2, 3], [0, 0], [5, 7]]) + @test_util.run_deprecated_v1 def testNegation(self): with self.cached_session(): values = constant_op.constant([2, 3, 5, 7], shape=[2, 2]) @@ -157,6 +165,7 @@ class IndexedSlicesTest(test_util.TensorFlowTestCase): self.assertAllEqual(x.values.eval(), [[-2, -3], [-5, -7]]) self.assertAllEqual(x.indices.eval(), [0, 2]) + @test_util.run_deprecated_v1 def testScalarMul(self): with self.cached_session(): values = constant_op.constant([2, 3, 5, 7], shape=[2, 2]) @@ -190,6 +199,7 @@ def _apply_op(g, *args, **kwargs): class OperationTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testNoInputs(self): op = test_ops.float_output_string_output(name="myop").a.op self.assertEqual(2, len(op.values())) @@ -212,6 +222,7 @@ class OperationTest(test_util.TensorFlowTestCase): self.assertProtoEquals("op:'FloatOutputStringOutput' name:'myop'", op.node_def) + @test_util.run_deprecated_v1 def testNoOutputs(self): op1 = test_ops.float_output(name="myop1").op float_t, = op1.values() @@ -227,6 +238,7 @@ class OperationTest(test_util.TensorFlowTestCase): self.assertProtoEquals("op:'FloatInput' name:'myop2' input:'myop1'", op2.node_def) + @test_util.run_deprecated_v1 def testInputsAndOutputs(self): op1 = test_ops.float_output(name="myop1").op self.assertEqual(1, len(op1.values())) @@ -308,6 +320,7 @@ class OperationTest(test_util.TensorFlowTestCase): with self.assertRaises(ValueError): ops.Operation(ops._NodeDef("op", "invalid:0"), g) + @test_util.run_deprecated_v1 def testNoShapeFunction(self): op = test_ops.a() self.assertEqual(tensor_shape.unknown_shape(), op.get_shape()) @@ -333,6 +346,7 @@ class OperationTest(test_util.TensorFlowTestCase): converted = ops.convert_to_tensor(1) self.assertTrue(isinstance(converted, ops.EagerTensor)) + @test_util.run_deprecated_v1 def testConvertToTensorNestedTuple(self): with self.cached_session(): values = ((2,), (3,), (5,), (7,)) @@ -384,6 +398,7 @@ class OperationTest(test_util.TensorFlowTestCase): values = [1.23] _ = ops.convert_to_tensor(values, dtype=dtypes.int64) + @test_util.run_deprecated_v1 def testNoConvert(self): # Operation cannot be converted to Tensor. op = control_flow_ops.no_op() @@ -401,6 +416,7 @@ class OperationTest(test_util.TensorFlowTestCase): ops._NodeDef("None", "op1"), ops.Graph(), [], [dtypes.float32]) self.assertEqual("<tf.Operation 'op1' type=None>", repr(op)) + @test_util.run_deprecated_v1 def testGetAttr(self): op = test_ops.default_attrs() self.assertEqual(op.get_attr("string_val"), b"abc") @@ -446,6 +462,7 @@ class OperationTest(test_util.TensorFlowTestCase): # TODO(b/65162920): remove this test when users who are directly mutating the # node_def have been updated to proper usage. + @test_util.run_deprecated_v1 def testSetAttr(self): op = test_ops.int_attr().op op._set_attr("foo", attr_value_pb2.AttrValue(i=2)) @@ -466,6 +483,7 @@ class OperationTest(test_util.TensorFlowTestCase): self.assertEqual(z.control_inputs, [x, y]) self.assertEqual(x._control_outputs, [z]) + @test_util.run_deprecated_v1 def testRemoveAllControlInputs(self): a = constant_op.constant(1) with ops.control_dependencies([a]): @@ -490,6 +508,7 @@ class OperationTest(test_util.TensorFlowTestCase): self.assertEqual(f.op.control_inputs, []) self.assertEqual(list(f.op.inputs), [d, e]) + @test_util.run_deprecated_v1 def testControlInputCycle(self): graph = ops.Graph() with graph.as_default(): @@ -582,6 +601,7 @@ class OperationTest(test_util.TensorFlowTestCase): ): x.op._update_input(1, x) # pylint: disable=protected-access + @test_util.run_deprecated_v1 def testOpDef(self): x = constant_op.constant(0) y = constant_op.constant(1) @@ -681,6 +701,7 @@ class CreateOpTest(test_util.TensorFlowTestCase): # the low-level behavior. class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasic(self): g = ops.Graph() with g.as_default(): @@ -731,6 +752,7 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase): self.assertEqual(op3.name, "myop_2") self.assertEqual(op4.name, "myop_1_1") + @test_util.run_deprecated_v1 def testCond(self): g = ops.Graph() with g.as_default(): @@ -760,6 +782,7 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase): "cond/cond_text") # pylint: enable=protected-access + @test_util.run_deprecated_v1 def testWhileLoop(self): g = ops.Graph() with g.as_default(): @@ -789,6 +812,7 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase): "myloop/while_context") # pylint: enable=protected-access + @test_util.run_deprecated_v1 def testWhileLoopWithInternalControlDep(self): g = ops.Graph() with g.as_default(): @@ -812,6 +836,7 @@ class CreateOpFromTFOperationTest(test_util.TensorFlowTestCase): # Internal control dep is preserved self.assertEqual(op.control_inputs, [c]) + @test_util.run_deprecated_v1 def testWhileLoopWithExternalControlDep(self): g = ops.Graph() with g.as_default(): @@ -945,6 +970,7 @@ class NameStackTest(test_util.TensorFlowTestCase): self.assertEqual("bar_2", g.unique_name("bar", mark_as_used=False)) self.assertEqual("bar_2", g.unique_name("bar")) + @test_util.run_deprecated_v1 def testNameAndVariableScope(self): with self.cached_session() as sess: with sess.graph.name_scope("l0"): @@ -1671,6 +1697,7 @@ def _CopyOverrideGrad(op, x_grad): # pylint: disable=invalid-name class RegistrationTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testRegisterGradients(self): x = test_ops.float_output() y = test_ops.copy_op(x) @@ -1710,6 +1737,7 @@ class ComparisonTest(test_util.TensorFlowTestCase): class ControlDependenciesTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasic(self): g = ops.Graph() with g.as_default(): @@ -1953,6 +1981,7 @@ class OpScopeTest(test_util.TensorFlowTestCase): with ops.name_scope(None, "default2") as scope2: self.assertEqual(scope2, "default/default2/") + @test_util.run_deprecated_v1 def testNoScopeName(self): g0 = ops.Graph() values = [ @@ -1966,6 +1995,7 @@ class OpScopeTest(test_util.TensorFlowTestCase): with ops.name_scope(None, None, values): pass + @test_util.run_deprecated_v1 def testEmptyScopeName(self): g0 = ops.Graph() a = g0.create_op("A", [], [dtypes.float32]) @@ -1977,6 +2007,7 @@ class OpScopeTest(test_util.TensorFlowTestCase): self.assertEqual("", scope) self.assertEqual(g0, ops.get_default_graph()) + @test_util.run_deprecated_v1 def testDefaultScopeName(self): g0 = ops.Graph() a = g0.create_op("A", [], [dtypes.float32]) @@ -2001,12 +2032,14 @@ class OpScopeTest(test_util.TensorFlowTestCase): with ops.name_scope(scope_name, values=graph_elements + [a]): pass + @test_util.run_deprecated_v1 def testTensor(self): g0 = ops.Graph() a = g0.create_op("A", [], [dtypes.float32]) b = g0.create_op("B", [], [dtypes.float32]) self._testGraphElements([a, b]) + @test_util.run_deprecated_v1 def testSparseTensor(self): g0 = ops.Graph() a = g0.create_op("A", [], [dtypes.float32]) @@ -2017,6 +2050,7 @@ class OpScopeTest(test_util.TensorFlowTestCase): _apply_op(g0, "Int64Output", [], [dtypes.int64])) self._testGraphElements([a, sparse, b]) + @test_util.run_deprecated_v1 def testVariable(self): g0 = ops.Graph() with g0.as_default(): @@ -2221,6 +2255,7 @@ class InitScopeTest(test_util.TensorFlowTestCase): self.assertEqual(4, int(compiled_outer(inner=compiled_inner))) self.assertEqual(7, int(compiled_outer(inner=compiled_inner))) + @test_util.run_deprecated_v1 def testFallsBackToGlobalGraphWhenAllGraphsAreBuildingFunctions(self): with context.graph_mode(): ops.reset_default_graph() @@ -2357,6 +2392,7 @@ class GraphTest(test_util.TensorFlowTestCase): g.prevent_feeding(a) self.assertFalse(g.is_feedable(a)) + @test_util.run_deprecated_v1 def testPreventFetching(self): g = ops.Graph() a = constant_op.constant(2.0) @@ -2440,10 +2476,12 @@ class AttrScopeTest(test_util.TensorFlowTestCase): b = None return (a, b) + @test_util.run_deprecated_v1 def testNoLabel(self): with self.cached_session(): self.assertAllEqual((None, None), self._get_test_attrs()) + @test_util.run_deprecated_v1 def testLabelMap(self): with self.cached_session() as sess: a1 = self._get_test_attrs() @@ -2478,11 +2516,13 @@ ops.RegisterShape("KernelLabel")(common_shapes.scalar_shape) class KernelLabelTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testNoLabel(self): with self.cached_session(): self.assertAllEqual(b"My label is: default", test_ops.kernel_label().eval()) + @test_util.run_deprecated_v1 def testLabelMap(self): with self.cached_session() as sess: default_1 = test_ops.kernel_label() @@ -2599,6 +2639,7 @@ class StatisticsTest(test_util.TensorFlowTestCase): class DeviceStackTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasicDeviceAssignmentMetadata(self): def device_func(unused_op): @@ -2630,6 +2671,7 @@ class DeviceStackTest(test_util.TensorFlowTestCase): expected_regex = r"device_func<.*ops_test.py, [0-9]+" self.assertRegexpMatches(func_description, expected_regex) + @test_util.run_deprecated_v1 def testDeviceAssignmentMetadataForGraphDeviceAndTfDeviceFunctions(self): with ops.device("/cpu"): @@ -2649,6 +2691,7 @@ class DeviceStackTest(test_util.TensorFlowTestCase): class ColocationGroupTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasic(self): a = constant_op.constant([2.0], name="a") with ops.colocate_with(a.op): @@ -2659,6 +2702,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): with self.assertRaises(ValueError): c.op.get_attr("_class") + @test_util.run_deprecated_v1 def testBasicColocationMetadata(self): const_two = constant_op.constant([2.0], name="two") with ops.colocate_with(const_two.op): @@ -2671,6 +2715,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): # colocation statement. self.assertEqual("ops_test.py", os.path.basename(metadata.filename)) + @test_util.run_deprecated_v1 def testColocationDeviceInteraction(self): with ops.device("/cpu:0"): with ops.device("/device:GPU:0"): @@ -2683,6 +2728,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual([b"loc:@a"], b.op.colocation_groups()) self.assertEqual(a.op.device, b.op.device) + @test_util.run_deprecated_v1 def testColocationCanonicalization(self): with ops.device("/device:GPU:0"): _ = constant_op.constant(2.0) @@ -2698,6 +2744,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): # inherits B's device name, after canonicalizing the names. self.assertEqual(b.op.device, c.op.device) + @test_util.run_deprecated_v1 def testLocationOverrides(self): with ops.device("/cpu:0"): with ops.device("/device:GPU:0"): @@ -2719,6 +2766,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual("/device:GPU:0", c.op.device) self.assertEqual("/device:CPU:0", d.op.device) + @test_util.run_deprecated_v1 def testNestedColocateWith(self): a = constant_op.constant([2.0], name="a") with ops.colocate_with(a.op): @@ -2728,6 +2776,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual([b"loc:@a"], b.op.colocation_groups()) self.assertEqual([b"loc:@a"], c.op.colocation_groups()) + @test_util.run_deprecated_v1 def testMultiColocationGroups(self): a = constant_op.constant([2.0], name="a") b = constant_op.constant(3.0, name="b") @@ -2736,6 +2785,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): c = constant_op.constant(4.0) self.assertEqual(set([b"loc:@a", b"loc:@b"]), set(c.op.colocation_groups())) + @test_util.run_deprecated_v1 def testColocationIgnoreStack(self): a = constant_op.constant([2.0], name="a") b = constant_op.constant(3.0, name="b") @@ -2744,6 +2794,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): c = constant_op.constant(4.0) self.assertEqual(set([b"loc:@b"]), set(c.op.colocation_groups())) + @test_util.run_deprecated_v1 def testColocateWithReset(self): a = constant_op.constant([2.0], name="a") with ops.colocate_with(a.op): @@ -2753,6 +2804,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual([b"loc:@a"], b.op.colocation_groups()) self.assertEqual([b"loc:@c"], c.op.colocation_groups()) + @test_util.run_deprecated_v1 def testColocateWithInitialNoneThenNested(self): a = constant_op.constant([2.0], name="a") with ops.colocate_with(a.op): @@ -2763,12 +2815,14 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual([b"loc:@b"], b.op.colocation_groups()) self.assertEqual([b"loc:@b"], c.op.colocation_groups()) + @test_util.run_deprecated_v1 def testColocateVariables(self): a = variables.Variable([2.0], name="a") with ops.colocate_with(a.op): b = variables.Variable([3.0], name="b") self.assertEqual([b"loc:@a"], b.op.colocation_groups()) + @test_util.run_deprecated_v1 def testInconsistentDeviceWithinColocate(self): with ops.device("/device:GPU:0"): a = constant_op.constant([2.0], name="a") @@ -2782,6 +2836,7 @@ class ColocationGroupTest(test_util.TensorFlowTestCase): self.assertEqual("/device:CPU:0", b.device) + @test_util.run_deprecated_v1 def testMakeColocationConflictMessage(self): """Test that provides an example of a complicated error message.""" # We could test the message with any ops, but this test will be more @@ -2926,6 +2981,7 @@ class NameScopeTest(test_util.TensorFlowTestCase): class TracebackTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testTracebackWithStartLines(self): with self.cached_session() as sess: a = constant_op.constant(2.0) @@ -2947,6 +3003,7 @@ class TracebackTest(test_util.TensorFlowTestCase): class EnableEagerExecutionTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBadArgumentsToEnableEagerExecution(self): with self.assertRaisesRegexp(TypeError, "config must be a tf.ConfigProto"): ops.enable_eager_execution(context.DEVICE_PLACEMENT_SILENT) diff --git a/tensorflow/python/framework/smart_cond_test.py b/tensorflow/python/framework/smart_cond_test.py index 174ada9fe11..f964c87f024 100644 --- a/tensorflow/python/framework/smart_cond_test.py +++ b/tensorflow/python/framework/smart_cond_test.py @@ -35,6 +35,7 @@ def raise_exception(): class SmartCondTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testTrue(self): with ops.Graph().as_default(): with session.Session(): @@ -44,6 +45,7 @@ class SmartCondTest(test_util.TensorFlowTestCase): lambda: math_ops.multiply(y, 5)) self.assertEqual(z.eval(), 32) + @test_util.run_deprecated_v1 def testFalse(self): with ops.Graph().as_default(): with session.Session(): @@ -99,6 +101,7 @@ class SmartCondTest(test_util.TensorFlowTestCase): class SmartCaseTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testTrue(self): x = array_ops.placeholder(dtype=dtypes.int32, shape=[]) conditions = [(True, lambda: constant_op.constant(1)), @@ -112,6 +115,7 @@ class SmartCaseTest(test_util.TensorFlowTestCase): self.assertEqual(self.evaluate(y), 1) self.assertEqual(self.evaluate(z), 1) + @test_util.run_deprecated_v1 def testFalse(self): conditions = [(False, raise_exception)] y = smart_cond.smart_case(conditions, @@ -124,6 +128,7 @@ class SmartCaseTest(test_util.TensorFlowTestCase): self.assertEqual(self.evaluate(y), 1) self.assertEqual(self.evaluate(z), 1) + @test_util.run_deprecated_v1 def testMix(self): x = array_ops.placeholder(dtype=dtypes.int32, shape=[]) y = constant_op.constant(10) diff --git a/tensorflow/python/framework/sparse_tensor_test.py b/tensorflow/python/framework/sparse_tensor_test.py index 9ee1bd75a53..a999c12ca89 100644 --- a/tensorflow/python/framework/sparse_tensor_test.py +++ b/tensorflow/python/framework/sparse_tensor_test.py @@ -65,6 +65,7 @@ class SparseTensorTest(test_util.TensorFlowTestCase): sparse_tensor.is_sparse( sparse_tensor.SparseTensorValue([[0]], [0], [1]))) + @test_util.run_deprecated_v1 def testConsumers(self): sp = sparse_tensor.SparseTensor([[0, 0], [1, 2]], [1.0, 3.0], [3, 4]) w = ops.convert_to_tensor(np.ones([4, 1], np.float32)) @@ -87,6 +88,7 @@ class ConvertToTensorOrSparseTensorTest(test_util.TensorFlowTestCase): value) self.assertAllEqual(value, self.evaluate(from_value)) + @test_util.run_deprecated_v1 def test_convert_sparse(self): with self.cached_session(): indices = [[0, 1], [1, 0]] diff --git a/tensorflow/python/framework/subscribe_test.py b/tensorflow/python/framework/subscribe_test.py index 5322204ce67..61c6ea65190 100644 --- a/tensorflow/python/framework/subscribe_test.py +++ b/tensorflow/python/framework/subscribe_test.py @@ -43,6 +43,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertTrue( all(subscribe._is_subscribed_identity(x) for x in container)) + @test_util.run_deprecated_v1 def testSideEffect(self): a = constant_op.constant(1) b = constant_op.constant(1) @@ -75,6 +76,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertEqual(d_out, [42]) self.assertEqual(shared, [2, 2, 2]) + @test_util.run_deprecated_v1 def testSupportedTypes(self): """Confirm that supported types are correctly detected and handled.""" @@ -120,6 +122,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): subscribe.subscribe(c.name, lambda t: script_ops.py_func(sub, [t], [t.dtype])) + @test_util.run_deprecated_v1 def testCaching(self): """Confirm caching of control output is recalculated between calls.""" a = constant_op.constant(1) @@ -152,6 +155,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertEqual(d_out, [11]) self.assertEqual(shared, {2: 1, 1: 1}) + @test_util.run_deprecated_v1 def testIsSubscribedIdentity(self): """Confirm subscribed identity ops are correctly detected.""" a = constant_op.constant(1) @@ -165,6 +169,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertFalse(subscribe._is_subscribed_identity(idop)) self.assertTrue(subscribe._is_subscribed_identity(c_sub)) + @test_util.run_deprecated_v1 def testSubscribeExtend(self): """Confirm side effect are correctly added for different input types.""" a = constant_op.constant(1) @@ -210,6 +215,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertIn('graph2', shared) self.assertIn('graph3', shared) + @test_util.run_deprecated_v1 def testSubscribeVariable(self): """Confirm that variables can be subscribed.""" v1 = variables.VariableV1(0.0) @@ -248,6 +254,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): # Make sure the values read from the variable match the expected ones. self.assertEqual([0.0, 3.0], shared) + @test_util.run_deprecated_v1 def testResourceType(self): """Confirm that subscribe correctly handles tensors with 'resource' type.""" tensor_array = tensor_array_ops.TensorArray( @@ -276,6 +283,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.evaluate([reader]) self.assertEqual(0, len(shared)) + @test_util.run_deprecated_v1 def testMultipleOutputs(self): """Handle subscriptions to multiple outputs from the same op.""" sparse_tensor_1 = sparse_tensor.SparseTensor( @@ -309,6 +317,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): # All three ops have been processed. self.assertEqual(3, len(shared)) + @test_util.run_deprecated_v1 def test_subscribe_tensors_on_different_devices(self): """Side effect ops are added with the same device of the subscribed op.""" c1 = constant_op.constant(10) @@ -335,6 +344,7 @@ class SubscribeTest(test_util.TensorFlowTestCase): self.assertEqual(add.device, add_sub.device) self.assertEqual(mul.device, mul_sub.device) + @test_util.run_deprecated_v1 def test_subscribe_tensors_within_control_flow_context(self): """Side effect ops are added with the same control flow context.""" c1 = constant_op.constant(10) diff --git a/tensorflow/python/framework/tensor_spec_test.py b/tensorflow/python/framework/tensor_spec_test.py index e3aad7cc236..75c197df09e 100644 --- a/tensorflow/python/framework/tensor_spec_test.py +++ b/tensorflow/python/framework/tensor_spec_test.py @@ -45,6 +45,7 @@ class TensorSpecTest(test_util.TensorFlowTestCase): desc = tensor_spec.TensorSpec(shape=None, dtype=dtypes.float32) self.assertEqual(desc.shape, tensor_shape.TensorShape(None)) + @test_util.run_deprecated_v1 def testShapeCompatibility(self): unknown = array_ops.placeholder(dtypes.int64) partial = array_ops.placeholder(dtypes.int64, shape=[None, 1]) @@ -75,6 +76,7 @@ class TensorSpecTest(test_util.TensorFlowTestCase): self.assertFalse(desc_rank3.is_compatible_with(full)) self.assertTrue(desc_rank3.is_compatible_with(rank3)) + @test_util.run_deprecated_v1 def testTypeCompatibility(self): floats = array_ops.placeholder(dtypes.float32, shape=[10, 10]) ints = array_ops.placeholder(dtypes.int32, shape=[10, 10]) @@ -106,6 +108,7 @@ class TensorSpecTest(test_util.TensorFlowTestCase): spec_2 = tensor_spec.TensorSpec.from_spec(spec_1) self.assertEqual(spec_1, spec_2) + @test_util.run_deprecated_v1 def testFromTensor(self): zero = constant_op.constant(0) spec = tensor_spec.TensorSpec.from_tensor(zero) @@ -113,6 +116,7 @@ class TensorSpecTest(test_util.TensorFlowTestCase): self.assertEqual(spec.shape, []) self.assertEqual(spec.name, "Const") + @test_util.run_deprecated_v1 def testFromPlaceholder(self): unknown = array_ops.placeholder(dtypes.int64, name="unknown") partial = array_ops.placeholder(dtypes.float32, diff --git a/tensorflow/python/framework/tensor_util_test.py b/tensorflow/python/framework/tensor_util_test.py index 87d65c8c466..00337546186 100644 --- a/tensorflow/python/framework/tensor_util_test.py +++ b/tensorflow/python/framework/tensor_util_test.py @@ -758,6 +758,7 @@ class TensorUtilTest(test.TestCase): self.assertFalse(tensor_util.ShapeEquals(t, [1, 4])) self.assertFalse(tensor_util.ShapeEquals(t, [4])) + @test_util.run_deprecated_v1 def testMockArray(self): class MockArray(object): @@ -787,6 +788,7 @@ class ConstantValueTest(test.TestCase): tf_val = constant_op.constant(np_val) self.assertAllClose(np_val, tensor_util.constant_value(tf_val)) + @test_util.run_deprecated_v1 def testUnknown(self): tf_val = gen_state_ops.variable( shape=[3, 4, 7], @@ -815,12 +817,14 @@ class ConstantValueTest(test.TestCase): c_val = tensor_util.constant_value(tf_val) self.assertEqual(6, c_val) + @test_util.run_deprecated_v1 def testSizeOfScalar(self): tf_val = array_ops.size(constant_op.constant(0.0)) c_val = tensor_util.constant_value(tf_val) self.assertEqual(1, c_val) self.assertEqual(np.ndarray, type(c_val)) + @test_util.run_deprecated_v1 def testRank(self): tf_val = array_ops.rank(constant_op.constant(0.0, shape=[1, 2, 3])) c_val = tensor_util.constant_value(tf_val) @@ -852,6 +856,7 @@ class ConstantValueTest(test.TestCase): c_val = tensor_util.constant_value(tf_val) self.assertAllClose(np_val.astype(np.float64), c_val) + @test_util.run_deprecated_v1 def testConcat(self): np_val = np.random.rand(3, 4, 7).astype(np.float32) tf_val = array_ops.concat( @@ -871,6 +876,7 @@ class ConstantValueTest(test.TestCase): c_val = tensor_util.constant_value(tf_val) self.assertIs(None, c_val) + @test_util.run_deprecated_v1 def testPack_Axis0(self): inputs = [np.random.rand(4, 7) for _ in range(3)] np_val = np.array(inputs) @@ -883,6 +889,7 @@ class ConstantValueTest(test.TestCase): c_val = tensor_util.constant_value(tf_val) self.assertIs(None, c_val) + @test_util.run_deprecated_v1 def testPack_Axis1(self): inputs = [np.random.rand(4, 7) for _ in range(3)] tf_val = array_ops.stack(inputs, axis=1) @@ -894,6 +901,7 @@ class ConstantValueTest(test.TestCase): c_val = tensor_util.constant_value(tf_val) self.assertIs(None, c_val) + @test_util.run_deprecated_v1 def testPack_Partial_Axis0(self): input_ = np.random.rand(4, 7) tf_val = array_ops.stack([input_, array_ops.placeholder(dtypes.float32)]) @@ -901,6 +909,7 @@ class ConstantValueTest(test.TestCase): self.assertAllClose(input_, c_val[0]) self.assertIsNone(c_val[1]) + @test_util.run_deprecated_v1 def testPack_Partial_Axis1(self): input_ = np.random.rand(4, 7) tf_val = array_ops.stack([input_, array_ops.placeholder(dtypes.float32)], @@ -966,12 +975,14 @@ class ConstantValueAsShapeTest(test.TestCase): c_val = tensor_util.constant_value_as_shape(tf_val) self.assertEqual([None, 1, None], c_val.as_list()) + @test_util.run_deprecated_v1 def testPack(self): tf_val = array_ops.stack( [constant_op.constant(16), 37, array_ops.placeholder(dtypes.int32)]) c_val = tensor_util.constant_value_as_shape(tf_val) self.assertEqual([16, 37, None], c_val.as_list()) + @test_util.run_deprecated_v1 def testConcat(self): tf_val = array_ops.concat( [[16, 37], array_ops.placeholder( @@ -985,6 +996,7 @@ class ConstantValueAsShapeTest(test.TestCase): c_val = tensor_util.constant_value_as_shape(tf_val) self.assertEqual([16, 37, None, 48], c_val.as_list()) + @test_util.run_deprecated_v1 def testSlice(self): tf_val = array_ops.placeholder(dtypes.int32, shape=(4,))[0:2] c_val = tensor_util.constant_value_as_shape(tf_val) diff --git a/tensorflow/python/framework/test_util_test.py b/tensorflow/python/framework/test_util_test.py index 2a37253db6d..dfdced5a988 100644 --- a/tensorflow/python/framework/test_util_test.py +++ b/tensorflow/python/framework/test_util_test.py @@ -49,6 +49,7 @@ from tensorflow.python.platform import googletest class TestUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def test_assert_ops_in_graph(self): with self.test_session(): constant_op.constant(["hello", "taffy"], name="hello") @@ -60,6 +61,7 @@ class TestUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertRaises(ValueError, test_util.assert_ops_in_graph, {"hello": "Variable"}, ops.get_default_graph()) + @test_util.run_deprecated_v1 def test_session_functions(self): with self.test_session() as sess: sess_ref = weakref.ref(sess) @@ -551,6 +553,7 @@ class TestUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.assertRaises(AssertionError): self.assertAllLessEqual(x, 95.0) + @test_util.run_deprecated_v1 def testAssertAllInRangeWithNonNumericValuesFails(self): s1 = constant_op.constant("Hello, ", name="s1") c = constant_op.constant([1 + 2j, -3 + 5j], name="c") @@ -614,6 +617,7 @@ class TestUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.assertRaises(AssertionError): self.assertAllInSet(x, (42,)) + @test_util.run_deprecated_v1 def testRandomSeed(self): # Call setUp again for WithCApi case (since it makes a new defeault graph # after setup). @@ -706,6 +710,7 @@ class TestUtilTest(test_util.TensorFlowTestCase, parameterized.TestCase): test_util.run_in_graph_and_eager_modes(_test)(self) self.assertEqual(modes, ["graph"]) + @test_util.run_deprecated_v1 def test_run_in_graph_and_eager_modes_setup_in_same_mode(self): modes = [] mode_name = lambda: "eager" if context.executing_eagerly() else "graph" diff --git a/tensorflow/python/grappler/cost_analyzer_test.py b/tensorflow/python/grappler/cost_analyzer_test.py index de80df1879d..ee3e289f65d 100644 --- a/tensorflow/python/grappler/cost_analyzer_test.py +++ b/tensorflow/python/grappler/cost_analyzer_test.py @@ -38,6 +38,7 @@ from tensorflow.python.training import adam class CostAnalysisTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasicCost(self): """Make sure arguments can be passed correctly.""" a = constant_op.constant(10, name="a") @@ -62,6 +63,7 @@ class CostAnalysisTest(test.TestCase): # Also print the report to make it easier to debug print("{}".format(report)) + @test_util.run_deprecated_v1 def testVerbose(self): """Make sure the full report is generated with verbose=True.""" a = constant_op.constant(10, name="a") @@ -81,6 +83,7 @@ class CostAnalysisTest(test.TestCase): # Also print the report to make it easier to debug print("{}".format(report)) + @test_util.run_deprecated_v1 def testSmallNetworkCost(self): image = array_ops.placeholder(dtypes.float32, shape=[1, 28, 28, 1]) label = array_ops.placeholder(dtypes.float32, shape=[1, 10]) @@ -129,6 +132,7 @@ class CostAnalysisTest(test.TestCase): # self.assertTrue(0 < upper) # self.assertTrue(lower <= upper) + @test_util.run_deprecated_v1 def testBasicMemory(self): """Make sure arguments can be passed correctly.""" with test_util.device(use_gpu=False): diff --git a/tensorflow/python/grappler/item_test.py b/tensorflow/python/grappler/item_test.py index d3d96c646cd..78604b259ca 100644 --- a/tensorflow/python/grappler/item_test.py +++ b/tensorflow/python/grappler/item_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import errors_impl from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.grappler import item from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_array_ops @@ -107,6 +108,7 @@ class ItemTest(test.TestCase): newest_tf_item = grappler_item.tf_item self.assertEqual(new_tf_item, newest_tf_item) + @test_util.run_deprecated_v1 def testColocationContraints(self): with ops.Graph().as_default() as g: c = constant_op.constant([10]) diff --git a/tensorflow/python/grappler/layout_optimizer_test.py b/tensorflow/python/grappler/layout_optimizer_test.py index 55ccfbb93c3..98f2e6d7181 100644 --- a/tensorflow/python/grappler/layout_optimizer_test.py +++ b/tensorflow/python/grappler/layout_optimizer_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.grappler import cluster as gcluster from tensorflow.python.grappler import tf_optimizer from tensorflow.python.layers import convolutional as conv_layers @@ -1441,6 +1442,7 @@ class LayoutOptimizerTest(test.TestCase): self._assert_trans_nchw_to_nhwc('Add-0-0', nodes) self.assertAllClose(output_val_ref, output_val, atol=1e-3) + @test_util.run_deprecated_v1 def testGradient(self): meta_graph = _simple_metagraph() config = config_pb2.ConfigProto() @@ -1458,6 +1460,7 @@ class LayoutOptimizerTest(test.TestCase): self.assertEqual(node.attr['data_format'].s, b'NCHW') self.assertEqual(found, 5) + @test_util.run_deprecated_v1 def testDepthwise(self): meta_graph = _simple_metagraph(depthwise=True) config = config_pb2.ConfigProto() diff --git a/tensorflow/python/grappler/memory_optimizer_test.py b/tensorflow/python/grappler/memory_optimizer_test.py index d233629cbbd..6eb16fbd39e 100644 --- a/tensorflow/python/grappler/memory_optimizer_test.py +++ b/tensorflow/python/grappler/memory_optimizer_test.py @@ -25,6 +25,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.grappler import tf_optimizer from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn @@ -37,6 +38,7 @@ from tensorflow.python.training import training as train class MemoryOptimizerSwapTest(test.TestCase): """Tests the Grappler memory optimizer.""" + @test_util.run_deprecated_v1 def testNoSwapping(self): """Make sure the graph is preserved when there is nothing to swap.""" a = variables.VariableV1(10, name='a') @@ -60,6 +62,7 @@ class MemoryOptimizerSwapTest(test.TestCase): self.assertEqual(len(graph.node), graph_size) self.assertItemsEqual([node.name for node in graph.node], nodes) + @test_util.run_deprecated_v1 def testSimpleSwap(self): """Check that the swap annotations are followed.""" a = variables.VariableV1(10, name='a') diff --git a/tensorflow/python/grappler/model_analyzer_test.py b/tensorflow/python/grappler/model_analyzer_test.py index ec172755f1a..d000cfa1ba2 100644 --- a/tensorflow/python/grappler/model_analyzer_test.py +++ b/tensorflow/python/grappler/model_analyzer_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.grappler import model_analyzer from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -28,6 +29,7 @@ from tensorflow.python.platform import test class PyWrapOptimizeGraphTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): """Make sure arguments can be passed correctly.""" a = constant_op.constant([10, 11], name="a") @@ -49,6 +51,7 @@ class PyWrapOptimizeGraphTest(test.TestCase): # Also print the report to make it easier to debug print("{}".format(report)) + @test_util.run_deprecated_v1 def testDebugMode(self): """Make sure arguments can be passed correctly.""" a = constant_op.constant([10, 11], name="a") diff --git a/tensorflow/python/grappler/tf_optimizer_test.py b/tensorflow/python/grappler/tf_optimizer_test.py index 0a4d4cbe2db..06ccaa813f2 100644 --- a/tensorflow/python/grappler/tf_optimizer_test.py +++ b/tensorflow/python/grappler/tf_optimizer_test.py @@ -23,6 +23,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.grappler import item as gitem from tensorflow.python.grappler import tf_optimizer from tensorflow.python.ops import array_ops @@ -34,6 +35,7 @@ from tensorflow.python.platform import test class PyWrapOptimizeGraphTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): """Make sure arguments can be passed correctly.""" a = constant_op.constant(10, name='a') @@ -55,6 +57,7 @@ class PyWrapOptimizeGraphTest(test.TestCase): self.assertEqual(len(graph.node), 1) self.assertItemsEqual([node.name for node in graph.node], ['d']) + @test_util.run_deprecated_v1 def testKeepNodes(self): g = ops.Graph() with g.as_default(): @@ -83,6 +86,7 @@ class PyWrapOptimizeGraphTest(test.TestCase): self.assertEqual(len(optimized_graph_nodes), len(expected_nodes)) self.assertAllInSet(optimized_graph_nodes, expected_nodes) + @test_util.run_deprecated_v1 def testLoops(self): g = ops.Graph() with g.as_default(): diff --git a/tensorflow/python/keras/activations_test.py b/tensorflow/python/keras/activations_test.py index ad238cb0a9b..6b7bfb698b8 100644 --- a/tensorflow/python/keras/activations_test.py +++ b/tensorflow/python/keras/activations_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python import keras +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -67,6 +68,7 @@ class KerasActivationsTest(test.TestCase): expected = _ref_softmax(test_values[0, 0]) self.assertAllClose(result[0, 0], expected, rtol=1e-05) + @test_util.run_deprecated_v1 def test_selu(self): x = keras.backend.placeholder(ndim=2) f = keras.backend.function([x], [keras.activations.selu(x)]) @@ -124,6 +126,7 @@ class KerasActivationsTest(test.TestCase): expected = sigmoid(test_values) self.assertAllClose(result, expected, rtol=1e-05) + @test_util.run_deprecated_v1 def test_hard_sigmoid(self): def ref_hard_sigmoid(x): x = (x * 0.2) + 0.5 @@ -147,6 +150,7 @@ class KerasActivationsTest(test.TestCase): # No negative values in test values... self.assertAllClose(result, test_values, rtol=1e-05) + @test_util.run_deprecated_v1 def test_elu(self): with self.cached_session(): x = keras.backend.placeholder(ndim=2) diff --git a/tensorflow/python/keras/backend_test.py b/tensorflow/python/keras/backend_test.py index 48fdd56e9f6..fa32b1ecd7a 100644 --- a/tensorflow/python/keras/backend_test.py +++ b/tensorflow/python/keras/backend_test.py @@ -1422,6 +1422,7 @@ class TestCTC(test.TestCase): decode_truth[i] == keras.backend.eval(decode_pred_tf[i]))) self.assertAllClose(log_prob_truth, log_prob_pred) + @test_util.run_deprecated_v1 def test_ctc_batch_cost(self): with self.cached_session(): label_lens = np.expand_dims(np.asarray([5, 4]), 1) @@ -1507,6 +1508,7 @@ class TestRandomOps(test.TestCase): class BackendGraphTests(test.TestCase): + @test_util.run_deprecated_v1 def test_is_placeholder(self): x = keras.backend.placeholder(shape=(1,)) self.assertEqual(keras.backend.is_placeholder(x), True) @@ -1546,6 +1548,7 @@ class BackendGraphTests(test.TestCase): output_values = f([None, None]) self.assertEqual(output_values, [5., 6.]) + @test_util.run_deprecated_v1 def test_function_tf_feed_symbols(self): # Test Keras backend functions with TF tensor inputs. with self.cached_session(): @@ -1579,6 +1582,7 @@ class BackendGraphTests(test.TestCase): outs = f([y5, y2, None]) self.assertEqual(outs, [11., 2.]) + @test_util.run_deprecated_v1 def test_function_tf_fetches(self): # Additional operations can be passed to tf.Session().run() via its # `fetches` arguments. In contrast to `updates` argument of @@ -1601,6 +1605,7 @@ class BackendGraphTests(test.TestCase): self.assertEqual(keras.backend.get_session().run(fetches=[x, y]), [11., 5.]) + @test_util.run_deprecated_v1 def test_function_tf_feed_dict(self): # Additional substitutions can be passed to `tf.Session().run()` via its # `feed_dict` arguments. Note that the feed_dict is passed once in the @@ -1633,6 +1638,7 @@ class BackendGraphTests(test.TestCase): self.assertEqual(keras.backend.get_session().run(fetches=[x, y]), [30., 40.]) + @test_util.run_deprecated_v1 def test_function_tf_run_options_with_run_metadata(self): with self.cached_session(): x_placeholder = keras.backend.placeholder(shape=()) @@ -1658,6 +1664,7 @@ class BackendGraphTests(test.TestCase): self.assertEqual(output1, [30.]) self.assertEqual(len(run_metadata.partition_graphs), 0) + @test_util.run_deprecated_v1 def test_function_fetch_callbacks(self): class CallbackStub(object): @@ -1694,6 +1701,7 @@ class BackendGraphTests(test.TestCase): x = keras.backend.placeholder(shape=(3, 4), sparse=True) self.assertEqual(x.get_shape().as_list(), [3, 4]) + @test_util.run_deprecated_v1 def test_batch_normalization(self): # No eager CPU kernel. g_val = np.random.random((3,)) diff --git a/tensorflow/python/keras/callbacks_test.py b/tensorflow/python/keras/callbacks_test.py index 9d9ede22c01..ed05572c68b 100644 --- a/tensorflow/python/keras/callbacks_test.py +++ b/tensorflow/python/keras/callbacks_test.py @@ -404,6 +404,7 @@ class KerasCallbacksTest(test.TestCase): float(keras.backend.get_value( model.optimizer.lr)) - 0.01 / 4) < keras.backend.epsilon() + @test_util.run_deprecated_v1 def test_ReduceLROnPlateau(self): with self.cached_session(): np.random.seed(1337) @@ -675,6 +676,7 @@ class KerasCallbacksTest(test.TestCase): self.assertEqual(len(loss), 1) self.assertEqual(loss[0], np.inf) + @test_util.run_deprecated_v1 def test_TensorBoard(self): np.random.seed(1337) @@ -778,6 +780,7 @@ class KerasCallbacksTest(test.TestCase): data_generator(True), len(x_train), epochs=2, callbacks=cbks) assert os.path.exists(temp_dir) + @test_util.run_deprecated_v1 def test_TensorBoard_histogram_freq_must_have_validation_data(self): np.random.seed(1337) tmpdir = self.get_temp_dir() @@ -850,6 +853,7 @@ class KerasCallbacksTest(test.TestCase): # Make sure file writer cache is clear to avoid failures during cleanup. writer_cache.FileWriterCache.clear() + @test_util.run_deprecated_v1 def test_TensorBoard_multi_input_output(self): np.random.seed(1337) tmpdir = self.get_temp_dir() @@ -921,6 +925,7 @@ class KerasCallbacksTest(test.TestCase): callbacks=callbacks_factory(histogram_freq=1)) assert os.path.isdir(filepath) + @test_util.run_deprecated_v1 def test_Tensorboard_histogram_summaries_in_test_function(self): class FileWriterStub(object): @@ -998,6 +1003,7 @@ class KerasCallbacksTest(test.TestCase): self.assertAllEqual(tsb.writer.steps_seen, [0, 0.5, 1, 1.5, 2, 2.5]) + @test_util.run_deprecated_v1 def test_Tensorboard_histogram_summaries_with_generator(self): np.random.seed(1337) tmpdir = self.get_temp_dir() @@ -1129,6 +1135,7 @@ class KerasCallbacksTest(test.TestCase): assert os.path.exists(temp_dir) + @test_util.run_deprecated_v1 def test_Tensorboard_batch_logging(self): class FileWriterStub(object): @@ -1163,6 +1170,7 @@ class KerasCallbacksTest(test.TestCase): self.assertEqual(tb_cbk.writer.summary_values, [0., 1., 2., 3., 4.]) self.assertEqual(tb_cbk.writer.summary_tags, ['batch_acc'] * 5) + @test_util.run_deprecated_v1 def test_Tensorboard_epoch_and_batch_logging(self): class FileWriterStub(object): @@ -1234,6 +1242,7 @@ class KerasCallbacksTest(test.TestCase): self.assertTrue(os.path.exists(temp_dir)) + @test_util.run_deprecated_v1 def test_TensorBoard_update_freq(self): class FileWriterStub(object): @@ -1325,6 +1334,7 @@ class KerasCallbacksTest(test.TestCase): callbacks=cbks, epochs=1) + @test_util.run_deprecated_v1 def test_fit_generator_with_callback(self): class TestCallback(keras.callbacks.Callback): diff --git a/tensorflow/python/keras/engine/saving_test.py b/tensorflow/python/keras/engine/saving_test.py index b92f06449e9..6d9d9a2fcae 100644 --- a/tensorflow/python/keras/engine/saving_test.py +++ b/tensorflow/python/keras/engine/saving_test.py @@ -289,6 +289,7 @@ class TestWeightSavingAndLoading(test.TestCase, parameterized.TestCase): r'element\(s\)\.'): saving.load_weights_from_hdf5_group_by_name(f_model, model.layers) + @test_util.run_deprecated_v1 def test_sequential_weight_loading_group_name_with_incorrect_shape(self): if h5py is None: return @@ -331,6 +332,7 @@ class TestWeightSavingAndLoading(test.TestCase, parameterized.TestCase): class TestWholeModelSaving(test.TestCase): + @test_util.run_deprecated_v1 def test_sequential_model_saving(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -383,6 +385,7 @@ class TestWholeModelSaving(test.TestCase): out2 = new_model.predict(x) self.assertAllClose(out, out2, atol=1e-05) + @test_util.run_deprecated_v1 def test_sequential_model_saving_without_input_shape(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -443,6 +446,7 @@ class TestWholeModelSaving(test.TestCase): out2 = new_model.predict(x) self.assertAllClose(out, out2, atol=1e-05) + @test_util.run_deprecated_v1 def test_sequential_model_saving_2(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -479,6 +483,7 @@ class TestWholeModelSaving(test.TestCase): out2 = model.predict(x) self.assertAllClose(out, out2, atol=1e-05) + @test_util.run_deprecated_v1 def test_functional_model_saving(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -630,6 +635,7 @@ class TestWholeModelSaving(test.TestCase): os.close(fd) os.remove(fname) + @test_util.run_deprecated_v1 def test_saving_model_with_long_weights_names(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -675,6 +681,7 @@ class TestWholeModelSaving(test.TestCase): os.close(fd) os.remove(fname) + @test_util.run_deprecated_v1 def test_model_saving_to_pre_created_h5py_file(self): if h5py is None: self.skipTest('h5py required to run this test') @@ -749,6 +756,7 @@ class SubclassedModel(training.Model): class TestWeightSavingAndLoadingTFFormat(test.TestCase): + @test_util.run_deprecated_v1 def test_keras_optimizer_warning(self): graph = ops.Graph() with graph.as_default(), self.session(graph): diff --git a/tensorflow/python/keras/engine/sequential_test.py b/tensorflow/python/keras/engine/sequential_test.py index 2e2927bf472..fbf893c6633 100644 --- a/tensorflow/python/keras/engine/sequential_test.py +++ b/tensorflow/python/keras/engine/sequential_test.py @@ -132,6 +132,7 @@ class TestSequential(test.TestCase, parameterized.TestCase): self.assertFalse(model._is_graph_network) @parameterized.parameters((True,), (False,)) + @tf_test_util.run_deprecated_v1 def test_training_and_eval_methods_on_symbolic_tensors(self, deferred): with self.cached_session(): @@ -219,6 +220,7 @@ class TestSequential(test.TestCase, parameterized.TestCase): inner_model.trainable = True self.assertEqual(len(model.trainable_weights), 4) + @tf_test_util.run_deprecated_v1 def test_sequential_update_disabling(self): val_a = np.random.random((10, 4)) val_out = np.random.random((10, 4)) diff --git a/tensorflow/python/keras/engine/topology_test.py b/tensorflow/python/keras/engine/topology_test.py index b4a4babf259..03bfd35589c 100644 --- a/tensorflow/python/keras/engine/topology_test.py +++ b/tensorflow/python/keras/engine/topology_test.py @@ -42,6 +42,7 @@ except ImportError: class TopologyConstructionTest(test.TestCase): + @test_util.run_deprecated_v1 def test_get_updates(self): class MyLayer(keras.layers.Layer): @@ -115,6 +116,7 @@ class TopologyConstructionTest(test.TestCase): self.assertEqual(len(layer.get_updates_for(x1)), 2) self.assertEqual(len(layer.get_updates_for(None)), 0) + @test_util.run_deprecated_v1 def test_get_losses(self): class MyLayer(keras.layers.Layer): @@ -268,6 +270,7 @@ class TopologyConstructionTest(test.TestCase): self.assertEqual(test_layer.input_shape, [(None, 32), (None, 32)]) self.assertEqual(test_layer.output_shape, (None, 32)) + @test_util.run_deprecated_v1 def testBasicNetwork(self): # minimum viable network x = input_layer_lib.Input(shape=(32,)) @@ -341,6 +344,7 @@ class TopologyConstructionTest(test.TestCase): self.assertListEqual(model.trainable_weights, []) self.assertListEqual(model.non_trainable_weights, weights) + @test_util.run_deprecated_v1 def test_layer_call_arguments(self): # Test the ability to pass and serialize arguments to `call`. inp = keras.layers.Input(shape=(2,)) @@ -491,6 +495,7 @@ class TopologyConstructionTest(test.TestCase): fn_outputs = fn([input_a_np, input_b_np]) self.assertListEqual([x.shape for x in fn_outputs], [(10, 64), (10, 5)]) + @test_util.run_deprecated_v1 def test_recursion(self): with self.cached_session(): a = keras.layers.Input(shape=(32,), name='input_a') @@ -675,6 +680,7 @@ class TopologyConstructionTest(test.TestCase): with self.assertRaises(Exception): keras.models.Model([j, k], [m, n, 0]) + @test_util.run_deprecated_v1 def test_raw_tf_compatibility(self): # test calling layers/models on TF tensors a = keras.layers.Input(shape=(32,), name='input_a') @@ -719,6 +725,7 @@ class TopologyConstructionTest(test.TestCase): model = keras.models.Model(a, b) self.assertEqual(model.output_mask.get_shape().as_list(), [None, 10]) + @test_util.run_deprecated_v1 def testMaskingSingleInput(self): class MaskedLayer(keras.layers.Layer): @@ -756,6 +763,7 @@ class TopologyConstructionTest(test.TestCase): y_2 = network(x_2) self.assertEqual(y_2.get_shape().as_list(), [None, 32]) + @test_util.run_deprecated_v1 def test_activity_regularization_with_model_composition(self): def reg(x): @@ -825,6 +833,7 @@ class TopologyConstructionTest(test.TestCase): output_val_2 = m2.predict(x_val) self.assertAllClose(output_val, output_val_2, atol=1e-6) + @test_util.run_deprecated_v1 def test_explicit_training_argument(self): with self.cached_session(): a = keras.layers.Input(shape=(2,)) @@ -1145,6 +1154,7 @@ class DefaultShapeInferenceBehaviorTest(test.TestCase): class GraphUtilsTest(test.TestCase): + @test_util.run_deprecated_v1 def testGetReachableFromInputs(self): with self.cached_session(): diff --git a/tensorflow/python/keras/engine/training_dataset_test.py b/tensorflow/python/keras/engine/training_dataset_test.py index e79e5842a1c..8020326377e 100644 --- a/tensorflow/python/keras/engine/training_dataset_test.py +++ b/tensorflow/python/keras/engine/training_dataset_test.py @@ -274,6 +274,7 @@ class TestTrainingWithDataset(test.TestCase, parameterized.TestCase): model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=1) + @tf_test_util.run_deprecated_v1 def test_dataset_input_shape_validation(self): with self.cached_session(): model = testing_utils.get_small_functional_mlp(1, 4, input_dim=3) diff --git a/tensorflow/python/keras/engine/training_test.py b/tensorflow/python/keras/engine/training_test.py index 97dfe6d9003..4674bce2449 100644 --- a/tensorflow/python/keras/engine/training_test.py +++ b/tensorflow/python/keras/engine/training_test.py @@ -449,6 +449,7 @@ class TrainingTest(test.TestCase): optimizer=keras.optimizers.Adam(lr=0.0001), metrics=['accuracy']) + @tf_test_util.run_deprecated_v1 def test_that_trainable_disables_updates(self): val_a = np.random.random((10, 4)) val_out = np.random.random((10, 4)) @@ -1146,6 +1147,7 @@ class LossMaskingTest(test.TestCase): class TestDynamicTrainability(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_trainable_warning(self): with self.cached_session(): x = np.random.random((5, 3)) @@ -1159,6 +1161,7 @@ class TestDynamicTrainability(test.TestCase): model.train_on_batch(x, y) self.assertRaises(Warning) + @tf_test_util.run_deprecated_v1 def test_trainable_argument(self): with self.cached_session(): x = np.random.random((5, 3)) @@ -1289,6 +1292,7 @@ class TestDynamicTrainability(test.TestCase): class TestTrainingWithDataTensors(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_training_and_eval_methods_on_symbolic_tensors_single_io(self): with self.cached_session(): x = keras.layers.Input(shape=(3,), name='input') @@ -1329,6 +1333,7 @@ class TestTrainingWithDataTensors(test.TestCase): epochs=1, steps_per_epoch=2, verbose=0, validation_data=(inputs, targets), validation_steps=2) + @tf_test_util.run_deprecated_v1 def test_training_and_eval_methods_on_symbolic_tensors_multi_io(self): with self.cached_session(): a = keras.layers.Input(shape=(3,), name='input_a') @@ -1424,6 +1429,7 @@ class TestTrainingWithDataTensors(test.TestCase): model.predict([input_a_tf, input_b_tf], steps=2) model.test_on_batch([input_a_tf, input_b_tf], [output_d_tf, output_e_tf]) + @tf_test_util.run_deprecated_v1 def test_model_with_input_feed_tensor(self): """We test building a model with a TF variable as input. @@ -1602,6 +1608,7 @@ class TestTrainingWithDataTensors(test.TestCase): # evaluate _ = model.evaluate(input_a_np, [output_a_np]) + @tf_test_util.run_deprecated_v1 def test_model_with_external_loss(self): with self.cached_session(): # None loss, only regularization loss. @@ -1797,6 +1804,7 @@ class TestTrainingWithDataTensors(test.TestCase): model.train_on_batch(input_val, None, sample_weight={'dense_a': np.random.random((10,))}) + @tf_test_util.run_deprecated_v1 def test_model_custom_target_tensors(self): with self.cached_session(): a = keras.Input(shape=(3,), name='input_a') @@ -2018,6 +2026,7 @@ class TestTrainingWithMetrics(test.TestCase): scores = model.train_on_batch(x, y, sample_weight=w) self.assertArrayNear(scores, [0.3328, 0.8], 0.001) + @tf_test_util.run_deprecated_v1 def test_add_metric_with_tensor_on_model_in_graph_mode(self): with self.cached_session(): x = keras.layers.Input(shape=(1,)) @@ -2180,6 +2189,7 @@ class TestTrainingWithMetrics(test.TestCase): self.assertEqual(history.history['metric_1'][-1], 5) self.assertAlmostEqual(history.history['val_metric_1'][-1], 5, 0) + @tf_test_util.run_deprecated_v1 def test_model_metrics_list(self): with self.cached_session(): x = keras.layers.Input(shape=(1,)) diff --git a/tensorflow/python/keras/initializers_test.py b/tensorflow/python/keras/initializers_test.py index 2b758a98f30..4f91bea1e33 100644 --- a/tensorflow/python/keras/initializers_test.py +++ b/tensorflow/python/keras/initializers_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python import keras from tensorflow.python.ops import init_ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -38,6 +39,7 @@ class KerasInitializersTest(test.TestCase): output_2 = keras.backend.get_value(variable) self.assertAllClose(output, output_2, atol=1e-4) + @test_util.run_deprecated_v1 def test_uniform(self): tensor_shape = (9, 6, 7) with self.cached_session(): @@ -47,6 +49,7 @@ class KerasInitializersTest(test.TestCase): tensor_shape, target_mean=0., target_max=1, target_min=-1) + @test_util.run_deprecated_v1 def test_normal(self): tensor_shape = (8, 12, 99) with self.cached_session(): @@ -54,6 +57,7 @@ class KerasInitializersTest(test.TestCase): tensor_shape, target_mean=0., target_std=1) + @test_util.run_deprecated_v1 def test_truncated_normal(self): tensor_shape = (12, 99, 7) with self.cached_session(): @@ -69,6 +73,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.Constant(2), tensor_shape, target_mean=2, target_max=2, target_min=2) + @test_util.run_deprecated_v1 def test_lecun_uniform(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -77,6 +82,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.lecun_uniform(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_glorot_uniform(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -85,6 +91,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.glorot_uniform(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_he_uniform(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -93,6 +100,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.he_uniform(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_lecun_normal(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -101,6 +109,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.lecun_normal(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_glorot_normal(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -109,6 +118,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.glorot_normal(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_he_normal(self): tensor_shape = (5, 6, 4, 2) with self.cached_session(): @@ -117,6 +127,7 @@ class KerasInitializersTest(test.TestCase): self._runner(keras.initializers.he_normal(seed=123), tensor_shape, target_mean=0., target_std=std) + @test_util.run_deprecated_v1 def test_orthogonal(self): tensor_shape = (20, 20) with self.cached_session(): diff --git a/tensorflow/python/keras/integration_test.py b/tensorflow/python/keras/integration_test.py index 3c0f73b1c3a..f1a0932613b 100644 --- a/tensorflow/python/keras/integration_test.py +++ b/tensorflow/python/keras/integration_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python import keras from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.keras import testing_utils from tensorflow.python.layers import core as tf_core_layers from tensorflow.python.ops import nn @@ -34,6 +35,7 @@ class KerasIntegrationTest(test.TestCase): def test_version(self): self.assertTrue(keras.__version__.endswith('-tf')) + @test_util.run_deprecated_v1 def test_vector_classification_sequential(self): with self.cached_session(): np.random.seed(1337) @@ -59,6 +61,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_vector_classification_functional(self): with self.cached_session(): np.random.seed(1337) @@ -83,6 +86,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_temporal_classification_sequential(self): with self.cached_session(): np.random.seed(1337) @@ -105,6 +109,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_temporal_classification_sequential_tf_rnn(self): with self.cached_session(): np.random.seed(1337) @@ -163,6 +168,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_video_classification_functional(self): with self.cached_session(): np.random.seed(1337) @@ -191,6 +197,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_vector_classification_shared_sequential(self): # Test that Sequential models that feature internal updates # and internal losses can be shared. @@ -225,6 +232,7 @@ class KerasIntegrationTest(test.TestCase): verbose=2) self.assertGreater(history.history['val_acc'][-1], 0.7) + @test_util.run_deprecated_v1 def test_vector_classification_shared_model(self): # Test that functional models that feature internal updates # and internal losses can be shared. diff --git a/tensorflow/python/keras/layers/local_test.py b/tensorflow/python/keras/layers/local_test.py index 1c20d437064..a23c5c38fe9 100644 --- a/tensorflow/python/keras/layers/local_test.py +++ b/tensorflow/python/keras/layers/local_test.py @@ -32,6 +32,7 @@ class LocallyConnected1DLayersTest(test.TestCase): # fails inside a graph function in an eager context (fails with error # "Incompatible shapes between op input and calculated input gradient"). + @tf_test_util.run_deprecated_v1 def test_locallyconnected_1d(self): with self.cached_session(): num_samples = 2 @@ -120,6 +121,7 @@ class LocallyConnected2DLayersTest(test.TestCase): # fails inside a graph function in an eager context (fails with error # "Incompatible shapes between op input and calculated input gradient"). + @tf_test_util.run_deprecated_v1 def test_locallyconnected_2d(self): with self.cached_session(): num_samples = 8 @@ -155,6 +157,7 @@ class LocallyConnected2DLayersTest(test.TestCase): kwargs=kwargs, input_shape=(num_samples, num_row, num_col, stack_size)) + @tf_test_util.run_deprecated_v1 def test_locallyconnected_2d_channels_first(self): with self.cached_session(): num_samples = 8 @@ -232,6 +235,7 @@ class LocallyConnected2DLayersTest(test.TestCase): class LocallyConnectedImplementationModeTest(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_locallyconnected_implementation(self): with self.cached_session(): num_samples = 4 diff --git a/tensorflow/python/keras/layers/lstm_test.py b/tensorflow/python/keras/layers/lstm_test.py index 9db697871fe..732bbcfa18e 100644 --- a/tensorflow/python/keras/layers/lstm_test.py +++ b/tensorflow/python/keras/layers/lstm_test.py @@ -114,6 +114,7 @@ class LSTMLayerTest(test.TestCase): self.assertEqual(layer.cell.recurrent_kernel.constraint, r_constraint) self.assertEqual(layer.cell.bias.constraint, b_constraint) + @tf_test_util.run_deprecated_v1 def test_with_masking_layer_LSTM(self): layer_class = keras.layers.LSTM inputs = np.random.random((2, 3, 4)) @@ -126,6 +127,7 @@ class LSTMLayerTest(test.TestCase): optimizer=RMSPropOptimizer(0.01)) model.fit(inputs, targets, epochs=1, batch_size=2, verbose=1) + @tf_test_util.run_deprecated_v1 def test_masking_with_stacking_LSTM(self): inputs = np.random.random((2, 3, 4)) targets = np.abs(np.random.random((2, 3, 5))) @@ -311,6 +313,7 @@ class LSTMLayerTest(test.TestCase): class LSTMLayerGraphOnlyTest(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_statefulness_LSTM(self): num_samples = 2 timesteps = 3 @@ -374,6 +377,7 @@ class LSTMLayerGraphOnlyTest(test.TestCase): self.assertAllClose(out7, out6, atol=1e-5) + @tf_test_util.run_deprecated_v1 def test_regularizers_LSTM(self): embedding_dim = 4 layer_class = keras.layers.LSTM diff --git a/tensorflow/python/keras/layers/merge_test.py b/tensorflow/python/keras/layers/merge_test.py index 698c5662b6f..fcb161ae20a 100644 --- a/tensorflow/python/keras/layers/merge_test.py +++ b/tensorflow/python/keras/layers/merge_test.py @@ -207,6 +207,7 @@ class MergeLayersGraphOnlyTest(test.TestCase): mask = layer.output_mask self.assertListEqual(mask.get_shape().as_list(), [None, 4]) + @tf_test_util.run_deprecated_v1 def test_merge_add_dynamic_shape(self): with self.cached_session(): i1 = array_ops.placeholder(shape=(4, None), dtype='float32') diff --git a/tensorflow/python/keras/layers/normalization_test.py b/tensorflow/python/keras/layers/normalization_test.py index 2f7f042b7f7..9138c0a08a3 100644 --- a/tensorflow/python/keras/layers/normalization_test.py +++ b/tensorflow/python/keras/layers/normalization_test.py @@ -301,6 +301,7 @@ class NormalizationLayersGraphModeOnlyTest(test.TestCase): x2 = model.predict(val_a) self.assertAllClose(x1, x2, atol=1e-7) + @tf_test_util.run_deprecated_v1 def test_batchnorm_trainable(self): """Tests that batchnorm layer is trainable when learning phase is enabled. diff --git a/tensorflow/python/keras/layers/simplernn_test.py b/tensorflow/python/keras/layers/simplernn_test.py index 93456b5e3a7..b49b159b719 100644 --- a/tensorflow/python/keras/layers/simplernn_test.py +++ b/tensorflow/python/keras/layers/simplernn_test.py @@ -98,6 +98,7 @@ class SimpleRNNLayerTest(test.TestCase): self.assertEqual(layer.cell.recurrent_kernel.constraint, r_constraint) self.assertEqual(layer.cell.bias.constraint, b_constraint) + @tf_test_util.run_deprecated_v1 def test_with_masking_layer_SimpleRNN(self): layer_class = keras.layers.SimpleRNN inputs = np.random.random((2, 3, 4)) @@ -120,6 +121,7 @@ class SimpleRNNLayerTest(test.TestCase): class SimpleRNNLayerGraphOnlyTest(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_statefulness_SimpleRNN(self): num_samples = 2 timesteps = 3 @@ -183,6 +185,7 @@ class SimpleRNNLayerGraphOnlyTest(test.TestCase): np.testing.assert_allclose(out7, out6, atol=1e-5) + @tf_test_util.run_deprecated_v1 def test_regularizers_SimpleRNN(self): embedding_dim = 4 layer_class = keras.layers.SimpleRNN diff --git a/tensorflow/python/keras/layers/unified_rnn_test.py b/tensorflow/python/keras/layers/unified_rnn_test.py index b08ff3cafc2..e26e47000d8 100644 --- a/tensorflow/python/keras/layers/unified_rnn_test.py +++ b/tensorflow/python/keras/layers/unified_rnn_test.py @@ -69,6 +69,7 @@ class RNNTest(test.TestCase): def tearDown(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def test_unifiedRNN(self): input_shape = 10 rnn_state_size = 8 @@ -113,6 +114,7 @@ class RNNTest(test.TestCase): self.assertNotEqual(existing_loss, loss_value) existing_loss = loss_value + @test_util.run_deprecated_v1 def test_unifiedRNN_with_cond(self): # This test is to demonstrate the graph rewrite of grappler plugin under # the condition that the function returns different number of internal diff --git a/tensorflow/python/keras/layers/wrappers_test.py b/tensorflow/python/keras/layers/wrappers_test.py index bbafa96aab8..427314faf17 100644 --- a/tensorflow/python/keras/layers/wrappers_test.py +++ b/tensorflow/python/keras/layers/wrappers_test.py @@ -201,6 +201,7 @@ class TimeDistributedTest(test.TestCase): assert len(layer.updates) == 2 assert len(layer.trainable_weights) == 2 + @tf_test_util.run_deprecated_v1 def test_TimeDistributed_with_masked_embedding_and_unspecified_shape(self): with self.cached_session(): # test with unspecified shape and Embeddings with mask_zero @@ -233,6 +234,7 @@ class TimeDistributedTest(test.TestCase): self.assertAllEqual(mask_outputs_val[i], ref_mask_val[i]) self.assertIs(mask_outputs[-1], None) # final layer + @tf_test_util.run_deprecated_v1 def test_TimeDistributed_with_masking_layer(self): with self.cached_session(): # test with Masking layer @@ -375,6 +377,7 @@ class BidirectionalTest(test.TestCase): model.compile(loss='mse', optimizer='sgd') model.fit(x, y, epochs=1, batch_size=1) + @tf_test_util.run_deprecated_v1 def test_Bidirectional_merged_value(self): rnn = keras.layers.LSTM samples = 2 @@ -505,6 +508,7 @@ class BidirectionalTest(test.TestCase): layer.trainable = True assert len(layer.trainable_weights) == 6 + @tf_test_util.run_deprecated_v1 def test_Bidirectional_updates(self): with self.cached_session(): x = keras.layers.Input(shape=(3, 2)) diff --git a/tensorflow/python/keras/model_subclassing_test.py b/tensorflow/python/keras/model_subclassing_test.py index ccfff57a3bd..ca7dded60d4 100644 --- a/tensorflow/python/keras/model_subclassing_test.py +++ b/tensorflow/python/keras/model_subclassing_test.py @@ -917,6 +917,7 @@ class ModelSubclassingTest(test.TestCase): class GraphSpecificModelSubclassingTests(test.TestCase): + @test_util.run_deprecated_v1 def test_single_io_workflow_with_tensors(self): num_classes = 2 num_samples = 10 @@ -934,6 +935,7 @@ class GraphSpecificModelSubclassingTests(test.TestCase): model.fit(x, y, epochs=2, steps_per_epoch=10, verbose=0) _ = model.evaluate(steps=10, verbose=0) + @test_util.run_deprecated_v1 def test_multi_io_workflow_with_tensors(self): num_classes = (2, 3) num_samples = 10 @@ -953,6 +955,7 @@ class GraphSpecificModelSubclassingTests(test.TestCase): model.fit([x1, x2], [y1, y2], epochs=2, steps_per_epoch=10, verbose=0) _ = model.evaluate(steps=10, verbose=0) + @test_util.run_deprecated_v1 def test_updates_and_losses_for_nested_models_in_subclassed_model(self): # Case 1: deferred-build sequential nested in subclass. @@ -1020,6 +1023,7 @@ class GraphSpecificModelSubclassingTests(test.TestCase): self.assertEqual(len(model.get_updates_for(x)), 2) self.assertEqual(len(model.get_losses_for(x)), 1) + @test_util.run_deprecated_v1 def test_multi_io_workflow_with_numpy_arrays_and_custom_placeholders(self): num_classes = (2, 3) num_samples = 1000 diff --git a/tensorflow/python/keras/models_test.py b/tensorflow/python/keras/models_test.py index c68c80f0cc5..8af3cc05f5d 100644 --- a/tensorflow/python/keras/models_test.py +++ b/tensorflow/python/keras/models_test.py @@ -69,6 +69,7 @@ def sequential_model(add_input_layer, include_input_shape=True): class TestModelCloning(test.TestCase): + @test_util.run_deprecated_v1 def test_clone_sequential_model(self): with self.cached_session(): val_a = np.random.random((10, 4)) @@ -101,7 +102,10 @@ class TestModelCloning(test.TestCase): new_model.compile('rmsprop', 'mse') new_model.train_on_batch(None, val_out) + @test_util.run_deprecated_v1 def test_clone_sequential_model_input_layer(self): + + @test_util.run_deprecated_v1 def test_input_layer(include_inputs): with self.cached_session(): val_a = np.random.random((10, 4)) @@ -138,6 +142,7 @@ class TestModelCloning(test.TestCase): test_input_layer(True) test_input_layer(False) + @test_util.run_deprecated_v1 def test_clone_functional_model(self): with self.cached_session(): val_a = np.random.random((10, 4)) @@ -397,6 +402,7 @@ class TestCloneAndBuildModel(test.TestCase): new_model.train_on_batch(inp, out) new_model.evaluate(inp, out) + @test_util.run_deprecated_v1 def test_clone_and_build_compiled_sequential_model(self): with self.cached_session(): model = keras.models.Sequential() @@ -409,6 +415,7 @@ class TestCloneAndBuildModel(test.TestCase): self._clone_and_build_test_helper(model) + @test_util.run_deprecated_v1 def test_clone_and_build_functional_model(self): with self.cached_session(): input_a = keras.Input(shape=(4,)) @@ -425,6 +432,7 @@ class TestCloneAndBuildModel(test.TestCase): self._clone_and_build_test_helper(model) + @test_util.run_deprecated_v1 def test_clone_and_build_subclassed_model(self): class SubclassedModel(keras.Model): @@ -473,9 +481,11 @@ class TestCloneAndBuildModel(test.TestCase): def test_replace_tf_optimizer_iterations_variable(self): self.assert_optimizer_iterations_increases(adam.AdamOptimizer(0.01)) + @test_util.run_deprecated_v1 def test_replace_keras_optimizer_iterations_variable(self): self.assert_optimizer_iterations_increases('adam') + @test_util.run_deprecated_v1 def test_clone_and_build_sequential_model_without_inputs_defined(self): with self.cached_session(): model = sequential_model(False, False) diff --git a/tensorflow/python/keras/optimizer_v2/adadelta_test.py b/tensorflow/python/keras/optimizer_v2/adadelta_test.py index ef95d27abff..6409f3ead44 100644 --- a/tensorflow/python/keras/optimizer_v2/adadelta_test.py +++ b/tensorflow/python/keras/optimizer_v2/adadelta_test.py @@ -147,6 +147,7 @@ class AdadeltaOptimizerTest(test.TestCase): with context.eager_mode(): self.doTestBasic(use_resource=True, use_callable_params=True) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/adagrad_test.py b/tensorflow/python/keras/optimizer_v2/adagrad_test.py index 5ddeb1ad801..8004907bf52 100644 --- a/tensorflow/python/keras/optimizer_v2/adagrad_test.py +++ b/tensorflow/python/keras/optimizer_v2/adagrad_test.py @@ -160,6 +160,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -179,6 +180,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( [[0, 1], [3, 4]], var0.eval(), atol=0.01) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -211,6 +213,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseBasic(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -255,6 +258,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseRepeatedIndices(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -287,6 +291,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllClose(aggregated_update_var.eval(), repeated_index_update_var.eval()) + @test_util.run_deprecated_v1 def testSparseRepeatedIndicesByEmbeddingLookUp(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -311,6 +316,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( var_repeated.eval(), var_aggregated.eval()) + @test_util.run_deprecated_v1 def testSparseStability(self): for dtype in [dtypes.half]: with self.cached_session(): @@ -343,6 +349,7 @@ class AdagradOptimizerTest(test.TestCase): -0.01029443 ]]), var0.eval()) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/adam_test.py b/tensorflow/python/keras/optimizer_v2/adam_test.py index e2bc6a39f96..b1b17f8f088 100644 --- a/tensorflow/python/keras/optimizer_v2/adam_test.py +++ b/tensorflow/python/keras/optimizer_v2/adam_test.py @@ -62,6 +62,7 @@ def get_beta_accumulators(opt, dtype): class AdamOptimizerTest(test.TestCase): + @test_util.run_deprecated_v1 def testSparse(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -106,6 +107,7 @@ class AdamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseDevicePlacement(self): for index_dtype in [dtypes.int32, dtypes.int64]: with self.cached_session(force_gpu=test.is_gpu_available()): @@ -119,6 +121,7 @@ class AdamOptimizerTest(test.TestCase): variables.global_variables_initializer().run() minimize_op.run() + @test_util.run_deprecated_v1 def testSparseRepeatedIndices(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -208,6 +211,7 @@ class AdamOptimizerTest(test.TestCase): with context.eager_mode(): self.doTestBasic(use_callable_params=True) + @test_util.run_deprecated_v1 def testBasicWithLearningRateDecay(self): for i, dtype in enumerate([dtypes.half, dtypes.float32, dtypes.float64]): with self.session(graph=ops.Graph()): @@ -254,6 +258,7 @@ class AdamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -292,6 +297,7 @@ class AdamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/adamax_test.py b/tensorflow/python/keras/optimizer_v2/adamax_test.py index aa215b0faf3..7521a6196e4 100644 --- a/tensorflow/python/keras/optimizer_v2/adamax_test.py +++ b/tensorflow/python/keras/optimizer_v2/adamax_test.py @@ -124,9 +124,11 @@ class AdamaxOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, var0.eval()) self.assertAllCloseAccordingToType(var1_np, var1.eval()) + @test_util.run_deprecated_v1 def testResourceSparse(self): self.doTestSparse(use_resource=True) + @test_util.run_deprecated_v1 def testSparseDevicePlacement(self): for index_dtype in [dtypes.int32, dtypes.int64]: with self.cached_session(force_gpu=test.is_gpu_available()): @@ -140,6 +142,7 @@ class AdamaxOptimizerTest(test.TestCase): variables.global_variables_initializer().run() minimize_op.run() + @test_util.run_deprecated_v1 def testSparseRepeatedIndices(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -272,6 +275,7 @@ class AdamaxOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1), rtol=1e-2) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -308,6 +312,7 @@ class AdamaxOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, var0.eval()) self.assertAllCloseAccordingToType(var1_np, var1.eval()) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/ftrl_test.py b/tensorflow/python/keras/optimizer_v2/ftrl_test.py index ca8c33dfa6d..bec400e8cbb 100644 --- a/tensorflow/python/keras/optimizer_v2/ftrl_test.py +++ b/tensorflow/python/keras/optimizer_v2/ftrl_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.keras.optimizer_v2 import ftrl from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops @@ -68,12 +69,15 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.28432083, -0.56694895]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithoutRegularization(self): self.doTestFtrlwithoutRegularization(use_resource=False) + @test_util.run_deprecated_v1 def testResourceFtrlWithoutRegularization(self): self.doTestFtrlwithoutRegularization(use_resource=True) + @test_util.run_deprecated_v1 def testFtrlwithoutRegularization2(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -103,6 +107,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.28232238, -0.56096673]), v1_val) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -121,6 +126,7 @@ class FtrlOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testFtrlWithL1(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -150,6 +156,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.93460727, -1.86147261]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -180,6 +187,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.02406147, -0.04830509]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2_L2Shrinkage(self): """Test the new FTRL op with support for l2 shrinkage. @@ -217,6 +225,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.14378493, -0.13229476]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2_L2ShrinkageSparse(self): """Tests the new FTRL op with support for l2 shrinkage on sparse grads.""" for dtype in [dtypes.half, dtypes.float32]: @@ -251,6 +260,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([[-0.22578995], [2.]], v0_val) self.assertAllCloseAccordingToType([[4.], [-0.13229476]], v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL2ShrinkageDoesNotChangeLrSchedule(self): """Verifies that l2 shrinkage in FTRL does not change lr schedule.""" for dtype in [dtypes.half, dtypes.float32]: @@ -335,6 +345,7 @@ class FtrlOptimizerTest(test.TestCase): # with Adagrad. # So, basing on these two properties, we test if our implementation of # FTRL-Proximal performs same updates as Adagrad or GradientDescent. + @test_util.run_deprecated_v1 def testEquivAdagradwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -355,6 +366,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivSparseAdagradwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -378,6 +390,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivSparseGradientDescentwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -401,6 +414,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivGradientDescentwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/gradient_descent_test.py b/tensorflow/python/keras/optimizer_v2/gradient_descent_test.py index 348d2728c89..dae2a47735e 100644 --- a/tensorflow/python/keras/optimizer_v2/gradient_descent_test.py +++ b/tensorflow/python/keras/optimizer_v2/gradient_descent_test.py @@ -134,6 +134,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.evaluate(var0)) self.assertAllCloseAccordingToType([3.0 - 1.0], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -173,6 +174,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([3.0 - 3.0 * 0.01, 4.0 - 3.0 * 0.01], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testGradWrtRef(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -206,6 +208,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([[3.0], [4.0 - 3.0 * 0.01]], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseBasicWithLearningRateDecay(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -331,6 +334,7 @@ class MomentumOptimizerTest(test.TestCase): 3.98 - ((0.9 * 0.01 + 0.01) * 2.0) ]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testNesterovMomentum(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -358,6 +362,7 @@ class MomentumOptimizerTest(test.TestCase): self.assertAllClose(var0_np, self.evaluate(var0)) self.assertAllClose(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseNesterovMomentum(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -399,6 +404,7 @@ class MomentumOptimizerTest(test.TestCase): self.assertAllClose(var1_np, self.evaluate(var1)) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: # This test invokes the ResourceSparseApplyMomentum operation, which @@ -452,6 +458,7 @@ class MomentumOptimizerTest(test.TestCase): self.evaluate(sgd_op) self.assertAllCloseAccordingToType([[1, 1], [0, 0]], self.evaluate(var0)) + @test_util.run_deprecated_v1 def testTensorLearningRateAndMomentum(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -510,6 +517,7 @@ class MomentumOptimizerTest(test.TestCase): 3.98 - ((0.9 * 0.01 + 0.01) * 2.0) ]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparse(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -585,6 +593,7 @@ class MomentumOptimizerTest(test.TestCase): ]), self.evaluate(var1)[2]) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/nadam_test.py b/tensorflow/python/keras/optimizer_v2/nadam_test.py index b7132bbea74..d991e3117ca 100644 --- a/tensorflow/python/keras/optimizer_v2/nadam_test.py +++ b/tensorflow/python/keras/optimizer_v2/nadam_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.keras.optimizer_v2 import nadam from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -111,9 +112,11 @@ class NadamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, var0.eval()) self.assertAllCloseAccordingToType(var1_np, var1.eval()) + @test_util.run_deprecated_v1 def testSparse(self): self.doTestSparse(use_resource=False) + @test_util.run_deprecated_v1 def testResourceSparse(self): self.doTestSparse(use_resource=True) @@ -158,9 +161,11 @@ class NadamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, var0.eval()) self.assertAllCloseAccordingToType(var1_np, var1.eval()) + @test_util.run_deprecated_v1 def testResourceBasic(self): self.doTestBasic(use_resource=True) + @test_util.run_deprecated_v1 def testBasicWithLearningRateDecay(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/keras/optimizer_v2/rmsprop_test.py b/tensorflow/python/keras/optimizer_v2/rmsprop_test.py index a320cc0c490..a8658a85507 100644 --- a/tensorflow/python/keras/optimizer_v2/rmsprop_test.py +++ b/tensorflow/python/keras/optimizer_v2/rmsprop_test.py @@ -86,6 +86,7 @@ class RMSpropOptimizerTest(test.TestCase): var_t[gindex] = var[gindex] - mom_t[gindex] return var_t, mg_t, rms_t, mom_t + @test_util.run_deprecated_v1 def testDense(self): for (dtype, learning_rate, rho, momentum, epsilon, centered) in _TESTPARAMS: with test_util.use_gpu(): @@ -158,6 +159,7 @@ class RMSpropOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testDenseWithLearningRateDecay(self): var0_np = np.array([1.0, 2.0]) grads0_np = np.array([0.1, 0.2]) @@ -225,6 +227,7 @@ class RMSpropOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -249,6 +252,7 @@ class RMSpropOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariableCentered(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -273,6 +277,7 @@ class RMSpropOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testSparse(self): for (dtype, learning_rate, rho, momentum, epsilon, centered) in _TESTPARAMS: with test_util.use_gpu(): diff --git a/tensorflow/python/keras/optimizers_test.py b/tensorflow/python/keras/optimizers_test.py index 46bb0274c6e..d3cacb702c9 100644 --- a/tensorflow/python/keras/optimizers_test.py +++ b/tensorflow/python/keras/optimizers_test.py @@ -91,22 +91,26 @@ def _test_optimizer(optimizer, target=0.75): class KerasOptimizersTest(test.TestCase): + @test_util.run_deprecated_v1 def test_sgd(self): with self.cached_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, momentum=0.9, nesterov=True)) + @test_util.run_deprecated_v1 def test_rmsprop(self): with self.cached_session(): _test_optimizer(keras.optimizers.RMSprop()) _test_optimizer(keras.optimizers.RMSprop(decay=1e-3)) + @test_util.run_deprecated_v1 def test_adagrad(self): with self.cached_session(): _test_optimizer(keras.optimizers.Adagrad()) _test_optimizer(keras.optimizers.Adagrad(decay=1e-3)) + @test_util.run_deprecated_v1 def test_adadelta(self): with self.cached_session(): _test_optimizer(keras.optimizers.Adadelta(), target=0.6) @@ -115,27 +119,32 @@ class KerasOptimizersTest(test.TestCase): # the accuracy. _test_optimizer(keras.optimizers.Adadelta(decay=1e-3), target=0.4) + @test_util.run_deprecated_v1 def test_adam(self): with self.cached_session(): _test_optimizer(keras.optimizers.Adam()) _test_optimizer(keras.optimizers.Adam(decay=1e-3)) _test_optimizer(keras.optimizers.Adam(amsgrad=True)) + @test_util.run_deprecated_v1 def test_adamax(self): with self.cached_session(): _test_optimizer(keras.optimizers.Adamax()) _test_optimizer(keras.optimizers.Adamax(decay=1e-3)) + @test_util.run_deprecated_v1 def test_nadam(self): with self.cached_session(): _test_optimizer(keras.optimizers.Nadam()) + @test_util.run_deprecated_v1 def test_clipnorm(self): with self.cached_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, momentum=0.9, clipnorm=0.5)) + @test_util.run_deprecated_v1 def test_clipvalue(self): with self.cached_session(): _test_optimizer(keras.optimizers.SGD(lr=0.01, diff --git a/tensorflow/python/keras/regularizers_test.py b/tensorflow/python/keras/regularizers_test.py index bba4ebb287b..3d6b259d87d 100644 --- a/tensorflow/python/keras/regularizers_test.py +++ b/tensorflow/python/keras/regularizers_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python import keras from tensorflow.python.keras import testing_utils +from tensorflow.python.framework import test_util from tensorflow.python.platform import test @@ -61,6 +62,7 @@ class KerasRegularizersTest(test.TestCase): model.fit(x_train, y_train, batch_size=10, epochs=1, verbose=0) + @test_util.run_deprecated_v1 def test_activity_regularization(self): with self.cached_session(): (x_train, y_train), _ = get_data() diff --git a/tensorflow/python/kernel_tests/accumulate_n_test.py b/tensorflow/python/kernel_tests/accumulate_n_test.py index c7f11f854d1..5eece9c9413 100644 --- a/tensorflow/python/kernel_tests/accumulate_n_test.py +++ b/tensorflow/python/kernel_tests/accumulate_n_test.py @@ -32,6 +32,7 @@ from tensorflow.python.platform import googletest class AccumulateNV2Test(test_util.TensorFlowTestCase): """Tests of the new, differentiable version of accumulate_n.""" + @test_util.run_deprecated_v1 def testFloat(self): np.random.seed(12345) x = [np.random.random((1, 2, 3, 4, 5)) - 0.5 for _ in range(5)] @@ -41,6 +42,7 @@ class AccumulateNV2Test(test_util.TensorFlowTestCase): self.assertAllClose(x[0] * 5, math_ops.accumulate_n([tf_x[0]] * 5).eval()) + @test_util.run_deprecated_v1 def testInt(self): np.random.seed(54321) x = [np.random.randint(-128, 128, (5, 4, 3, 2, 1)) for _ in range(6)] @@ -50,12 +52,14 @@ class AccumulateNV2Test(test_util.TensorFlowTestCase): self.assertAllEqual(x[0] * 6, math_ops.accumulate_n([tf_x[0]] * 6).eval()) + @test_util.run_deprecated_v1 def testUnknownShape(self): with self.session(use_gpu=True): x0 = array_ops.placeholder(dtype=dtypes_lib.int32, shape=[None]) acc = math_ops.accumulate_n([x0, x0], shape=[None]) self.assertAllEqual([2, 4], acc.eval(feed_dict={x0: [1, 2]})) + @test_util.run_deprecated_v1 def testGrad(self): np.random.seed(42) for num_inputs in range(1, 10): diff --git a/tensorflow/python/kernel_tests/ackermann_test.py b/tensorflow/python/kernel_tests/ackermann_test.py index d267e497527..6c20b19be9e 100644 --- a/tensorflow/python/kernel_tests/ackermann_test.py +++ b/tensorflow/python/kernel_tests/ackermann_test.py @@ -20,12 +20,14 @@ from __future__ import print_function import os from tensorflow.python.framework import load_library +from tensorflow.python.framework import test_util from tensorflow.python.platform import resource_loader from tensorflow.python.platform import test class AckermannTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): library_filename = os.path.join(resource_loader.get_data_files_path(), 'ackermann_op.so') diff --git a/tensorflow/python/kernel_tests/aggregate_ops_test.py b/tensorflow/python/kernel_tests/aggregate_ops_test.py index 874d6166580..d9787cc3bf6 100644 --- a/tensorflow/python/kernel_tests/aggregate_ops_test.py +++ b/tensorflow/python/kernel_tests/aggregate_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.core.framework import tensor_pb2 from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import logging_ops from tensorflow.python.ops import math_ops @@ -67,6 +68,7 @@ class AddNTest(test.TestCase): tol = 5e-3 if dtype == dtypes.float16 else 5e-7 self.assertAllClose(expected, actual, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testUnknownShapes(self): np.random.seed(12345) with self.session(use_gpu=True) as sess: @@ -80,6 +82,7 @@ class AddNTest(test.TestCase): tol = 5e-3 if dtype == dtypes.float16 else 5e-7 self.assertAllClose(expected, actual, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testVariant(self): def create_constant_variant(value): diff --git a/tensorflow/python/kernel_tests/argmax_op_test.py b/tensorflow/python/kernel_tests/argmax_op_test.py index d34a1dc9b29..06ec0948c25 100644 --- a/tensorflow/python/kernel_tests/argmax_op_test.py +++ b/tensorflow/python/kernel_tests/argmax_op_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -110,12 +111,14 @@ class ArgMaxTest(test.TestCase): r"Reduction axis 0 is empty in shape \[0\]"): op([], 0).eval() + @test_util.run_deprecated_v1 def testDefaultAxis(self): with self.cached_session(): for op in math_ops.argmin, math_ops.argmax: ans = op([1]).eval() self.assertAllEqual(ans, 0) + @test_util.run_deprecated_v1 def testOutputEmpty(self): with self.cached_session(): for op in math_ops.argmin, math_ops.argmax: diff --git a/tensorflow/python/kernel_tests/array_ops_test.py b/tensorflow/python/kernel_tests/array_ops_test.py index afc158f6975..f4c442b7b19 100644 --- a/tensorflow/python/kernel_tests/array_ops_test.py +++ b/tensorflow/python/kernel_tests/array_ops_test.py @@ -143,36 +143,43 @@ class BooleanMaskTest(test_util.TensorFlowTestCase): self.assertAllClose(masked_arr, masked_tensor.eval()) + @test_util.run_deprecated_v1 def testMaskDim1ArrDim2Axis1(self): ndims_mask = 1 for arr_shape in [(1, 1), (2, 2), (2, 5)]: self.CheckVersusNumpy(ndims_mask, arr_shape, axis=1) + @test_util.run_deprecated_v1 def testMaskDim2ArrDim2Axis1(self): ndims_mask = 2 for arr_shape in [(1, 1), (2, 2), (2, 5)]: self.CheckVersusNumpy(ndims_mask, arr_shape, axis=1) + @test_util.run_deprecated_v1 def testMaskDim1ArrDim1(self): ndims_mask = 1 for arr_shape in [(1,), (2,), (3,), (10,)]: self.CheckVersusNumpy(ndims_mask, arr_shape) + @test_util.run_deprecated_v1 def testMaskDim1ArrDim2(self): ndims_mask = 1 for arr_shape in [(1, 1), (2, 2), (2, 5)]: self.CheckVersusNumpy(ndims_mask, arr_shape) + @test_util.run_deprecated_v1 def testMaskDim2ArrDim2(self): ndims_mask = 2 for arr_shape in [(1, 1), (2, 2), (2, 5)]: self.CheckVersusNumpy(ndims_mask, arr_shape) + @test_util.run_deprecated_v1 def testMaskDim2ArrDim3(self): ndims_mask = 2 for arr_shape in [(1, 1, 1), (1, 2, 2), (2, 2, 1)]: self.CheckVersusNumpy(ndims_mask, arr_shape) + @test_util.run_deprecated_v1 def testEmptyInput2D(self): mask = np.array([True, False]) arr = np.array([[], []]).astype(np.float32) @@ -191,6 +198,7 @@ class BooleanMaskTest(test_util.TensorFlowTestCase): with self.cached_session(): self.assertAllClose(numpy_result, tf_result.eval()) + @test_util.run_deprecated_v1 def testEmptyOutput(self): make_mask = lambda shape: np.zeros(shape, dtype=bool) for ndims_mask in range(1, 4): @@ -199,6 +207,7 @@ class BooleanMaskTest(test_util.TensorFlowTestCase): arr_shape = np.random.randint(1, 5, size=ndims_arr) self.CheckVersusNumpy(ndims_mask, arr_shape, make_mask=make_mask) + @test_util.run_deprecated_v1 def testWorksWithDimensionsEqualToNoneDuringGraphBuild(self): # The rank of the mask tensor must be specified. This is explained # in the docstring as well. @@ -217,6 +226,7 @@ class BooleanMaskTest(test_util.TensorFlowTestCase): }) np.testing.assert_allclose(masked_tensor, arr[mask]) + @test_util.run_deprecated_v1 def testMaskDimensionsSetToNoneRaises(self): # The rank of the mask tensor must be specified. This is explained # in the docstring as well. @@ -283,6 +293,7 @@ class OperatorShapeTest(test_util.TensorFlowTestCase): class ReverseV2Test(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testReverse0DimAuto(self): x_np = 4 for use_gpu in [False, True]: @@ -327,6 +338,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): # This test covers the axis validation in the shape function # (no eval()) + @test_util.run_deprecated_v1 def testInvalidAxis(self): x_np = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32) with self.assertRaisesRegexp(ValueError, @@ -345,6 +357,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): # # Note: this test passes placeholder as constant axis is validated # in shape function (see testInvalidAxis) + @test_util.run_deprecated_v1 def testInvalid(self): x_np = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32) axis = array_ops.placeholder(dtypes.int32) @@ -359,6 +372,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): "axis 0 specified more than once"): array_ops.reverse_v2(x_np, axis).eval(feed_dict={axis: [0, -2]}) + @test_util.run_deprecated_v1 def testReverse1DimAuto(self): for dtype in [ np.uint8, np.int8, np.uint16, np.int16, np.int32, np.int64, np.bool, @@ -367,6 +381,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): ]: self._reverse1DimAuto(dtype) + @test_util.run_deprecated_v1 def testReverse2DimAuto(self): for dtype in [ np.uint8, np.int8, np.uint16, np.int16, np.int32, np.int64, np.bool, @@ -375,6 +390,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): ]: self._reverse2DimAuto(dtype) + @test_util.run_deprecated_v1 def testUnknownDims(self): reverse_v2 = array_ops.reverse_v2 data_t = array_ops.placeholder(dtypes.float32) @@ -392,6 +408,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): reverse_2d_t = reverse_v2(data_2d_t, axis_2d_t) self.assertEqual(2, reverse_2d_t.get_shape().ndims) + @test_util.run_deprecated_v1 def testReverseRowsOf3Channels(self): """Tests optimized code for reversing rows with last dim size = 3.""" with self.session(use_gpu=True): @@ -405,6 +422,7 @@ class ReverseV2Test(test_util.TensorFlowTestCase): np_answer = x_np[:, ::-1, :] self.assertAllEqual(x_tf, np_answer) + @test_util.run_deprecated_v1 def testReverseRowsOf4Channels(self): with self.session(use_gpu=True): for reverse_f in [array_ops.reverse_v2, array_ops.reverse]: @@ -454,6 +472,7 @@ class MeshgridTest(test_util.TensorFlowTestCase): for x_np, x_tf in zip(numpy_out, tf_out): self.assertAllEqual(x_np, x_tf.eval()) + @test_util.run_deprecated_v1 def testCompare(self): for t in (np.float16, np.float32, np.float64, np.int32, np.int64, np.complex64, np.complex128): @@ -526,6 +545,7 @@ STRIDED_SLICE_TYPES = [ class StridedSliceTest(test_util.TensorFlowTestCase): """Test the strided slice operation with variants of slices.""" + @test_util.run_deprecated_v1 def test_basic_slice(self): for tensor_type in STRIDED_SLICE_TYPES: with self.cached_session(use_gpu=True): @@ -581,6 +601,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): v = variables.Variable([1., 2.]) v[0] # pylint: disable=pointless-statement + @test_util.run_deprecated_v1 def testDegenerateSlices(self): with self.session(use_gpu=True): checker = StridedSliceChecker(self, StridedSliceChecker.REF_TENSOR) @@ -591,6 +612,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): # empty interval in every dimension _ = checker[-1:0, 2:2, 2:3:-1] + @test_util.run_deprecated_v1 def testEllipsis(self): with self.session(use_gpu=True): raw = [[[[[1, 2], [3, 4], [5, 6]]], [[[7, 8], [9, 10], [11, 12]]]]] @@ -611,6 +633,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): with self.assertRaisesRegexp(ValueError, "Multiple ellipses"): _ = checker[..., :, ...].eval() + @test_util.run_deprecated_v1 def testShrink(self): with self.session(use_gpu=True): raw = [[[[[1, 2, 4, 5], [5, 6, 7, 8], [9, 10, 11, 12]]], @@ -621,6 +644,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): _ = checker[:, 0] _ = checker[:, :, 0] + @test_util.run_deprecated_v1 def testBothNewAxisAndShrink(self): with self.session(use_gpu=True): ones = array_ops.placeholder(shape=[2, 2], dtype=dtypes.int16) @@ -629,6 +653,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): feed_dict={ones: [[1, 1], [1, 1]]}), [[1, 1]]) + @test_util.run_deprecated_v1 def testTensorIndexing(self): with self.session(use_gpu=True): raw = [[[[[1, 2, 4, 5], [5, 6, 7, 8], [9, 10, 11, 12]]], @@ -654,6 +679,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): with self.assertRaisesRegexp(TypeError, expected): _ = checker[constant_op.constant(0.0)] + @test_util.run_deprecated_v1 def testExpand(self): with self.session(use_gpu=True): raw = [[[[[1, 2, 4, 5], [5, 6, 7, 8], [9, 10, 11, 12]]], @@ -671,6 +697,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): # Ellipsis in middle of two newaxis _ = checker[np.newaxis, ..., np.newaxis] + @test_util.run_deprecated_v1 def testExpandVariable(self): with self.session(use_gpu=True): x = variables.Variable(7, dtype=dtypes.int32) @@ -679,6 +706,7 @@ class StridedSliceTest(test_util.TensorFlowTestCase): self.assertEqual(y.shape, (1,)) self.assertAllEqual(y, (7,)) + @test_util.run_deprecated_v1 def testOptimizedCases(self): with self.session(use_gpu=True): checker = StridedSliceChecker(self, @@ -708,6 +736,7 @@ class StridedSliceShapeChecker(object): class StridedSliceShapeTest(test_util.TensorFlowTestCase): """Test the shape inference of StridedSliceShapes.""" + @test_util.run_deprecated_v1 def testUnknown(self): with self.session(use_gpu=True): uncertain_tensor = array_ops.placeholder(dtypes.float32) @@ -719,6 +748,7 @@ class StridedSliceShapeTest(test_util.TensorFlowTestCase): self.assertTrue(x is not None and y is not None or x is None and y is None) self.assertEqual(x.as_list(), y.as_list()) + @test_util.run_deprecated_v1 def testTensorShapeUncertain(self): with self.session(use_gpu=True): uncertain_tensor = array_ops.placeholder( @@ -742,6 +772,7 @@ class StridedSliceShapeTest(test_util.TensorFlowTestCase): self.tensorShapeEqual(a[::-1, :, array_ops.newaxis, ::-2], tensor_shape.TensorShape([5, None, 1, 4])) + @test_util.run_deprecated_v1 def testTensorValuedIndexShape(self): with self.session(use_gpu=True): defined_shape_tensor = array_ops.placeholder( @@ -798,6 +829,7 @@ class GradSliceChecker(object): class StridedSliceGradTest(test_util.TensorFlowTestCase): """Test that strided slice's custom gradient produces correct gradients.""" + @test_util.run_deprecated_v1 def testGradient(self): with self.session(use_gpu=True) as sess: var = variables.Variable( @@ -827,6 +859,7 @@ class StridedSliceGradTest(test_util.TensorFlowTestCase): grad = GradSliceChecker(self, sess, var, np.array(8)) _ = grad[tuple()] + @test_util.run_deprecated_v1 def testInt64Indices(self): with self.session(use_gpu=True) as sess: a = math_ops.range(3, dtype=dtypes.float32) @@ -839,6 +872,7 @@ class StridedSliceGradTest(test_util.TensorFlowTestCase): class StridedSliceGradTypeTest(test_util.TensorFlowTestCase): """Test varied index types and host located memory.""" + @test_util.run_deprecated_v1 def testHostVsDevice(self): with self.session(use_gpu=True) as sess: var2 = variables.Variable( @@ -853,6 +887,7 @@ class StridedSliceGradTypeTest(test_util.TensorFlowTestCase): foo = array_ops.strided_slice_grad(varshape, begin, end, strides, var2) sess.run(foo) + @test_util.run_deprecated_v1 def testInt64Shape(self): with self.session(use_gpu=True) as sess: original_dy = array_ops.reshape( @@ -867,6 +902,7 @@ class StridedSliceGradTypeTest(test_util.TensorFlowTestCase): original_dy) sess.run(dx) + @test_util.run_deprecated_v1 def testMixedIndexTypes(self): with self.session(use_gpu=True) as sess: original_dy = array_ops.reshape( @@ -975,6 +1011,7 @@ class StridedSliceAssignChecker(object): class SliceAssignTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testInvalidSlice(self): with self.cached_session() as sess: foo = constant_op.constant([1, 2, 3]) @@ -1012,12 +1049,15 @@ class SliceAssignTest(test_util.TensorFlowTestCase): checker2[...] = 6 # ellipsis checker2[None] = [6] # new axis + @test_util.run_deprecated_v1 def testSliceAssign(self): self.doTestSliceAssign(use_resource=False) + @test_util.run_deprecated_v1 def testSliceAssignResource(self): self.doTestSliceAssign(use_resource=True) + @test_util.run_deprecated_v1 def testUninitialized(self): with self.assertRaisesRegexp( errors.FailedPreconditionError, @@ -1036,6 +1076,7 @@ class SliceAssignTest(test_util.TensorFlowTestCase): with self.assertRaises(TypeError): v[:].assign(too_large_val) + @test_util.run_deprecated_v1 def testTypeErrorResource(self): init_val = constant_op.constant([1, 2], dtype=dtypes.int32) too_small_val = constant_op.constant([3, 4], dtype=dtypes.int8) @@ -1092,6 +1133,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase): with self.assertRaisesRegexp(ValueError, "maxlen must be scalar"): array_ops.sequence_mask([10, 20], [10, 20]) + @test_util.run_deprecated_v1 def testOneDimensionalWithMaxlen(self): with self.cached_session(): res = array_ops.sequence_mask(constant_op.constant([1, 3, 2]), 5) @@ -1101,6 +1143,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase): [[True, False, False, False, False], [True, True, True, False, False], [True, True, False, False, False]]) + @test_util.run_deprecated_v1 def testOneDimensionalDtypeWithoutMaxlen(self): with self.cached_session(): # test dtype and default maxlen: @@ -1111,6 +1154,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase): res.eval(), [[0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0]]) + @test_util.run_deprecated_v1 def testOneDimensionalWithoutMaxlen(self): with self.cached_session(): res = array_ops.sequence_mask( @@ -1139,11 +1183,13 @@ class SequenceMaskTest(test_util.TensorFlowTestCase): [[[0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0]], [[1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 0.0, 0.0], [1.0, 1.0, 1.0, 0.0]]]) + @test_util.run_deprecated_v1 def testUnknownShape(self): lengths = array_ops.placeholder(dtype=dtypes.int32) res = array_ops.sequence_mask(lengths) self.assertEqual(res.shape, None) + @test_util.run_deprecated_v1 def testDtypes(self): def check_dtypes(lengths_dtype, maxlen_dtype): @@ -1166,6 +1212,7 @@ class SequenceMaskTest(test_util.TensorFlowTestCase): class ConcatSliceResourceTest(test_util.TensorFlowTestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testConcatSlice(self): r1 = test_ops.stub_resource_handle_op(container="a", shared_name="b") r2 = test_ops.stub_resource_handle_op(container="a", shared_name="c") @@ -1221,6 +1268,7 @@ class PadTest(test_util.TensorFlowTestCase): class InvertPermutationTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testInvertPermutation(self): for dtype in [dtypes.int32, dtypes.int64]: with self.cached_session(use_gpu=True): @@ -1255,12 +1303,14 @@ class UnravelIndexTest(test_util.TensorFlowTestCase): class GuaranteeConstOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testSimple(self): with self.cached_session(): a = array_ops.constant(10) guarantee_a = array_ops.guarantee_const(a) self.assertEqual(10, guarantee_a.eval()) + @test_util.run_deprecated_v1 def testVariables(self): with self.cached_session() as sess: for use_resource in [False, True]: @@ -1272,6 +1322,7 @@ class GuaranteeConstOpTest(test_util.TensorFlowTestCase): self.evaluate(variables.global_variables_initializer()) self.assertEqual(10.0, guarantee_a.eval()) + @test_util.run_deprecated_v1 def testResourceRejection(self): with self.cached_session() as sess: a = variable_scope.get_variable( @@ -1287,6 +1338,7 @@ class GuaranteeConstOpTest(test_util.TensorFlowTestCase): class SnapshotOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testInvertPermutation(self): for dtype in [dtypes.int32, dtypes.int64, dtypes.float32, dtypes.float64]: with self.cached_session(use_gpu=True): diff --git a/tensorflow/python/kernel_tests/as_string_op_test.py b/tensorflow/python/kernel_tests/as_string_op_test.py index dd4a90e5f65..287701a73e4 100644 --- a/tensorflow/python/kernel_tests/as_string_op_test.py +++ b/tensorflow/python/kernel_tests/as_string_op_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -27,6 +28,7 @@ from tensorflow.python.platform import test class AsStringOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testFloat(self): float_inputs_ = [ 0, 1, -1, 0.5, 0.25, 0.125, float("INF"), float("NAN"), float("-INF") @@ -78,6 +80,7 @@ class AsStringOpTest(test.TestCase): output = string_ops.as_string(input_, fill="ab") output.eval(feed_dict={input_: float_inputs_}) + @test_util.run_deprecated_v1 def testInt(self): # Cannot use values outside -128..127 for test, because we're also # testing int8 @@ -112,6 +115,7 @@ class AsStringOpTest(test.TestCase): output = string_ops.as_string(input_, precision=0) output.eval(feed_dict={input_: int_inputs_}) + @test_util.run_deprecated_v1 def testLargeInt(self): # Cannot use values outside -128..127 for test, because we're also # testing int8 @@ -130,6 +134,7 @@ class AsStringOpTest(test.TestCase): result = output.eval(feed_dict={input_: int_inputs_}) self.assertAllEqual(s(result), ["%d" % x for x in int_inputs_]) + @test_util.run_deprecated_v1 def testHalfInt(self): s = lambda strs: [x.decode("ascii") for x in strs] @@ -140,6 +145,7 @@ class AsStringOpTest(test.TestCase): result = output.eval(feed_dict={input_: int_inputs_}) self.assertAllEqual(s(result), ["%d" % x for x in int_inputs_]) + @test_util.run_deprecated_v1 def testBool(self): bool_inputs_ = [False, True] s = lambda strs: [x.decode("ascii") for x in strs] @@ -152,6 +158,7 @@ class AsStringOpTest(test.TestCase): result = output.eval(feed_dict={input_: bool_inputs_}) self.assertAllEqual(s(result), ["false", "true"]) + @test_util.run_deprecated_v1 def testComplex(self): float_inputs_ = [ 0, 1, -1, 0.5, 0.25, 0.125, complex("INF"), complex("NAN"), diff --git a/tensorflow/python/kernel_tests/atrous_conv2d_test.py b/tensorflow/python/kernel_tests/atrous_conv2d_test.py index fefb7979956..a13e325835c 100644 --- a/tensorflow/python/kernel_tests/atrous_conv2d_test.py +++ b/tensorflow/python/kernel_tests/atrous_conv2d_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_impl @@ -58,6 +59,7 @@ def _upsample_filters(filters, rate): class AtrousConv2DTest(test.TestCase): + @test_util.run_deprecated_v1 def testAtrousConv2DForward(self): with self.session(use_gpu=True): # Input: [batch, height, width, input_depth] @@ -82,6 +84,7 @@ class AtrousConv2DTest(test.TestCase): self.assertAllClose( y1.eval(), self.evaluate(y2), rtol=1e-3, atol=1e-3) + @test_util.run_deprecated_v1 def testAtrousSequence(self): """Tests optimization of sequence of atrous convolutions. @@ -135,6 +138,7 @@ class AtrousConv2DTest(test.TestCase): self.assertAllClose( y1.eval(), self.evaluate(y2), rtol=1e-2, atol=1e-2) + @test_util.run_deprecated_v1 def testGradient(self): with self.session(use_gpu=True): # Input: [batch, height, width, input_depth] @@ -162,6 +166,7 @@ class AtrousConv2DTest(test.TestCase): class AtrousConv2DTransposeTest(test.TestCase): + @test_util.run_deprecated_v1 def testAtrousConv2DTransposeForward(self): with self.session(use_gpu=True): # Input: [batch, height, width, input_depth] @@ -201,6 +206,7 @@ class AtrousConv2DTransposeTest(test.TestCase): class AtrousDepthwiseConv2DTest(test.TestCase): + @test_util.run_deprecated_v1 def testAtrousDepthwiseConv2DForward(self): strides = [1, 1, 1, 1] with self.session(use_gpu=True): diff --git a/tensorflow/python/kernel_tests/barrier_ops_test.py b/tensorflow/python/kernel_tests/barrier_ops_test.py index 495bbe7b341..60fe6f0eecd 100644 --- a/tensorflow/python/kernel_tests/barrier_ops_test.py +++ b/tensorflow/python/kernel_tests/barrier_ops_test.py @@ -25,6 +25,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import data_flow_ops from tensorflow.python.platform import test @@ -66,6 +67,7 @@ class BarrierTest(test.TestCase): attr { key: 'shared_name' value: { s: 'B' } } """, b.barrier_ref.op.node_def) + @test_util.run_deprecated_v1 def testInsertMany(self): with self.cached_session(): b = data_flow_ops.Barrier( @@ -90,6 +92,7 @@ class BarrierTest(test.TestCase): data_flow_ops.Barrier( (dtypes.float32, dtypes.float32), shapes=((1,), (0,)), name="B") + @test_util.run_deprecated_v1 def testInsertManyEmptyTensorUnknown(self): with self.cached_session(): b = data_flow_ops.Barrier((dtypes.float32, dtypes.float32), name="B") @@ -102,6 +105,7 @@ class BarrierTest(test.TestCase): ".*Tensors with no elements are not supported.*"): insert_0_op.run() + @test_util.run_deprecated_v1 def testTakeMany(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -127,6 +131,7 @@ class BarrierTest(test.TestCase): self.assertEqual(values_0_val[idx], v0) self.assertEqual(values_1_val[idx], v1) + @test_util.run_deprecated_v1 def testTakeManySmallBatch(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -191,6 +196,7 @@ class BarrierTest(test.TestCase): with self.assertRaisesOpError("is closed"): insert_1_3_op.run() + @test_util.run_deprecated_v1 def testUseBarrierWithShape(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -220,6 +226,7 @@ class BarrierTest(test.TestCase): self.assertAllEqual(values_0_val[idx], v0) self.assertAllEqual(values_1_val[idx], v1) + @test_util.run_deprecated_v1 def testParallelInsertMany(self): with self.cached_session() as sess: b = data_flow_ops.Barrier(dtypes.float32, shapes=()) @@ -240,6 +247,7 @@ class BarrierTest(test.TestCase): idx = keys_val.tolist().index(k) self.assertEqual(values_val[idx], v) + @test_util.run_deprecated_v1 def testParallelTakeMany(self): with self.cached_session() as sess: b = data_flow_ops.Barrier(dtypes.float32, shapes=()) @@ -274,6 +282,7 @@ class BarrierTest(test.TestCase): self.assertItemsEqual( zip(keys, values), [(k[0], v[0]) for k, v in zip(key_vals, value_vals)]) + @test_util.run_deprecated_v1 def testBlockingTakeMany(self): with self.cached_session() as sess: b = data_flow_ops.Barrier(dtypes.float32, shapes=()) @@ -296,6 +305,7 @@ class BarrierTest(test.TestCase): insert_op.run() t.join() + @test_util.run_deprecated_v1 def testParallelInsertManyTakeMany(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -375,6 +385,7 @@ class BarrierTest(test.TestCase): 2 + outer_indices_from_keys + inner_indices_from_keys)).T self.assertAllEqual(taken_i["values_1"], expected_values_1) + @test_util.run_deprecated_v1 def testClose(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -433,6 +444,7 @@ class BarrierTest(test.TestCase): with self.assertRaisesOpError("is closed and has insufficient elements"): sess.run(take_t[0]) + @test_util.run_deprecated_v1 def testCancel(self): with self.cached_session() as sess: b = data_flow_ops.Barrier( @@ -495,6 +507,7 @@ class BarrierTest(test.TestCase): with self.assertRaisesOpError("is closed and has insufficient elements"): self.evaluate(take_t) + @test_util.run_deprecated_v1 def testClosedEmptyBarrierTakeManyAllowSmallBatchRaises(self): self._testClosedEmptyBarrierTakeManyAllowSmallBatchRaises(cancel=False) self._testClosedEmptyBarrierTakeManyAllowSmallBatchRaises(cancel=True) @@ -569,9 +582,11 @@ class BarrierTest(test.TestCase): sorted(taken), [0] * (num_iterations // 2) + [10] * (num_iterations // 2)) + @test_util.run_deprecated_v1 def testParallelInsertManyTakeManyCloseHalfwayThrough(self): self._testParallelInsertManyTakeManyCloseHalfwayThrough(cancel=False) + @test_util.run_deprecated_v1 def testParallelInsertManyTakeManyCancelHalfwayThrough(self): self._testParallelInsertManyTakeManyCloseHalfwayThrough(cancel=True) @@ -669,12 +684,15 @@ class BarrierTest(test.TestCase): else: self.assertEqual(taken, [10] * num_iterations) + @test_util.run_deprecated_v1 def testParallelPartialInsertManyTakeManyCloseHalfwayThrough(self): self._testParallelPartialInsertManyTakeManyCloseHalfwayThrough(cancel=False) + @test_util.run_deprecated_v1 def testParallelPartialInsertManyTakeManyCancelHalfwayThrough(self): self._testParallelPartialInsertManyTakeManyCloseHalfwayThrough(cancel=True) + @test_util.run_deprecated_v1 def testIncompatibleSharedBarrierErrors(self): with self.cached_session(): # Do component types and shapes. diff --git a/tensorflow/python/kernel_tests/basic_gpu_test.py b/tensorflow/python/kernel_tests/basic_gpu_test.py index cd330481214..1a8513d022d 100644 --- a/tensorflow/python/kernel_tests/basic_gpu_test.py +++ b/tensorflow/python/kernel_tests/basic_gpu_test.py @@ -159,6 +159,7 @@ class BroadcastSimpleTest(test.TestCase): with self.cached_session(use_gpu=True) as sess: return sess.run(broadcast_gradient_args(xs, ys)) + @test_util.run_deprecated_v1 def testBroadcast(self): r0, r1 = self._GetGradientArgs([2, 3, 5], [1]) self.assertAllEqual(r0, []) @@ -219,6 +220,7 @@ class BroadcastSimpleTest(test.TestCase): self.assertShapeEqual(np_ans, out) # TODO(zhifengc/ke): make gradient checker work on GPU. + @test_util.run_deprecated_v1 def testGradient(self): x = (1 + np.linspace(0, 5, np.prod([1, 3, 2]))).astype(np.float32).reshape( [1, 3, 2]) @@ -255,6 +257,7 @@ class GpuMultiSessionMemoryTest(test_util.TensorFlowTestCase): if len(results) != 1: break + @test_util.run_deprecated_v1 def testConcurrentSessions(self): n_threads = 4 threads = [] diff --git a/tensorflow/python/kernel_tests/batch_gather_op_test.py b/tensorflow/python/kernel_tests/batch_gather_op_test.py index ad4e8791314..7e0b3e1b5ea 100644 --- a/tensorflow/python/kernel_tests/batch_gather_op_test.py +++ b/tensorflow/python/kernel_tests/batch_gather_op_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test @@ -87,6 +88,7 @@ class GatherTest(test.TestCase, parameterized.TestCase): self.assertAllEqual(np_val, gather_val) self.assertEqual(np_val.shape, gather_t.get_shape()) + @test_util.run_deprecated_v1 def testString(self): params = np.array([[b"asdf", b"zxcv"], [b"qwer", b"uiop"]]) with self.cached_session(): @@ -94,6 +96,7 @@ class GatherTest(test.TestCase, parameterized.TestCase): self.assertAllEqual([[b"qwer", b"uiop"]], array_ops.batch_gather(params, indices_tf).eval()) + @test_util.run_deprecated_v1 def testUnknownIndices(self): params = constant_op.constant([[0, 1, 2]]) indices = array_ops.placeholder(dtypes.int32, shape=[None, None]) @@ -106,6 +109,7 @@ class GatherTest(test.TestCase, parameterized.TestCase): with self.assertRaisesOpError(r"indices\[0\] = 7 is not in \[0, 2\)"): array_ops.batch_gather(params, [7]).eval() + @test_util.run_deprecated_v1 def testEmptySlices(self): with self.session(use_gpu=True): for dtype in _TEST_TYPES: diff --git a/tensorflow/python/kernel_tests/batch_scatter_ops_test.py b/tensorflow/python/kernel_tests/batch_scatter_ops_test.py index a4b461bc87b..eefcdc508f0 100644 --- a/tensorflow/python/kernel_tests/batch_scatter_ops_test.py +++ b/tensorflow/python/kernel_tests/batch_scatter_ops_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import state_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -73,6 +74,7 @@ class ScatterTest(test.TestCase): tf_scatter(ref, indices, updates).eval() self.assertAllClose(ref.eval(), new) + @test_util.run_deprecated_v1 def testVariableRankUpdate(self): vtypes = [np.float32, np.float64] for vtype in vtypes: @@ -80,6 +82,7 @@ class ScatterTest(test.TestCase): self._VariableRankTest( state_ops.batch_scatter_update, vtype, itype) + @test_util.run_deprecated_v1 def testBooleanScatterUpdate(self): with self.session(use_gpu=False) as session: var = variables.Variable([True, False]) @@ -93,6 +96,7 @@ class ScatterTest(test.TestCase): self.assertAllEqual([False, True], self.evaluate(var)) + @test_util.run_deprecated_v1 def testScatterOutOfRange(self): params = np.array([1, 2, 3, 4, 5, 6]).astype(np.float32) updates = np.array([-3, -4, -5]).astype(np.float32) diff --git a/tensorflow/python/kernel_tests/batchtospace_op_test.py b/tensorflow/python/kernel_tests/batchtospace_op_test.py index 03f3f64353d..c422df8806f 100644 --- a/tensorflow/python/kernel_tests/batchtospace_op_test.py +++ b/tensorflow/python/kernel_tests/batchtospace_op_test.py @@ -27,6 +27,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import gradient_checker @@ -50,6 +51,7 @@ class CppOpImpl(object): class BatchToSpaceDepthToSpace(test.TestCase, PythonOpImpl): # Verifies that: batch_to_space(x) = transpose(depth_to_space(transpose(x))) + @test_util.run_deprecated_v1 def testDepthToSpaceTranspose(self): x = np.arange(20 * 5 * 8 * 7, dtype=np.float32).reshape([20, 5, 8, 7]) block_size = 2 @@ -70,6 +72,7 @@ class BatchToSpaceDepthToSpaceCpp(BatchToSpaceDepthToSpace, CppOpImpl): class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): + @test_util.run_deprecated_v1 def testInputWrongDimMissingBatch(self): # The input is missing the first dimension ("batch") x_np = [[[1], [2]], [[3], [4]]] @@ -78,6 +81,7 @@ class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.batch_to_space(x_np, crops, block_size) + @test_util.run_deprecated_v1 def testBlockSize0(self): # The block size is 0. x_np = [[[[1], [2]], [[3], [4]]]] @@ -87,6 +91,7 @@ class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeOne(self): # The block size is 1. The block size needs to be > 1. x_np = [[[[1], [2]], [[3], [4]]]] @@ -96,6 +101,7 @@ class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeLarger(self): # The block size is too large for this input. x_np = [[[[1], [2]], [[3], [4]]]] @@ -105,6 +111,7 @@ class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.batch_to_space(x_np, crops, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeSquaredNotDivisibleBatch(self): # The block size squared does not divide the batch. x_np = [[[[1], [2], [3]], [[3], [4], [7]]]] @@ -113,6 +120,7 @@ class BatchToSpaceErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.batch_to_space(x_np, crops, block_size) + @test_util.run_deprecated_v1 def testUnknownShape(self): t = self.batch_to_space( array_ops.placeholder(dtypes.float32), @@ -160,28 +168,35 @@ class BatchToSpaceNDErrorHandlingTest(test.TestCase): self._testStaticShape(input_shape, block_shape, paddings, error) self._testDynamicShape(input_shape, block_shape, paddings) + @test_util.run_deprecated_v1 def testInputWrongDimMissingBatch(self): self._testShape([2, 2], [2, 2], [[0, 0], [0, 0]], ValueError) self._testShape([2, 2, 3], [2, 2, 3], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockSize0(self): # The block size is 0. self._testShape([1, 2, 2, 1], [0, 1], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockSizeNegative(self): self._testShape([1, 2, 2, 1], [-1, 1], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testNegativePadding(self): self._testShape([1, 2, 2], [1, 1], [[0, -1], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testCropTooLarge(self): # The amount to crop exceeds the padded size. self._testShape([1 * 2 * 2, 2, 3, 1], [2, 2], [[3, 2], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockSizeSquaredNotDivisibleBatch(self): # The batch dimension is not divisible by the product of the block_shape. self._testShape([3, 1, 1, 1], [2, 3], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testUnknownShape(self): # Verify that input shape and paddings shape can be unknown. _ = array_ops.batch_to_space_nd( @@ -263,18 +278,21 @@ class BatchToSpaceGradientTest(test.TestCase, PythonOpImpl): # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): block_size = 2 crop_beg = 0 crop_end = 0 self._compare(1, 2, 3, 5, block_size, crop_beg, crop_end) + @test_util.run_deprecated_v1 def testSmall2(self): block_size = 2 crop_beg = 0 crop_end = 0 self._compare(2, 4, 3, 2, block_size, crop_beg, crop_end) + @test_util.run_deprecated_v1 def testSmallCrop1x1(self): block_size = 2 crop_beg = 1 @@ -316,14 +334,17 @@ class BatchToSpaceNDGradientTest(test.TestCase): # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): for dtype in [dtypes.int64, dtypes.int32]: self._compare([1, 2, 3, 5], [2, 2], [[0, 0], [0, 0]], dtype) + @test_util.run_deprecated_v1 def testSmall2(self): for dtype in [dtypes.int64, dtypes.int32]: self._compare([2, 4, 3, 2], [2, 2], [[0, 0], [0, 0]], dtype) + @test_util.run_deprecated_v1 def testSmallCrop1x1(self): for dtype in [dtypes.int64, dtypes.int32]: self._compare([1, 2, 3, 5], [2, 2], [[1, 1], [1, 1]], dtype) diff --git a/tensorflow/python/kernel_tests/bcast_ops_test.py b/tensorflow/python/kernel_tests/bcast_ops_test.py index 3ec820aeada..ae00955ac29 100644 --- a/tensorflow/python/kernel_tests/bcast_ops_test.py +++ b/tensorflow/python/kernel_tests/bcast_ops_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops.gen_array_ops import broadcast_args from tensorflow.python.ops.gen_array_ops import broadcast_gradient_args from tensorflow.python.platform import test @@ -35,6 +36,7 @@ class BcastOpsTest(test.TestCase): with self.cached_session() as sess: return sess.run(broadcast_gradient_args(xs, ys)) + @test_util.run_deprecated_v1 def testBasic(self): r = self._GetBroadcastShape([2, 3, 5], [1]) self.assertAllEqual(r, [2, 3, 5]) @@ -66,6 +68,7 @@ class BcastOpsTest(test.TestCase): r = self._GetBroadcastShape([3, 1], [2, 1, 5]) self.assertAllEqual(r, [2, 3, 5]) + @test_util.run_deprecated_v1 def testBasicGradient(self): r0, r1 = self._GetGradientArgs([2, 3, 5], [1]) self.assertAllEqual(r0, []) @@ -107,6 +110,7 @@ class BcastOpsTest(test.TestCase): self.assertAllEqual(r0, [0, 2]) self.assertAllEqual(r1, [1]) + @test_util.run_deprecated_v1 def testZeroDims(self): r = self._GetBroadcastShape([2, 0, 3, 0, 5], [3, 0, 5]) self.assertAllEqual(r, [2, 0, 3, 0, 5]) @@ -120,6 +124,7 @@ class BcastOpsTest(test.TestCase): r = self._GetBroadcastShape([3, 1, 5], [2, 0, 3, 0, 5]) self.assertAllEqual(r, [2, 0, 3, 0, 5]) + @test_util.run_deprecated_v1 def testZeroDimsGradient(self): r0, r1 = self._GetGradientArgs([2, 0, 3, 0, 5], [3, 0, 5]) self.assertAllEqual(r0, []) @@ -137,6 +142,7 @@ class BcastOpsTest(test.TestCase): self.assertAllEqual(r0, [0, 1, 3]) self.assertAllEqual(r1, []) + @test_util.run_deprecated_v1 def testDataTypes(self): for dtype in [dtypes.int32, dtypes.int64]: r = self._GetBroadcastShape( diff --git a/tensorflow/python/kernel_tests/betainc_op_test.py b/tensorflow/python/kernel_tests/betainc_op_test.py index 5d7446042e1..9dc34a60628 100644 --- a/tensorflow/python/kernel_tests/betainc_op_test.py +++ b/tensorflow/python/kernel_tests/betainc_op_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -109,36 +110,42 @@ class BetaincTest(test.TestCase): except ImportError as e: tf_logging.warn("Cannot test special functions: %s" % str(e)) + @test_util.run_deprecated_v1 def testBetaIncFloat(self): a_s = np.abs(np.random.randn(10, 10) * 30) # in (0, infty) b_s = np.abs(np.random.randn(10, 10) * 30) # in (0, infty) x_s = np.random.rand(10, 10) # in (0, 1) self._testBetaInc(a_s, b_s, x_s, dtypes.float32) + @test_util.run_deprecated_v1 def testBetaIncDouble(self): a_s = np.abs(np.random.randn(10, 10) * 30) # in (0, infty) b_s = np.abs(np.random.randn(10, 10) * 30) # in (0, infty) x_s = np.random.rand(10, 10) # in (0, 1) self._testBetaInc(a_s, b_s, x_s, dtypes.float64) + @test_util.run_deprecated_v1 def testBetaIncDoubleVeryLargeValues(self): a_s = np.abs(np.random.randn(10, 10) * 1e15) # in (0, infty) b_s = np.abs(np.random.randn(10, 10) * 1e15) # in (0, infty) x_s = np.random.rand(10, 10) # in (0, 1) self._testBetaInc(a_s, b_s, x_s, dtypes.float64) + @test_util.run_deprecated_v1 def testBetaIncDoubleVerySmallValues(self): a_s = np.abs(np.random.randn(10, 10) * 1e-16) # in (0, infty) b_s = np.abs(np.random.randn(10, 10) * 1e-16) # in (0, infty) x_s = np.random.rand(10, 10) # in (0, 1) self._testBetaInc(a_s, b_s, x_s, dtypes.float64) + @test_util.run_deprecated_v1 def testBetaIncFloatVerySmallValues(self): a_s = np.abs(np.random.randn(10, 10) * 1e-8) # in (0, infty) b_s = np.abs(np.random.randn(10, 10) * 1e-8) # in (0, infty) x_s = np.random.rand(10, 10) # in (0, 1) self._testBetaInc(a_s, b_s, x_s, dtypes.float32) + @test_util.run_deprecated_v1 def testBetaIncFpropAndBpropAreNeverNAN(self): with self.cached_session() as sess: space = np.logspace(-8, 5).tolist() @@ -159,6 +166,7 @@ class BetaincTest(test.TestCase): self.assertAllEqual(np.zeros_like(grads_x).astype(np.bool), np.isnan(grads_x)) + @test_util.run_deprecated_v1 def testBetaIncGrads(self): err_tolerance = 1e-3 with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/bias_op_test.py b/tensorflow/python/kernel_tests/bias_op_test.py index 749d6a791e3..66f442dbddb 100644 --- a/tensorflow/python/kernel_tests/bias_op_test.py +++ b/tensorflow/python/kernel_tests/bias_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -89,10 +90,12 @@ class BiasAddTest(test.TestCase): self._testBiasNCHW(np_inputs, np_bias, use_gpu=True) + @test_util.run_deprecated_v1 def testInputDims(self): with self.assertRaises(ValueError): nn_ops.bias_add([1, 2], [1]) + @test_util.run_deprecated_v1 def testBiasVec(self): with self.assertRaises(ValueError): nn_ops.bias_add( @@ -101,6 +104,7 @@ class BiasAddTest(test.TestCase): array_ops.reshape( [1, 2], shape=[1, 2])) + @test_util.run_deprecated_v1 def testBiasInputsMatch(self): with self.assertRaises(ValueError): nn_ops.bias_add( @@ -109,23 +113,27 @@ class BiasAddTest(test.TestCase): array_ops.reshape( [1], shape=[1])) + @test_util.run_deprecated_v1 def testIntTypes(self): for t in [np.int8, np.int16, np.int32, np.int64]: self._testAll( np.array([[10, 20, 30], [40, 50, 60]]).astype(t), np.array([1, 2, 3]).astype(t)) + @test_util.run_deprecated_v1 def testFloatTypes(self): for t in [np.float16, np.float32, np.float64]: self._testAll( np.random.rand(4, 3, 3).astype(t), np.random.rand(3).astype(t)) + @test_util.run_deprecated_v1 def test4DFloatTypes(self): for t in [np.float16, np.float32, np.float64]: self._testAll( np.random.rand(4, 3, 2, 3).astype(t), np.random.rand(3).astype(t)) + @test_util.run_deprecated_v1 def test5DFloatTypes(self): for t in [np.float16, np.float32, np.float64]: self._testAll( @@ -187,6 +195,7 @@ class BiasAddTest(test.TestCase): self.assertAllClose(bias_jacob_t, bias_jacob_n, threshold, threshold) self.assertAllClose(grad_jacob_t, grad_jacob_n, threshold, threshold) + @test_util.run_deprecated_v1 def testGradientTensor(self): # TODO(yongtang): BiasAddGrad with NCHW only works 4D. Reenable once # all dimensions are supported. @@ -198,6 +207,7 @@ class BiasAddTest(test.TestCase): bias = np.array([1.3, 2.4], dtype=dtype.as_numpy_dtype) self._testGradient(np_input, bias, dtype, data_format, use_gpu) + @test_util.run_deprecated_v1 def testGradientTensor4D(self): # BiasAddGrad with NCHW support 4D so all are enabled. for (data_format, use_gpu) in [("NHWC", False), ("NHWC", True), @@ -209,11 +219,13 @@ class BiasAddTest(test.TestCase): bias = np.array([1.3, 2.4], dtype=dtype.as_numpy_dtype) self._testGradient(np_input, bias, dtype, data_format, use_gpu) + @test_util.run_deprecated_v1 def testEmpty(self): np.random.seed(7) for shape in (0, 0), (2, 0), (0, 2), (4, 3, 0), (4, 0, 3), (0, 4, 3): self._testAll(np.random.randn(*shape), np.random.randn(shape[-1])) + @test_util.run_deprecated_v1 def testEmptyGradient(self): # TODO(yongtang): BiasAddGrad with NCHW only works 4D. Reenable once # all dimensions are supported. diff --git a/tensorflow/python/kernel_tests/bincount_op_test.py b/tensorflow/python/kernel_tests/bincount_op_test.py index 49eb835847e..d064d736cf2 100644 --- a/tensorflow/python/kernel_tests/bincount_op_test.py +++ b/tensorflow/python/kernel_tests/bincount_op_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class BincountTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def test_empty(self): with self.session(use_gpu=True): self.assertAllEqual( @@ -43,6 +44,7 @@ class BincountTest(test_util.TensorFlowTestCase): math_ops.bincount([], minlength=3, dtype=np.float64).eval().dtype, np.float64) + @test_util.run_deprecated_v1 def test_values(self): with self.session(use_gpu=True): self.assertAllEqual( @@ -58,12 +60,14 @@ class BincountTest(test_util.TensorFlowTestCase): self.assertAllEqual( math_ops.bincount(np.arange(10000)).eval(), np.ones(10000)) + @test_util.run_deprecated_v1 def test_maxlength(self): with self.session(use_gpu=True): self.assertAllEqual(math_ops.bincount([5], maxlength=3).eval(), [0, 0, 0]) self.assertAllEqual(math_ops.bincount([1], maxlength=3).eval(), [0, 1]) self.assertAllEqual(math_ops.bincount([], maxlength=3).eval(), []) + @test_util.run_deprecated_v1 def test_random_with_weights(self): num_samples = 10000 with self.session(use_gpu=True): @@ -77,6 +81,7 @@ class BincountTest(test_util.TensorFlowTestCase): self.assertAllClose( math_ops.bincount(arr, weights).eval(), np.bincount(arr, weights)) + @test_util.run_deprecated_v1 def test_random_without_weights(self): num_samples = 10000 with self.session(use_gpu=True): @@ -87,6 +92,7 @@ class BincountTest(test_util.TensorFlowTestCase): self.assertAllClose( math_ops.bincount(arr, None).eval(), np.bincount(arr, weights)) + @test_util.run_deprecated_v1 def test_zero_weights(self): with self.session(use_gpu=True): self.assertAllEqual( @@ -99,6 +105,7 @@ class BincountTest(test_util.TensorFlowTestCase): with self.assertRaises(errors.InvalidArgumentError): math_ops.bincount([1, 2, 3, -1, 6, 8]).eval() + @test_util.run_deprecated_v1 def test_shape_function(self): # size must be scalar. with self.assertRaisesRegexp( diff --git a/tensorflow/python/kernel_tests/bitcast_op_test.py b/tensorflow/python/kernel_tests/bitcast_op_test.py index 5ceffcfeda3..b4f9a21a899 100644 --- a/tensorflow/python/kernel_tests/bitcast_op_test.py +++ b/tensorflow/python/kernel_tests/bitcast_op_test.py @@ -60,6 +60,7 @@ class BitcastTest(test.TestCase): shape = [3, 4] self._testBitcast(x, dtypes.int64, shape) + @test_util.run_deprecated_v1 def testErrors(self): x = np.zeros([1, 1], np.int8) datatype = dtypes.int32 @@ -72,6 +73,7 @@ class BitcastTest(test.TestCase): shape = [4] self._testBitcast(x, datatype, shape) + @test_util.run_deprecated_v1 def testUnknown(self): x = array_ops.placeholder(dtypes.float32) datatype = dtypes.int8 diff --git a/tensorflow/python/kernel_tests/boosted_trees/prediction_ops_test.py b/tensorflow/python/kernel_tests/boosted_trees/prediction_ops_test.py index 7cdc67f83f0..6b04e8abf40 100644 --- a/tensorflow/python/kernel_tests/boosted_trees/prediction_ops_test.py +++ b/tensorflow/python/kernel_tests/boosted_trees/prediction_ops_test.py @@ -28,6 +28,7 @@ from tensorflow.python.platform import googletest class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): """Tests prediction ops for training.""" + @test_util.run_deprecated_v1 def testCachedPredictionOnEmptyEnsemble(self): """Tests that prediction on a dummy ensemble does not fail.""" with self.cached_session() as session: @@ -61,6 +62,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(cached_node_ids, new_node_ids) self.assertAllClose([[0], [0]], logits_updates) + @test_util.run_deprecated_v1 def testNoCachedPredictionButTreeExists(self): """Tests that predictions are updated once trees are added.""" with self.cached_session() as session: @@ -127,6 +129,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): self.assertAllClose([2, 1], new_node_ids) self.assertAllClose([[0.1 * 8.79], [0.1 * 1.14]], logits_updates) + @test_util.run_deprecated_v1 def testCachedPredictionIsCurrent(self): """Tests that prediction based on previous node in the tree works.""" with self.cached_session() as session: @@ -199,6 +202,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(cached_node_ids, new_node_ids) self.assertAllClose([[0], [0]], logits_updates) + @test_util.run_deprecated_v1 def testCachedPredictionFromTheSameTree(self): """Tests that prediction based on previous node in the tree works.""" with self.cached_session() as session: @@ -313,6 +317,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): # 1.65 and -3.875, and then multiply them by 0.1 (lr) self.assertAllClose([[0.1 * 1.65], [0.1 * -3.875]], logits_updates) + @test_util.run_deprecated_v1 def testCachedPredictionFromPreviousTree(self): """Tests the predictions work when we have cache from previous trees.""" with self.cached_session() as session: @@ -445,6 +450,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): # change= 0.1(1.14+7.0-7.0) self.assertAllClose([[1], [0.114]], logits_updates) + @test_util.run_deprecated_v1 def testCategoricalSplits(self): """Tests the training prediction work for categorical splits.""" with self.cached_session() as session: @@ -517,6 +523,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): self.assertAllClose([3, 4, 2], new_node_ids) self.assertAllClose([[5.], [6.], [7.]], logits_updates) + @test_util.run_deprecated_v1 def testCachedPredictionFromTheSameTreeWithPostPrunedNodes(self): """Tests that prediction based on previous node in the tree works.""" with self.cached_session() as session: @@ -647,6 +654,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): self.assertAllClose([[0.01], [0.01], [0.0553], [0.0783], [0.01], [0.01]], logits_updates + cached_values) + @test_util.run_deprecated_v1 def testCachedPredictionFromThePreviousTreeWithPostPrunedNodes(self): """Tests that prediction based on previous node in the tree works.""" with self.cached_session() as session: @@ -792,6 +800,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): [root + 0.0783], [root + 0.01], [root + 0.01]], logits_updates + cached_values) + @test_util.run_deprecated_v1 def testCachedPredictionTheWholeTreeWasPruned(self): """Tests that prediction based on previous node in the tree works.""" with self.cached_session() as session: @@ -864,6 +873,7 @@ class TrainingPredictionOpsTest(test_util.TensorFlowTestCase): class PredictionOpsTest(test_util.TensorFlowTestCase): """Tests prediction ops for inference.""" + @test_util.run_deprecated_v1 def testPredictionOnEmptyEnsemble(self): """Tests that prediction on a empty ensemble does not fail.""" with self.cached_session() as session: @@ -886,6 +896,7 @@ class PredictionOpsTest(test_util.TensorFlowTestCase): logits = session.run(predict_op) self.assertAllClose(expected_logits, logits) + @test_util.run_deprecated_v1 def testPredictionMultipleTree(self): """Tests the predictions work when we have multiple trees.""" with self.cached_session() as session: @@ -996,6 +1007,7 @@ class PredictionOpsTest(test_util.TensorFlowTestCase): logits = session.run(predict_op) self.assertAllClose(expected_logits, logits) + @test_util.run_deprecated_v1 def testCategoricalSplits(self): """Tests the predictions work for categorical splits.""" with self.cached_session() as session: @@ -1062,6 +1074,7 @@ class PredictionOpsTest(test_util.TensorFlowTestCase): class FeatureContribsOpsTest(test_util.TensorFlowTestCase): """Tests feature contribs ops for model understanding.""" + @test_util.run_deprecated_v1 def testContribsForOnlyABiasNode(self): """Tests case when, after training, only left with a bias node. @@ -1122,6 +1135,7 @@ class FeatureContribsOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(feature_ids, expected_feature_ids) self.assertAllClose(logits_paths, expected_logits_paths) + @test_util.run_deprecated_v1 def testContribsMultipleTreeWhenFirstTreeIsABiasNode(self): """Tests case when, after training, first tree contains only a bias node.""" with self.cached_session() as session: @@ -1219,6 +1233,7 @@ class FeatureContribsOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(feature_ids, expected_feature_ids) self.assertAllClose(logits_paths, expected_logits_paths) + @test_util.run_deprecated_v1 def testContribsMultipleTree(self): """Tests that the contribs work when we have multiple trees.""" with self.cached_session() as session: diff --git a/tensorflow/python/kernel_tests/boosted_trees/quantile_ops_test.py b/tensorflow/python/kernel_tests/boosted_trees/quantile_ops_test.py index 1a7b1a7e90e..390672febeb 100644 --- a/tensorflow/python/kernel_tests/boosted_trees/quantile_ops_test.py +++ b/tensorflow/python/kernel_tests/boosted_trees/quantile_ops_test.py @@ -82,6 +82,7 @@ class QuantileOpsTest(test_util.TensorFlowTestCase): self.max_elements = 1 << 16 self.num_quantiles = constant_op.constant(3, dtype=dtypes.int64) + @test_util.run_deprecated_v1 def testBasicQuantileBucketsSingleResource(self): with self.cached_session() as sess: quantile_accumulator_handle = self.create_resource("floats", self.eps, @@ -106,6 +107,7 @@ class QuantileOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(self._feature_0_quantiles, quantiles[0].eval()) self.assertAllClose(self._feature_1_quantiles, quantiles[1].eval()) + @test_util.run_deprecated_v1 def testBasicQuantileBucketsMultipleResources(self): with self.cached_session() as sess: quantile_accumulator_handle_0 = self.create_resource("float_0", self.eps, @@ -140,6 +142,7 @@ class QuantileOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(self._feature_0_quantiles, quantiles[0].eval()) self.assertAllClose(self._feature_1_quantiles, quantiles[1].eval()) + @test_util.run_deprecated_v1 def testSaveRestoreAfterFlush(self): save_dir = os.path.join(self.get_temp_dir(), "save_restore") save_path = os.path.join(tempfile.mkdtemp(prefix=save_dir), "hash") @@ -172,6 +175,7 @@ class QuantileOpsTest(test_util.TensorFlowTestCase): self.assertAllClose(self._feature_0_boundaries, buckets[0].eval()) self.assertAllClose(self._feature_1_boundaries, buckets[1].eval()) + @test_util.run_deprecated_v1 def testSaveRestoreBeforeFlush(self): save_dir = os.path.join(self.get_temp_dir(), "save_restore") save_path = os.path.join(tempfile.mkdtemp(prefix=save_dir), "hash") diff --git a/tensorflow/python/kernel_tests/boosted_trees/resource_ops_test.py b/tensorflow/python/kernel_tests/boosted_trees/resource_ops_test.py index 493cad80f3c..0a34277bbdb 100644 --- a/tensorflow/python/kernel_tests/boosted_trees/resource_ops_test.py +++ b/tensorflow/python/kernel_tests/boosted_trees/resource_ops_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class ResourceOpsTest(test_util.TensorFlowTestCase): """Tests resource_ops.""" + @test_util.run_deprecated_v1 def testCreate(self): with self.cached_session(): ensemble = boosted_trees_ops.TreeEnsemble('ensemble') @@ -43,6 +44,7 @@ class ResourceOpsTest(test_util.TensorFlowTestCase): self.assertEqual(0, self.evaluate(num_attempted_layers)) self.assertAllEqual([0, 1], self.evaluate(nodes_range)) + @test_util.run_deprecated_v1 def testCreateWithProto(self): with self.cached_session(): ensemble_proto = boosted_trees_pb2.TreeEnsemble() @@ -160,6 +162,7 @@ class ResourceOpsTest(test_util.TensorFlowTestCase): self.assertEqual(6, self.evaluate(num_attempted_layers)) self.assertAllEqual([16, 19], self.evaluate(nodes_range)) + @test_util.run_deprecated_v1 def testSerializeDeserialize(self): with self.cached_session(): # Initialize. diff --git a/tensorflow/python/kernel_tests/boosted_trees/stats_ops_test.py b/tensorflow/python/kernel_tests/boosted_trees/stats_ops_test.py index e1036b0b754..e2e23486b5a 100644 --- a/tensorflow/python/kernel_tests/boosted_trees/stats_ops_test.py +++ b/tensorflow/python/kernel_tests/boosted_trees/stats_ops_test.py @@ -327,6 +327,7 @@ class StatsOpsTest(test_util.TensorFlowTestCase): max_splits=max_splits) self.assertAllEqual([[], []], self.evaluate(node_ids_list)) + @test_util.run_deprecated_v1 def testMakeStatsSummarySimple(self): """Simple test for MakeStatsSummary.""" with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/boosted_trees/training_ops_test.py b/tensorflow/python/kernel_tests/boosted_trees/training_ops_test.py index ea022820e44..afc0564fc5a 100644 --- a/tensorflow/python/kernel_tests/boosted_trees/training_ops_test.py +++ b/tensorflow/python/kernel_tests/boosted_trees/training_ops_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): """Tests for growing tree ensemble from split candidates.""" + @test_util.run_deprecated_v1 def testGrowWithEmptyEnsemble(self): """Test growing an empty ensemble.""" with self.cached_session() as session: @@ -139,6 +140,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testBiasCenteringOnEmptyEnsemble(self): """Test growing with bias centering on an empty ensemble.""" with self.cached_session() as session: @@ -182,6 +184,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testGrowExistingEnsembleTreeNotFinalized(self): """Test growing an existing ensemble with the last tree not finalized.""" with self.cached_session() as session: @@ -366,6 +369,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testGrowExistingEnsembleTreeFinalized(self): """Test growing an existing ensemble with the last tree finalized.""" with self.cached_session() as session: @@ -515,6 +519,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testPrePruning(self): """Test growing an existing ensemble with pre-pruning.""" with self.cached_session() as session: @@ -671,6 +676,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testMetadataWhenCantSplitDueToEmptySplits(self): """Test that the metadata is updated even though we can't split.""" with self.cached_session() as session: @@ -782,6 +788,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testMetadataWhenCantSplitDuePrePruning(self): """Test metadata is updated correctly when no split due to prepruning.""" with self.cached_session() as session: @@ -917,6 +924,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 1) self.assertProtoEquals(expected_result, tree_ensemble) + @test_util.run_deprecated_v1 def testPostPruningOfSomeNodes(self): """Test growing an ensemble with post-pruning.""" with self.cached_session() as session: @@ -1251,6 +1259,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): self.assertEqual(new_stamp, 3) self.assertProtoEquals(expected_result, res_ensemble) + @test_util.run_deprecated_v1 def testPostPruningOfAllNodes(self): """Test growing an ensemble with post-pruning, with all nodes are pruned.""" with self.cached_session() as session: @@ -1434,6 +1443,7 @@ class UpdateTreeEnsembleOpTest(test_util.TensorFlowTestCase): } """, res_ensemble) + @test_util.run_deprecated_v1 def testPostPruningChangesNothing(self): """Test growing an ensemble with post-pruning with all gains >0.""" with self.cached_session() as session: diff --git a/tensorflow/python/kernel_tests/broadcast_to_ops_test.py b/tensorflow/python/kernel_tests/broadcast_to_ops_test.py index 233c1664052..b9eb2391b49 100644 --- a/tensorflow/python/kernel_tests/broadcast_to_ops_test.py +++ b/tensorflow/python/kernel_tests/broadcast_to_ops_test.py @@ -29,6 +29,7 @@ from tensorflow.python.platform import test as test_lib class BroadcastToTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBroadcastToBasic(self): for dtype in [np.uint8, np.uint16, np.int8, np.int16, np.int32, np.int64]: with self.session(use_gpu=True): @@ -37,6 +38,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, [3, 3]) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastToString(self): with self.session(use_gpu=True): x = np.array([b"1", b"2", b"3"]) @@ -44,6 +46,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, [3, 3]) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastToBool(self): with self.session(use_gpu=True): x = np.array([True, False, True], dtype=np.bool) @@ -51,6 +54,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, [3, 3]) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastToShape(self): for input_dim in range(1, 6): for output_dim in range(input_dim, 6): @@ -62,6 +66,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, output_shape) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastToScalar(self): with self.session(use_gpu=True): x = np.array(1, dtype=np.int32) @@ -69,6 +74,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, [3, 3]) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastScalarToNonScalar(self): with self.session(use_gpu=True): x = np.array(1.0, dtype=np.float) @@ -76,6 +82,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): v_np = np.broadcast_to(x, [2, 3, 4]) self.assertAllEqual(v_tf.eval(), v_np) + @test_util.run_deprecated_v1 def testBroadcastToShapeTypeAndInference(self): for dtype in [dtypes.int32, dtypes.int64]: with self.cached_session(use_gpu=True): @@ -89,6 +96,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): # check shape inference when shape input is constant self.assertAllEqual(shape, v_np.shape) + @test_util.run_deprecated_v1 def testGradientForScalar(self): x = constant_op.constant(1, dtype=dtypes.float32) v = array_ops.broadcast_to(x, [2, 4, 3]) @@ -98,6 +106,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): out.get_shape()) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientWithSameRank(self): x = constant_op.constant(np.reshape(np.arange(6), (2, 1, 3)), dtype=dtypes.float32) @@ -108,6 +117,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): out, out.get_shape()) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientWithIncreasingRank(self): x = constant_op.constant([[1], [2]], dtype=dtypes.float32) @@ -118,6 +128,7 @@ class BroadcastToTest(test_util.TensorFlowTestCase): out, out.get_shape()) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientWithBroadcastAllDimensions(self): x = constant_op.constant([[1, 2, 3], [4, 5, 6]], dtype=dtypes.float32) v = array_ops.broadcast_to(x, [5, 4, 6]) diff --git a/tensorflow/python/kernel_tests/bucketize_op_test.py b/tensorflow/python/kernel_tests/bucketize_op_test.py index f40ca825270..95df6943705 100644 --- a/tensorflow/python/kernel_tests/bucketize_op_test.py +++ b/tensorflow/python/kernel_tests/bucketize_op_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -50,6 +51,7 @@ class BucketizationOpTest(test.TestCase): with self.session(use_gpu=True) as sess: self.assertAllEqual(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def testInvalidBoundariesOrder(self): op = math_ops._bucketize( constant_op.constant([-5, 0]), boundaries=[0, 8, 3, 11]) diff --git a/tensorflow/python/kernel_tests/candidate_sampler_ops_test.py b/tensorflow/python/kernel_tests/candidate_sampler_ops_test.py index 031accee553..fa6eb5c9689 100644 --- a/tensorflow/python/kernel_tests/candidate_sampler_ops_test.py +++ b/tensorflow/python/kernel_tests/candidate_sampler_ops_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import candidate_sampling_ops from tensorflow.python.ops import math_ops @@ -37,6 +38,7 @@ class RangeSamplerOpsTest(test.TestCase): TRUE_LABELS = [[1, 2], [0, 4], [3, 3]] + @test_util.run_deprecated_v1 def testTrueCandidates(self): with self.cached_session() as sess: indices = constant_op.constant([0, 0, 1, 1, 2, 2]) @@ -106,6 +108,7 @@ class RangeSamplerOpsTest(test.TestCase): self.assertTrue(id_ in self.TRUE_LABELS[index]) self.assertLess(weight, -1.0e37) + @test_util.run_deprecated_v1 def testSeed(self): def draw(seed): diff --git a/tensorflow/python/kernel_tests/cast_op_test.py b/tensorflow/python/kernel_tests/cast_op_test.py index 2cfe084d957..b3187e16371 100644 --- a/tensorflow/python/kernel_tests/cast_op_test.py +++ b/tensorflow/python/kernel_tests/cast_op_test.py @@ -25,6 +25,7 @@ import platform from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops @@ -90,10 +91,12 @@ class CastOpTest(test.TestCase): if x.dtype == np.float32 or x.dtype == np.float64: self._testTypes(x, use_gpu=True) + @test_util.run_deprecated_v1 def testBasic(self): self._testAll(np.arange(-10, 10).reshape(2, 10)) self._testAll(np.linspace(-10, 10, 17)) + @test_util.run_deprecated_v1 def testSmallValues(self): f4 = np.finfo(np.float32) f8 = np.finfo(np.float64) @@ -112,6 +115,7 @@ class CastOpTest(test.TestCase): b = math_ops.cast(math_ops.cast(a, dtypes.bfloat16), dtypes.float32) self.assertAllClose(a, self.evaluate(b), rtol=1 / 128.) + @test_util.run_deprecated_v1 def testRandom(self): self._testAll(np.random.normal(0, 10, 210).reshape([2, 3, 5, 7])) self._testAll(np.random.normal(0, 1e6, 210).reshape([2, 3, 5, 7])) @@ -124,6 +128,7 @@ class CastOpTest(test.TestCase): self._cast( x, dst_dtype, use_gpu=use_gpu), dst_dtype(expected)) + @test_util.run_deprecated_v1 def testIntToFloatBoundary(self): i4 = np.iinfo(np.int32) i8 = np.iinfo(np.int64) @@ -138,6 +143,7 @@ class CastOpTest(test.TestCase): self._compare(i8.max, np.float64, i8.max, False) # NOTE: GPU does not support int32/int64 for casting. + @test_util.run_deprecated_v1 def testInfNan(self): i4 = np.iinfo(np.int32) i8 = np.iinfo(np.int64) @@ -181,6 +187,7 @@ class CastOpTest(test.TestCase): def testNotImplemented(self): self._OpError(np.arange(0, 10), dtypes.string, "Cast.*int64.*string.*") + @test_util.run_deprecated_v1 def testCastToTypeOfVariable(self): with self.cached_session() as sess: x = variables.Variable(5, dtype=dtypes.float32) @@ -189,6 +196,7 @@ class CastOpTest(test.TestCase): variables.global_variables_initializer().run() self.assertEqual(1.0, self.evaluate(cast)) + @test_util.run_deprecated_v1 def testGradients(self): t = [dtypes.float32, dtypes.float64, dtypes.complex64, dtypes.complex128] for src_t in t: @@ -203,6 +211,7 @@ class CastOpTest(test.TestCase): class SparseTensorCastTest(test.TestCase): + @test_util.run_deprecated_v1 def testCast(self): indices = constant_op.constant([[0], [1], [2]], dtypes.int64) values = constant_op.constant(np.array([1, 2, 3], np.int64)) diff --git a/tensorflow/python/kernel_tests/check_ops_test.py b/tensorflow/python/kernel_tests/check_ops_test.py index 15124a19a27..95bac85027b 100644 --- a/tensorflow/python/kernel_tests/check_ops_test.py +++ b/tensorflow/python/kernel_tests/check_ops_test.py @@ -173,6 +173,7 @@ class AssertEqualTest(test.TestCase): assert x is None @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_greater(self): # Static check static_small = constant_op.constant([1, 2], name="small") @@ -180,6 +181,7 @@ class AssertEqualTest(test.TestCase): with self.assertRaisesRegexp(errors.InvalidArgumentError, "fail"): check_ops.assert_equal(static_big, static_small, message="fail") + @test_util.run_deprecated_v1 def test_raises_when_greater_dynamic(self): with self.cached_session(): small = array_ops.placeholder(dtypes.int32, name="small") @@ -251,6 +253,7 @@ First 2 elements of y: summarize=2) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_less(self): # Static check static_small = constant_op.constant([3, 1], name="small") @@ -258,6 +261,7 @@ First 2 elements of y: with self.assertRaisesRegexp(errors.InvalidArgumentError, "fail"): check_ops.assert_equal(static_big, static_small, message="fail") + @test_util.run_deprecated_v1 def test_raises_when_less_dynamic(self): with self.cached_session(): small = array_ops.placeholder(dtypes.int32, name="small") @@ -317,6 +321,7 @@ class AssertNoneEqualTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_equal(self): small = constant_op.constant([3, 1], name="small") with self.assertRaisesOpError("x != y did not hold"): @@ -506,6 +511,7 @@ class AssertAllCloseTest(test.TestCase): class AssertLessTest(test.TestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_equal(self): small = constant_op.constant([1, 2], name="small") with self.assertRaisesOpError("failure message.*\n*.* x < y did not hold"): @@ -516,6 +522,7 @@ class AssertLessTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_greater(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") @@ -582,6 +589,7 @@ class AssertLessEqualTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_greater(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") @@ -637,6 +645,7 @@ class AssertLessEqualTest(test.TestCase): class AssertGreaterTest(test.TestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_equal(self): small = constant_op.constant([1, 2], name="small") with self.assertRaisesOpError("fail"): @@ -647,6 +656,7 @@ class AssertGreaterTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_less(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") @@ -706,6 +716,7 @@ class AssertGreaterEqualTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_less(self): small = constant_op.constant([1, 2], name="small") big = constant_op.constant([3, 4], name="big") @@ -770,6 +781,7 @@ class AssertNegativeTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_positive(self): doug = constant_op.constant([1, 2], name="doug") with self.assertRaisesOpError("fail"): @@ -780,6 +792,7 @@ class AssertNegativeTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_zero(self): claire = constant_op.constant([0], name="claire") with self.assertRaisesOpError("x < 0 did not hold"): @@ -802,6 +815,7 @@ class AssertNegativeTest(test.TestCase): class AssertPositiveTest(test.TestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_negative(self): freddie = constant_op.constant([-1, -2], name="freddie") with self.assertRaisesOpError("fail"): @@ -819,6 +833,7 @@ class AssertPositiveTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_zero(self): meechum = constant_op.constant([0], name="meechum") with self.assertRaisesOpError("x > 0 did not hold"): @@ -841,26 +856,31 @@ class AssertPositiveTest(test.TestCase): class EnsureShapeTest(test.TestCase): # Static shape inference + @test_util.run_deprecated_v1 def testStaticShape(self): placeholder = array_ops.placeholder(dtypes.int32) ensure_shape_op = check_ops.ensure_shape(placeholder, (3, 3, 3)) self.assertEqual(ensure_shape_op.get_shape(), (3, 3, 3)) + @test_util.run_deprecated_v1 def testStaticShape_MergesShapes(self): placeholder = array_ops.placeholder(dtypes.int32, shape=(None, None, 3)) ensure_shape_op = check_ops.ensure_shape(placeholder, (5, 4, None)) self.assertEqual(ensure_shape_op.get_shape(), (5, 4, 3)) + @test_util.run_deprecated_v1 def testStaticShape_RaisesErrorWhenRankIncompatible(self): placeholder = array_ops.placeholder(dtypes.int32, shape=(None, None, 3)) with self.assertRaises(ValueError): check_ops.ensure_shape(placeholder, (2, 3)) + @test_util.run_deprecated_v1 def testStaticShape_RaisesErrorWhenDimIncompatible(self): placeholder = array_ops.placeholder(dtypes.int32, shape=(None, None, 3)) with self.assertRaises(ValueError): check_ops.ensure_shape(placeholder, (2, 2, 4)) + @test_util.run_deprecated_v1 def testStaticShape_CanSetUnknownShape(self): placeholder = array_ops.placeholder(dtypes.int32) derived = placeholder / 3 @@ -868,6 +888,7 @@ class EnsureShapeTest(test.TestCase): self.assertEqual(ensure_shape_op.get_shape(), None) # Dynamic shape check + @test_util.run_deprecated_v1 def testEnsuresDynamicShape_RaisesError(self): placeholder = array_ops.placeholder(dtypes.int32) derived = math_ops.divide(placeholder, 3, name="MyDivide") @@ -880,6 +901,7 @@ class EnsureShapeTest(test.TestCase): r"expected shape \[3,3,3\]."): sess.run(derived, feed_dict={placeholder: feed_val}) + @test_util.run_deprecated_v1 def testEnsuresDynamicShape_RaisesErrorDimUnknown(self): placeholder = array_ops.placeholder(dtypes.int32) derived = placeholder / 3 @@ -892,6 +914,7 @@ class EnsureShapeTest(test.TestCase): r"expected shape \[\?,\?,3\]."): sess.run(derived, feed_dict={placeholder: feed_val}) + @test_util.run_deprecated_v1 def testEnsuresDynamicShape(self): placeholder = array_ops.placeholder(dtypes.int32) derived = placeholder / 3 @@ -900,6 +923,7 @@ class EnsureShapeTest(test.TestCase): with self.cached_session() as sess: sess.run(derived, feed_dict={placeholder: feed_val}) + @test_util.run_deprecated_v1 def testEnsuresDynamicShape_WithUnknownDims(self): placeholder = array_ops.placeholder(dtypes.int32) derived = placeholder / 3 @@ -908,6 +932,7 @@ class EnsureShapeTest(test.TestCase): with self.cached_session() as sess: sess.run(derived, feed_dict={placeholder: feed_val}) + @test_util.run_deprecated_v1 def testGradient(self): placeholder = array_ops.placeholder(dtypes.float32) derived = check_ops.ensure_shape(placeholder, (None, None)) @@ -1003,6 +1028,7 @@ class AssertRankTest(test.TestCase): tensor, desired_rank, message="fail")]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1021,6 +1047,7 @@ class AssertRankTest(test.TestCase): [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1038,6 +1065,7 @@ class AssertRankTest(test.TestCase): [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_raises_if_rank_too_large_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1055,6 +1083,7 @@ class AssertRankTest(test.TestCase): [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1072,6 +1101,7 @@ class AssertRankTest(test.TestCase): [check_ops.assert_rank(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1087,6 +1117,7 @@ class AssertRankTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "Rank must be a scalar"): check_ops.assert_rank(tensor, np.array([], dtype=np.int32)) + @test_util.run_deprecated_v1 def test_raises_if_rank_is_not_scalar_dynamic(self): with self.cached_session(): tensor = constant_op.constant( @@ -1104,6 +1135,7 @@ class AssertRankTest(test.TestCase): "must be of type <dtype: 'int32'>"): check_ops.assert_rank(tensor, .5) + @test_util.run_deprecated_v1 def test_raises_if_rank_is_not_integer_dynamic(self): with self.cached_session(): tensor = constant_op.constant( @@ -1127,6 +1159,7 @@ class AssertRankInTest(test.TestCase): check_ops.assert_rank_in(tensor_rank0, (1, 2), message="fail")]): self.evaluate(array_ops.identity(tensor_rank0)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_raises_if_rank_mismatch_dynamic_rank(self): with self.cached_session(): tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1143,6 +1176,7 @@ class AssertRankInTest(test.TestCase): check_ops.assert_rank_in(tensor_rank0, desired_ranks)]): self.evaluate(array_ops.identity(tensor_rank0)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_doesnt_raise_if_rank_matches_dynamic_rank(self): with self.cached_session(): tensor_rank0 = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1159,6 +1193,7 @@ class AssertRankInTest(test.TestCase): check_ops.assert_rank_in(tensor_rank1, desired_ranks)]): self.evaluate(array_ops.identity(tensor_rank1)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_doesnt_raise_if_rank_matches_dynamic_rank(self): with self.cached_session(): tensor_rank1 = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1177,6 +1212,7 @@ class AssertRankInTest(test.TestCase): check_ops.assert_rank_in(tensor_rank1, (0, 2))]): self.evaluate(array_ops.identity(tensor_rank1)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_raises_if_rank_mismatches_dynamic_rank(self): with self.cached_session(): tensor_rank1 = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1196,6 +1232,7 @@ class AssertRankInTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "Rank must be a scalar"): check_ops.assert_rank_in(tensor, desired_ranks) + @test_util.run_deprecated_v1 def test_raises_if_rank_is_not_scalar_dynamic(self): with self.cached_session(): tensor = constant_op.constant( @@ -1218,6 +1255,7 @@ class AssertRankInTest(test.TestCase): "must be of type <dtype: 'int32'>"): check_ops.assert_rank_in(tensor, (1, .5,)) + @test_util.run_deprecated_v1 def test_raises_if_rank_is_not_integer_dynamic(self): with self.cached_session(): tensor = constant_op.constant( @@ -1241,6 +1279,7 @@ class AssertRankAtLeastTest(test.TestCase): [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1258,6 +1297,7 @@ class AssertRankAtLeastTest(test.TestCase): [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_zero_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1274,6 +1314,7 @@ class AssertRankAtLeastTest(test.TestCase): [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_ten_doesnt_raise_if_rank_too_large_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1290,6 +1331,7 @@ class AssertRankAtLeastTest(test.TestCase): [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_doesnt_raise_if_rank_just_right_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1307,6 +1349,7 @@ class AssertRankAtLeastTest(test.TestCase): [check_ops.assert_rank_at_least(tensor, desired_rank)]): self.evaluate(array_ops.identity(tensor)) + @test_util.run_deprecated_v1 def test_rank_one_tensor_raises_if_rank_too_small_dynamic_rank(self): with self.cached_session(): tensor = array_ops.placeholder(dtypes.float32, name="my_tensor") @@ -1320,6 +1363,7 @@ class AssertRankAtLeastTest(test.TestCase): class AssertNonNegativeTest(test.TestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_negative(self): zoe = constant_op.constant([-1, -2], name="zoe") with self.assertRaisesOpError("x >= 0 did not hold"): @@ -1356,6 +1400,7 @@ class AssertNonPositiveTest(test.TestCase): self.evaluate(out) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_raises_when_positive(self): rachel = constant_op.constant([0, 2], name="rachel") with self.assertRaisesOpError("x <= 0 did not hold"): diff --git a/tensorflow/python/kernel_tests/checkpoint_ops_test.py b/tensorflow/python/kernel_tests/checkpoint_ops_test.py index 213ac292d3e..b8c8c9edb5a 100644 --- a/tensorflow/python/kernel_tests/checkpoint_ops_test.py +++ b/tensorflow/python/kernel_tests/checkpoint_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_checkpoint_ops from tensorflow.python.ops import partitioned_variables from tensorflow.python.ops import variable_scope @@ -48,6 +49,7 @@ class GenerateVocabRemappingTest(test.TestCase): with open(self.old_vocab_file, 'w') as f: f.write('\n'.join(['knitting', 'eminem', 'MISSING']) + '\n') + @test_util.run_deprecated_v1 def test_generate_remapping_with_no_vocab_changes(self): """Tests where vocab does not change at all.""" remapping, num_present = gen_checkpoint_ops.generate_vocab_remapping( @@ -368,6 +370,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): np.reshape(initializing_values, (new_rows, num_cols)), self.evaluate(remapped_matrix)) + @test_util.run_deprecated_v1 def test_loading_rows_divisible_by_max_rows(self): """Tests loading normal var when rows are evenly divisible by max_rows.""" self._test_loading_variable_with_max_rows( @@ -376,6 +379,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): # 9 is evenly divisible by 3. max_rows_in_memory=3) + @test_util.run_deprecated_v1 def test_loading_rows_not_divisible_by_max_rows(self): """Tests loading normal var when rows aren't divisible by max_rows.""" self._test_loading_variable_with_max_rows( @@ -384,6 +388,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): # 9 is not evenly divisible by 4. max_rows_in_memory=4) + @test_util.run_deprecated_v1 def test_loading_rows_less_than_max_rows(self): """Tests loading normal var as a single slice. @@ -395,6 +400,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): # 10 > 9. max_rows_in_memory=10) + @test_util.run_deprecated_v1 def test_loading_no_max_rows(self): """Tests loading normal var as a single slice with no valid max_rows.""" self._test_loading_variable_with_max_rows( @@ -402,6 +408,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): partitioner=None, max_rows_in_memory=-1) + @test_util.run_deprecated_v1 def test_loading_partitions_equals_max_rows(self): """Tests loading partitioned var sliced on partition boundary.""" self._test_loading_variable_with_max_rows( @@ -411,6 +418,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): # exactly 3 rows. max_rows_in_memory=3) + @test_util.run_deprecated_v1 def test_loading_partitions_greater_than_max_rows(self): """Tests loading partitioned var with more slices than partitions.""" self._test_loading_variable_with_max_rows( @@ -420,6 +428,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): # row at a time. max_rows_in_memory=1) + @test_util.run_deprecated_v1 def test_loading_partitions_less_than_max_rows(self): """Tests loading partitioned var as a single slice. @@ -430,6 +439,7 @@ class LoadAndRemapMatrixWithMaxRowsTest(test.TestCase): partitioner=partitioned_variables.fixed_size_partitioner(3), max_rows_in_memory=10) + @test_util.run_deprecated_v1 def test_loading_partitions_no_max_rows(self): """Tests loading partitioned var as single slice with no valid max_rows.""" self._test_loading_variable_with_max_rows( diff --git a/tensorflow/python/kernel_tests/cholesky_op_test.py b/tensorflow/python/kernel_tests/cholesky_op_test.py index 1a509a43d1f..f3947236b1f 100644 --- a/tensorflow/python/kernel_tests/cholesky_op_test.py +++ b/tensorflow/python/kernel_tests/cholesky_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_linalg_ops @@ -145,6 +146,7 @@ class CholeskyOpTest(test.TestCase): matrices[i] = np.dot(matrices[i].T.conj(), matrices[i]) self._verifyCholesky(matrices) + @test_util.run_deprecated_v1 def testNonSquareMatrix(self): with self.assertRaises(ValueError): linalg_ops.cholesky(np.array([[1., 2., 3.], [3., 4., 5.]])) @@ -175,6 +177,7 @@ class CholeskyOpTest(test.TestCase): self._verifyCholesky(np.empty([0, 2, 2])) self._verifyCholesky(np.empty([2, 0, 0])) + @test_util.run_deprecated_v1 def testConcurrentExecutesWithoutError(self): with self.session(use_gpu=True) as sess: matrix1 = random_ops.random_normal([5, 5], seed=42) @@ -193,18 +196,21 @@ class CholeskyGradTest(test.TestCase): def getShapes(self, shapeList): return ((elem, int(np.floor(1.2 * elem))) for elem in shapeList) + @test_util.run_deprecated_v1 def testSmallMatrices(self): np.random.seed(0) shapes = self.getShapes([1, 2, 10]) self.runFiniteDifferences( shapes, dtypes=(dtypes_lib.float32, dtypes_lib.float64)) + @test_util.run_deprecated_v1 def testSmallMatricesComplex(self): np.random.seed(0) shapes = self.getShapes([1, 2, 10]) self.runFiniteDifferences( shapes, dtypes=(dtypes_lib.complex64, dtypes_lib.complex128)) + @test_util.run_deprecated_v1 def testOneBlockMatrices(self): np.random.seed(0) shapes = self.getShapes([self._backprop_block_size + 1]) @@ -213,12 +219,14 @@ class CholeskyGradTest(test.TestCase): dtypes=(dtypes_lib.float32, dtypes_lib.float64), scalarTest=True) + @test_util.run_deprecated_v1 def testTwoBlockMatrixFloat(self): np.random.seed(0) shapes = self.getShapes([2 * self._backprop_block_size + 1]) self.runFiniteDifferences( shapes, dtypes=(dtypes_lib.float32,), scalarTest=True) + @test_util.run_deprecated_v1 def testTwoBlockMatrixDouble(self): np.random.seed(0) shapes = self.getShapes([2 * self._backprop_block_size + 1]) @@ -231,6 +239,7 @@ class CholeskyGradTest(test.TestCase): self.runFiniteDifferences( shapes, dtypes=(dtypes_lib.complex64,), scalarTest=True) + @test_util.run_deprecated_v1 def testTwoBlockMatrixComplexDouble(self): np.random.seed(0) shapes = self.getShapes([2 * self._backprop_block_size + 1]) diff --git a/tensorflow/python/kernel_tests/clip_ops_test.py b/tensorflow/python/kernel_tests/clip_ops_test.py index 5f1b6b6917a..45f1e6152a2 100644 --- a/tensorflow/python/kernel_tests/clip_ops_test.py +++ b/tensorflow/python/kernel_tests/clip_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import clip_ops from tensorflow.python.ops import gradient_checker @@ -166,6 +167,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans, tf_ans) self.assertAllClose(np_ans, tf_ans_tensor) + @test_util.run_deprecated_v1 def testClipByNormGradientZeros(self): with self.session(use_gpu=True): x = array_ops.zeros([3]) @@ -242,6 +244,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans, tf_ans) # ClipByGlobalNorm tests + @test_util.run_deprecated_v1 def testClipByGlobalNormClipped(self): # Norm clipping when clip_norm < 5 with self.session(use_gpu=True): @@ -263,6 +266,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + @test_util.run_deprecated_v1 def testClipByGlobalNormClippedTensor(self): # Norm clipping when clip_norm < 5 with self.session(use_gpu=True): @@ -284,6 +288,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + @test_util.run_deprecated_v1 def testClipByGlobalNormSupportsNone(self): # Norm clipping when clip_norm < 5 with self.session(use_gpu=True): @@ -307,6 +312,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + @test_util.run_deprecated_v1 def testClipByGlobalNormWithIndexedSlicesClipped(self): # Norm clipping when clip_norm < 5 with self.session(use_gpu=True): @@ -340,6 +346,7 @@ class ClipTest(test.TestCase): self.assertEqual(dense_shape, slices.dense_shape) self.assertEqual(dense_shape, modified_slices.dense_shape) + @test_util.run_deprecated_v1 def testClipByGlobalNormNotClipped(self): # No norm clipping when clip_norm >= 5 with self.session(use_gpu=True): @@ -359,6 +366,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + @test_util.run_deprecated_v1 def testClipByGlobalNormZero(self): # No norm clipping when norm = 0 with self.session(use_gpu=True): @@ -378,6 +386,7 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + @test_util.run_deprecated_v1 def testClipByGlobalNormInf(self): with self.session(use_gpu=True): x0 = constant_op.constant([-2.0, 0.0, np.inf, 4.0, 0.0, 0.0], @@ -456,6 +465,7 @@ class ClipTest(test.TestCase): clip_by_norm_ans = self.evaluate(without_norm) self.assertAllClose(clip_by_average_norm_ans, clip_by_norm_ans) + @test_util.run_deprecated_v1 def testClipByValueEmptyTensor(self): # Test case for GitHub issue 19337 zero = array_ops.placeholder(dtype=dtypes.float32, shape=None) diff --git a/tensorflow/python/kernel_tests/concat_op_test.py b/tensorflow/python/kernel_tests/concat_op_test.py index 27137f76bd1..474760a93ff 100644 --- a/tensorflow/python/kernel_tests/concat_op_test.py +++ b/tensorflow/python/kernel_tests/concat_op_test.py @@ -35,6 +35,7 @@ from tensorflow.python.platform import test class ConcatOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testHStack(self): with self.session(use_gpu=True): p1 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) @@ -50,6 +51,7 @@ class ConcatOpTest(test.TestCase): self.assertAllEqual(result[:4, :], params[p1]) self.assertAllEqual(result[4:, :], params[p2]) + @test_util.run_deprecated_v1 def testVStack(self): with self.session(use_gpu=True): p1 = array_ops.placeholder(dtypes.float32, shape=[4, 4]) @@ -138,6 +140,7 @@ class ConcatOpTest(test.TestCase): else: self.assertAllClose(result[ind], params[p[i]], 0.01) + @test_util.run_deprecated_v1 def testRandom(self): self._testRandom(dtypes.bool) self._testRandom(dtypes.float32) @@ -148,6 +151,7 @@ class ConcatOpTest(test.TestCase): self._testRandom(dtypes.complex64) self._testRandom(dtypes.complex128) + @test_util.run_deprecated_v1 def testInvalidConcatDimTypeAndShape(self): a = variables.Variable(constant_op.constant(1.0, shape=[1])) b = variables.Variable(constant_op.constant(2.0, shape=[1])) @@ -199,10 +203,12 @@ class ConcatOpTest(test.TestCase): result = self.evaluate(concated_grad) self.assertAllEqual(result, grad_inp) + @test_util.run_deprecated_v1 def testGradientsSimple(self): self._testGradientsSimple(dtypes.float32) self._testGradientsSimple(dtypes.complex64) + @test_util.run_deprecated_v1 def testGradientsFirstDim(self): with test_util.use_gpu(): inp = [] @@ -227,6 +233,7 @@ class ConcatOpTest(test.TestCase): self.assertAllEqual(result, grad_inp) + @test_util.run_deprecated_v1 def testGradientsLastDim(self): # Test both positive and negative concat axis. # -1 and 2 correspond to the same axis for 3-dimensional tensors. @@ -284,10 +291,12 @@ class ConcatOpTest(test.TestCase): self.assertAllEqual(result, grad_inp) + @test_util.run_deprecated_v1 def testGradientsRandom(self): for _ in range(5): self._RunAndVerifyGradientsRandom() + @test_util.run_deprecated_v1 def testGradientWithUnknownInputDim(self): with self.session(use_gpu=True): x = array_ops.placeholder(dtypes.float32) @@ -309,6 +318,7 @@ class ConcatOpTest(test.TestCase): self.assertAllEqual(result, grad_inp) + @test_util.run_deprecated_v1 def testShapeError(self): # Rank doesn't match. with self.assertRaises(ValueError): @@ -338,6 +348,7 @@ class ConcatOpTest(test.TestCase): constant_op.constant(20.0, shape=[4, 4, 4]) ], -4) + @test_util.run_deprecated_v1 def testShapeWithUnknownConcatDim(self): p1 = array_ops.placeholder(dtypes.float32) c1 = constant_op.constant(10.0, shape=[4, 4, 4, 4]) @@ -356,6 +367,7 @@ class ConcatOpTest(test.TestCase): with self.assertRaises(ValueError): array_ops.concat([p1, c1, p2, c3], dim) + @test_util.run_deprecated_v1 def testZeroSize(self): # Verify that concat doesn't crash and burn for zero size inputs np.random.seed(7) @@ -377,6 +389,7 @@ class ConcatOpTest(test.TestCase): dxs = self.evaluate(gradients_impl.gradients(c, xs, dc)) self.assertAllEqual(dc, np.concatenate(dxs, axis=axis)) + @test_util.run_deprecated_v1 def testTensorConcatDim0Grad(self): x_shapes = [[20, 7, 3], [10, 7, 3], [14, 7, 3]] output_shape = [44, 7, 3] @@ -391,6 +404,7 @@ class ConcatOpTest(test.TestCase): output_shape) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testTensorConcatDim1Grad(self): x_shapes = [[20, 7, 3], [20, 3, 3], [20, 1, 3]] output_shape = [20, 11, 3] @@ -405,6 +419,7 @@ class ConcatOpTest(test.TestCase): output_shape) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testIndexedSlicesConcatDim0Grad(self): x_shapes = [[20, 7, 3], [10, 7, 3], [14, 7, 3]] output_shape = [4, 7, 3] @@ -420,6 +435,7 @@ class ConcatOpTest(test.TestCase): output_shape) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testIndexedSlicesConcatDim1Grad(self): x_shapes = [[20, 7, 3], [20, 3, 3], [20, 1, 3]] output_shape = [4, 11, 3] @@ -435,6 +451,7 @@ class ConcatOpTest(test.TestCase): output_shape) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testIndexedSlicesConcatDim2Grad(self): x_shapes = [[20, 7, 3], [20, 7, 1], [20, 7, 2]] output_shape = [4, 7, 6] @@ -450,6 +467,7 @@ class ConcatOpTest(test.TestCase): output_shape) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testIndexedSlicesConcatDim1Grad_UnknownInputDim(self): x_shapes = [[20, 7, 3], [20, 3, 3], [20, 1, 3]] output_shape = [4, 11, 3] @@ -479,6 +497,7 @@ class ConcatOpTest(test.TestCase): self.assertAllEqual( self.evaluate(concat_list_t), self.evaluate(concat_tuple_t)) + @test_util.run_deprecated_v1 def testConcatNoScalars(self): scalar = constant_op.constant(7) dim = array_ops.placeholder(dtypes.int32) @@ -488,6 +507,7 @@ class ConcatOpTest(test.TestCase): # important as gpu implementation could fail if # shared memory is not large for all the inputs + @test_util.run_deprecated_v1 def testConcatLargeNumberOfTensors(self): with self.session(use_gpu=True): for concat_dim in range(2): @@ -529,6 +549,7 @@ class ConcatOpTest(test.TestCase): output = gen_array_ops.concat_v2([t1, t2], 0) self.assertFalse(self.evaluate(output)) # Checks that output is empty + @test_util.run_deprecated_v1 def testConcatInvalidAxis(self): with self.assertRaises(ValueError): with test_util.use_gpu(): @@ -578,6 +599,7 @@ class ConcatOpTest(test.TestCase): result = concated_grad.eval(feed_dict=feed_dict) self.assertAllEqual(result, grad_inp) + @test_util.run_deprecated_v1 def testGradientsNegativeAxis(self): x1 = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] x2 = [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]] @@ -630,6 +652,7 @@ class ConcatOffsetTest(test.TestCase): ans = self.evaluate(off) self.assertAllEqual(ans, [[0, 0, 0], [0, 3, 0], [0, 10, 0]]) + @test_util.run_deprecated_v1 def testNotVector(self): cdim = constant_op.constant(1, dtypes.int32) s0 = constant_op.constant([[2, 3, 5]], dtypes.int32) @@ -639,6 +662,7 @@ class ConcatOffsetTest(test.TestCase): r"should be a vector"): self.evaluate(off) + @test_util.run_deprecated_v1 def testConcatDimOutOfRange(self): cdim = constant_op.constant(4, dtypes.int32) s0 = constant_op.constant([2, 3, 5], dtypes.int32) @@ -648,6 +672,7 @@ class ConcatOffsetTest(test.TestCase): r"Concat dim is out of range: 4 vs. 3"): self.evaluate(off) + @test_util.run_deprecated_v1 def testDimMismatch(self): cdim = constant_op.constant(1, dtypes.int32) s0 = constant_op.constant([2, 3, 5], dtypes.int32) @@ -657,6 +682,7 @@ class ConcatOffsetTest(test.TestCase): r"should contain 3 elem"): self.evaluate(off) + @test_util.run_deprecated_v1 def testSizeMismatch(self): cdim = constant_op.constant(1, dtypes.int32) s0 = constant_op.constant([2, 3, 5], dtypes.int32) diff --git a/tensorflow/python/kernel_tests/cond_v2_test.py b/tensorflow/python/kernel_tests/cond_v2_test.py index 4baa8b02124..1f4b37ce2a4 100644 --- a/tensorflow/python/kernel_tests/cond_v2_test.py +++ b/tensorflow/python/kernel_tests/cond_v2_test.py @@ -68,6 +68,7 @@ class CondV2Test(test.TestCase): self.assertEqual(expected_val, actual_val) self.assertEqual(expected_grad_val, actual_grad_val) + @test_util.run_deprecated_v1 def testBasic(self): x = constant_op.constant(1.0, name="x") y = constant_op.constant(2.0, name="y") @@ -82,6 +83,7 @@ class CondV2Test(test.TestCase): self._testCond(true_fn, false_fn, [x, y]) self._testCond(true_fn, false_fn, [y]) + @test_util.run_deprecated_v1 def testMultipleOutputs(self): x = constant_op.constant(1.0, name="x") y = constant_op.constant(3.0, name="y") @@ -96,6 +98,7 @@ class CondV2Test(test.TestCase): self._testCond(true_fn, false_fn, [x, y]) self._testCond(true_fn, false_fn, [y]) + @test_util.run_deprecated_v1 def testBasic2(self): x = constant_op.constant(1.0, name="x") y = constant_op.constant(2.0, name="y") @@ -110,6 +113,7 @@ class CondV2Test(test.TestCase): self._testCond(true_fn, false_fn, [x, y]) self._testCond(true_fn, false_fn, [y]) + @test_util.run_deprecated_v1 def testNoInputs(self): with self.cached_session() as sess: pred = array_ops.placeholder(dtypes.bool, name="pred") @@ -540,6 +544,7 @@ class CondV2Test(test.TestCase): pred_inner: False }), [5., 0.]) + @test_util.run_deprecated_v1 def testSecondDerivative(self): with self.cached_session() as sess: pred = array_ops.placeholder(dtypes.bool, name="pred") @@ -636,6 +641,7 @@ class CondV2Test(test.TestCase): self.assertFalse(if_found, "An `If` op was found, but it should be lowered.") + @test_util.run_deprecated_v1 def testLoweringDisabledInXLA(self): with self.session(graph=ops.Graph()) as sess: # Build the cond_v2 in an XLA context @@ -668,6 +674,7 @@ class CondV2Test(test.TestCase): if_found, "An `If` op was not found, but the graph should not be lowered.") + @test_util.run_deprecated_v1 def testLoweringDisabledWithSingleThreadedExecutorContext(self): with self.session(graph=ops.Graph()) as sess: @function.defun @@ -702,6 +709,7 @@ class CondV2Test(test.TestCase): self.assertEqual(self.evaluate(output[1]), 9.) @test_util.enable_control_flow_v2 + @test_util.run_deprecated_v1 def testRaisesOutputStructuresMismatch(self): x = constant_op.constant(1.0, name="x") y = constant_op.constant(3.0, name="y") diff --git a/tensorflow/python/kernel_tests/conditional_accumulator_test.py b/tensorflow/python/kernel_tests/conditional_accumulator_test.py index 7ee1a4bc327..5847e4639bb 100644 --- a/tensorflow/python/kernel_tests/conditional_accumulator_test.py +++ b/tensorflow/python/kernel_tests/conditional_accumulator_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import math_ops @@ -79,11 +80,13 @@ class ConditionalAccumulatorTest(test.TestCase): attr { key: 'reduction_type' value {s: 'MEAN'} } """, q.accumulator_ref.op.node_def) + @test_util.run_deprecated_v1 def testAccumulatorSizeEmpty(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator(dtypes_lib.float32, name="Q") self.assertEqual(q.num_accumulated().eval(), 0) + @test_util.run_deprecated_v1 def testAccumulatorSetGlobalStep(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -91,6 +94,7 @@ class ConditionalAccumulatorTest(test.TestCase): set_global_step_op = q.set_global_step(1) set_global_step_op.run() + @test_util.run_deprecated_v1 def testAccumulatorApplyGradFloat32(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -98,6 +102,7 @@ class ConditionalAccumulatorTest(test.TestCase): accum_op = q.apply_grad((10.0,)) accum_op.run() + @test_util.run_deprecated_v1 def testDtypes(self): with self.cached_session() as sess: dtypes = [dtypes_lib.float16, dtypes_lib.float32, dtypes_lib.float64] @@ -115,6 +120,7 @@ class ConditionalAccumulatorTest(test.TestCase): self.assertEqual(sum(elems) / len(elems), result) + @test_util.run_deprecated_v1 def testAccumulatorMultipleAccumulators(self): with self.cached_session(): q_f32_0 = data_flow_ops.ConditionalAccumulator( @@ -134,6 +140,7 @@ class ConditionalAccumulatorTest(test.TestCase): result = accums[i].take_grad(1).eval() self.assertEqual(result, i + 10.0) + @test_util.run_deprecated_v1 def testAccumulatorApplyAndTakeGradWithShape(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -155,6 +162,7 @@ class ConditionalAccumulatorTest(test.TestCase): is_all_equal &= (val[i][j] == elems_ave[i][j]) self.assertTrue(is_all_equal) + @test_util.run_deprecated_v1 def testAccumulatorApplyGradWithWrongShape(self): q = data_flow_ops.ConditionalAccumulator( dtypes_lib.float32, name="Q", shape=(3, 2)) @@ -165,6 +173,7 @@ class ConditionalAccumulatorTest(test.TestCase): with self.assertRaises(ValueError): q.apply_grad([[1.0], [2.0], [3.0]]) + @test_util.run_deprecated_v1 def testAccumulatorDynamicShape(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( @@ -190,6 +199,7 @@ class ConditionalAccumulatorTest(test.TestCase): is_all_equal &= (val[i][j] == elems_ave[i][j]) self.assertTrue(is_all_equal) + @test_util.run_deprecated_v1 def testAccumulatorWrongDynamicShape(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( @@ -208,6 +218,7 @@ class ConditionalAccumulatorTest(test.TestCase): with self.assertRaises(errors_impl.InvalidArgumentError): sess.run(accum_op, feed_dict={x: [[1.0], [2.0], [3.0]]}) + @test_util.run_deprecated_v1 def testAccumulatorSizeAfterApplyGrad(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -219,6 +230,7 @@ class ConditionalAccumulatorTest(test.TestCase): accum_op.run() self.assertEqual(q.num_accumulated().eval(), 2) + @test_util.run_deprecated_v1 def testAccumulatorSizeAfterApplyGradAndTakeGrad(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -247,6 +259,7 @@ class ConditionalAccumulatorTest(test.TestCase): extract_t.op.run() self.assertEqual(q.num_accumulated().eval(), 0) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradMean(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -271,6 +284,7 @@ class ConditionalAccumulatorTest(test.TestCase): val = self.evaluate(takeg_t) self.assertEqual(15.0, val) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradSum(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -298,6 +312,7 @@ class ConditionalAccumulatorTest(test.TestCase): val = self.evaluate(takeg_t) self.assertEqual(30.0, val) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradInvalidReductionType(self): with self.assertRaises(ValueError): data_flow_ops.ConditionalAccumulator( @@ -306,6 +321,7 @@ class ConditionalAccumulatorTest(test.TestCase): shape=tensor_shape.TensorShape([1]), reduction_type="Invalid") + @test_util.run_deprecated_v1 def testAccumulatorInvalidTakeGrad(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -321,6 +337,7 @@ class ConditionalAccumulatorTest(test.TestCase): with self.assertRaises(errors_impl.InvalidArgumentError): self.evaluate(takeg_t) + @test_util.run_deprecated_v1 def testAccumulatorRepeatedTakeGradMean(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -348,6 +365,7 @@ class ConditionalAccumulatorTest(test.TestCase): val = self.evaluate(takeg_t) self.assertEqual(elems_ave + 0.0, val) + @test_util.run_deprecated_v1 def testAccumulatorRepeatedTakeGradSum(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -378,6 +396,7 @@ class ConditionalAccumulatorTest(test.TestCase): val = self.evaluate(takeg_t) self.assertEqual(elems_sum, val) + @test_util.run_deprecated_v1 def testAccumulatorIncrementGlobalStep(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -394,6 +413,7 @@ class ConditionalAccumulatorTest(test.TestCase): set_global_step_op.run() self.evaluate(inc_global_step) + @test_util.run_deprecated_v1 def testAccumulatorSetGlobalStepPreventsAccumulation(self): with self.cached_session(): q = data_flow_ops.ConditionalAccumulator( @@ -415,6 +435,7 @@ class ConditionalAccumulatorTest(test.TestCase): if x >= ls) / sum(1 for x in local_steps if x >= ls), val) + @test_util.run_deprecated_v1 def testParallelApplyGrad(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( @@ -440,6 +461,7 @@ class ConditionalAccumulatorTest(test.TestCase): self.assertEqual(val, sum(elems) / len(elems)) + @test_util.run_deprecated_v1 def testParallelTakeGrad(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( @@ -472,6 +494,7 @@ class ConditionalAccumulatorTest(test.TestCase): self.assertItemsEqual(elems, results) + @test_util.run_deprecated_v1 def testAccumulatorApplyAndBlockingTake(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( @@ -505,6 +528,7 @@ class ConditionalAccumulatorTest(test.TestCase): with self.assertRaisesOpError("was cancelled"): self.evaluate(takeg_op) + @test_util.run_deprecated_v1 def testAccumulatorCancel(self): with self.cached_session() as sess: q = data_flow_ops.ConditionalAccumulator( diff --git a/tensorflow/python/kernel_tests/confusion_matrix_test.py b/tensorflow/python/kernel_tests/confusion_matrix_test.py index b001341c03d..ae13c8e32e5 100644 --- a/tensorflow/python/kernel_tests/confusion_matrix_test.py +++ b/tensorflow/python/kernel_tests/confusion_matrix_test.py @@ -71,9 +71,11 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix(labels=labels, predictions=predictions, truth=truth) + @test_util.run_deprecated_v1 def testInt32Basic(self): self._testBasic(dtype=np.int32) + @test_util.run_deprecated_v1 def testInt64Basic(self): self._testBasic(dtype=np.int64) @@ -111,9 +113,11 @@ class ConfusionMatrixTest(test.TestCase): self.assertEqual(cm_out.dtype, np_dtype) self.assertAllClose(cm_out, truth, atol=1e-10) + @test_util.run_deprecated_v1 def testOnTensors_int32(self): self._testConfMatrixOnTensors(dtypes.int32, np.int32) + @test_util.run_deprecated_v1 def testOnTensors_int64(self): self._testConfMatrixOnTensors(dtypes.int64, np.int64) @@ -133,9 +137,11 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix(labels=labels, predictions=predictions, truth=truth) + @test_util.run_deprecated_v1 def testInt32DifferentLabels(self, dtype=np.int32): self._testDifferentLabelsInPredictionAndTarget(dtype) + @test_util.run_deprecated_v1 def testInt64DifferentLabels(self, dtype=np.int64): self._testDifferentLabelsInPredictionAndTarget(dtype) @@ -155,12 +161,15 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix(labels=labels, predictions=predictions, truth=truth) + @test_util.run_deprecated_v1 def testInt32MultipleLabels(self, dtype=np.int32): self._testMultipleLabels(dtype) + @test_util.run_deprecated_v1 def testInt64MultipleLabels(self, dtype=np.int64): self._testMultipleLabels(dtype) + @test_util.run_deprecated_v1 def testWeighted(self): labels = np.arange(5, dtype=np.int32) predictions = np.arange(5, dtype=np.int32) @@ -177,6 +186,7 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix( labels=labels, predictions=predictions, weights=weights, truth=truth) + @test_util.run_deprecated_v1 def testLabelsTooLarge(self): labels = np.asarray([1, 1, 0, 3, 5], dtype=np.int32) predictions = np.asarray([2, 1, 0, 2, 2], dtype=np.int32) @@ -191,6 +201,7 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix( labels=labels, predictions=predictions, num_classes=3, truth=None) + @test_util.run_deprecated_v1 def testPredictionsTooLarge(self): labels = np.asarray([1, 1, 0, 2, 2], dtype=np.int32) predictions = np.asarray([2, 1, 0, 3, 5], dtype=np.int32) @@ -205,6 +216,7 @@ class ConfusionMatrixTest(test.TestCase): self._testConfMatrix( labels=labels, predictions=predictions, num_classes=3, truth=None) + @test_util.run_deprecated_v1 def testInvalidRank_predictionsTooBig(self): labels = np.asarray([1, 2, 3]) predictions = np.asarray([[1, 2, 3]]) @@ -212,6 +224,7 @@ class ConfusionMatrixTest(test.TestCase): confusion_matrix.confusion_matrix, predictions, labels) + @test_util.run_deprecated_v1 def testInvalidRank_predictionsTooSmall(self): labels = np.asarray([[1, 2, 3]]) predictions = np.asarray([1, 2, 3]) @@ -219,6 +232,7 @@ class ConfusionMatrixTest(test.TestCase): confusion_matrix.confusion_matrix, predictions, labels) + @test_util.run_deprecated_v1 def testInputDifferentSize(self): labels = np.asarray([1, 2]) predictions = np.asarray([1, 2, 3]) @@ -247,6 +261,7 @@ class ConfusionMatrixTest(test.TestCase): class RemoveSqueezableDimensionsTest(test.TestCase): + @test_util.run_deprecated_v1 def testBothScalarShape(self): label_values = 1.0 prediction_values = 0.0 @@ -272,6 +287,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSameShape(self): label_values = np.ones(shape=(2, 3, 1)) prediction_values = np.zeros_like(label_values) @@ -297,6 +313,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSameShapeExpectedRankDiff0(self): label_values = np.ones(shape=(2, 3, 1)) prediction_values = np.zeros_like(label_values) @@ -322,6 +339,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSqueezableLabels(self): label_values = np.ones(shape=(2, 3, 1)) prediction_values = np.zeros(shape=(2, 3)) @@ -348,6 +366,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSqueezableLabelsExpectedRankDiffPlus1(self): label_values = np.ones(shape=(2, 3, 1)) prediction_values = np.zeros(shape=(2, 3, 5)) @@ -374,6 +393,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSqueezablePredictions(self): label_values = np.ones(shape=(2, 3)) prediction_values = np.zeros(shape=(2, 3, 1)) @@ -402,6 +422,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): expected_prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testSqueezablePredictionsExpectedRankDiffMinus1(self): label_values = np.ones(shape=(2, 3, 5)) prediction_values = np.zeros(shape=(2, 3, 1)) @@ -430,6 +451,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): expected_prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testUnsqueezableLabels(self): label_values = np.ones(shape=(2, 3, 2)) prediction_values = np.zeros(shape=(2, 3)) @@ -455,6 +477,7 @@ class RemoveSqueezableDimensionsTest(test.TestCase): self.assertAllEqual( prediction_values, dynamic_predictions.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testUnsqueezablePredictions(self): label_values = np.ones(shape=(2, 3)) prediction_values = np.zeros(shape=(2, 3, 2)) diff --git a/tensorflow/python/kernel_tests/constant_op_test.py b/tensorflow/python/kernel_tests/constant_op_test.py index 9c3c96bd317..583082c2aa2 100644 --- a/tensorflow/python/kernel_tests/constant_op_test.py +++ b/tensorflow/python/kernel_tests/constant_op_test.py @@ -70,6 +70,7 @@ class ConstantTest(test.TestCase): with self.assertRaises(TypeError): constant_op.constant(dtypes_lib.string, "[,]") + @test_util.run_deprecated_v1 def testBFloat16(self): bfloat16 = dtypes_lib.bfloat16.as_numpy_dtype self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(bfloat16)) @@ -77,36 +78,42 @@ class ConstantTest(test.TestCase): np.random.normal(size=30).reshape([2, 3, 5]).astype(bfloat16)) self._testAll(np.empty((2, 0, 5)).astype(bfloat16)) + @test_util.run_deprecated_v1 def testHalf(self): self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(np.float16)) self._testAll( np.random.normal(size=30).reshape([2, 3, 5]).astype(np.float16)) self._testAll(np.empty((2, 0, 5)).astype(np.float16)) + @test_util.run_deprecated_v1 def testFloat(self): self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(np.float32)) self._testAll( np.random.normal(size=30).reshape([2, 3, 5]).astype(np.float32)) self._testAll(np.empty((2, 0, 5)).astype(np.float32)) + @test_util.run_deprecated_v1 def testDouble(self): self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(np.float64)) self._testAll( np.random.normal(size=30).reshape([2, 3, 5]).astype(np.float64)) self._testAll(np.empty((2, 0, 5)).astype(np.float64)) + @test_util.run_deprecated_v1 def testInt32(self): self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(np.int32)) self._testAll((100 * np.random.normal(size=30)).reshape([2, 3, 5]).astype( np.int32)) self._testAll(np.empty((2, 0, 5)).astype(np.int32)) + @test_util.run_deprecated_v1 def testInt64(self): self._testAll(np.arange(-15, 15).reshape([2, 3, 5]).astype(np.int64)) self._testAll((100 * np.random.normal(size=30)).reshape([2, 3, 5]).astype( np.int64)) self._testAll(np.empty((2, 0, 5)).astype(np.int64)) + @test_util.run_deprecated_v1 def testComplex64(self): self._testAll( np.complex(1, 2) * @@ -116,6 +123,7 @@ class ConstantTest(test.TestCase): np.random.normal(size=30).reshape([2, 3, 5]).astype(np.complex64)) self._testAll(np.empty((2, 0, 5)).astype(np.complex64)) + @test_util.run_deprecated_v1 def testComplex128(self): self._testAll( np.complex(1, 2) * @@ -125,12 +133,14 @@ class ConstantTest(test.TestCase): np.random.normal(size=30).reshape([2, 3, 5]).astype(np.complex128)) self._testAll(np.empty((2, 0, 5)).astype(np.complex128)) + @test_util.run_deprecated_v1 def testString(self): self._testCpu( np.array([compat.as_bytes(str(x)) for x in np.arange(-15, 15)]).reshape( [2, 3, 5])) self._testCpu(np.empty((2, 0, 5)).astype(np.str_)) + @test_util.run_deprecated_v1 def testVariant(self): # TODO(ebrevdo): Re-enable use_gpu=True once non-DMA Variant # copying between CPU and GPU is supported. @@ -161,6 +171,7 @@ class ConstantTest(test.TestCase): message="Variant storing an int, decoded const value:").op logging_const_op.run() + @test_util.run_deprecated_v1 def testStringWithNulls(self): with self.cached_session(): val = ops.convert_to_tensor(b"\0\0\0\0").eval() @@ -265,6 +276,7 @@ class ConstantTest(test.TestCase): "GraphDef cannot be larger than 2GB."): g.as_graph_def() + @test_util.run_deprecated_v1 def testSparseValuesRaiseErrors(self): with self.assertRaisesRegexp(ValueError, "setting an array element with a sequence"): @@ -342,6 +354,7 @@ class AsTensorTest(test.TestCase): ops.convert_to_tensor( tensor_shape.TensorShape([1, 2, 3]), dtype=dtypes_lib.float32) + @test_util.run_deprecated_v1 def testAsTensorForDimensionInput(self): with self.cached_session(): x = ops.convert_to_tensor(tensor_shape.TensorShape([1, 2, 3])[1]) @@ -409,6 +422,7 @@ class ZerosTest(test.TestCase): self.assertShapeEqual(np_ans, d) self.assertShapeEqual(np_ans, z) + @test_util.run_deprecated_v1 def testDtype(self): with self.cached_session(): d = array_ops.fill([2, 3], 12., name="fill") @@ -477,6 +491,7 @@ class ZerosLikeTest(test.TestCase): self.assertFalse(np.any(z_value)) self.assertEqual((2, 3), z_value.shape) + @test_util.run_deprecated_v1 def testZerosLikeCPU(self): for dtype in [ dtypes_lib.half, dtypes_lib.float32, dtypes_lib.float64, @@ -487,6 +502,7 @@ class ZerosLikeTest(test.TestCase): self._compareZeros(dtype, fully_defined_shape=False, use_gpu=False) self._compareZeros(dtype, fully_defined_shape=True, use_gpu=False) + @test_util.run_deprecated_v1 def testZerosLikeGPU(self): for dtype in [ dtypes_lib.half, dtypes_lib.float32, dtypes_lib.float64, @@ -496,11 +512,13 @@ class ZerosLikeTest(test.TestCase): self._compareZeros(dtype, fully_defined_shape=False, use_gpu=True) self._compareZeros(dtype, fully_defined_shape=True, use_gpu=True) + @test_util.run_deprecated_v1 def testZerosLikePartialShape(self): d = array_ops.placeholder(dtypes_lib.float32, shape=[None, 4, None]) z = array_ops.zeros_like(d) self.assertEqual(d.get_shape().as_list(), z.get_shape().as_list()) + @test_util.run_deprecated_v1 def testZerosLikeDtype(self): # Make sure zeros_like works even for dtypes that cannot be cast between with self.cached_session(): @@ -514,6 +532,7 @@ class ZerosLikeTest(test.TestCase): self.assertEqual(y.shape, shape) self.assertAllEqual(y, np.zeros(shape, dtype=out_type)) + @test_util.run_deprecated_v1 def testZerosLikeVariant(self): # TODO(ebrevdo): Re-enable use_gpu=True once non-DMA Variant # copying between CPU and GPU is supported AND we register a @@ -574,6 +593,7 @@ class OnesTest(test.TestCase): self.assertShapeEqual(np_ans, d) self.assertShapeEqual(np_ans, z) + @test_util.run_deprecated_v1 def testAutoPack(self): with self.cached_session(): h = array_ops.placeholder(dtypes_lib.int32, shape=[]) @@ -582,6 +602,7 @@ class OnesTest(test.TestCase): out = z.eval(feed_dict={h: 4, w: 16}) self.assertAllEqual(out, np.array([[1] * 16] * 4)) + @test_util.run_deprecated_v1 def testDtype(self): with self.cached_session(): d = array_ops.fill([2, 3], 12., name="fill") @@ -635,6 +656,7 @@ class OnesLikeTest(test.TestCase): self.assertTrue(np.array_equal(z_value, np.array([[1] * 3] * 2))) self.assertEqual([2, 3], z_var.get_shape()) + @test_util.run_deprecated_v1 def testOnesLikePartialShape(self): d = array_ops.placeholder(dtypes_lib.float32, shape=[None, 4, None]) z = array_ops.ones_like(d) @@ -679,12 +701,14 @@ class FillTest(test.TestCase): np_ans = np.array([[0.15 + 0.3j] * 3] * 2).astype(np.complex128) self._compareAll([2, 3], np_ans[0][0], np_ans) + @test_util.run_deprecated_v1 def testFillString(self): np_ans = np.array([[b"yolo"] * 3] * 2) with self.session(use_gpu=False): tf_ans = array_ops.fill([2, 3], np_ans[0][0], name="fill").eval() self.assertAllEqual(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testFillNegative(self): with self.cached_session(): for shape in (-1,), (2, -1), (-1, 2), (-2), (-3): @@ -698,6 +722,7 @@ class FillTest(test.TestCase): with self.assertRaises(errors_impl.InvalidArgumentError): fill_t.eval({dims: shape}) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): # Non-vector dimensions. with self.assertRaises(ValueError): @@ -716,6 +741,7 @@ class FillTest(test.TestCase): dtypes_lib.int32, shape=()), 17], 1.0) self.assertEqual([None, 17], f.get_shape().as_list()) + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): in_v = constant_op.constant(5.0) @@ -728,6 +754,7 @@ class FillTest(test.TestCase): class PlaceholderTest(test.TestCase): + @test_util.run_deprecated_v1 def testDtype(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=(10, 10), name="p") @@ -740,6 +767,7 @@ class PlaceholderTest(test.TestCase): "must feed a value for placeholder tensor 'p' with dtype float"): self.evaluate(p_identity) + @test_util.run_deprecated_v1 def testShape(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=(10, 10), name="p") @@ -757,6 +785,7 @@ class PlaceholderTest(test.TestCase): ValueError, lambda e: "Cannot feed value of shape" in str(e)): p_identity.eval(feed_dict={p: feed_array[:5, :5]}) + @test_util.run_deprecated_v1 def testUnknownShape(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=None, name="p") @@ -769,12 +798,14 @@ class PlaceholderTest(test.TestCase): self.assertAllClose( p_identity.eval(feed_dict={p: feed_array}), feed_array) + @test_util.run_deprecated_v1 def testScalarShape(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=[], name="p") p_identity = array_ops.identity(p) self.assertAllClose(p_identity.eval(feed_dict={p: 5}), 5) + @test_util.run_deprecated_v1 def testPartialShape(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=[None, 3], name="p") @@ -787,6 +818,7 @@ class PlaceholderTest(test.TestCase): ValueError, lambda e: "Cannot feed value of shape" in str(e)): p_identity.eval(feed_dict={p: feed_array[:5, :2]}) + @test_util.run_deprecated_v1 def testPartialShapeWhenNotFed(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.float32, shape=[None, 3], name="p") @@ -797,6 +829,7 @@ class PlaceholderTest(test.TestCase): "must feed a value for placeholder tensor 'p' with dtype float"): self.evaluate(p_identity) + @test_util.run_deprecated_v1 def testControlDependency(self): with self.cached_session(): p = array_ops.placeholder(dtypes_lib.int32, shape=[], name="p") @@ -806,10 +839,12 @@ class PlaceholderTest(test.TestCase): val = np.array(2).astype(np.int) self.assertEqual(10, d.eval(feed_dict={p: val})) + @test_util.run_deprecated_v1 def testBadShape(self): with self.assertRaises(ValueError): array_ops.placeholder(dtypes_lib.float32, shape=(-1, 10)) + @test_util.run_deprecated_v1 def testTensorStr(self): a = array_ops.placeholder(dtypes_lib.float32, shape=None, name="a") self.assertEqual("<tf.Tensor 'a:0' shape=<unknown> dtype=float32>", repr(a)) @@ -825,6 +860,7 @@ class PlaceholderTest(test.TestCase): self.assertEqual( "<tf.Tensor 'c:0' shape=(32, ?, 2) dtype=qint32>", repr(c)) + @test_util.run_deprecated_v1 def testOldGraph(self): # Load graph generated from earlier version of TF where # placeholder shape was not set. @@ -904,6 +940,7 @@ versions { class PlaceholderWithDefaultTest(test.TestCase): + @test_util.run_deprecated_v1 def testFullShape(self): with self.session(force_gpu=test_util.is_gpu_available()): p = array_ops.placeholder_with_default([[2, 2], [2, 2]], shape=[2, 2]) @@ -915,6 +952,7 @@ class PlaceholderWithDefaultTest(test.TestCase): with self.assertRaises(ValueError): a.eval(feed_dict={p: [[6, 6, 6], [6, 6, 6]]}) + @test_util.run_deprecated_v1 def testPartialShape(self): with self.session(force_gpu=test_util.is_gpu_available()): p = array_ops.placeholder_with_default([1, 2, 3], shape=[None]) @@ -925,6 +963,7 @@ class PlaceholderWithDefaultTest(test.TestCase): with self.assertRaises(ValueError): a.eval(feed_dict={p: [[2, 2], [2, 2]]}) + @test_util.run_deprecated_v1 def testNoShape(self): with self.session(force_gpu=test_util.is_gpu_available()): p = array_ops.placeholder_with_default([17], shape=None) @@ -934,6 +973,7 @@ class PlaceholderWithDefaultTest(test.TestCase): self.assertAllEqual( [[3, 3], [3, 3]], a.eval(feed_dict={p: [[3, 3], [3, 3]]})) + @test_util.run_deprecated_v1 def testGradient(self): with self.session(force_gpu=test_util.is_gpu_available()): x = array_ops.placeholder(dtypes_lib.float32, [5, 7]) diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 685d0438af2..f1efc5ce59d 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -141,6 +141,7 @@ class ControlFlowTest(test.TestCase): variables.global_variables_initializer().run() self.assertEqual(9, self.evaluate(v2)) + @test_util.run_deprecated_v1 def testRefEnter(self): with self.cached_session(): v = variables.VariableV1(7) @@ -154,6 +155,7 @@ class ControlFlowTest(test.TestCase): variables.global_variables_initializer().run() self.assertEqual(9, self.evaluate(v3)) + @test_util.run_deprecated_v1 def testRefSwitch(self): with self.cached_session(): v = variables.VariableV1(7) @@ -176,6 +178,7 @@ class ControlFlowTest(test.TestCase): result = self.evaluate(exit_op) self.assertAllEqual(np.array([x * 5 for x in [1, 2, 3, 4, 5, 6]]), result) + @test_util.run_deprecated_v1 def testEnterShapePropagation(self): with self.cached_session(): v = variables.Variable([0.0, 0.0], dtype=dtypes.float32) @@ -272,6 +275,7 @@ class ControlFlowTest(test.TestCase): result = self.evaluate(exit_n) self.assertAllEqual(10, result) + @test_util.run_deprecated_v1 def testLoop_1(self): with self.cached_session(): zero = constant_op.constant(0) @@ -333,6 +337,7 @@ class ControlFlowTest(test.TestCase): with self.assertRaisesOpError("has inputs from different frames"): res.eval(feed_dict={data: 1.0}) + @test_util.run_deprecated_v1 def testCondBool(self): values = constant_op.constant(10) fn1 = lambda: math_ops.add(values, 1) @@ -340,6 +345,7 @@ class ControlFlowTest(test.TestCase): with self.assertRaisesRegexp(TypeError, "must not be a Python bool"): _ = control_flow_ops.cond(False, fn1, fn2) + @test_util.run_deprecated_v1 def testCondInt(self): p = array_ops.placeholder(dtypes.bool, shape=[]) v = constant_op.constant(10) @@ -627,6 +633,7 @@ class ControlFlowTest(test.TestCase): test_result = self.evaluate(r) self.assertDictEqual({"a": 210, "b": 210}, test_result) + @test_util.run_deprecated_v1 def testEmbeddedListOutput(self): with self.cached_session() as sess: x = constant_op.constant(10) @@ -678,6 +685,7 @@ class ControlFlowTest(test.TestCase): r = control_flow_ops.cond(pred, fn1, fn2) self.evaluate(r) + @test_util.run_deprecated_v1 def testCondRef(self): with self.cached_session(): @@ -693,6 +701,7 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual([2.0], self.evaluate(r)) @test_util.disable_control_flow_v2("b/79881896 (control deps)") + @test_util.run_deprecated_v1 def testCondWithControl(self): with self.cached_session(): control_holder = array_ops.placeholder(dtypes.float32, shape=()) @@ -773,6 +782,7 @@ class ControlFlowTest(test.TestCase): grad = gradients_impl.gradients(r, [x])[0] self.assertAllEqual(1.0, self.evaluate(grad)) + @test_util.run_deprecated_v1 def testCondGrad_2(self): with self.cached_session(): c = array_ops.placeholder(dtypes.int32, shape=[]) @@ -788,6 +798,7 @@ class ControlFlowTest(test.TestCase): @test_util.disable_control_flow_v2( "b/110550782 (gradient w.r.t external variable)") + @test_util.run_deprecated_v1 def testCondGrad_3(self): with self.cached_session(): c = array_ops.placeholder(dtypes.int32, shape=[]) @@ -805,6 +816,7 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(980.0, r.eval(feed_dict={c: 1})) self.assertAllEqual(30.0, r.eval(feed_dict={c: 3})) + @test_util.run_deprecated_v1 def testCondGradMultiDevice(self): config = config_pb2.ConfigProto(device_count={"CPU": 2}, allow_soft_placement=True) @@ -849,6 +861,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual(1.0, self.evaluate(result)) @test_util.disable_control_flow_v2("b/113327884") + @test_util.run_deprecated_v1 def testCondGrad_Gather(self): with self.cached_session() as sess: v1 = variables.Variable([1.0, 42.0]) @@ -1030,6 +1043,7 @@ class ControlFlowTest(test.TestCase): self.assertAllEqual(v.eval(), 1.0) @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileWithRefs_1(self): with self.cached_session() as sess: x = variables.VariableV1(0)._ref() # pylint: disable=protected-access @@ -1269,6 +1283,7 @@ class ControlFlowTest(test.TestCase): # Have more than 10 parallel iterations and hence exercise k-bound # most of the time. + @test_util.run_deprecated_v1 def testWhile_3(self): with self.cached_session(): @@ -1289,6 +1304,7 @@ class ControlFlowTest(test.TestCase): result = r[3].eval() self.assertAllEqual(10100, result) + @test_util.run_deprecated_v1 def testWhile_4(self): with self.cached_session(): @@ -1402,6 +1418,7 @@ class ControlFlowTest(test.TestCase): r = r[1] * array_ops.ones([8, 8]) self.assertAllEqual(np.ones((8, 8)), self.evaluate(r)) + @test_util.run_deprecated_v1 def testWhileWithNonTensorInput_Scalar(self): with self.cached_session(): n = 0 @@ -1476,6 +1493,7 @@ class ControlFlowTest(test.TestCase): [i.get_shape(), tensor_shape.TensorShape([5])]) @test_util.disable_control_flow_v2("b/116282023 (IndexedSlices)") + @test_util.run_deprecated_v1 def testWhileShapeInferenceIndexedSlices(self): with self.cached_session(): values = constant_op.constant([[2.0, 4.0], [3.0, 5.0]], name="values") @@ -1582,6 +1600,7 @@ class ControlFlowTest(test.TestCase): condition, body, [n, r], parallel_iterations=1) self.assertAllEqual(12, res[1].eval()) + @test_util.run_deprecated_v1 def testWhileWithControl_2(self): with self.cached_session(): r = constant_op.constant(0) @@ -1736,6 +1755,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual([2.0], sess.run(r1, {p: False})) @test_util.disable_control_flow_v2("b/116743589") + @test_util.run_deprecated_v1 def testCondWhile_3(self): self._testCondWhile_3(use_gpu=False) self._testCondWhile_3(use_gpu=True) @@ -1779,6 +1799,7 @@ class ControlFlowTest(test.TestCase): r = control_flow_ops.while_loop(c, b, [n]) self.assertAllEqual(10, self.evaluate(r)) + @test_util.run_deprecated_v1 def testWhileCondGradMultiDevice(self): config = config_pb2.ConfigProto(device_count={"CPU": 2}, allow_soft_placement=True) @@ -1810,6 +1831,7 @@ class ControlFlowTest(test.TestCase): # NOTE: It is ok to have parallel_iterations > 1 @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileUpdateVariable_1(self): with self.cached_session(): select = variables.Variable([3.0, 4.0, 5.0]) @@ -1860,6 +1882,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(np.array([10.0, 10.0, 10.0]), result2) @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileUpdateVariable_3(self): with self.cached_session(): select = variables.Variable([3.0, 4.0, 5.0]) @@ -1882,6 +1905,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(np.array([10.0, 10.0, 10.0]), result) @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileUpdateVariable_4(self): with self.cached_session(): var_a = variables.Variable(0, name="a") @@ -1910,6 +1934,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual(10, self.evaluate(var_b)) @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileUpdateVariable_5(self): with self.cached_session(): # Create some variables. @@ -2089,6 +2114,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual([None], r.get_shape().as_list()) self.assertAllClose([810.0, 2560.0], r.eval(feed_dict={x: [3.0, 4.0]})) + @test_util.run_deprecated_v1 def testWhileGrad_BaseShape(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32, [None]) @@ -2137,6 +2163,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(81.0, grad_v_val) @test_util.disable_control_flow_v2("b/116630618 (parallel_iters: times out)") + @test_util.run_deprecated_v1 def testWhileGrad_Mul(self): self._testWhileGrad_Mul(use_gpu=False, p_iters=1) self._testWhileGrad_Mul(use_gpu=False, p_iters=10) @@ -2166,9 +2193,11 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients(r, v)[0] self.assertAllClose(512.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testNestedWhileCondWhileGrad(self): self._testNestedWhileCondWhileGrad(use_gpu=False) + @test_util.run_deprecated_v1 def testNestedWhileCondWhileGradGpu(self): self._testNestedWhileCondWhileGrad(use_gpu=True) @@ -2184,6 +2213,7 @@ class ControlFlowTest(test.TestCase): variables.global_variables_initializer().run() self.assertAllClose(216.0, r[0].eval()) + @test_util.run_deprecated_v1 def testWhileGrad_ResourceVariable(self): with self.cached_session(): a = resource_variable_ops.ResourceVariable(3.0) @@ -2213,6 +2243,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(9.0, r.eval(feed_dict={x: 1.0})) @test_util.disable_control_flow_v2("b/116340060") + @test_util.run_deprecated_v1 def testGradInWhileWrtInitialLoopVal(self): with self.cached_session(): x = array_ops.placeholder(dtypes.float32, shape=(), name="x") @@ -2330,6 +2361,7 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients([rx], y) self.assertAllClose(120.0, r[0].eval()) + @test_util.run_deprecated_v1 def testWhileGrad_Dependency(self): with self.cached_session(): i = constant_op.constant(0, name="i") @@ -2381,6 +2413,7 @@ class ControlFlowTest(test.TestCase): variables.global_variables_initializer().run() self.assertAllClose(np.ones([2, 3]), sess.run(grad[0])) + @test_util.run_deprecated_v1 def testWhileGrad_Const(self): with self.cached_session() as sess: c0 = constant_op.constant(0.0, name="c0") @@ -2475,6 +2508,7 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients(r, v)[0] self.assertAllClose(8.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testNestedWhileGrad_Simple(self): self._testNestedWhileGrad_Simple(use_gpu=False) self._testNestedWhileGrad_Simple(use_gpu=True) @@ -2502,6 +2536,7 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients(r, v)[0] self.assertAllClose(256.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testNestedWhileGrad_ParallelInner(self): with self.cached_session(): v = constant_op.constant(1.0) @@ -2564,11 +2599,13 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(1024.0, self.evaluate(r)) @test_util.disable_control_flow_v2("b/117519152") + @test_util.run_deprecated_v1 def testWhileCondGrad_Simple(self): self._testWhileCondGrad_Simple(use_gpu=False) self._testWhileCondGrad_Simple(use_gpu=True) @test_util.disable_control_flow_v2("b/117276490") + @test_util.run_deprecated_v1 def testWhileCondGrad_UnknownShape(self): with self.cached_session() as sess: v = array_ops.placeholder(dtypes.float32) @@ -2586,6 +2623,7 @@ class ControlFlowTest(test.TestCase): r = sess.run(r, feed_dict={v: 2.0}) self.assertAllClose(1024.0, r) + @test_util.run_deprecated_v1 def testWhileGrad_Concat(self): with self.cached_session() as sess: x = variable_scope.get_variable("x", initializer=[[1., 2.]]) @@ -2661,6 +2699,7 @@ class ControlFlowTest(test.TestCase): self.assertAllClose(np.array([1024.0, 1024.0]), self.evaluate(r)) @test_util.disable_control_flow_v2("b/116328420 (SparseTensor)") + @test_util.run_deprecated_v1 def testWhileGrad_SparseTensor(self): with self.cached_session(): values = constant_op.constant([2.0, 4.0], name="values") @@ -2703,6 +2742,7 @@ class ControlFlowTest(test.TestCase): c, b, [i0, constant_op.constant(0.0)]) self.assertAllClose(600.0, self.evaluate(output_grad)[1]) + @test_util.run_deprecated_v1 def testWhileAndTensorArray(self): with self.cached_session() as sess: param = constant_op.constant(2.0) @@ -2722,6 +2762,7 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients(r, param)[0] self.assertAllClose(107520.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testWhileGrad_StopGrad(self): with self.cached_session(): x = constant_op.constant(3.0, name="x") @@ -2765,6 +2806,7 @@ class ControlFlowTest(test.TestCase): math_ops.add(array_ops.stop_gradient(rx), ry), y)[0] self.assertEqual(32.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testWhileGrad_StopGradInside(self): with self.cached_session(): x = constant_op.constant(3.0, name="x") @@ -2784,6 +2826,7 @@ class ControlFlowTest(test.TestCase): r = gradients_impl.gradients(rx, x)[0] self.assertAllClose(156.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testWhileGrad_StopGradInsideNoShape(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32) @@ -2808,6 +2851,7 @@ class ControlFlowTest(test.TestCase): self.assertFalse(any(name in op.name for op in all_ops)) @test_util.disable_control_flow_v2("b/117954949") + @test_util.run_deprecated_v1 def testWhileGradGradFail(self): theta = variables.Variable(initial_value=1.) @@ -2822,6 +2866,7 @@ class ControlFlowTest(test.TestCase): grad_theta_stopped = array_ops.stop_gradient(grad_theta) gradients_impl.gradients(grad_theta_stopped, theta) + @test_util.run_deprecated_v1 def testStopGradOnWhileGrad(self): with self.cached_session(): x = constant_op.constant(2.0, name="x") @@ -2839,6 +2884,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual(388.0, self.evaluate(r)) @test_util.disable_control_flow_v2("b/113324949 (RefVariable)") + @test_util.run_deprecated_v1 def testWhileGradientWithNontrainablePath1(self): q = variables.Variable([7., 8.]) @@ -2940,6 +2986,7 @@ class ControlFlowTest(test.TestCase): # False case: c = 0 is not >= 1 self.assertEqual([2], i.eval(feed_dict={c: 0})) + @test_util.run_deprecated_v1 def testExampleCond(self): with self.cached_session(): @@ -3191,6 +3238,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual(op.type, "NoOp") self.assertEqual(op.control_inputs, []) + @test_util.run_deprecated_v1 def testMergeShapes(self): # All inputs unknown. p1 = array_ops.placeholder(dtypes.float32) @@ -3245,6 +3293,7 @@ class ControlFlowTest(test.TestCase): self.assertEqual([None, None], m.get_shape().as_list()) self.assertEqual([], index.get_shape()) + @test_util.run_deprecated_v1 def testRefSelect(self): index = array_ops.placeholder(dtypes.int32) @@ -3278,6 +3327,7 @@ class ControlFlowTest(test.TestCase): s = control_flow_ops.ref_select(index, [v1, v2]) self.assertEqual(None, s.get_shape()) + @test_util.run_deprecated_v1 def testRunLoopTensor(self): with self.cached_session() as sess: tensor_list = [] @@ -3364,6 +3414,7 @@ class ControlFlowTest(test.TestCase): result = control_flow_ops.merge([v_f, v_t]) self.evaluate(result) + @test_util.run_deprecated_v1 def testQIntArgAndRet(self): @function.Defun(dtypes.qint8) @@ -3411,6 +3462,7 @@ class ControlFlowContextCheckTest(test.TestCase): "is in a while loop. See info log for more details."): math_ops.add(1, while_tensor) + @test_util.run_deprecated_v1 def testInvalidContextInCond(self): # Accessing a while loop tensor in cond is illegal. while_tensor = self._getWhileTensor() @@ -3479,6 +3531,7 @@ class ControlFlowContextCheckTest(test.TestCase): control_flow_ops.while_loop(lambda i: i < 5, body, [0]) + @test_util.run_deprecated_v1 def testInvalidNestedContexts(self): # Accessing a tensor from a while context in a different while context, all # inside a cond context, is illegal. @@ -3527,6 +3580,7 @@ class TupleTest(test.TestCase): self.assertAllClose([30.0], self.evaluate(t2)) self.assertAllClose([1.0], self.evaluate(v1)) + @test_util.run_deprecated_v1 def testIndexedSlices(self): for v1_first in [True, False]: with self.cached_session(): @@ -3582,6 +3636,7 @@ class TupleTest(test.TestCase): class AssertTest(test.TestCase): + @test_util.run_deprecated_v1 def testGuardedAssertDoesNotCopyWhenTrue(self): with self.session(use_gpu=True) as sess: with ops.device(test.gpu_device_name()): diff --git a/tensorflow/python/kernel_tests/conv2d_backprop_filter_grad_test.py b/tensorflow/python/kernel_tests/conv2d_backprop_filter_grad_test.py index af6ffc1d195..7b3b560b240 100644 --- a/tensorflow/python/kernel_tests/conv2d_backprop_filter_grad_test.py +++ b/tensorflow/python/kernel_tests/conv2d_backprop_filter_grad_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops @@ -31,6 +32,7 @@ from tensorflow.python.platform import test class Conv2DBackpropFilterGradTest(test.TestCase): + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): for padding in ["SAME", "VALID"]: diff --git a/tensorflow/python/kernel_tests/conv2d_transpose_test.py b/tensorflow/python/kernel_tests/conv2d_transpose_test.py index d9aa4ab9672..c603c086306 100644 --- a/tensorflow/python/kernel_tests/conv2d_transpose_test.py +++ b/tensorflow/python/kernel_tests/conv2d_transpose_test.py @@ -23,6 +23,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops @@ -154,6 +155,7 @@ class Conv2DTransposeTest(test.TestCase): self.assertAllClose(cache_values, value) + @test_util.run_deprecated_v1 def testGradient(self): x_shape = [2, 6, 4, 3] f_shape = [3, 3, 2, 3] diff --git a/tensorflow/python/kernel_tests/conv3d_backprop_filter_v2_grad_test.py b/tensorflow/python/kernel_tests/conv3d_backprop_filter_v2_grad_test.py index 89b64068ace..7e913febed3 100644 --- a/tensorflow/python/kernel_tests/conv3d_backprop_filter_v2_grad_test.py +++ b/tensorflow/python/kernel_tests/conv3d_backprop_filter_v2_grad_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops @@ -31,6 +32,7 @@ from tensorflow.python.platform import test class Conv3DBackpropFilterV2GradTest(test.TestCase): + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): for padding in ["SAME", "VALID"]: diff --git a/tensorflow/python/kernel_tests/conv3d_transpose_test.py b/tensorflow/python/kernel_tests/conv3d_transpose_test.py index d4e7ec14da3..22ba5b90375 100644 --- a/tensorflow/python/kernel_tests/conv3d_transpose_test.py +++ b/tensorflow/python/kernel_tests/conv3d_transpose_test.py @@ -23,6 +23,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import @@ -119,6 +120,7 @@ class Conv3DTransposeTest(test.TestCase): target = 3.0 self.assertAllClose(target, value[n, d, h, w, k]) + @test_util.run_deprecated_v1 def testConv3DTransposeShapeMismatch(self): # Test case for GitHub issue 18460 x_shape = [2, 2, 3, 4, 3] @@ -201,6 +203,7 @@ class Conv3DTransposeTest(test.TestCase): self.assertAllClose(cache_values, value) + @test_util.run_deprecated_v1 def testGradient(self): x_shape = [2, 3, 4, 3, 2] f_shape = [3, 3, 3, 2, 2] diff --git a/tensorflow/python/kernel_tests/conv_ops_3d_test.py b/tensorflow/python/kernel_tests/conv_ops_3d_test.py index 3ec5c29df7d..4a689b3fdfa 100644 --- a/tensorflow/python/kernel_tests/conv_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/conv_ops_3d_test.py @@ -462,6 +462,7 @@ class Conv3DTest(test.TestCase): self._ConstructAndTestGradientForConfig(data_format=data_format, use_gpu=use_gpu, **kwargs) + @test_util.run_deprecated_v1 def testInputGradientValidPaddingStrideOne(self): self.ConstructAndTestGradient( batch=2, @@ -473,6 +474,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientValidPaddingStrideOne(self): self.ConstructAndTestGradient( batch=4, @@ -484,6 +486,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientValidPaddingStrideTwo(self): self.ConstructAndTestGradient( batch=2, @@ -495,6 +498,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientValidPaddingStrideTwo(self): self.ConstructAndTestGradient( batch=2, @@ -506,6 +510,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientValidPaddingStrideThree(self): self.ConstructAndTestGradient( batch=2, @@ -517,6 +522,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientValidPaddingStrideThree(self): self.ConstructAndTestGradient( batch=2, @@ -528,6 +534,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientSamePaddingStrideOne(self): self.ConstructAndTestGradient( batch=2, @@ -539,6 +546,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientSamePaddingStrideOne(self): self.ConstructAndTestGradient( batch=2, @@ -550,6 +558,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientSamePaddingStrideTwo(self): self.ConstructAndTestGradient( batch=2, @@ -561,6 +570,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientSamePaddingStrideTwo(self): self.ConstructAndTestGradient( batch=4, @@ -572,6 +582,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientSamePaddingStrideThree(self): self.ConstructAndTestGradient( batch=2, @@ -583,6 +594,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientSamePaddingStrideThree(self): self.ConstructAndTestGradient( batch=2, @@ -594,6 +606,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientSamePaddingDifferentStrides(self): self.ConstructAndTestGradient( batch=1, @@ -605,6 +618,7 @@ class Conv3DTest(test.TestCase): padding="SAME", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientKernelSizeMatchesInputSize(self): self.ConstructAndTestGradient( batch=2, @@ -616,6 +630,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=False) + @test_util.run_deprecated_v1 def testInputGradientKernelSizeMatchesInputSize(self): self.ConstructAndTestGradient( batch=2, @@ -640,6 +655,7 @@ class Conv3DTest(test.TestCase): # Test the fast path in gemm_pack_rhs/mkldnn_gemm_pack, when channel # dimension is a multiple of packet size. + @test_util.run_deprecated_v1 def testInputGradientValidPaddingStrideOneFastPath(self): self.ConstructAndTestGradient( batch=2, @@ -651,6 +667,7 @@ class Conv3DTest(test.TestCase): padding="VALID", test_input=True) + @test_util.run_deprecated_v1 def testFilterGradientValidPaddingStrideOneFastPath(self): self.ConstructAndTestGradient( batch=2, diff --git a/tensorflow/python/kernel_tests/cross_grad_test.py b/tensorflow/python/kernel_tests/cross_grad_test.py index 0bd4006d6ac..b397133fd73 100644 --- a/tensorflow/python/kernel_tests/cross_grad_test.py +++ b/tensorflow/python/kernel_tests/cross_grad_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops @@ -26,6 +27,7 @@ from tensorflow.python.platform import test class CrossOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testGradientRandomValues(self): with self.cached_session(): us = [2, 3] diff --git a/tensorflow/python/kernel_tests/ctc_decoder_ops_test.py b/tensorflow/python/kernel_tests/ctc_decoder_ops_test.py index d818fbd75ce..0d86d13c715 100644 --- a/tensorflow/python/kernel_tests/ctc_decoder_ops_test.py +++ b/tensorflow/python/kernel_tests/ctc_decoder_ops_test.py @@ -25,6 +25,7 @@ from six.moves import zip_longest from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import ctc_ops from tensorflow.python.platform import test @@ -94,6 +95,7 @@ class CTCGreedyDecoderTest(test.TestCase): with self.assertRaisesOpError(expected_err_re): sess.run(decoded_unwrapped + [log_probability]) + @test_util.run_deprecated_v1 def testCTCGreedyDecoder(self): """Test two batch entries - best path decoder.""" max_time_steps = 6 @@ -170,6 +172,7 @@ class CTCGreedyDecoderTest(test.TestCase): self._testCTCDecoder(ctc_ops.ctc_greedy_decoder, inputs, seq_lens, log_prob_truth, decode_truth) + @test_util.run_deprecated_v1 def testCTCDecoderBeamSearch(self): """Test one batch, two beams - hibernating beam search.""" # max_time_steps == 8 diff --git a/tensorflow/python/kernel_tests/ctc_loss_op_test.py b/tensorflow/python/kernel_tests/ctc_loss_op_test.py index 36cae2846cd..e6b5835079e 100644 --- a/tensorflow/python/kernel_tests/ctc_loss_op_test.py +++ b/tensorflow/python/kernel_tests/ctc_loss_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import ctc_ops from tensorflow.python.ops import gradients_impl @@ -105,6 +106,7 @@ class CTCLossTest(test.TestCase): with self.assertRaisesOpError(expected_err_re): self.evaluate([loss, grad]) + @test_util.run_deprecated_v1 def testBasic(self): """Test two batch entries.""" # Input and ground truth from Alex Graves' implementation. @@ -240,6 +242,7 @@ class CTCLossTest(test.TestCase): self._testCTCLoss(inputs, seq_lens, labels, loss_truth, grad_truth) + @test_util.run_deprecated_v1 def test_time_major(self): """Testing time_major param. @@ -269,6 +272,7 @@ class CTCLossTest(test.TestCase): (tf_loss, tf_loss_transposed) = self.evaluate([loss, loss_transposed]) self.assertAllEqual(tf_loss, tf_loss_transposed) + @test_util.run_deprecated_v1 def testInvalidSecondGradient(self): inputs = np.random.randn(2, 2, 3).astype(np.float32) inputs_t = constant_op.constant(inputs) @@ -285,6 +289,7 @@ class CTCLossTest(test.TestCase): "explicitly disabled"): _ = gradients_impl._hessian_vector_product(loss, [inputs_t], v) + @test_util.run_deprecated_v1 def testEmptyBatch(self): inputs = constant_op.constant([], dtype=dtypes.float32, shape=(1, 0, 2)) sequence_lengths = constant_op.constant([], dtype=dtypes.int32) @@ -301,6 +306,7 @@ class CTCLossTest(test.TestCase): class CTCLossTestV2(test.TestCase): + @test_util.run_deprecated_v1 def testCtcLossV2(self): random_seed.set_random_seed(5) @@ -345,6 +351,7 @@ class CTCLossTestV2(test.TestCase): logit_length=logit_length, blank_index=0)) + @test_util.run_deprecated_v1 def testCtcLossDenseIsSameAsCtcLoss(self): with ops.device("/GPU:0" if test.is_gpu_available() else "/CPU:0"): random_seed.set_random_seed(5) @@ -398,6 +405,7 @@ class CTCLossTestV2(test.TestCase): rtol=2e-06, atol=2e-06) + @test_util.run_deprecated_v1 def testCtcLossDenseUniqueFastPathIsSameAsCtcLoss(self): random_seed.set_random_seed(5) @@ -451,6 +459,7 @@ class CTCLossTestV2(test.TestCase): rtol=2e-06, atol=2e-06) + @test_util.run_deprecated_v1 def testCtcLossDenseWithBlankIndexIsSameAsCtcLoss(self): random_seed.set_random_seed(5) @@ -507,6 +516,7 @@ class CTCLossTestV2(test.TestCase): rtol=2e-06, atol=2e-06) + @test_util.run_deprecated_v1 def testCtcLossDenseWithNegativeBlankIndexIsSameAsCtcLoss(self): with ops.device("/GPU:0" if test.is_gpu_available() else "/CPU:0"): random_seed.set_random_seed(5) @@ -555,6 +565,7 @@ class CTCLossTestV2(test.TestCase): rtol=2e-06, atol=2e-06) + @test_util.run_deprecated_v1 def testCollapseRepeated(self): collapsed, new_seq_lengths = ctc_ops.collapse_repeated( labels=[[1, 3, 3, 3, 0], @@ -568,6 +579,7 @@ class CTCLossTestV2(test.TestCase): [1, 4, 0, 0], [4, 2, 9, 4]]) + @test_util.run_deprecated_v1 def testCollapseRepeatedPreservesDtypes(self): collapsed, new_seq_lengths = ctc_ops.collapse_repeated( labels=constant_op.constant( @@ -585,6 +597,7 @@ class CTCLossTestV2(test.TestCase): [1, 4, 0, 0], [4, 2, 9, 4]]) + @test_util.run_deprecated_v1 def testCollapseRepeatedExtraPadding(self): collapsed, new_seq_lengths = ctc_ops.collapse_repeated( labels=[[1, 3, 3, 3, 0, 0, 0], @@ -598,6 +611,7 @@ class CTCLossTestV2(test.TestCase): [1, 4, 0, 0], [4, 2, 9, 4]]) + @test_util.run_deprecated_v1 def testCollapseRepeatedFrontRepeats(self): collapsed, new_seq_lengths = ctc_ops.collapse_repeated( labels=[[1, 1, 1, 2, 2], @@ -611,6 +625,7 @@ class CTCLossTestV2(test.TestCase): [1, 2], [1, 0]]) + @test_util.run_deprecated_v1 def testCollapseRepeatedAllLabelsTheSame(self): collapsed, new_seq_lengths = ctc_ops.collapse_repeated( labels=[[1, 1, 1, 1, 1], @@ -643,6 +658,7 @@ class CTCLossTestV2(test.TestCase): self.assertAllEqual(padded_dense, new_dense) + @test_util.run_deprecated_v1 def testUnique(self): labels = [ [3, 4, 4, 3], @@ -658,6 +674,7 @@ class CTCLossTestV2(test.TestCase): [0, 0, 0, 1], ], idx) + @test_util.run_deprecated_v1 def testSumStates(self): idx = [ [0, 1, 0, 1], @@ -677,6 +694,7 @@ class CTCLossTestV2(test.TestCase): [1.8, 0.8, 0.0, 0.0]] ], sum_of_states) + @test_util.run_deprecated_v1 def testStateToOlabel(self): labels = [ [3, 4, 3, 4], @@ -715,6 +733,7 @@ class CTCLossTestV2(test.TestCase): [22.0 + 23.0 + 24.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]], ]) + @test_util.run_deprecated_v1 def testStateToOlabelUnique(self): labels = [ [3, 4, 3, 4], @@ -753,6 +772,7 @@ class CTCLossTestV2(test.TestCase): [22.0 + 23.0 + 24.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]], ]) + @test_util.run_deprecated_v1 def testScan(self): with ops.device("/GPU:0" if test.is_gpu_available() else "/CPU:0"): out = ctc_ops._scan( @@ -785,6 +805,7 @@ class CTCLossTestV2(test.TestCase): constant_op.constant([23.0, 24.0])) self.assertAllEqual([[23.0, 25.0], [25.0, 28.0], [29.0, 33.0]], out) + @test_util.run_deprecated_v1 def testScanCapturesVariables(self): with self.cached_session() as sess: x = random_ops.random_uniform([]) @@ -794,6 +815,7 @@ class CTCLossTestV2(test.TestCase): [23.0 + x * 0.0, 23.0 + x * 1.0, 23.0 + x * 3.0], out ])) + @test_util.run_deprecated_v1 def testScanMultipleAccumulators(self): with ops.device("/GPU:0" if test.is_gpu_available() else "/CPU:0"): def fn(accum, elem): @@ -806,6 +828,7 @@ class CTCLossTestV2(test.TestCase): self.assertAllEqual([24.0, 26.0, 29.0], a) self.assertAllEqual([[1.0, 2.0], [2.0, 4.0], [6.0, 12.0]], b) + @test_util.run_deprecated_v1 def testScanMultipleElements(self): with ops.device("/GPU:0" if test.is_gpu_available() else "/CPU:0"): def fn(accum, elem): diff --git a/tensorflow/python/kernel_tests/cwise_ops_binary_test.py b/tensorflow/python/kernel_tests/cwise_ops_binary_test.py index 272c2b1dac8..49dbbb125a1 100644 --- a/tensorflow/python/kernel_tests/cwise_ops_binary_test.py +++ b/tensorflow/python/kernel_tests/cwise_ops_binary_test.py @@ -196,6 +196,7 @@ class BinaryOpTest(test.TestCase): self._compareGradientY(x, y, np_func, tf_func) self._compareGpu(x, y, np_func, tf_func) + @test_util.run_deprecated_v1 def testFloatBasic(self): x = np.linspace(-5, 20, 15).reshape(1, 3, 5).astype(np.float32) y = np.linspace(20, -5, 15).reshape(1, 3, 5).astype(np.float32) @@ -233,6 +234,7 @@ class BinaryOpTest(test.TestCase): except ImportError as e: tf_logging.warn("Cannot test special functions: %s" % str(e)) + @test_util.run_deprecated_v1 def testFloatDifferentShapes(self): x = np.array([1, 2, 3, 4]).reshape(2, 2).astype(np.float32) y = np.array([1, 2]).reshape(2, 1).astype(np.float32) @@ -262,6 +264,7 @@ class BinaryOpTest(test.TestCase): self.assertAllEqual(np_result, left_result) self.assertAllEqual(np_result, right_result) + @test_util.run_deprecated_v1 def testDoubleBasic(self): x = np.linspace(-5, 20, 15).reshape(1, 3, 5).astype(np.float64) y = np.linspace(20, -5, 15).reshape(1, 3, 5).astype(np.float64) @@ -353,6 +356,7 @@ class BinaryOpTest(test.TestCase): self._compareBoth(x, y, np.floor_divide, _FLOORDIV) self._compareBoth(x, y, np.mod, _MOD) + @test_util.run_deprecated_v1 def testComplex64Basic(self): x = np.complex(1, 1) * np.linspace(-10, 10, 6).reshape(1, 3, 2).astype( np.complex64) @@ -367,6 +371,7 @@ class BinaryOpTest(test.TestCase): self._compareBoth(x, y, np.multiply, _MUL) self._compareBoth(x, y + 0.1, np.true_divide, _TRUEDIV) + @test_util.run_deprecated_v1 def testComplex128Basic(self): x = np.complex(1, 1) * np.linspace(-10, 10, 6).reshape(1, 3, 2).astype( np.complex128) @@ -480,198 +485,263 @@ class BinaryOpTest(test.TestCase): ] self._testBCastByFunc(funcs, xs, ys) + @test_util.run_deprecated_v1 def testBCast_0A(self): self._testBCastA([1, 3, 2], [1]) + @test_util.run_deprecated_v1 def testBCast_0B(self): self._testBCastB([1, 3, 2], [1]) + @test_util.run_deprecated_v1 def testBCast_0C(self): self._testBCastC([1, 3, 2], [1]) + @test_util.run_deprecated_v1 def testBCast_0D(self): self._testBCastD([1, 3, 2], [1]) + @test_util.run_deprecated_v1 def testBCast_1A(self): self._testBCastA([1, 3, 2], [2]) + @test_util.run_deprecated_v1 def testBCast_1B(self): self._testBCastB([1, 3, 2], [2]) + @test_util.run_deprecated_v1 def testBCast_1C(self): self._testBCastC([1, 3, 2], [2]) + @test_util.run_deprecated_v1 def testBCast_1D(self): self._testBCastD([1, 3, 2], [2]) + @test_util.run_deprecated_v1 def testBCast_2A(self): self._testBCastA([1, 3, 2], [3, 2]) + @test_util.run_deprecated_v1 def testBCast_2B(self): self._testBCastB([1, 3, 2], [3, 2]) + @test_util.run_deprecated_v1 def testBCast_2C(self): self._testBCastC([1, 3, 2], [3, 2]) + @test_util.run_deprecated_v1 def testBCast_2D(self): self._testBCastD([1, 3, 2], [3, 2]) + @test_util.run_deprecated_v1 def testBCast_3A(self): self._testBCastA([1, 3, 2], [3, 1]) + @test_util.run_deprecated_v1 def testBCast_3B(self): self._testBCastB([1, 3, 2], [3, 1]) + @test_util.run_deprecated_v1 def testBCast_3C(self): self._testBCastC([1, 3, 2], [3, 1]) + @test_util.run_deprecated_v1 def testBCast_3D(self): self._testBCastD([1, 3, 2], [3, 1]) + @test_util.run_deprecated_v1 def testBCast_4A(self): self._testBCastA([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_4B(self): self._testBCastB([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_4C(self): self._testBCastC([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_4D(self): self._testBCastD([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_5A(self): self._testBCastA([1, 3, 2], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_5B(self): self._testBCastB([1, 3, 2], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_5C(self): self._testBCastC([1, 3, 2], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_5D(self): self._testBCastD([1, 3, 2], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_6A(self): self._testBCastA([1, 3, 2], [2, 1, 1]) + @test_util.run_deprecated_v1 def testBCast_6B(self): self._testBCastB([1, 3, 2], [2, 1, 1]) + @test_util.run_deprecated_v1 def testBCast_6C(self): self._testBCastC([1, 3, 2], [2, 1, 1]) + @test_util.run_deprecated_v1 def testBCast_6D(self): self._testBCastD([1, 3, 2], [2, 1, 1]) + @test_util.run_deprecated_v1 def testBCast_7A(self): self._testBCastA([1, 3, 2], [1, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_7B(self): self._testBCastB([1, 3, 2], [1, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_7C(self): self._testBCastC([1, 3, 2], [1, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_7D(self): self._testBCastD([1, 3, 2], [1, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_8A(self): self._testBCastA([2, 1, 5], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_8B(self): self._testBCastB([2, 1, 5], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_8C(self): self._testBCastC([2, 1, 5], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_8D(self): self._testBCastD([2, 1, 5], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_9A(self): self._testBCastA([2, 0, 5], [2, 0, 1]) + @test_util.run_deprecated_v1 def testBCast_9B(self): self._testBCastB([2, 0, 5], [2, 0, 1]) + @test_util.run_deprecated_v1 def testBCast_9C(self): self._testBCastC([2, 0, 5], [2, 0, 1]) + @test_util.run_deprecated_v1 def testBCast_9D(self): self._testBCastD([2, 0, 5], [2, 0, 1]) + @test_util.run_deprecated_v1 def testBCast_10A(self): self._testBCastA([2, 3, 0], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_10B(self): self._testBCastB([2, 3, 0], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_10C(self): self._testBCastC([2, 3, 0], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_10D(self): self._testBCastD([2, 3, 0], [2, 3, 1]) + @test_util.run_deprecated_v1 def testBCast_11A(self): self._testBCastA([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_11B(self): self._testBCastB([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_11C(self): self._testBCastC([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_11D(self): self._testBCastD([1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_12A(self): self._testBCastA([1, 1, 1, 1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_12B(self): self._testBCastB([1, 1, 1, 1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_12C(self): self._testBCastC([1, 1, 1, 1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_12D(self): self._testBCastD([1, 1, 1, 1, 3, 2], [1, 3, 2]) + @test_util.run_deprecated_v1 def testBCast_13A(self): self._testBCastA([1, 3, 2, 1, 1], [1]) + @test_util.run_deprecated_v1 def testBCast_13B(self): self._testBCastB([1, 3, 2, 1, 1], [1]) + @test_util.run_deprecated_v1 def testBCast_13C(self): self._testBCastC([1, 3, 2, 1, 1], [1]) + @test_util.run_deprecated_v1 def testBCast_13D(self): self._testBCastD([1, 3, 2, 1, 1], [1]) + @test_util.run_deprecated_v1 def testBCast_14A(self): self._testBCastA([2, 3, 1, 1, 5], [1]) + @test_util.run_deprecated_v1 def testBCast_14B(self): self._testBCastB([2, 3, 1, 1, 5], [1]) + @test_util.run_deprecated_v1 def testBCast_14C(self): self._testBCastC([2, 3, 1, 1, 5], [1]) + @test_util.run_deprecated_v1 def testBCast_14D(self): self._testBCastD([2, 3, 1, 1, 5], [1]) + @test_util.run_deprecated_v1 def testBCast_15A(self): self._testBCastA([10, 3, 1, 2], [3, 1, 2]) + @test_util.run_deprecated_v1 def testBCast_15B(self): self._testBCastB([10, 3, 1, 2], [3, 1, 2]) + @test_util.run_deprecated_v1 def testBCast_15C(self): self._testBCastC([10, 3, 1, 2], [3, 1, 2]) + @test_util.run_deprecated_v1 def testBCast_15D(self): self._testBCastD([10, 3, 1, 2], [3, 1, 2]) + @test_util.run_deprecated_v1 def testMismatchedDimensions(self): for func in [ math_ops.add, math_ops.subtract, math_ops.multiply, math_ops.div, _ADD, @@ -683,6 +753,7 @@ class BinaryOpTest(test.TestCase): ops.convert_to_tensor([10.0, 20.0, 30.0]), ops.convert_to_tensor([[40.0, 50.0], [60.0, 70.0]])) + @test_util.run_deprecated_v1 def testZeroPowGrad(self): with self.cached_session(): for dtype in (np.float16, np.float32, np.float64, np.complex64, @@ -693,6 +764,7 @@ class BinaryOpTest(test.TestCase): error = gradient_checker.compute_gradient_error(y, [], z, []) self.assertEqual(error, 0) + @test_util.run_deprecated_v1 def testComplexPowGrad(self): with self.cached_session(): for dtype in np.complex64, np.complex128: @@ -861,6 +933,7 @@ class ComparisonOpTest(test.TestCase): self._testBCastByFunc( np.not_equal, math_ops.not_equal, include_complex=True) + @test_util.run_deprecated_v1 def testShapeMismatch(self): dtypes = [np.float16, np.float32, np.float64, np.int32, np.int64] funcs = [ diff --git a/tensorflow/python/kernel_tests/cwise_ops_test.py b/tensorflow/python/kernel_tests/cwise_ops_test.py index 7e14f95be42..9bb7d8b8b12 100644 --- a/tensorflow/python/kernel_tests/cwise_ops_test.py +++ b/tensorflow/python/kernel_tests/cwise_ops_test.py @@ -199,6 +199,7 @@ class ComparisonOpTest(test.TestCase): self._testBCastByFunc( np.not_equal, math_ops.not_equal, include_complex=True) + @test_util.run_deprecated_v1 def testShapeMismatch(self): dtypes = [np.float16, np.float32, np.float64, np.int32, np.int64] funcs = [ @@ -280,6 +281,7 @@ class LogicalOpTest(test.TestCase): self._compareBinary(x, y, np.logical_or, math_ops.logical_or, use_gpu) self._compareBinary(x, y, np.logical_xor, math_ops.logical_xor, use_gpu) + @test_util.run_deprecated_v1 def testShapeMismatch(self): x = np.random.randint(0, 2, 6).astype(np.bool).reshape(1, 3, 2) y = np.random.randint(0, 2, 6).astype(np.bool).reshape(3, 2, 1) @@ -288,6 +290,7 @@ class LogicalOpTest(test.TestCase): ValueError, lambda e: "Dimensions must" in str(e)): f(x, y) + @test_util.run_deprecated_v1 def testUsingAsPythonValueFails(self): # Ensure that we raise an error when the user attempts to treat a # `Tensor` as a Python `bool`. @@ -396,6 +399,7 @@ class SelectOpTest(test.TestCase): if t in [np.float16, np.float32, np.float64]: self._compare(c, xt, yt, use_gpu=True) + @test_util.run_deprecated_v1 def testGradients(self): c = np.random.randint(0, 2, 6).astype(np.bool).reshape(1, 3, 2) x = np.random.rand(1, 3, 2) * 100 @@ -415,6 +419,7 @@ class SelectOpTest(test.TestCase): self._compareGradientX(c, xt, yt) self._compareGradientY(c, xt, yt) + @test_util.run_deprecated_v1 def testShapeMismatch(self): c = np.random.randint(0, 2, 6).astype(np.bool).reshape(1, 3, 2) x = np.random.rand(1, 3, 2) * 100 @@ -428,6 +433,7 @@ class SelectOpTest(test.TestCase): with self.assertRaises(ValueError): array_ops.where(c, xt, yt) + @test_util.run_deprecated_v1 def testEmptyTensor(self): c = np.random.randint(0, 3, 0).astype(np.bool).reshape(1, 3, 0) x = np.random.rand(1, 3, 0) * 100 @@ -439,6 +445,7 @@ class SelectOpTest(test.TestCase): z = array_ops.where(c, xt, yt).eval() self.assertAllEqual(z_expected, z) + @test_util.run_deprecated_v1 def testNan(self): """Verify that nans don't propagate where they shouldn't.""" with self.cached_session(): @@ -525,6 +532,7 @@ class BatchSelectOpTest(test.TestCase): if t in [np.float16, np.float32, np.float64]: self._compare(c, xt, yt, use_gpu=True) + @test_util.run_deprecated_v1 def testGradients(self): c = np.random.randint(0, 2, 16).astype(np.bool) x = np.random.rand(16, 2, 8) * 100 @@ -544,6 +552,7 @@ class BatchSelectOpTest(test.TestCase): self._compareGradientX(c, xt, yt) self._compareGradientY(c, xt, yt) + @test_util.run_deprecated_v1 def testShapeMismatch(self): c = np.random.randint(0, 2, 8).astype(np.bool) x = np.random.rand(16, 3, 2) * 100 @@ -622,6 +631,7 @@ class MinMaxOpTest(test.TestCase): elif x.dtype == np.float64: self.assertAllClose(jacob_t, jacob_n, rtol=1e-5, atol=1e-5) + @test_util.run_deprecated_v1 def testGradients(self): x = np.random.rand(1, 3, 2) * 100. # ensure x != y @@ -898,6 +908,7 @@ class ComplexMakeRealImagTest(test.TestCase): # build failures on GPU (See #10643 for context). # self._compareAngle(cplx, use_gpu=True) + @test_util.run_deprecated_v1 def testRealReal(self): for dtype in (dtypes_lib.int32, dtypes_lib.int64, dtypes_lib.float32, dtypes_lib.float64): @@ -928,6 +939,7 @@ class ComplexMakeRealImagTest(test.TestCase): self._compareConj(cplx, use_gpu=False) self._compareConj(cplx, use_gpu=True) + @test_util.run_deprecated_v1 def testConjReal(self): for dtype in (dtypes_lib.int32, dtypes_lib.int64, dtypes_lib.float16, dtypes_lib.float32, dtypes_lib.float64): @@ -935,6 +947,7 @@ class ComplexMakeRealImagTest(test.TestCase): y = math_ops.conj(x) self.assertEqual(x, y) + @test_util.run_deprecated_v1 def testConjString(self): x = array_ops.placeholder(dtypes_lib.string) with self.assertRaisesRegexp(TypeError, @@ -971,6 +984,7 @@ class ComplexMakeRealImagTest(test.TestCase): x_, list(x.shape), z, [1], x_init_value=x, delta=epsilon) self.assertAllClose(jacob_t, jacob_n, rtol=epsilon, atol=epsilon) + @test_util.run_deprecated_v1 def testGradient(self): # complex64 data = np.arange(1, 2, 0.10).reshape([5, 2]).astype(np.float32) @@ -1006,6 +1020,7 @@ class ComplexMakeRealImagTest(test.TestCase): inp, list(data.shape), loss, [1], x_init_value=data, delta=epsilon) self.assertAllClose(jacob_t, jacob_n, rtol=epsilon, atol=epsilon) + @test_util.run_deprecated_v1 def testMulGradient(self): data = np.arange(1, 2, 0.125).reshape([2, 4]).astype(np.float32) self._compareMulGradient(data) diff --git a/tensorflow/python/kernel_tests/cwise_ops_unary_test.py b/tensorflow/python/kernel_tests/cwise_ops_unary_test.py index 3e8294f34bd..709a20f3d0d 100644 --- a/tensorflow/python/kernel_tests/cwise_ops_unary_test.py +++ b/tensorflow/python/kernel_tests/cwise_ops_unary_test.py @@ -184,6 +184,7 @@ class UnaryOpTest(test.TestCase): return func + @test_util.run_deprecated_v1 def testFloatBasic(self): x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float32) w = x - x.min() + 1.02 # all greater than 1 @@ -238,12 +239,14 @@ class UnaryOpTest(test.TestCase): self._compareBothSparse(y, np.sign, math_ops.sign) self._compareBothSparse(x, np.vectorize(math.erf), math_ops.erf) + @test_util.run_deprecated_v1 def testFloatTanhEdge(self): x = np.arange(40, 40 + 6).reshape(6).astype(np.float32) self._compareBoth(x, np.tanh, math_ops.tanh) x = np.arange(-40, -40 + 6).reshape(6).astype(np.float32) self._compareBoth(x, np.tanh, math_ops.tanh) + @test_util.run_deprecated_v1 def testFloatEmpty(self): x = np.empty((2, 0, 5), dtype=np.float32) self._compareBoth(x, np.abs, math_ops.abs) @@ -289,6 +292,7 @@ class UnaryOpTest(test.TestCase): self._compareBothSparse(x, np.sign, math_ops.sign) self._compareBothSparse(x, np.sign, math_ops.erf) + @test_util.run_deprecated_v1 def testDoubleBasic(self): x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float64) w = x - x.min() + 1.02 # all greater than 1 @@ -342,6 +346,7 @@ class UnaryOpTest(test.TestCase): self._compareBothSparse(y, np.sign, math_ops.sign) self._compareBothSparse(x, np.vectorize(math.erf), math_ops.erf) + @test_util.run_deprecated_v1 def testHalfBasic(self): x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float16) y = (x + .5).astype(np.float16) # no zero @@ -414,6 +419,7 @@ class UnaryOpTest(test.TestCase): self._compareCpu(x, np.square, math_ops.square) self._compareBothSparse(x, np.square, math_ops.square) + @test_util.run_deprecated_v1 def testComplex64Basic(self): x = np.complex(1, 1) * np.arange(-3, 3).reshape(1, 3, 2).astype( np.complex64) @@ -458,6 +464,7 @@ class UnaryOpTest(test.TestCase): self._compareBoth(y, complex_sign, math_ops.sign) self._compareBothSparse(y, complex_sign, math_ops.sign) + @test_util.run_deprecated_v1 def testComplex128Basic(self): x = np.complex(1, 1) * np.arange(-3, 3).reshape(1, 3, 2).astype( np.complex128) @@ -497,6 +504,7 @@ class UnaryOpTest(test.TestCase): self._compareBoth(y, complex_sign, math_ops.sign) self._compareBothSparse(y, complex_sign, math_ops.sign) + @test_util.run_deprecated_v1 def testGradGrad(self): np.random.seed(7) shape = (5,) diff --git a/tensorflow/python/kernel_tests/decode_compressed_op_test.py b/tensorflow/python/kernel_tests/decode_compressed_op_test.py index 1cc1c7da30a..fd871c00906 100644 --- a/tensorflow/python/kernel_tests/decode_compressed_op_test.py +++ b/tensorflow/python/kernel_tests/decode_compressed_op_test.py @@ -24,6 +24,7 @@ import zlib from six import BytesIO from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import parsing_ops from tensorflow.python.platform import test @@ -42,6 +43,7 @@ class DecodeCompressedOpTest(test.TestCase): f.write(bytes_in) return out.getvalue() + @test_util.run_deprecated_v1 def testDecompress(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.cached_session(): @@ -55,6 +57,7 @@ class DecodeCompressedOpTest(test.TestCase): self._compress(b"bBbb", compression_type)]}) self.assertAllEqual([b"AaAA", b"bBbb"], result) + @test_util.run_deprecated_v1 def testDecompressWithRaw(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/decode_image_op_test.py b/tensorflow/python/kernel_tests/decode_image_op_test.py index 267afdeb5e1..ba5770001ad 100644 --- a/tensorflow/python/kernel_tests/decode_image_op_test.py +++ b/tensorflow/python/kernel_tests/decode_image_op_test.py @@ -23,6 +23,7 @@ import os.path import numpy as np from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import image_ops from tensorflow.python.ops import io_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import @@ -44,6 +45,7 @@ class DecodeImageOpTest(test.TestCase): self.assertEqual(len(bmp0), 4194) self.assertAllEqual(image0, image1) + @test_util.run_deprecated_v1 def testGif(self): # Read some real GIFs path = os.path.join(prefix_path, "gif", "testdata", "scan.gif") @@ -78,6 +80,7 @@ class DecodeImageOpTest(test.TestCase): with self.assertRaises(errors_impl.InvalidArgumentError): self.evaluate(bad_channels) + @test_util.run_deprecated_v1 def testJpeg(self): # Read a real jpeg and verify shape path = os.path.join(prefix_path, "jpeg", "testdata", "jpeg_merge_test1.jpg") @@ -108,6 +111,7 @@ class DecodeImageOpTest(test.TestCase): self.assertEqual(image0.shape, (26, 51, channels or channels_in)) self.assertAllEqual(image0, image1) + @test_util.run_deprecated_v1 def testInvalidBytes(self): image_bytes = b"ThisIsNotAnImage!" decode = image_ops.decode_image(image_bytes) diff --git a/tensorflow/python/kernel_tests/decode_raw_op_test.py b/tensorflow/python/kernel_tests/decode_raw_op_test.py index dcc984811cb..008e59ba3e6 100644 --- a/tensorflow/python/kernel_tests/decode_raw_op_test.py +++ b/tensorflow/python/kernel_tests/decode_raw_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import parsing_ops from tensorflow.python.platform import test @@ -28,6 +29,7 @@ from tensorflow.python.platform import test class DecodeRawOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testToUint8(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[2]) @@ -46,6 +48,7 @@ class DecodeRawOpTest(test.TestCase): "element 1 has size 5 != 6"): decode.eval(feed_dict={in_bytes: ["short", "longer"]}) + @test_util.run_deprecated_v1 def testToInt16(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) @@ -61,6 +64,7 @@ class DecodeRawOpTest(test.TestCase): "size of int16"): decode.eval(feed_dict={in_bytes: ["123", "456"]}) + @test_util.run_deprecated_v1 def testEndianness(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) @@ -73,6 +77,7 @@ class DecodeRawOpTest(test.TestCase): result = decode_be.eval(feed_dict={in_bytes: ["\x01\x02\x03\x04"]}) self.assertAllEqual([[0x01020304]], result) + @test_util.run_deprecated_v1 def testToFloat16(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) @@ -84,6 +89,7 @@ class DecodeRawOpTest(test.TestCase): self.assertAllEqual(expected_result, result) + @test_util.run_deprecated_v1 def testEmptyStringInput(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) @@ -93,6 +99,7 @@ class DecodeRawOpTest(test.TestCase): result = decode.eval(feed_dict={in_bytes: [""] * num_inputs}) self.assertEqual((num_inputs, 0), result.shape) + @test_util.run_deprecated_v1 def testToUInt16(self): with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) diff --git a/tensorflow/python/kernel_tests/denormal_test.py b/tensorflow/python/kernel_tests/denormal_test.py index 71a528c4aa2..80a3033ecc4 100644 --- a/tensorflow/python/kernel_tests/denormal_test.py +++ b/tensorflow/python/kernel_tests/denormal_test.py @@ -22,6 +22,7 @@ import numpy as np import platform from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test @@ -50,10 +51,12 @@ class DenormalTest(test.TestCase): # Make sure the flags don't leak out self.testPythonHasDenormals() + @test_util.run_deprecated_v1 def testFlushDenormalsCPU(self): # On CPUs, the processor flags flush for both single and double precision. self._flushDenormalsTest(use_gpu=False, dtypes=(np.float32, np.float64)) + @test_util.run_deprecated_v1 def testFlushDenormalsGPU(self): # On GPUs, only single precision can flush to zero. self._flushDenormalsTest(use_gpu=True, dtypes=(np.float32,)) diff --git a/tensorflow/python/kernel_tests/dense_update_ops_no_tsan_test.py b/tensorflow/python/kernel_tests/dense_update_ops_no_tsan_test.py index 0676664685d..4f74e1e7412 100644 --- a/tensorflow/python/kernel_tests/dense_update_ops_no_tsan_test.py +++ b/tensorflow/python/kernel_tests/dense_update_ops_no_tsan_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import state_ops @@ -32,6 +33,7 @@ class AssignOpTest(test.TestCase): # NOTE(mrry): We exclude thess tests from the TSAN TAP target, because they # contain benign and deliberate data races when multiple threads update # the same parameters without a lock. + @test_util.run_deprecated_v1 def testParallelUpdateWithoutLocking(self): with self.cached_session() as sess: ones_t = array_ops.fill([1024, 1024], 1.0) @@ -59,6 +61,7 @@ class AssignOpTest(test.TestCase): self.assertTrue((vals >= ones).all()) self.assertTrue((vals <= ones * 20).all()) + @test_util.run_deprecated_v1 def testParallelAssignWithoutLocking(self): with self.cached_session() as sess: ones_t = array_ops.fill([1024, 1024], float(1)) @@ -91,6 +94,7 @@ class AssignOpTest(test.TestCase): # contain non-benign but known data races between the variable assignment and # returning the output tensors. This issue will be resolved with the new # resource variables. + @test_util.run_deprecated_v1 def testParallelUpdateWithLocking(self): with self.cached_session() as sess: zeros_t = array_ops.fill([1024, 1024], 0.0) @@ -118,6 +122,7 @@ class AssignOpTest(test.TestCase): ones = np.ones((1024, 1024)).astype(np.float32) self.assertAllEqual(vals, ones * 20) + @test_util.run_deprecated_v1 def testParallelAssignWithLocking(self): with self.cached_session() as sess: zeros_t = array_ops.fill([1024, 1024], 0.0) diff --git a/tensorflow/python/kernel_tests/dense_update_ops_test.py b/tensorflow/python/kernel_tests/dense_update_ops_test.py index a4766fed72e..309da88bef7 100644 --- a/tensorflow/python/kernel_tests/dense_update_ops_test.py +++ b/tensorflow/python/kernel_tests/dense_update_ops_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import state_ops from tensorflow.python.ops import variables @@ -81,9 +82,11 @@ class AssignOpTest(test.TestCase): self.assertAllEqual(x - y, var_value) self.assertAllEqual(x - y, op_value) + @test_util.run_deprecated_v1 def testBasic(self): self._testTypes(np.arange(0, 20).reshape([4, 5])) + @test_util.run_deprecated_v1 def testAssignNonStrictShapeChecking(self): with self.cached_session(): data = array_ops.fill([1024, 1024], 0) @@ -98,6 +101,7 @@ class AssignOpTest(test.TestCase): a2.op.run() self.assertAllEqual(p.eval(), self.evaluate(data2)) + @test_util.run_deprecated_v1 def testInitRequiredAssignAdd(self): with self.cached_session(): p = variables.VariableV1(array_ops.fill([1024, 1024], 1), dtypes.int32) @@ -105,6 +109,7 @@ class AssignOpTest(test.TestCase): with self.assertRaisesOpError("use uninitialized"): a.op.run() + @test_util.run_deprecated_v1 def testInitRequiredAssignSub(self): with self.cached_session(): p = variables.VariableV1(array_ops.fill([1024, 1024], 1), dtypes.int32) diff --git a/tensorflow/python/kernel_tests/depthtospace_op_test.py b/tensorflow/python/kernel_tests/depthtospace_op_test.py index 19f145865fd..96c9b5258e2 100644 --- a/tensorflow/python/kernel_tests/depthtospace_op_test.py +++ b/tensorflow/python/kernel_tests/depthtospace_op_test.py @@ -53,12 +53,14 @@ class DepthToSpaceTest(test.TestCase): output_nhwc = test_util.NCHWToNHWC(output_nchw) self.assertAllEqual(output_nhwc.eval(), outputs) + @test_util.run_deprecated_v1 def testBasic(self): x_np = [[[[1, 2, 3, 4]]]] block_size = 2 x_out = [[[[1], [2]], [[3], [4]]]] self._testOne(x_np, block_size, x_out) + @test_util.run_deprecated_v1 def testBasicFloat16(self): x_np = [[[[1, 2, 3, 4]]]] block_size = 2 @@ -67,6 +69,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for larger input dimensions. To make sure elements are # correctly ordered spatially. + @test_util.run_deprecated_v1 def testBlockSize2(self): x_np = [[[[1, 2, 3, 4], [5, 6, 7, 8]], @@ -79,6 +82,7 @@ class DepthToSpaceTest(test.TestCase): [[11], [12], [15], [16]]]] self._testOne(x_np, block_size, x_out) + @test_util.run_deprecated_v1 def testBlockSize2Batch10(self): block_size = 2 def batch_input_elt(i): @@ -115,6 +119,7 @@ class DepthToSpaceTest(test.TestCase): self.evaluate(x_tf) # Tests for different width and height. + @test_util.run_deprecated_v1 def testNonSquare(self): x_np = [[[[1, 10, 2, 20, 3, 30, 4, 40]], [[5, 50, 6, 60, 7, 70, 8, 80]], @@ -130,6 +135,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for larger input dimensions. To make sure elements are # correctly ordered spatially. + @test_util.run_deprecated_v1 def testBlockSize4FlatInput(self): x_np = [[[[1, 2, 5, 6, 3, 4, 7, 8, 9, 10, 13, 14, 11, 12, 15, 16]]]] block_size = 4 @@ -141,6 +147,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for larger input depths. # To make sure elements are properly interleaved in depth. + @test_util.run_deprecated_v1 def testDepthInterleaved(self): x_np = [[[[1, 10, 2, 20, 3, 30, 4, 40]]]] block_size = 2 @@ -150,6 +157,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for larger input depths. Here an odd depth. # To make sure elements are properly interleaved in depth. + @test_util.run_deprecated_v1 def testDepthInterleavedDepth3(self): x_np = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]] block_size = 2 @@ -159,6 +167,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for larger input depths. # To make sure elements are properly interleaved in depth. + @test_util.run_deprecated_v1 def testDepthInterleavedLarger(self): x_np = [[[[1, 10, 2, 20, 3, 30, 4, 40], [5, 50, 6, 60, 7, 70, 8, 80]], @@ -175,6 +184,7 @@ class DepthToSpaceTest(test.TestCase): # Tests for a block larger for the depth. In this case should raise an # exception. + @test_util.run_deprecated_v1 def testBlockSizeTooLarge(self): x_np = [[[[1, 2, 3, 4], [5, 6, 7, 8]], @@ -188,6 +198,7 @@ class DepthToSpaceTest(test.TestCase): self.evaluate(out_tf) # Test when the block size is 0. + @test_util.run_deprecated_v1 def testBlockSize0(self): x_np = [[[[1], [2]], [[3], [4]]]] @@ -197,6 +208,7 @@ class DepthToSpaceTest(test.TestCase): self.evaluate(out_tf) # Test when the block size is 1. The block size should be > 1. + @test_util.run_deprecated_v1 def testBlockSizeOne(self): x_np = [[[[1, 1, 1, 1], [2, 2, 2, 2]], @@ -207,6 +219,7 @@ class DepthToSpaceTest(test.TestCase): out_tf = array_ops.depth_to_space(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testBlockSizeLargerThanInput(self): # The block size is too large for this input. x_np = [[[[1], [2]], @@ -216,6 +229,7 @@ class DepthToSpaceTest(test.TestCase): out_tf = array_ops.space_to_depth(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleDepth(self): # The depth is not divisible by the square of the block size. x_np = [[[[1, 1, 1, 1], @@ -226,6 +240,7 @@ class DepthToSpaceTest(test.TestCase): with self.assertRaises(ValueError): _ = array_ops.space_to_depth(x_np, block_size) + @test_util.run_deprecated_v1 def testUnknownShape(self): t = array_ops.depth_to_space( array_ops.placeholder(dtypes.float32), block_size=4) @@ -343,11 +358,13 @@ class DepthToSpaceGradientTest(test.TestCase): # Don't use very large numbers as dimensions here, as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): block_size = 2 self._compare(3, 2, 5, 3, block_size, "NHWC") self._compare(3, 2, 5, 3, block_size, "NCHW") + @test_util.run_deprecated_v1 def testSmall2(self): block_size = 3 self._compare(1, 2, 3, 2, block_size, "NHWC") diff --git a/tensorflow/python/kernel_tests/diag_op_test.py b/tensorflow/python/kernel_tests/diag_op_test.py index f7a9cd8d6e2..ed2a9e8e47e 100644 --- a/tensorflow/python/kernel_tests/diag_op_test.py +++ b/tensorflow/python/kernel_tests/diag_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -31,6 +32,7 @@ from tensorflow.python.platform import tf_logging class MatrixDiagTest(test.TestCase): + @test_util.run_deprecated_v1 def testVector(self): with self.session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) @@ -49,6 +51,7 @@ class MatrixDiagTest(test.TestCase): self.assertEqual((2, 3, 3), v_batch_diag.get_shape()) self.assertAllEqual(v_batch_diag.eval(), mat_batch) + @test_util.run_deprecated_v1 def testBatchVector(self): self._testBatchVector(np.float32) self._testBatchVector(np.float64) @@ -56,16 +59,19 @@ class MatrixDiagTest(test.TestCase): self._testBatchVector(np.int64) self._testBatchVector(np.bool) + @test_util.run_deprecated_v1 def testInvalidShape(self): with self.assertRaisesRegexp(ValueError, "must be at least rank 1"): array_ops.matrix_diag(0) + @test_util.run_deprecated_v1 def testInvalidShapeAtEval(self): with self.session(use_gpu=True): v = array_ops.placeholder(dtype=dtypes_lib.float32) with self.assertRaisesOpError("input must be at least 1-dim"): array_ops.matrix_diag(v).eval(feed_dict={v: 0.0}) + @test_util.run_deprecated_v1 def testGrad(self): shapes = ((3,), (7, 4)) with self.session(use_gpu=True): @@ -81,6 +87,7 @@ class MatrixDiagTest(test.TestCase): class MatrixSetDiagTest(test.TestCase): + @test_util.run_deprecated_v1 def testSquare(self): with self.session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) @@ -91,6 +98,7 @@ class MatrixSetDiagTest(test.TestCase): self.assertEqual((3, 3), output.get_shape()) self.assertAllEqual(mat_set_diag, self.evaluate(output)) + @test_util.run_deprecated_v1 def testRectangular(self): with self.session(use_gpu=True): v = np.array([3.0, 4.0]) @@ -123,6 +131,7 @@ class MatrixSetDiagTest(test.TestCase): self.assertEqual((2, 3, 3), output.get_shape()) self.assertAllEqual(mat_set_diag_batch, self.evaluate(output)) + @test_util.run_deprecated_v1 def testSquareBatch(self): self._testSquareBatch(np.float32) self._testSquareBatch(np.float64) @@ -130,6 +139,7 @@ class MatrixSetDiagTest(test.TestCase): self._testSquareBatch(np.int64) self._testSquareBatch(np.bool) + @test_util.run_deprecated_v1 def testRectangularBatch(self): with self.session(use_gpu=True): v_batch = np.array([[-1.0, -2.0], [-4.0, -5.0]]) @@ -142,12 +152,14 @@ class MatrixSetDiagTest(test.TestCase): self.assertEqual((2, 2, 3), output.get_shape()) self.assertAllEqual(mat_set_diag_batch, self.evaluate(output)) + @test_util.run_deprecated_v1 def testInvalidShape(self): with self.assertRaisesRegexp(ValueError, "must be at least rank 2"): array_ops.matrix_set_diag(0, [0]) with self.assertRaisesRegexp(ValueError, "must be at least rank 1"): array_ops.matrix_set_diag([[0]], 0) + @test_util.run_deprecated_v1 def testInvalidShapeAtEval(self): with self.session(use_gpu=True): v = array_ops.placeholder(dtype=dtypes_lib.float32) @@ -157,6 +169,7 @@ class MatrixSetDiagTest(test.TestCase): r"but received input shape: \[1,1\] and diagonal shape: \[\]"): array_ops.matrix_set_diag([[v]], v).eval(feed_dict={v: 0.0}) + @test_util.run_deprecated_v1 def testGrad(self): shapes = ((3, 4, 4), (3, 3, 4), (3, 4, 3), (7, 4, 8, 8)) with self.session(use_gpu=True): @@ -178,6 +191,7 @@ class MatrixSetDiagTest(test.TestCase): y.get_shape().as_list()) self.assertLess(error_x_diag, 1e-4) + @test_util.run_deprecated_v1 def testGradWithNoShapeInformation(self): with self.session(use_gpu=True) as sess: v = array_ops.placeholder(dtype=dtypes_lib.float32) @@ -200,6 +214,7 @@ class MatrixSetDiagTest(test.TestCase): class MatrixDiagPartTest(test.TestCase): + @test_util.run_deprecated_v1 def testSquare(self): with self.session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) @@ -208,6 +223,7 @@ class MatrixDiagPartTest(test.TestCase): self.assertEqual((3,), mat_diag.get_shape()) self.assertAllEqual(mat_diag.eval(), v) + @test_util.run_deprecated_v1 def testRectangular(self): with self.session(use_gpu=True): mat = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]) @@ -228,6 +244,7 @@ class MatrixDiagPartTest(test.TestCase): self.assertEqual((2, 3), mat_batch_diag.get_shape()) self.assertAllEqual(mat_batch_diag.eval(), v_batch) + @test_util.run_deprecated_v1 def testSquareBatch(self): self._testSquareBatch(np.float32) self._testSquareBatch(np.float64) @@ -235,6 +252,7 @@ class MatrixDiagPartTest(test.TestCase): self._testSquareBatch(np.int64) self._testSquareBatch(np.bool) + @test_util.run_deprecated_v1 def testRectangularBatch(self): with self.session(use_gpu=True): v_batch = np.array([[1.0, 2.0], [4.0, 5.0]]) @@ -245,16 +263,19 @@ class MatrixDiagPartTest(test.TestCase): self.assertEqual((2, 2), mat_batch_diag.get_shape()) self.assertAllEqual(mat_batch_diag.eval(), v_batch) + @test_util.run_deprecated_v1 def testInvalidShape(self): with self.assertRaisesRegexp(ValueError, "must be at least rank 2"): array_ops.matrix_diag_part(0) + @test_util.run_deprecated_v1 def testInvalidShapeAtEval(self): with self.session(use_gpu=True): v = array_ops.placeholder(dtype=dtypes_lib.float32) with self.assertRaisesOpError("input must be at least 2-dim"): array_ops.matrix_diag_part(v).eval(feed_dict={v: 0.0}) + @test_util.run_deprecated_v1 def testGrad(self): shapes = ((3, 3), (2, 3), (3, 2), (5, 3, 3)) with self.session(use_gpu=True): @@ -407,6 +428,7 @@ class DiagTest(test.TestCase): dtype=dtype) self.diagOp(x, dtype, expected_ans) + @test_util.run_deprecated_v1 def testInvalidRank(self): with self.assertRaisesRegexp(ValueError, "must be at least rank 1"): array_ops.diag(0.0) @@ -476,6 +498,7 @@ class DiagPartOpTest(test.TestCase): self.diagPartOp(x, np.complex64, expected_ans) self.diagPartOp(x, np.complex128, expected_ans) + @test_util.run_deprecated_v1 def testOddRank(self): w = np.random.rand(2) x = np.random.rand(2, 2, 2) @@ -484,6 +507,7 @@ class DiagPartOpTest(test.TestCase): with self.assertRaises(ValueError): array_ops.diag_part(0.0) + @test_util.run_deprecated_v1 def testUnevenDimensions(self): w = np.random.rand(2, 5) x = np.random.rand(2, 1, 2, 3) @@ -493,6 +517,7 @@ class DiagPartOpTest(test.TestCase): class DiagGradOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testDiagGrad(self): np.random.seed(0) shapes = ((3,), (3, 3), (3, 3, 3)) @@ -513,6 +538,7 @@ class DiagGradOpTest(test.TestCase): class DiagGradPartOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testDiagPartGrad(self): np.random.seed(0) shapes = ((3, 3), (3, 3, 3, 3)) diff --git a/tensorflow/python/kernel_tests/distributions/bernoulli_test.py b/tensorflow/python/kernel_tests/distributions/bernoulli_test.py index 37b35ba51a8..e6d560b4bc4 100644 --- a/tensorflow/python/kernel_tests/distributions/bernoulli_test.py +++ b/tensorflow/python/kernel_tests/distributions/bernoulli_test.py @@ -151,6 +151,7 @@ class BernoulliTest(test.TestCase): self.assertAllClose(self.evaluate(dist.prob(x)), expected_pmf) self.assertAllClose(self.evaluate(dist.log_prob(x)), np.log(expected_pmf)) + @test_util.run_deprecated_v1 def testPmfCorrectBroadcastDynamicShape(self): with self.cached_session(): p = array_ops.placeholder(dtype=dtypes.float32) @@ -167,6 +168,7 @@ class BernoulliTest(test.TestCase): }), [[0.2, 0.7, 0.4]]) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testPmfInvalid(self): p = [0.1, 0.2, 0.7] dist = bernoulli.Bernoulli(probs=p, validate_args=True) @@ -193,6 +195,7 @@ class BernoulliTest(test.TestCase): self.evaluate( bernoulli.Bernoulli(probs=p, validate_args=False).log_prob(samps))) + @test_util.run_deprecated_v1 def testBroadcasting(self): with self.cached_session(): p = array_ops.placeholder(dtypes.float32) @@ -207,6 +210,7 @@ class BernoulliTest(test.TestCase): p: [0.5, 0.5, 0.5] })) + @test_util.run_deprecated_v1 def testPmfShapes(self): with self.cached_session(): p = array_ops.placeholder(dtypes.float32, shape=[None, 1]) @@ -276,6 +280,7 @@ class BernoulliTest(test.TestCase): grad_p = tape.gradient(samples, p) self.assertIsNone(grad_p) + @test_util.run_deprecated_v1 def testSampleActsLikeSampleN(self): with self.cached_session() as sess: p = [0.2, 0.6] diff --git a/tensorflow/python/kernel_tests/distributions/bijector_test.py b/tensorflow/python/kernel_tests/distributions/bijector_test.py index e20f59f48ac..a0e0a36fecc 100644 --- a/tensorflow/python/kernel_tests/distributions/bijector_test.py +++ b/tensorflow/python/kernel_tests/distributions/bijector_test.py @@ -132,6 +132,7 @@ class BijectorTestEventNdims(test.TestCase): with self.assertRaisesRegexp(ValueError, "Expected scalar"): bij.inverse_log_det_jacobian(1., event_ndims=(1, 2)) + @test_util.run_deprecated_v1 def testBijectorDynamicEventNdims(self): bij = BrokenBijector(validate_args=True) event_ndims = array_ops.placeholder(dtype=np.int32, shape=None) @@ -301,6 +302,7 @@ class BijectorReduceEventDimsTest(test.TestCase): 8., self.evaluate(bij.inverse_log_det_jacobian(x, event_ndims=2))) + @test_util.run_deprecated_v1 def testHandlesNonStaticEventNdims(self): x_ = [[[1., 2.], [3., 4.]]] x = array_ops.placeholder_with_default(x_, shape=None) diff --git a/tensorflow/python/kernel_tests/distributions/categorical_test.py b/tensorflow/python/kernel_tests/distributions/categorical_test.py index 9c593d2737a..ec1d4ed2070 100644 --- a/tensorflow/python/kernel_tests/distributions/categorical_test.py +++ b/tensorflow/python/kernel_tests/distributions/categorical_test.py @@ -25,6 +25,7 @@ from tensorflow.python.eager import backprop from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_util +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops @@ -44,6 +45,7 @@ def make_categorical(batch_shape, num_classes, dtype=dtypes.int32): class CategoricalTest(test.TestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testP(self): p = [0.2, 0.8] dist = categorical.Categorical(probs=p) @@ -51,6 +53,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertAllClose(p, dist.probs.eval()) self.assertAllEqual([2], dist.logits.get_shape()) + @test_util.run_deprecated_v1 def testLogits(self): p = np.array([0.2, 0.8], dtype=np.float32) logits = np.log(p) - 50. @@ -61,6 +64,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertAllClose(dist.probs.eval(), p) self.assertAllClose(dist.logits.eval(), logits) + @test_util.run_deprecated_v1 def testShapes(self): with self.cached_session(): for batch_shape in ([], [1], [2, 3, 4]): @@ -107,6 +111,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertEqual(dist.dtype, dtype) self.assertEqual(dist.dtype, dist.sample(5).dtype) + @test_util.run_deprecated_v1 def testUnknownShape(self): with self.cached_session(): logits = array_ops.placeholder(dtype=dtypes.float32) @@ -121,18 +126,21 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): feed_dict={logits: [[-1000.0, 1000.0], [1000.0, -1000.0]]}) self.assertAllEqual([1, 0], sample_value_batch) + @test_util.run_deprecated_v1 def testPMFWithBatch(self): histograms = [[0.2, 0.8], [0.6, 0.4]] dist = categorical.Categorical(math_ops.log(histograms) - 50.) with self.cached_session(): self.assertAllClose(dist.prob([0, 1]).eval(), [0.2, 0.4]) + @test_util.run_deprecated_v1 def testPMFNoBatch(self): histograms = [0.2, 0.8] dist = categorical.Categorical(math_ops.log(histograms) - 50.) with self.cached_session(): self.assertAllClose(dist.prob(0).eval(), 0.2) + @test_util.run_deprecated_v1 def testCDFWithDynamicEventShapeKnownNdims(self): """Test that dynamically-sized events with unknown shape work.""" batch_size = 2 @@ -184,6 +192,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): actual_cdf = self.evaluate(cdf_op) self.assertAllClose(actual_cdf, expected_cdf) + @test_util.run_deprecated_v1 def testCDFWithBatch(self): histograms = [[0.1, 0.2, 0.3, 0.25, 0.15], [0.0, 0.75, 0.2, 0.05, 0.0]] @@ -195,6 +204,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): with self.cached_session(): self.assertAllClose(cdf_op.eval(), expected_cdf) + @test_util.run_deprecated_v1 def testCDFNoBatch(self): histogram = [0.1, 0.2, 0.3, 0.4] event = 2 @@ -205,6 +215,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): with self.cached_session(): self.assertAlmostEqual(cdf_op.eval(), expected_cdf) + @test_util.run_deprecated_v1 def testCDFBroadcasting(self): # shape: [batch=2, n_bins=3] histograms = [[0.2, 0.1, 0.7], @@ -298,6 +309,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertAllEqual(run_result["cat_log_cdf"].shape, run_result["norm_log_cdf"].shape) + @test_util.run_deprecated_v1 def testLogPMF(self): logits = np.log([[0.2, 0.8], [0.6, 0.4]]) - 50. dist = categorical.Categorical(logits) @@ -305,6 +317,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertAllClose(dist.log_prob([0, 1]).eval(), np.log([0.2, 0.4])) self.assertAllClose(dist.log_prob([0.0, 1.0]).eval(), np.log([0.2, 0.4])) + @test_util.run_deprecated_v1 def testEntropyNoBatch(self): logits = np.log([0.2, 0.8]) - 50. dist = categorical.Categorical(logits) @@ -312,6 +325,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertAllClose(dist.entropy().eval(), -(0.2 * np.log(0.2) + 0.8 * np.log(0.8))) + @test_util.run_deprecated_v1 def testEntropyWithBatch(self): logits = np.log([[0.2, 0.8], [0.6, 0.4]]) - 50. dist = categorical.Categorical(logits) @@ -321,6 +335,7 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): -(0.6 * np.log(0.6) + 0.4 * np.log(0.4)) ]) + @test_util.run_deprecated_v1 def testEntropyGradient(self): with self.cached_session() as sess: logits = constant_op.constant([[1., 2., 3.], [2., 5., 1.]]) @@ -440,12 +455,14 @@ class CategoricalTest(test.TestCase, parameterized.TestCase): self.assertEqual(3, log_prob.get_shape().ndims) self.assertAllEqual([2, 2, 2], log_prob.get_shape()) + @test_util.run_deprecated_v1 def testMode(self): with self.cached_session(): histograms = [[[0.2, 0.8], [0.6, 0.4]]] dist = categorical.Categorical(math_ops.log(histograms) - 50.) self.assertAllEqual(dist.mode().eval(), [[1, 0]]) + @test_util.run_deprecated_v1 def testCategoricalCategoricalKL(self): def np_softmax(logits): diff --git a/tensorflow/python/kernel_tests/distributions/dirichlet_multinomial_test.py b/tensorflow/python/kernel_tests/distributions/dirichlet_multinomial_test.py index 3662ca1ad1f..c530037e1ed 100644 --- a/tensorflow/python/kernel_tests/distributions/dirichlet_multinomial_test.py +++ b/tensorflow/python/kernel_tests/distributions/dirichlet_multinomial_test.py @@ -22,6 +22,7 @@ from tensorflow.python.eager import backprop from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops.distributions import dirichlet_multinomial @@ -36,6 +37,7 @@ class DirichletMultinomialTest(test.TestCase): def setUp(self): self._rng = np.random.RandomState(42) + @test_util.run_deprecated_v1 def testSimpleShapes(self): with self.cached_session(): alpha = np.random.rand(3) @@ -45,6 +47,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertEqual(tensor_shape.TensorShape([3]), dist.event_shape) self.assertEqual(tensor_shape.TensorShape([]), dist.batch_shape) + @test_util.run_deprecated_v1 def testComplexShapes(self): with self.cached_session(): alpha = np.random.rand(3, 2, 2) @@ -55,6 +58,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertEqual(tensor_shape.TensorShape([2]), dist.event_shape) self.assertEqual(tensor_shape.TensorShape([3, 2]), dist.batch_shape) + @test_util.run_deprecated_v1 def testNproperty(self): alpha = [[1., 2, 3]] n = [[5.]] @@ -63,6 +67,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertEqual([1, 1], dist.total_count.get_shape()) self.assertAllClose(n, dist.total_count.eval()) + @test_util.run_deprecated_v1 def testAlphaProperty(self): alpha = [[1., 2, 3]] with self.cached_session(): @@ -70,6 +75,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertEqual([1, 3], dist.concentration.get_shape()) self.assertAllClose(alpha, dist.concentration.eval()) + @test_util.run_deprecated_v1 def testPmfNandCountsAgree(self): alpha = [[1., 2, 3]] n = [[5.]] @@ -83,6 +89,7 @@ class DirichletMultinomialTest(test.TestCase): "last-dimension must sum to `self.total_count`"): dist.prob([3., 3, 0]).eval() + @test_util.run_deprecated_v1 def testPmfNonIntegerCounts(self): alpha = [[1., 2, 3]] n = [[5.]] @@ -178,6 +185,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertAllClose([1 / 3., 2 / 5.], self.evaluate(pmf)) self.assertAllEqual([2], pmf.get_shape()) + @test_util.run_deprecated_v1 def testPmfForOneVoteIsTheMeanWithOneRecordInput(self): # The probabilities of one vote falling into class k is the mean for class # k. @@ -194,6 +202,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertAllEqual([3], mean.shape) self.assertAllEqual([], pmf.shape) + @test_util.run_deprecated_v1 def testMeanDoubleTwoVotes(self): # The probabilities of two votes falling into class k for # DirichletMultinomial(2, alpha) is twice as much as the probability of one @@ -215,6 +224,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertAllClose(mean2[class_num], 2 * mean1[class_num]) self.assertAllEqual([3], mean1.shape) + @test_util.run_deprecated_v1 def testCovarianceFromSampling(self): # We will test mean, cov, var, stddev on a DirichletMultinomial constructed # via broadcast between alpha, n. @@ -412,6 +422,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertLess(5 * self.evaluate(pmf_different), self.evaluate(pmf_same)) self.assertEqual((), pmf_same.get_shape()) + @test_util.run_deprecated_v1 def testNonStrictTurnsOffAllChecks(self): # Make totally invalid input. with self.cached_session(): @@ -421,6 +432,7 @@ class DirichletMultinomialTest(test.TestCase): dist = ds.DirichletMultinomial(n, alpha, validate_args=False) dist.prob(counts).eval() # Should not raise. + @test_util.run_deprecated_v1 def testSampleUnbiasedNonScalarBatch(self): with self.cached_session() as sess: dist = ds.DirichletMultinomial( @@ -450,6 +462,7 @@ class DirichletMultinomialTest(test.TestCase): self.assertAllClose( actual_covariance_, sample_covariance_, atol=0., rtol=0.20) + @test_util.run_deprecated_v1 def testSampleUnbiasedScalarBatch(self): with self.cached_session() as sess: dist = ds.DirichletMultinomial( diff --git a/tensorflow/python/kernel_tests/distributions/identity_bijector_test.py b/tensorflow/python/kernel_tests/distributions/identity_bijector_test.py index e35a8e1cdd7..62b562387d0 100644 --- a/tensorflow/python/kernel_tests/distributions/identity_bijector_test.py +++ b/tensorflow/python/kernel_tests/distributions/identity_bijector_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops.distributions import bijector_test_util from tensorflow.python.ops.distributions import identity_bijector from tensorflow.python.platform import test @@ -41,6 +42,7 @@ class IdentityBijectorTest(test.TestCase): self.evaluate( bijector.forward_log_det_jacobian(x, event_ndims=3))) + @test_util.run_deprecated_v1 def testScalarCongruency(self): with self.cached_session(): bijector = identity_bijector.Identity() diff --git a/tensorflow/python/kernel_tests/distributions/kullback_leibler_test.py b/tensorflow/python/kernel_tests/distributions/kullback_leibler_test.py index b8bc2e55cfe..1e967de570f 100644 --- a/tensorflow/python/kernel_tests/distributions/kullback_leibler_test.py +++ b/tensorflow/python/kernel_tests/distributions/kullback_leibler_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops.distributions import kullback_leibler from tensorflow.python.ops.distributions import normal @@ -45,6 +46,7 @@ class KLTest(test.TestCase): a = MyDist(loc=0.0, scale=1.0) self.assertEqual("OK", kullback_leibler.kl_divergence(a, a, name="OK")) + @test_util.run_deprecated_v1 def testDomainErrorExceptions(self): class MyDistException(normal.Normal): diff --git a/tensorflow/python/kernel_tests/distributions/normal_test.py b/tensorflow/python/kernel_tests/distributions/normal_test.py index 6625a88843f..f2a193e69bd 100644 --- a/tensorflow/python/kernel_tests/distributions/normal_test.py +++ b/tensorflow/python/kernel_tests/distributions/normal_test.py @@ -511,6 +511,7 @@ class NormalTest(test.TestCase): self.assertAllEqual(self.evaluate(normal.event_shape_tensor()), []) self.assertEqual(normal.event_shape, tensor_shape.TensorShape([])) + @test_util.run_deprecated_v1 def testNormalShapeWithPlaceholders(self): mu = array_ops.placeholder(dtype=dtypes.float32) sigma = array_ops.placeholder(dtype=dtypes.float32) diff --git a/tensorflow/python/kernel_tests/distributions/special_math_test.py b/tensorflow/python/kernel_tests/distributions/special_math_test.py index 0f800b95fac..d97fcfa655f 100644 --- a/tensorflow/python/kernel_tests/distributions/special_math_test.py +++ b/tensorflow/python/kernel_tests/distributions/special_math_test.py @@ -104,6 +104,7 @@ class NdtriTest(test.TestCase): x = special_math.ndtri(p) self.assertAllClose(expected_x, self.evaluate(x), atol=0.) + @test_util.run_deprecated_v1 def testNdtriDynamicShape(self): """Verifies that ndtri computation is correct.""" with self.cached_session() as sess: @@ -213,9 +214,11 @@ class NdtrTest(test.TestCase): rtol=error_spec.rtol, atol=error_spec.atol) + @test_util.run_deprecated_v1 def test_float32(self): self._test_grid(np.float32, self._grid32, self._error32) + @test_util.run_deprecated_v1 def test_float64(self): self._test_grid(np.float64, self._grid64, self._error64) @@ -338,10 +341,12 @@ class NdtrGradientTest(test.TestCase): rtol=error_spec.rtol, atol=error_spec.atol) + @test_util.run_deprecated_v1 def test_float32(self): self._test_grad_accuracy(np.float32, self._grid, self._error32) self._test_grad_finite(np.float32) + @test_util.run_deprecated_v1 def test_float64(self): self._test_grad_accuracy(np.float64, self._grid, self._error64) self._test_grad_finite(np.float64) @@ -418,6 +423,7 @@ class LogCDFLaplaceTest(test.TestCase): rtol=error_spec.rtol, atol=error_spec.atol) + @test_util.run_deprecated_v1 def test_float32_lower_and_mid_segment_scipy_float32_ok(self): # Choose values mild enough that we can use scipy in float32, which will # allow for a high accuracy match to scipy (since we both use float32). @@ -427,6 +433,7 @@ class LogCDFLaplaceTest(test.TestCase): GridSpec(min=-10, max=self.CUTOFF_FLOAT32_UPPER - 5, shape=[100]), ErrorSpec(rtol=5e-4, atol=0)) + @test_util.run_deprecated_v1 def test_float32_all_segments_with_scipy_float64_ok(self): # Choose values outside the range where scipy float32 works. # Let scipy use float64. This means we @@ -437,6 +444,7 @@ class LogCDFLaplaceTest(test.TestCase): GridSpec(min=-50, max=self.CUTOFF_FLOAT32_UPPER + 5, shape=[100]), ErrorSpec(rtol=0.05, atol=0)) + @test_util.run_deprecated_v1 def test_float32_extreme_values_result_and_gradient_finite_and_nonzero(self): with self.cached_session() as sess: # On the lower branch, log_cdf_laplace(x) = x, so we know this will be @@ -456,6 +464,7 @@ class LogCDFLaplaceTest(test.TestCase): self.assertFalse(np.any(actual_ == 0)) self.assertFalse(np.any(grad_ == 0)) + @test_util.run_deprecated_v1 def test_float64_extreme_values_result_and_gradient_finite_and_nonzero(self): with self.cached_session() as sess: # On the lower branch, log_cdf_laplace(x) = x, so we know this will be diff --git a/tensorflow/python/kernel_tests/distributions/util_test.py b/tensorflow/python/kernel_tests/distributions/util_test.py index d3fa513f059..030ad601bf4 100644 --- a/tensorflow/python/kernel_tests/distributions/util_test.py +++ b/tensorflow/python/kernel_tests/distributions/util_test.py @@ -59,6 +59,7 @@ def _logit(x): class AssertCloseTest(test.TestCase): + @test_util.run_deprecated_v1 def testAssertIntegerForm(self): # This should only be detected as an integer. x = array_ops.placeholder(dtypes.float32) @@ -112,6 +113,7 @@ class MaybeGetStaticTest(test.TestCase): self.assertAllClose( np.array(2.), du.maybe_get_static_value(x, dtype=np.float64)) + @test_util.run_deprecated_v1 def testGetStaticPlaceholder(self): x = array_ops.placeholder(dtype=dtypes.int32, shape=[1]) self.assertEqual(None, du.maybe_get_static_value(x)) @@ -235,6 +237,7 @@ class GetLogitsAndProbsTest(test.TestCase): probs=p4, multidimensional=True, validate_args=False) self.evaluate(prob) + @test_util.run_deprecated_v1 def testProbsMultidimShape(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -249,6 +252,7 @@ class GetLogitsAndProbsTest(test.TestCase): probs=p, multidimensional=True, validate_args=True) prob.eval(feed_dict={p: np.ones([int(2**11+1)])}) + @test_util.run_deprecated_v1 def testLogitsMultidimShape(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -266,6 +270,7 @@ class GetLogitsAndProbsTest(test.TestCase): class EmbedCheckCategoricalEventShapeTest(test.TestCase): + @test_util.run_deprecated_v1 def testTooSmall(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -280,6 +285,7 @@ class EmbedCheckCategoricalEventShapeTest(test.TestCase): param) checked_param.eval(feed_dict={param: np.ones([1])}) + @test_util.run_deprecated_v1 def testTooLarge(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -305,6 +311,7 @@ class EmbedCheckCategoricalEventShapeTest(test.TestCase): class EmbedCheckIntegerCastingClosedTest(test.TestCase): + @test_util.run_deprecated_v1 def testCorrectlyAssertsNonnegative(self): with self.cached_session(): with self.assertRaisesOpError("Elements must be non-negative"): @@ -313,6 +320,7 @@ class EmbedCheckIntegerCastingClosedTest(test.TestCase): x, target_dtype=dtypes.int16) x_checked.eval(feed_dict={x: np.array([1, -1], dtype=np.float16)}) + @test_util.run_deprecated_v1 def testCorrectlyAssersIntegerForm(self): with self.cached_session(): with self.assertRaisesOpError("Elements must be int16-equivalent."): @@ -321,6 +329,7 @@ class EmbedCheckIntegerCastingClosedTest(test.TestCase): x, target_dtype=dtypes.int16) x_checked.eval(feed_dict={x: np.array([1, 1.5], dtype=np.float16)}) + @test_util.run_deprecated_v1 def testCorrectlyAssertsLargestPossibleInteger(self): with self.cached_session(): with self.assertRaisesOpError("Elements cannot exceed 32767."): @@ -329,6 +338,7 @@ class EmbedCheckIntegerCastingClosedTest(test.TestCase): x, target_dtype=dtypes.int16) x_checked.eval(feed_dict={x: np.array([1, 2**15], dtype=np.int32)}) + @test_util.run_deprecated_v1 def testCorrectlyAssertsSmallestPossibleInteger(self): with self.cached_session(): with self.assertRaisesOpError("Elements cannot be smaller than 0."): @@ -369,6 +379,7 @@ class LogCombinationsTest(test.TestCase): class DynamicShapeTest(test.TestCase): + @test_util.run_deprecated_v1 def testSameDynamicShape(self): with self.cached_session(): scalar = constant_op.constant(2.0) @@ -493,6 +504,7 @@ class RotateTransposeTest(test.TestCase): self._np_rotate_transpose(x, shift), self.evaluate(y)) self.assertAllEqual(np.roll(x.shape, shift), y.get_shape().as_list()) + @test_util.run_deprecated_v1 def testRollDynamic(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32) @@ -511,6 +523,7 @@ class RotateTransposeTest(test.TestCase): class PickVectorTest(test.TestCase): + @test_util.run_deprecated_v1 def testCorrectlyPicksVector(self): with self.cached_session(): x = np.arange(10, 12) @@ -529,36 +542,42 @@ class PickVectorTest(test.TestCase): class PreferStaticRankTest(test.TestCase): + @test_util.run_deprecated_v1 def testNonEmptyConstantTensor(self): x = array_ops.zeros((2, 3, 4)) rank = du.prefer_static_rank(x) self.assertIsInstance(rank, np.ndarray) self.assertEqual(3, rank) + @test_util.run_deprecated_v1 def testEmptyConstantTensor(self): x = constant_op.constant([]) rank = du.prefer_static_rank(x) self.assertIsInstance(rank, np.ndarray) self.assertEqual(1, rank) + @test_util.run_deprecated_v1 def testScalarTensor(self): x = constant_op.constant(1.) rank = du.prefer_static_rank(x) self.assertIsInstance(rank, np.ndarray) self.assertEqual(0, rank) + @test_util.run_deprecated_v1 def testDynamicRankEndsUpBeingNonEmpty(self): x = array_ops.placeholder(np.float64, shape=None) rank = du.prefer_static_rank(x) with self.cached_session(): self.assertAllEqual(2, rank.eval(feed_dict={x: np.zeros((2, 3))})) + @test_util.run_deprecated_v1 def testDynamicRankEndsUpBeingEmpty(self): x = array_ops.placeholder(np.int32, shape=None) rank = du.prefer_static_rank(x) with self.cached_session(): self.assertAllEqual(1, rank.eval(feed_dict={x: []})) + @test_util.run_deprecated_v1 def testDynamicRankEndsUpBeingScalar(self): x = array_ops.placeholder(np.int32, shape=None) rank = du.prefer_static_rank(x) @@ -568,36 +587,42 @@ class PreferStaticRankTest(test.TestCase): class PreferStaticShapeTest(test.TestCase): + @test_util.run_deprecated_v1 def testNonEmptyConstantTensor(self): x = array_ops.zeros((2, 3, 4)) shape = du.prefer_static_shape(x) self.assertIsInstance(shape, np.ndarray) self.assertAllEqual(np.array([2, 3, 4]), shape) + @test_util.run_deprecated_v1 def testEmptyConstantTensor(self): x = constant_op.constant([]) shape = du.prefer_static_shape(x) self.assertIsInstance(shape, np.ndarray) self.assertAllEqual(np.array([0]), shape) + @test_util.run_deprecated_v1 def testScalarTensor(self): x = constant_op.constant(1.) shape = du.prefer_static_shape(x) self.assertIsInstance(shape, np.ndarray) self.assertAllEqual(np.array([]), shape) + @test_util.run_deprecated_v1 def testDynamicShapeEndsUpBeingNonEmpty(self): x = array_ops.placeholder(np.float64, shape=None) shape = du.prefer_static_shape(x) with self.cached_session(): self.assertAllEqual((2, 3), shape.eval(feed_dict={x: np.zeros((2, 3))})) + @test_util.run_deprecated_v1 def testDynamicShapeEndsUpBeingEmpty(self): x = array_ops.placeholder(np.int32, shape=None) shape = du.prefer_static_shape(x) with self.cached_session(): self.assertAllEqual(np.array([0]), shape.eval(feed_dict={x: []})) + @test_util.run_deprecated_v1 def testDynamicShapeEndsUpBeingScalar(self): x = array_ops.placeholder(np.int32, shape=None) shape = du.prefer_static_shape(x) @@ -607,24 +632,28 @@ class PreferStaticShapeTest(test.TestCase): class PreferStaticValueTest(test.TestCase): + @test_util.run_deprecated_v1 def testNonEmptyConstantTensor(self): x = array_ops.zeros((2, 3, 4)) value = du.prefer_static_value(x) self.assertIsInstance(value, np.ndarray) self.assertAllEqual(np.zeros((2, 3, 4)), value) + @test_util.run_deprecated_v1 def testEmptyConstantTensor(self): x = constant_op.constant([]) value = du.prefer_static_value(x) self.assertIsInstance(value, np.ndarray) self.assertAllEqual(np.array([]), value) + @test_util.run_deprecated_v1 def testScalarTensor(self): x = constant_op.constant(1.) value = du.prefer_static_value(x) self.assertIsInstance(value, np.ndarray) self.assertAllEqual(np.array(1.), value) + @test_util.run_deprecated_v1 def testDynamicValueEndsUpBeingNonEmpty(self): x = array_ops.placeholder(np.float64, shape=None) value = du.prefer_static_value(x) @@ -632,12 +661,14 @@ class PreferStaticValueTest(test.TestCase): self.assertAllEqual(np.zeros((2, 3)), value.eval(feed_dict={x: np.zeros((2, 3))})) + @test_util.run_deprecated_v1 def testDynamicValueEndsUpBeingEmpty(self): x = array_ops.placeholder(np.int32, shape=None) value = du.prefer_static_value(x) with self.cached_session(): self.assertAllEqual(np.array([]), value.eval(feed_dict={x: []})) + @test_util.run_deprecated_v1 def testDynamicValueEndsUpBeingScalar(self): x = array_ops.placeholder(np.int32, shape=None) value = du.prefer_static_value(x) @@ -698,43 +729,55 @@ class FillTriangularTest(test.TestCase): self.assertAllClose(expected, actual_, rtol=1e-8, atol=1e-9) self.assertAllClose(x_, grad_actual_, rtol=1e-8, atol=1e-9) + @test_util.run_deprecated_v1 def testCorrectlyMakes1x1TriLower(self): self._run_test(self._rng.randn(3, int(1*2/2))) + @test_util.run_deprecated_v1 def testCorrectlyMakesNoBatchTriLower(self): self._run_test(self._rng.randn(int(4*5/2))) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatchTriLower(self): self._run_test(self._rng.randn(2, 3, int(3*4/2))) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatchTriLowerUnknownShape(self): self._run_test(self._rng.randn(2, 3, int(3*4/2)), use_deferred_shape=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatch7x7TriLowerUnknownShape(self): self._run_test(self._rng.randn(2, 3, int(7*8/2)), use_deferred_shape=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatch7x7TriLower(self): self._run_test(self._rng.randn(2, 3, int(7*8/2))) + @test_util.run_deprecated_v1 def testCorrectlyMakes1x1TriUpper(self): self._run_test(self._rng.randn(3, int(1*2/2)), upper=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesNoBatchTriUpper(self): self._run_test(self._rng.randn(int(4*5/2)), upper=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatchTriUpper(self): self._run_test(self._rng.randn(2, 2, int(3*4/2)), upper=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatchTriUpperUnknownShape(self): self._run_test(self._rng.randn(2, 2, int(3*4/2)), use_deferred_shape=True, upper=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatch7x7TriUpperUnknownShape(self): self._run_test(self._rng.randn(2, 3, int(7*8/2)), use_deferred_shape=True, upper=True) + @test_util.run_deprecated_v1 def testCorrectlyMakesBatch7x7TriUpper(self): self._run_test(self._rng.randn(2, 3, int(7*8/2)), upper=True) @@ -773,6 +816,7 @@ class ReduceWeightedLogSumExp(test.TestCase): m = np.squeeze(m, axis=axis) return m + np.log(sgn * sum_), sgn + @test_util.run_deprecated_v1 def testNoWeights(self): logx_ = np.array([[0., -1, 1000.], [0, 1, -1000.], @@ -903,6 +947,7 @@ class SoftplusTest(test.TestCase): self.assertAllEqual(np.ones_like(tf_softplus_inverse).astype(np.bool), np.isfinite(tf_softplus_inverse)) + @test_util.run_deprecated_v1 def testNumbers(self): for t in [np.float16, np.float32, np.float64]: lower = {np.float16: -15, np.float32: -50, np.float64: -50}.get(t, -100) @@ -933,6 +978,7 @@ class SoftplusTest(test.TestCase): ], use_gpu=True) + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): x = constant_op.constant( @@ -949,6 +995,7 @@ class SoftplusTest(test.TestCase): tf_logging.vlog(2, "softplus (float) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testInverseSoftplusGradientNeverNan(self): with self.cached_session(): # Note that this range contains both zero and inf. @@ -958,6 +1005,7 @@ class SoftplusTest(test.TestCase): # Equivalent to `assertAllFalse` (if it existed). self.assertAllEqual(np.zeros_like(grads).astype(np.bool), np.isnan(grads)) + @test_util.run_deprecated_v1 def testInverseSoftplusGradientFinite(self): with self.cached_session(): # This range of x is all finite, and so is 1 / x. So the diff --git a/tensorflow/python/kernel_tests/duplicate_op_test.py b/tensorflow/python/kernel_tests/duplicate_op_test.py index 654267a5825..fef3127d4a8 100644 --- a/tensorflow/python/kernel_tests/duplicate_op_test.py +++ b/tensorflow/python/kernel_tests/duplicate_op_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import os from tensorflow.python.framework import load_library +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.platform import resource_loader from tensorflow.python.platform import test @@ -27,6 +28,7 @@ from tensorflow.python.platform import test class DuplicateOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): library_filename = os.path.join(resource_loader.get_data_files_path(), 'duplicate_op.so') diff --git a/tensorflow/python/kernel_tests/dynamic_partition_op_test.py b/tensorflow/python/kernel_tests/dynamic_partition_op_test.py index 3622fde3f3a..8c448194076 100644 --- a/tensorflow/python/kernel_tests/dynamic_partition_op_test.py +++ b/tensorflow/python/kernel_tests/dynamic_partition_op_test.py @@ -25,6 +25,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import gradients_impl @@ -34,6 +35,7 @@ from tensorflow.python.platform import test class DynamicPartitionTest(test.TestCase): + @test_util.run_deprecated_v1 def testSimpleOneDimensional(self): with self.session(use_gpu=True) as sess: data = constant_op.constant([0, 13, 2, 39, 4, 17], dtype=dtypes.float32) @@ -54,6 +56,7 @@ class DynamicPartitionTest(test.TestCase): self.assertEqual([None], partitions[2].get_shape().as_list()) self.assertEqual([None], partitions[3].get_shape().as_list()) + @test_util.run_deprecated_v1 def testSimpleTwoDimensional(self): with self.session(use_gpu=True) as sess: data = constant_op.constant([[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], @@ -151,6 +154,7 @@ class DynamicPartitionTest(test.TestCase): dtype=np.float64).reshape(-1, 4), partition_vals[3]) + @test_util.run_deprecated_v1 def testHigherRank(self): np.random.seed(7) with self.session(use_gpu=True) as sess: @@ -287,6 +291,7 @@ class DynamicPartitionTest(test.TestCase): for i in range(40): self.assertAllEqual([], partition_vals[i]) + @test_util.run_deprecated_v1 def testErrorIndexOutOfRange(self): with self.cached_session() as sess: data = constant_op.constant([[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], @@ -297,6 +302,7 @@ class DynamicPartitionTest(test.TestCase): with self.assertRaisesOpError(r"partitions\[2\] = 99 is not in \[0, 4\)"): self.evaluate(partitions) + @test_util.run_deprecated_v1 def testScalarIndexOutOfRange(self): with self.cached_session() as sess: bad = 17 @@ -305,6 +311,7 @@ class DynamicPartitionTest(test.TestCase): with self.assertRaisesOpError(r"partitions = 17 is not in \[0, 7\)"): self.evaluate(partitions) + @test_util.run_deprecated_v1 def testHigherRankIndexOutOfRange(self): with self.cached_session() as sess: shape = (2, 3) @@ -320,6 +327,7 @@ class DynamicPartitionTest(test.TestCase): r"partitions\[%d,%d\] = 17 is not in \[0, 7\)" % (i, j)): sess.run(partitions, feed_dict={indices: bad}) + @test_util.run_deprecated_v1 def testErrorWrongDimsIndices(self): data = constant_op.constant([[0], [1], [2]]) indices = constant_op.constant([[0], [0]]) diff --git a/tensorflow/python/kernel_tests/dynamic_stitch_op_test.py b/tensorflow/python/kernel_tests/dynamic_stitch_op_test.py index 3d063c4e0ec..4f338880aa3 100644 --- a/tensorflow/python/kernel_tests/dynamic_stitch_op_test.py +++ b/tensorflow/python/kernel_tests/dynamic_stitch_op_test.py @@ -47,6 +47,7 @@ class DynamicStitchTestBase(object): # Dimension 0 is max(flatten(indices))+1. self.assertEqual([2], stitched_t.get_shape().as_list()) + @test_util.run_deprecated_v1 def testShapeInferenceForScalarWithNonConstantIndices(self): with test_util.use_gpu(): indices = [ @@ -134,6 +135,7 @@ class DynamicStitchTestBase(object): # Dimension 0 is max(flatten(indices))+1. self.assertEqual([8, 2], stitched_t.get_shape().as_list()) + @test_util.run_deprecated_v1 def testHigherRank(self): with self.session(use_gpu=True) as sess: indices = [ @@ -160,6 +162,7 @@ class DynamicStitchTestBase(object): for datum, grad in zip(data, sess.run(grads[3:])): self.assertAllEqual(7. * self.evaluate(datum), grad) + @test_util.run_deprecated_v1 def testErrorIndicesMultiDimensional(self): indices = [ constant_op.constant([0, 4, 7]), @@ -172,6 +175,7 @@ class DynamicStitchTestBase(object): with self.assertRaises(ValueError): self.stitch_op(indices, data) + @test_util.run_deprecated_v1 def testErrorDataNumDimsMismatch(self): indices = [ constant_op.constant([0, 4, 7]), @@ -184,6 +188,7 @@ class DynamicStitchTestBase(object): with self.assertRaises(ValueError): self.stitch_op(indices, data) + @test_util.run_deprecated_v1 def testErrorDataDimSizeMismatch(self): indices = [ constant_op.constant([0, 4, 5]), @@ -196,6 +201,7 @@ class DynamicStitchTestBase(object): with self.assertRaises(ValueError): self.stitch_op(indices, data) + @test_util.run_deprecated_v1 def testErrorDataAndIndicesSizeMismatch(self): indices = [ constant_op.constant([0, 4, 7]), @@ -233,6 +239,7 @@ class ParallelDynamicStitchTest(DynamicStitchTestBase, test.TestCase): # Dimension 0 is max(flatten(indices))+1. self.assertEqual([2], stitched_t.get_shape().as_list()) + @test_util.run_deprecated_v1 def testHigherRank(self): with self.session(use_gpu=True) as sess: indices = [ @@ -271,6 +278,7 @@ class ParallelDynamicStitchTest(DynamicStitchTestBase, test.TestCase): # Dimension 0 is max(flatten(indices))+1. self.assertEqual([2], stitched_t.get_shape().as_list()) + @test_util.run_deprecated_v1 def testHigherRankGPU(self): with self.cached_session() as sess: indices = [ diff --git a/tensorflow/python/kernel_tests/embedding_ops_test.py b/tensorflow/python/kernel_tests/embedding_ops_test.py index 39c0575cd55..6019245d0f8 100644 --- a/tensorflow/python/kernel_tests/embedding_ops_test.py +++ b/tensorflow/python/kernel_tests/embedding_ops_test.py @@ -28,6 +28,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import embedding_ops @@ -87,16 +88,19 @@ class ScatterAddSubTest(test.TestCase): vals_shape[0], -1)[i, :]) self.assertTrue(all((p_init == result).ravel())) + @test_util.run_deprecated_v1 def testNoRepetitions(self): self._TestCase([2, 2], [1]) self._TestCase([4, 4, 4], [2, 0]) self._TestCase([43, 20, 10, 10], [42, 5, 6, 1, 3, 5, 7, 9]) + @test_util.run_deprecated_v1 def testWithRepetitions(self): self._TestCase([2, 2], [1, 1]) self._TestCase([5, 3, 9, 5], [2, 0, 4, 1, 3, 1, 4, 0, 4, 3]) self._TestCase([32, 4, 4], [31] * 8) + @test_util.run_deprecated_v1 def testRandom(self): # Random shapes of rank 4, random indices for _ in range(5): @@ -104,6 +108,7 @@ class ScatterAddSubTest(test.TestCase): indices = np.random.randint(shape[0], size=2 * shape[0]) self._TestCase(_AsLong(list(shape)), list(indices)) + @test_util.run_deprecated_v1 def testSubRandom(self): # Random shapes of rank 4, random indices for _ in range(5): @@ -111,6 +116,7 @@ class ScatterAddSubTest(test.TestCase): indices = np.random.randint(shape[0], size=2 * shape[0]) self._TestCase(_AsLong(list(shape)), list(indices), state_ops.scatter_sub) + @test_util.run_deprecated_v1 def testWrongShape(self): # Indices and values mismatch. var = variables.Variable( @@ -241,6 +247,7 @@ class EmbeddingLookupTest(test.TestCase): # both the ids are in the first shard, one of the resulting lookup # vector is going to be empty. The subsequent DivOp fails because of that. # TODO(keveman): Disabling the test until the underlying problem is fixed. + @test_util.run_deprecated_v1 def testSimpleSharded(self): with self.cached_session(): num_shards = 2 @@ -257,6 +264,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testMaxNorm(self): with self.cached_session(): embeddings = constant_op.constant([[2.0]]) @@ -267,6 +275,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(embedding.eval(), [[1.0]]) + @test_util.run_deprecated_v1 def testMaxNormNontrivial(self): with self.cached_session(): embeddings = constant_op.constant([[2.0, 4.0], [3.0, 1.0]]) @@ -280,6 +289,7 @@ class EmbeddingLookupTest(test.TestCase): normalized = embeddings / array_ops.stack([norms, norms], axis=1) self.assertAllEqual(embedding.eval(), 2 * self.evaluate(normalized)) + @test_util.run_deprecated_v1 def testSimpleShardedPartitionedVariable(self): with self.cached_session() as sess: num_shards = 2 @@ -302,6 +312,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testSimpleShardedPartitionedResourceVariable(self): with self.cached_session() as sess: num_shards = 2 @@ -325,6 +336,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedModPartitioningInt32Ids(self): with self.cached_session(): num_shards = 5 @@ -347,6 +359,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedModPartitioningInt64Ids(self): with self.cached_session(): num_shards = 5 @@ -369,6 +382,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedDivPartitioningInt32Ids(self): with self.cached_session(): num_shards = 5 @@ -393,6 +407,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedDivPartitioningInt32IdsPartitionedVariable(self): with self.cached_session(): num_shards = 5 @@ -418,6 +433,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedDivPartitioningInt64Ids(self): with self.cached_session(): num_shards = 5 @@ -442,6 +458,7 @@ class EmbeddingLookupTest(test.TestCase): self.assertAllEqual(np_result, tf_result) self.assertShapeEqual(np_result, embedding) + @test_util.run_deprecated_v1 def testShardedDivPartitioningUnknownParamShape(self): with self.cached_session(): num_shards = 5 @@ -468,6 +485,7 @@ class EmbeddingLookupTest(test.TestCase): params, id_vals, num_shards, vocab_size, partition_strategy="div") self.assertAllEqual(np_result, tf_result) + @test_util.run_deprecated_v1 def testGradientsEmbeddingLookup(self): vocab_size = 9 num_ids = 10 @@ -488,6 +506,7 @@ class EmbeddingLookupTest(test.TestCase): x, x_shape, y, y_shape, x_init_value=x_init_value) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientsEmbeddingLookupWithComputedParams(self): vocab_size = 9 num_ids = 5 @@ -526,6 +545,7 @@ class EmbeddingLookupTest(test.TestCase): ids = constant_op.constant([0, 1, 1, 17], dtype=dtypes.int32) embedding_ops.embedding_lookup(p, ids) + @test_util.run_deprecated_v1 def testHigherRank(self): np.random.seed(8) with self.cached_session(): @@ -546,6 +566,7 @@ class EmbeddingLookupTest(test.TestCase): sharded = embedding_ops.embedding_lookup(split_params, ids).eval() self.assertAllEqual(simple, sharded) + @test_util.run_deprecated_v1 def testHigherRankMaxNorm(self): np.random.seed(8) with self.cached_session(): @@ -574,6 +595,7 @@ class EmbeddingLookupTest(test.TestCase): split_params, ids, max_norm=1.0).eval() self.assertAllEqual(simple, sharded) + @test_util.run_deprecated_v1 def testTransform(self): # This tests all combinations of: # - ids rank 0, 1, >1 @@ -648,6 +670,7 @@ class EmbeddingLookupSparseTest(test.TestCase): index += num_val return grouped_vals + @test_util.run_deprecated_v1 def testEmbeddingLookupSparse(self): vocab_size = 13 batch_size = 10 @@ -706,6 +729,7 @@ class EmbeddingLookupSparseTest(test.TestCase): atol = rtol self.assertAllClose(np_embedding_sum, tf_embedding_sum, rtol, atol) + @test_util.run_deprecated_v1 def testGradientsEmbeddingLookupSparse(self): vocab_size = 12 batch_size = 4 @@ -733,6 +757,7 @@ class EmbeddingLookupSparseTest(test.TestCase): x, x_shape, y, y_shape, x_init_value=x_init_value) self.assertLess(err, 1e-5 if dtype == dtypes.float64 else 2e-3) + @test_util.run_deprecated_v1 def testIncompatibleShapes(self): with self.cached_session(): x, _, _ = _EmbeddingParams(1, 10, dtype=dtypes.float32) @@ -820,6 +845,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): return sparse_ids, sparse_weights + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_return_zero_vector(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -833,6 +859,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): [(1.0 * embedding_weights[0][0] + 2.0 * embedding_weights[0][1]) / 3.0, [0] * 4, [0] * 4, embedding_weights[0][2], [0] * 4]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_return_special_vector(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -847,6 +874,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): 3.0, embedding_weights[0][3], embedding_weights[0][3], embedding_weights[0][2], embedding_weights[0][3]]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_no_weights(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -861,6 +889,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): [0] * 4, embedding_weights[0][2], ( embedding_weights[0][0] + embedding_weights[0][1]) / 2.0]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_partitioned(self): with self.cached_session(): embedding_weights = self._random_weights(num_shards=3) @@ -875,6 +904,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): [0] * 4, [0] * 4, embedding_weights[2], (embedding_weights[0] + embedding_weights[1]) / 2.0]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_partitioned_inconsistent_weights(self): with self.cached_session(): embedding_weights = self._random_weights(num_shards=3) @@ -890,6 +920,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): self.assertRaises(ValueError, embedding_ops.safe_embedding_lookup_sparse, embedding_weights, sparse_ids, sparse_weights) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_3d_return_zero_vector(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -903,6 +934,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): [0] * 4, [0] * 4 ], [embedding_weights[0][2], [0] * 4, [0] * 4]]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_3d_return_special_vector(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -919,6 +951,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): embedding_weights[0][3] ]]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_3d_no_weights(self): with self.cached_session(): embedding_weights = self._random_weights() @@ -935,6 +968,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): (embedding_weights[0][0] + embedding_weights[0][1]) / 2.0, [0] * 4 ]]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_3d_partitioned(self): with self.cached_session(): embedding_weights = self._random_weights(num_shards=3) @@ -951,6 +985,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): (embedding_weights[0] + embedding_weights[1]) / 2.0, [0] * 4 ]]) + @test_util.run_deprecated_v1 def test_safe_embedding_lookup_sparse_3d_partitioned_inconsistent_weights( self): with self.cached_session(): @@ -970,6 +1005,7 @@ class SafeEmbeddingLookupSparseTest(test.TestCase): class DynamicStitchOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testCint32Cpu(self): with self.session(use_gpu=False): indices = [ @@ -983,6 +1019,7 @@ class DynamicStitchOpTest(test.TestCase): self.assertAllEqual( data_flow_ops.dynamic_stitch(indices, values).eval(), [12, 23, 1, 2]) + @test_util.run_deprecated_v1 def testCint32Gpu(self): with self.session(use_gpu=True): indices = [ @@ -996,6 +1033,7 @@ class DynamicStitchOpTest(test.TestCase): self.assertAllEqual( data_flow_ops.dynamic_stitch(indices, values).eval(), [12, 23, 1, 2]) + @test_util.run_deprecated_v1 def testInt32Cpu(self): with self.session(use_gpu=False): indices = [ @@ -1009,6 +1047,7 @@ class DynamicStitchOpTest(test.TestCase): self.assertAllEqual( data_flow_ops.dynamic_stitch(indices, values).eval(), [12, 23, 1, 2]) + @test_util.run_deprecated_v1 def testInt32Gpu(self): with self.session(use_gpu=True): indices = [ @@ -1022,6 +1061,7 @@ class DynamicStitchOpTest(test.TestCase): self.assertAllEqual( data_flow_ops.dynamic_stitch(indices, values).eval(), [12, 23, 1, 2]) + @test_util.run_deprecated_v1 def testSumGradArgs(self): with self.session(use_gpu=False): indices = [ @@ -1036,6 +1076,7 @@ class DynamicStitchOpTest(test.TestCase): data_flow_ops.dynamic_stitch(indices, values).eval(), [2, 3, 1, 1]) # We expect that the values are merged in order. + @test_util.run_deprecated_v1 def testStitchOrder(self): with self.cached_session(): indices = [] @@ -1051,6 +1092,7 @@ class DynamicStitchOpTest(test.TestCase): class ParallelDynamicStitchOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testCint32Cpu(self): with self.session(use_gpu=False): indices = [ @@ -1065,6 +1107,7 @@ class ParallelDynamicStitchOpTest(test.TestCase): data_flow_ops.parallel_dynamic_stitch(indices, values).eval(), [12, 23, 1, 2, 34, 3, 45]) + @test_util.run_deprecated_v1 def testInt32Cpu(self): with self.session(use_gpu=False): indices = [ @@ -1079,6 +1122,7 @@ class ParallelDynamicStitchOpTest(test.TestCase): data_flow_ops.parallel_dynamic_stitch(indices, values).eval(), [12, 23, 1, 2, 3, 34, 45, 56]) + @test_util.run_deprecated_v1 def testSimple(self): with self.session(use_gpu=False): indices = [ops.convert_to_tensor([0, 1]), ops.convert_to_tensor([2, 3])] diff --git a/tensorflow/python/kernel_tests/extract_image_patches_grad_test.py b/tensorflow/python/kernel_tests/extract_image_patches_grad_test.py index 7d9d4e51752..7ba2dc6c209 100644 --- a/tensorflow/python/kernel_tests/extract_image_patches_grad_test.py +++ b/tensorflow/python/kernel_tests/extract_image_patches_grad_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed as random_seed_lib +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -78,6 +79,7 @@ class ExtractImagePatchesGradTest(test.TestCase): }, ] + @test_util.run_deprecated_v1 def testGradient(self): # Set graph seed for determinism. random_seed = 42 @@ -102,6 +104,7 @@ class ExtractImagePatchesGradTest(test.TestCase): print('extract_image_patches gradient err: %.4e' % err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testConstructGradientWithLargeImages(self): batch_size = 4 height = 1024 diff --git a/tensorflow/python/kernel_tests/fractional_avg_pool_op_test.py b/tensorflow/python/kernel_tests/fractional_avg_pool_op_test.py index 272adecfb8a..0d5928aefac 100644 --- a/tensorflow/python/kernel_tests/fractional_avg_pool_op_test.py +++ b/tensorflow/python/kernel_tests/fractional_avg_pool_op_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker @@ -281,6 +282,7 @@ class FractionalAvgTest(test.TestCase): self._ValidateFractionalAvgPoolResult(rand_mat, [1, 2, 2, 1], pseudo_random, overlapping) + @test_util.run_deprecated_v1 def testDifferentInputTensorShape(self): """Runs the operation in one session with different input tensor shapes.""" with self.cached_session() as sess: @@ -427,6 +429,7 @@ class FractionalAvgPoolGradTest(test.TestCase): self.assertShapeEqual(input_backprop, fap_input_backprop_tensor) self.assertAllClose(input_backprop, fap_input_backprop) + @test_util.run_deprecated_v1 def testAllInputOptionsThroughGradientError(self): input_shape = (1, 7, 13, 1) input_data = self._GenerateRandomInputTensor(input_shape) @@ -455,6 +458,7 @@ class FractionalAvgPoolGradTest(test.TestCase): delta=1e-2) self.assertLess(gradient_error, error_margin) + @test_util.run_deprecated_v1 def testDifferentTensorShapesThroughGradientError(self): pseudo_random = True overlapping = True @@ -486,6 +490,7 @@ class FractionalAvgPoolGradTest(test.TestCase): delta=1e-2) self.assertLess(gradient_error, error_margin) + @test_util.run_deprecated_v1 def testLargePoolingRatioThroughGradientError(self): input_shape = (1, 17, 23, 1) input_data = self._GenerateRandomInputTensor(input_shape) diff --git a/tensorflow/python/kernel_tests/fractional_max_pool_op_test.py b/tensorflow/python/kernel_tests/fractional_max_pool_op_test.py index 9b1e73b318c..fa886cc215a 100644 --- a/tensorflow/python/kernel_tests/fractional_max_pool_op_test.py +++ b/tensorflow/python/kernel_tests/fractional_max_pool_op_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker @@ -278,6 +279,7 @@ class FractionalMaxPoolTest(test.TestCase): self._ValidateFractionalMaxPoolResult(rand_mat, [1, 2, 2, 1], pseudo_random, overlapping) + @test_util.run_deprecated_v1 def testDifferentInputTensorShape(self): """Runs the operation in one session with different input tensor shapes.""" with self.cached_session() as sess: @@ -430,6 +432,7 @@ class FractionalMaxPoolGradTest(test.TestCase): self.assertShapeEqual(input_backprop, fmp_input_backprop_tensor) self.assertAllClose(input_backprop, fmp_input_backprop) + @test_util.run_deprecated_v1 def testAllInputOptionsThroughGradientError(self): input_shape = (1, 7, 13, 1) input_data = self._GenerateUniqueRandomInputTensor(input_shape) @@ -460,6 +463,7 @@ class FractionalMaxPoolGradTest(test.TestCase): delta=1e-2) self.assertLess(gradient_error, error_margin) + @test_util.run_deprecated_v1 def testDifferentTensorShapesThroughGradientError(self): pseudo_random = True overlapping = True @@ -493,6 +497,7 @@ class FractionalMaxPoolGradTest(test.TestCase): delta=1e-2) self.assertLess(gradient_error, error_margin) + @test_util.run_deprecated_v1 def testLargePoolingRatioThroughGradientError(self): input_shape = (1, 17, 23, 1) input_data = self._GenerateUniqueRandomInputTensor(input_shape) diff --git a/tensorflow/python/kernel_tests/functional_ops_test.py b/tensorflow/python/kernel_tests/functional_ops_test.py index 23b3c7e1cc2..c489623fe56 100644 --- a/tensorflow/python/kernel_tests/functional_ops_test.py +++ b/tensorflow/python/kernel_tests/functional_ops_test.py @@ -101,6 +101,7 @@ class FunctionalOpsTest(test.TestCase): (elems, other_elems), initializer) self.assertAllEqual([1.0, 2.0, 3.0], self.evaluate(r)) + @test_util.run_deprecated_v1 def testFoldl_Scoped(self): with self.cached_session() as sess: with variable_scope.variable_scope("root") as varscope: @@ -153,6 +154,7 @@ class FunctionalOpsTest(test.TestCase): initializer) self.assertAllEqual(1, self.evaluate(r)) + @test_util.run_deprecated_v1 def testFoldr_Scoped(self): with self.cached_session() as sess: with variable_scope.variable_scope("root") as varscope: @@ -173,6 +175,7 @@ class FunctionalOpsTest(test.TestCase): self.assertAllEqual(1282, self.evaluate(r)) # pylint: disable=unnecessary-lambda + @test_util.run_deprecated_v1 def testFold_Grad(self): with self.cached_session(): elems = constant_op.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name="data") @@ -214,6 +217,7 @@ class FunctionalOpsTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "not a scalar"): functional_ops.map_fn(lambda x: x, 1) + @test_util.run_deprecated_v1 def testMap_Scoped(self): with self.cached_session() as sess: @@ -245,6 +249,7 @@ class FunctionalOpsTest(test.TestCase): self.assertEqual(len(variables.trainable_variables()), 1) self.assertAllEqual(doubles, self.evaluate(r)) + @test_util.run_deprecated_v1 def testMap_Grad(self): with self.cached_session(): param = constant_op.constant(2.0) @@ -381,6 +386,7 @@ class FunctionalOpsTest(test.TestCase): ValueError, "two structures don't have the same nested structure"): functional_ops.scan(lambda a, x: (a, -a), elems, initializer) + @test_util.run_deprecated_v1 def testScan_Scoped(self): with self.cached_session() as sess: with variable_scope.variable_scope("root") as varscope: @@ -425,6 +431,7 @@ class FunctionalOpsTest(test.TestCase): # t_1 == 1, b == 4.5, y == 0.5, returns b * y * x = 9 self.assertAllClose([1., 1., 2.25, 9.], self.evaluate(r)) + @test_util.run_deprecated_v1 def testScan_Control(self): with self.cached_session() as sess: s = array_ops.placeholder(dtypes.float32, shape=[None]) @@ -436,6 +443,7 @@ class FunctionalOpsTest(test.TestCase): np.array([1.0, 3.0, 9.0]), sess.run(c, {s: [1, 3, 3], b: True})) + @test_util.run_deprecated_v1 def testScan_Grad(self): with self.cached_session(): elems = constant_op.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name="data") @@ -448,6 +456,7 @@ class FunctionalOpsTest(test.TestCase): r = gradients_impl.gradients(r, v)[0] self.assertAllEqual(873.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testScanGradientWithPartStopGradient(self): a = variables.Variable(0.0, name="a") b = variables.Variable(0.0, name="b") @@ -477,6 +486,7 @@ class FunctionalOpsTest(test.TestCase): y = functional_ops.map_fn(lambda e: e, x) self.assertAllEqual(y.get_shape(), self.evaluate(y).shape) + @test_util.run_deprecated_v1 def testMapUnknownShape(self): x = array_ops.placeholder(dtypes.float32) y = functional_ops.map_fn(lambda e: e, x) @@ -484,6 +494,7 @@ class FunctionalOpsTest(test.TestCase): @test_util.disable_control_flow_v2("b/119323354") @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testMapEmptyScalar(self): map_return = functional_ops.map_fn(lambda x: 1, constant_op.constant([])) self.assertAllEqual([0], map_return.get_shape().dims) @@ -492,6 +503,7 @@ class FunctionalOpsTest(test.TestCase): # TODO(akshayka): this test fails in eager: the iterable is of length 0 so # so the body of the while loop never executes @test_util.disable_control_flow_v2("b/119323354") + @test_util.run_deprecated_v1 def testMapEmptyTensor(self): with self.cached_session(): map_return = functional_ops.map_fn(lambda x: array_ops.zeros([3, 2]), @@ -512,6 +524,7 @@ class FunctionalOpsTest(test.TestCase): # TODO(akshayka): this test fails in eager: the iterable is of length 0 so # so the body of the while loop never executes + @test_util.run_deprecated_v1 def testScanEmptyTensor(self): with self.cached_session(): x = functional_ops.scan( @@ -519,6 +532,7 @@ class FunctionalOpsTest(test.TestCase): self.assertAllEqual([0, 2, 4], x.get_shape()) self.assertAllEqual(x.get_shape(), self.evaluate(x).shape) + @test_util.run_deprecated_v1 def testScanUnknownShape(self): x = array_ops.placeholder(dtypes.float32) initializer = array_ops.placeholder(dtypes.float32) @@ -529,6 +543,7 @@ class FunctionalOpsTest(test.TestCase): y = functional_ops.scan(fn, x, initializer=initializer) self.assertIs(None, y.get_shape().dims) + @test_util.run_deprecated_v1 def testScanVaryingShape(self): with self.cached_session() as sess: x = array_ops.placeholder(dtype=dtypes.float32, shape=[None, 2]) @@ -545,6 +560,7 @@ class FunctionalOpsTest(test.TestCase): sess.run([result, result_t, result_grad, result_t_grad], feed_dict={x: [[1.0, 2.0]]}) + @test_util.run_deprecated_v1 def testRemoteFunction(self): worker_config = config_pb2.ConfigProto() worker_config.device_count["CPU"] = 2 @@ -571,6 +587,7 @@ class FunctionalOpsTest(test.TestCase): mul = self.evaluate(remote_op) self.assertEqual(mul, [6]) + @test_util.run_deprecated_v1 def testRemoteFunctionDirectSession(self): worker_config = config_pb2.ConfigProto() worker_config.device_count["CPU"] = 2 @@ -595,6 +612,7 @@ class FunctionalOpsTest(test.TestCase): mul = self.evaluate(remote_op) self.assertEqual(mul, [6]) + @test_util.run_deprecated_v1 def testRemoteFunctionSameDeviceDirectSession(self): @function.Defun(dtypes.int32, dtypes.int32) @@ -680,6 +698,7 @@ class FunctionalOpsTest(test.TestCase): ret = self.evaluate(remote_op) self.assertAllEqual(ret, [b"a"]) + @test_util.run_deprecated_v1 def testRemoteFunctionCrossProcess(self): workers, _ = test_util.create_local_cluster(2, 1) @@ -703,6 +722,7 @@ class FunctionalOpsTest(test.TestCase): mul = self.evaluate(remote_op) self.assertEqual(mul, 9) + @test_util.run_deprecated_v1 def testIf(self): @function.Defun(dtypes.float32) @@ -742,6 +762,7 @@ class FunctionalOpsTest(test.TestCase): self.assertAllEqual(Run(sess, 20.), 210.) self.assertAllEqual(Run(sess, 100.), 5050.) + @test_util.run_deprecated_v1 def testWhileLowering(self): def Run(n, fetch_by_name): @@ -776,6 +797,7 @@ class FunctionalOpsTest(test.TestCase): self.assertAllEqual(Run(100., False), 5050.) self.assertAllEqual(Run(100., True), 5050.) + @test_util.run_deprecated_v1 def testWhileError(self): for use_gpu in (True, False): with ops.Graph().as_default() as g: @@ -922,6 +944,7 @@ class FunctionalOpsTest(test.TestCase): self.assertTrue("TestBody_Cond" in names) self.assertTrue("TestBody_Body" in names) + @test_util.run_deprecated_v1 def testForCapturedInputs(self): v = variables.Variable(1.0) @@ -996,12 +1019,15 @@ class FunctionalOpsTest(test.TestCase): tf_for_ans = self._tfMLP(xval, wsval, bsval, rewrite_with_while) self.assertAllClose(np_ans, tf_for_ans) + @test_util.run_deprecated_v1 def testForMLP(self): self._testForMLP(False) + @test_util.run_deprecated_v1 def testForMLPWhile(self): self._testForMLP(True) + @test_util.run_deprecated_v1 def testForError(self): @function.Defun(dtypes.int32, dtypes.float32) @@ -1024,6 +1050,7 @@ class FunctionalOpsTest(test.TestCase): "For loop body returned 2 arguments. Expected: 1"): functional_ops.For(0, 10, 1, [0.0], ReturnsTooManyArgs)[0].eval() + @test_util.run_deprecated_v1 def testGradient(self): @function.Defun(dtypes.float32) @@ -1049,6 +1076,7 @@ class FunctionalOpsTest(test.TestCase): # below test cases. class PartitionedCallTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasicSingleDevice(self): @function.Defun(*[dtypes.float32] * 2) @@ -1064,6 +1092,7 @@ class PartitionedCallTest(test.TestCase): constant_op.constant(2.)], f=Body)) self.assertEqual(output, 6.) + @test_util.run_deprecated_v1 def testBasicMultiDevice(self): config = config_pb2.ConfigProto(device_count={"CPU": 3}) @@ -1107,6 +1136,7 @@ class PartitionedCallTest(test.TestCase): constant_op.constant(2.)], f=Body)) self.assertEqual(output, 6.) + @test_util.run_deprecated_v1 def testBasicNoDeviceAnnotations(self): @function.Defun(*[dtypes.float32] * 2) @@ -1121,6 +1151,7 @@ class PartitionedCallTest(test.TestCase): constant_op.constant(2.)], f=Body)) self.assertEqual(output, 6.) + @test_util.run_deprecated_v1 def testShardsRunOnRequestedDevices(self): config = config_pb2.ConfigProto(device_count={"CPU": 4}) @@ -1150,6 +1181,7 @@ class PartitionedCallTest(test.TestCase): self.assertIn(compat.as_bytes("CPU:1"), outputs[1]) self.assertIn(compat.as_bytes("CPU:2"), outputs[2]) + @test_util.run_deprecated_v1 def testAssignAddResourceVariable(self): v = resource_variable_ops.ResourceVariable(1.0) @@ -1201,6 +1233,7 @@ class PartitionedCallTest(test.TestCase): self.assertAllEqual(expected, result) # Use an invalid executor name to test the plumbing of the executor_type attr. + @test_util.run_deprecated_v1 def testExecutorTypeAttrExecutorNotFound(self): @function.Defun(dtypes.int32) def AddFive(x): diff --git a/tensorflow/python/kernel_tests/gather_nd_op_test.py b/tensorflow/python/kernel_tests/gather_nd_op_test.py index 532d8903ee1..320ffc9674b 100644 --- a/tensorflow/python/kernel_tests/gather_nd_op_test.py +++ b/tensorflow/python/kernel_tests/gather_nd_op_test.py @@ -27,6 +27,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import variables @@ -54,6 +55,7 @@ class GatherNdTest(test.TestCase): self._testSimpleDtype(np.complex128) self._testSimpleDtype("|S") # byte strings in python2 + 3 + @test_util.run_deprecated_v1 def testEmptyIndicesAndParamsOKButJustEmptyParamsFails(self): with self.session(use_gpu=True): params = np.ones((3, 3), dtype=np.float32) @@ -190,6 +192,7 @@ class GatherNdTest(test.TestCase): def assertIndexedSlices(self, t): self.assertIsInstance(t, ops.IndexedSlices) + @test_util.run_deprecated_v1 def testUnknownIndices(self): params = constant_op.constant([[0, 1, 2]]) indices = array_ops.placeholder(dtypes.int32) @@ -198,6 +201,7 @@ class GatherNdTest(test.TestCase): self.assertEqual(None, shape.ndims) self.assertEqual(None, tensor_shape.dimension_value(shape[0])) + @test_util.run_deprecated_v1 def testBadIndicesCPU(self): with self.session(use_gpu=False): params = [0, 1, 2] @@ -220,6 +224,7 @@ class GatherNdTest(test.TestCase): r"indices\[0,1\] = \[7\] does not index into param shape \[3\]"): self.evaluate(gather_nd) + @test_util.run_deprecated_v1 def testBadIndicesWithSlicesCPU(self): with self.session(use_gpu=False): params = [[0, 1, 2]] @@ -242,6 +247,7 @@ class GatherNdTest(test.TestCase): r"indices\[0,2\] = \[1\] does not index into param shape \[1,3\]"): self.evaluate(gather_nd) + @test_util.run_deprecated_v1 def testGradientsRank2Elements(self): indices = constant_op.constant([[0, 0], [1, 1]], dtype=dtypes.int32) inputs = constant_op.constant([[1, 2], [3, 4]], dtype=dtypes.float64) @@ -253,6 +259,7 @@ class GatherNdTest(test.TestCase): with self.session(use_gpu=True): assert np.array_equal(expected_grads, self.evaluate(grads)) + @test_util.run_deprecated_v1 def testGradientsRank2Slices(self): indices = constant_op.constant([[1], [0]], dtype=dtypes.int32) inputs = constant_op.constant([[1, 2], [3, 4]], dtype=dtypes.float64) @@ -265,6 +272,7 @@ class GatherNdTest(test.TestCase): self.assertIndexedSlices(grads) self.assertAllEqual(expected_grads, ops.convert_to_tensor(grads).eval()) + @test_util.run_deprecated_v1 def testGradientsRank3Elements(self): indices = constant_op.constant( [[[0, 1], [1, 0]], [[0, 0], [1, 1]]], dtype=dtypes.int32) @@ -280,6 +288,7 @@ class GatherNdTest(test.TestCase): with self.session(use_gpu=True): self.assertAllEqual(expected_grads, self.evaluate(grads)) + @test_util.run_deprecated_v1 def testGradientsRank7Elements(self): # Shape [1,1,2,1,1,2,2] indices = constant_op.constant( @@ -309,6 +318,7 @@ class GatherNdTest(test.TestCase): with self.session(use_gpu=True): self.assertAllEqual(expected_grads, self.evaluate(grads)) + @test_util.run_deprecated_v1 def testGradientsInt64Indices(self): indices = constant_op.constant( [[[0, 1], [1, 0]], [[0, 0], [1, 1]]], dtype=dtypes.int64) @@ -324,6 +334,7 @@ class GatherNdTest(test.TestCase): with self.session(use_gpu=True): self.assertAllEqual(expected_grads, self.evaluate(grads)) + @test_util.run_deprecated_v1 def testGradientsRank2SlicesWithEmptySpace(self): indices = constant_op.constant([[2], [0], [5]], dtype=dtypes.int32) inputs = constant_op.constant( diff --git a/tensorflow/python/kernel_tests/gather_op_test.py b/tensorflow/python/kernel_tests/gather_op_test.py index 326e4aacd20..fc86068c3fc 100644 --- a/tensorflow/python/kernel_tests/gather_op_test.py +++ b/tensorflow/python/kernel_tests/gather_op_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.platform import test @@ -87,6 +88,7 @@ class GatherTest(test.TestCase): expected_shape = data.shape[:axis] + (4,) + data.shape[axis + 1:] self.assertEqual(expected_shape, gather_t.get_shape()) + @test_util.run_deprecated_v1 def testHigherRank(self): # We check that scalar and empty indices shapes work as well shape = (2, 1, 3, 2) @@ -148,6 +150,7 @@ class GatherTest(test.TestCase): atol=2e-6, rtol=2e-6) + @test_util.run_deprecated_v1 def testString(self): params = np.array([[b"asdf", b"zxcv"], [b"qwer", b"uiop"]]) with self.cached_session(): @@ -156,6 +159,7 @@ class GatherTest(test.TestCase): self.assertAllEqual([b"asdf", b"qwer"], array_ops.gather(params, 0, axis=1).eval()) + @test_util.run_deprecated_v1 def testUInt32AndUInt64(self): for unsigned_type in (dtypes.uint32, dtypes.uint64): params = self._buildParams( @@ -165,12 +169,14 @@ class GatherTest(test.TestCase): array_ops.gather(params, 1, axis=0).eval()) self.assertAllEqual([1, 7], array_ops.gather(params, 0, axis=1).eval()) + @test_util.run_deprecated_v1 def testUnknownIndices(self): params = constant_op.constant([[0, 1, 2]]) indices = array_ops.placeholder(dtypes.int32) gather_t = array_ops.gather(params, indices) self.assertEqual(None, gather_t.get_shape()) + @test_util.run_deprecated_v1 def testUnknownAxis(self): params = constant_op.constant([[0, 1, 2]]) indices = constant_op.constant([[0, 0], [0, 0]]) @@ -204,6 +210,7 @@ class GatherTest(test.TestCase): with self.assertRaisesOpError(r"indices\[0,0\] = 7 is not in \[0, 3\)"): array_ops.gather(params, [[7]], axis=1).eval() + @test_util.run_deprecated_v1 def testBadAxis(self): with self.session(use_gpu=True): params = [0, 1, 2] @@ -220,6 +227,7 @@ class GatherTest(test.TestCase): array_ops.gather(params_ph, indices, axis=bad_axis).eval( feed_dict={params_ph: params}) + @test_util.run_deprecated_v1 def testEmptySlices(self): with self.session(use_gpu=True): for dtype in _TEST_TYPES: diff --git a/tensorflow/python/kernel_tests/gradient_correctness_test.py b/tensorflow/python/kernel_tests/gradient_correctness_test.py index 12b8a4c8e3b..0148de5047a 100644 --- a/tensorflow/python/kernel_tests/gradient_correctness_test.py +++ b/tensorflow/python/kernel_tests/gradient_correctness_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -29,6 +30,7 @@ from tensorflow.python.platform import test class GradientCorrectnessTest(test.TestCase): + @test_util.run_deprecated_v1 def testMultipleOutputChainedGradients(self): with self.cached_session() as sess: x = constant_op.constant(1.0, dtype=dtypes.float32) @@ -40,18 +42,21 @@ class GradientCorrectnessTest(test.TestCase): # [dexp(x)/dx + d(log(exp(x)))/dx] @ x=1 == exp(1) + 1 self.assertAllClose(grad_vals[0], exp1_plus_one) + @test_util.run_deprecated_v1 def testIdentityGradient(self): x = constant_op.constant(3.) dx_dx, = gradients_impl.gradients(x, x) with self.cached_session() as sess: self.assertAllClose(1., self.evaluate(dx_dx)) + @test_util.run_deprecated_v1 def testIntegerIdentityGradient(self): x = constant_op.constant(3) dx_dx, = gradients_impl.gradients(x, x) with self.cached_session() as sess: self.assertAllClose(1, self.evaluate(dx_dx)) + @test_util.run_deprecated_v1 def testGradientWithIntegerPath(self): x = constant_op.constant([3.9, 4.1]) k = math_ops.to_float(math_ops.to_int32(x)) @@ -60,6 +65,7 @@ class GradientCorrectnessTest(test.TestCase): with self.cached_session() as sess: self.assertAllClose([3., 4.], self.evaluate(dy_dx)) + @test_util.run_deprecated_v1 def testNoIntegerGradient1(self): x = constant_op.constant([3.9, 4.1]) k = math_ops.to_float(math_ops.to_int32(x)) @@ -67,6 +73,7 @@ class GradientCorrectnessTest(test.TestCase): dy_dx, = gradients_impl.gradients(y, x) self.assertIsNone(dy_dx) + @test_util.run_deprecated_v1 def testNoIntegerGradient2(self): k = constant_op.constant([3, 4]) x = math_ops.to_float(k) @@ -74,18 +81,21 @@ class GradientCorrectnessTest(test.TestCase): dy_dk, = gradients_impl.gradients(y, k) self.assertIsNone(dy_dk) + @test_util.run_deprecated_v1 def testNoIntegerGradient3(self): k = constant_op.constant([3, 4]) m = k * k dm_dk, = gradients_impl.gradients(m, k) self.assertIsNone(dm_dk) + @test_util.run_deprecated_v1 def testNoIntegerGradient4(self): k = constant_op.constant([3, 4]) m = k * k * k dm_dk, = gradients_impl.gradients(m, k) self.assertIsNone(dm_dk) + @test_util.run_deprecated_v1 def testNoIntegerGradient5(self): k = constant_op.constant([3, 4]) m = k * k @@ -93,6 +103,7 @@ class GradientCorrectnessTest(test.TestCase): dn_dk, = gradients_impl.gradients(n, k) self.assertIsNone(dn_dk) + @test_util.run_deprecated_v1 def testNoIntegerGradient6(self): k = constant_op.constant(3) x = math_ops.to_float(k) diff --git a/tensorflow/python/kernel_tests/identity_n_op_py_test.py b/tensorflow/python/kernel_tests/identity_n_op_py_test.py index 518733cd8e9..a1110d640f0 100644 --- a/tensorflow/python/kernel_tests/identity_n_op_py_test.py +++ b/tensorflow/python/kernel_tests/identity_n_op_py_test.py @@ -21,12 +21,14 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test class IdentityNOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testInt32String_6(self): with self.cached_session() as sess: [value0, value1] = sess.run( @@ -36,6 +38,7 @@ class IdentityNOpTest(test.TestCase): self.assertAllEqual( np.array([b"a", b"b", b"C", b"d", b"E", b"f", b"g"]), value1) + @test_util.run_deprecated_v1 def testInt32_shapes(self): with self.cached_session() as sess: inp0 = constant_op.constant([10, 20, 30, 40, 50, 60], shape=[2, 3]) @@ -50,6 +53,7 @@ class IdentityNOpTest(test.TestCase): np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]), value2) + @test_util.run_deprecated_v1 def testString(self): source = [b"A", b"b", b"C", b"d", b"E", b"f"] with self.cached_session() as sess: diff --git a/tensorflow/python/kernel_tests/identity_op_py_test.py b/tensorflow/python/kernel_tests/identity_op_py_test.py index 88ea10c22a3..1a6794e896f 100644 --- a/tensorflow/python/kernel_tests/identity_op_py_test.py +++ b/tensorflow/python/kernel_tests/identity_op_py_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import variables @@ -30,17 +31,20 @@ from tensorflow.python.platform import test class IdentityOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testInt32_6(self): with self.cached_session(): value = array_ops.identity([1, 2, 3, 4, 5, 6]).eval() self.assertAllEqual(np.array([1, 2, 3, 4, 5, 6]), value) + @test_util.run_deprecated_v1 def testInt32_2_3(self): with self.cached_session(): inp = constant_op.constant([10, 20, 30, 40, 50, 60], shape=[2, 3]) value = array_ops.identity(inp).eval() self.assertAllEqual(np.array([[10, 20, 30], [40, 50, 60]]), value) + @test_util.run_deprecated_v1 def testString(self): source = [b"A", b"b", b"C", b"d", b"E", b"f"] with self.cached_session(): @@ -58,6 +62,7 @@ class IdentityOpTest(test.TestCase): self.assertEquals(shape, array_ops.identity(np.array(array_2x3)).get_shape()) + @test_util.run_deprecated_v1 def testRefIdentityShape(self): with self.cached_session(): shape = [2, 3] diff --git a/tensorflow/python/kernel_tests/init_ops_test.py b/tensorflow/python/kernel_tests/init_ops_test.py index 87c7bbef3cf..09b9944baa1 100644 --- a/tensorflow/python/kernel_tests/init_ops_test.py +++ b/tensorflow/python/kernel_tests/init_ops_test.py @@ -25,6 +25,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.layers import convolutional from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops @@ -106,6 +107,7 @@ def _init_sampler(tc, init, num): class ConstantInitializersTest(test.TestCase): + @test_util.run_deprecated_v1 def testZerosInitializer(self): with self.session(use_gpu=True): shape = [2, 3] @@ -114,6 +116,7 @@ class ConstantInitializersTest(test.TestCase): x.initializer.run() self.assertAllEqual(x.eval(), np.zeros(shape)) + @test_util.run_deprecated_v1 def testOnesInitializer(self): with self.session(use_gpu=True): shape = [2, 3] @@ -122,6 +125,7 @@ class ConstantInitializersTest(test.TestCase): x.initializer.run() self.assertAllEqual(x.eval(), np.ones(shape)) + @test_util.run_deprecated_v1 def testConstantZeroInitializer(self): with self.session(use_gpu=True): shape = [2, 3] @@ -130,6 +134,7 @@ class ConstantInitializersTest(test.TestCase): x.initializer.run() self.assertAllEqual(x.eval(), np.zeros(shape)) + @test_util.run_deprecated_v1 def testConstantOneInitializer(self): with self.session(use_gpu=True): shape = [2, 3] @@ -138,6 +143,7 @@ class ConstantInitializersTest(test.TestCase): x.initializer.run() self.assertAllEqual(x.eval(), np.ones(shape)) + @test_util.run_deprecated_v1 def testConstantIntInitializer(self): with self.session(use_gpu=True): shape = [2, 3] @@ -150,6 +156,7 @@ class ConstantInitializersTest(test.TestCase): self.assertEqual(x.dtype.base_dtype, dtypes.int32) self.assertAllEqual(x.eval(), 7 * np.ones(shape, dtype=np.int32)) + @test_util.run_deprecated_v1 def testConstantTupleInitializer(self): with self.session(use_gpu=True): shape = [3] @@ -173,6 +180,7 @@ class ConstantInitializersTest(test.TestCase): for a, e in zip(actual, expected): self.assertEqual(a, e) + @test_util.run_deprecated_v1 def testNDimConstantInitializer(self): value = [0, 1, 2, 3, 4, 5] shape = [2, 3] @@ -199,6 +207,7 @@ class ConstantInitializersTest(test.TestCase): e = expected[i] if i < len(expected) else expected[-1] self.assertEqual(a, e) + @test_util.run_deprecated_v1 def testNDimConstantInitializerLessValues(self): value = [0, 1, 2, 3, 4, 5] shape = [2, 4] @@ -222,6 +231,7 @@ class ConstantInitializersTest(test.TestCase): shape=shape, initializer=init) + @test_util.run_deprecated_v1 def testNDimConstantInitializerMoreValues(self): value = [0, 1, 2, 3, 4, 5, 6, 7] shape = [2, 3] @@ -243,18 +253,21 @@ class ConstantInitializersTest(test.TestCase): class RandomNormalInitializationTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.random_normal_initializer(0.0, 1.0, seed=1, dtype=dtype) init2 = init_ops.random_normal_initializer(0.0, 1.0, seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.random_normal_initializer(0.0, 1.0, seed=1, dtype=dtype) init2 = init_ops.random_normal_initializer(0.0, 1.0, seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.random_normal_initializer(0.0, 1.0) self.assertFalse(duplicated_initializer(self, init, 1)) @@ -270,6 +283,7 @@ class RandomNormalInitializationTest(test.TestCase): class TruncatedNormalInitializationTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.truncated_normal_initializer( @@ -278,6 +292,7 @@ class TruncatedNormalInitializationTest(test.TestCase): 0.0, 1.0, seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.truncated_normal_initializer( @@ -286,6 +301,7 @@ class TruncatedNormalInitializationTest(test.TestCase): 0.0, 1.0, seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.truncated_normal_initializer(0.0, 1.0) self.assertFalse(duplicated_initializer(self, init, 1)) @@ -301,18 +317,21 @@ class TruncatedNormalInitializationTest(test.TestCase): class RandomUniformInitializationTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64, dtypes.int64]: init1 = init_ops.random_uniform_initializer(0, 7, seed=1, dtype=dtype) init2 = init_ops.random_uniform_initializer(0, 7, seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64, dtypes.int32, dtypes.int64]: init1 = init_ops.random_uniform_initializer(0, 7, seed=1, dtype=dtype) init2 = init_ops.random_uniform_initializer(0, 7, seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2)) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.random_uniform_initializer(0.0, 1.0) self.assertFalse(duplicated_initializer(self, init, 1)) @@ -320,6 +339,7 @@ class RandomUniformInitializationTest(test.TestCase): class UniformUnitScalingInitializationTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.uniform_unit_scaling_initializer(seed=1, dtype=dtype) @@ -331,6 +351,7 @@ class UniformUnitScalingInitializationTest(test.TestCase): 1.5, seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init3, init4)) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.uniform_unit_scaling_initializer(seed=1, dtype=dtype) @@ -341,6 +362,7 @@ class UniformUnitScalingInitializationTest(test.TestCase): self.assertFalse(identicaltest(self, init1, init3)) self.assertFalse(identicaltest(self, init2, init3)) + @test_util.run_deprecated_v1 def testZeroSize(self): shape = [0, 2] with self.cached_session(): @@ -351,6 +373,7 @@ class UniformUnitScalingInitializationTest(test.TestCase): variables.global_variables_initializer().run() self.assertAllEqual(shape, self.evaluate(x).shape) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.uniform_unit_scaling_initializer() self.assertFalse(duplicated_initializer(self, init, 1)) @@ -364,6 +387,7 @@ class UniformUnitScalingInitializationTest(test.TestCase): class VarianceScalingInitializationTest(test.TestCase): + @test_util.run_deprecated_v1 def testTruncatedNormalDistribution(self): shape = [100, 100] expect_mean = 0. @@ -381,6 +405,7 @@ class VarianceScalingInitializationTest(test.TestCase): self.assertNear(np.mean(x), expect_mean, err=1e-2) self.assertNear(np.var(x), expect_var, err=1e-2) + @test_util.run_deprecated_v1 def testNormalDistribution(self): shape = [100, 100] expect_mean = 0. @@ -397,6 +422,7 @@ class VarianceScalingInitializationTest(test.TestCase): self.assertNear(np.mean(x), expect_mean, err=1e-2) self.assertNear(np.var(x), expect_var, err=1e-2) + @test_util.run_deprecated_v1 def testUntruncatedNormalDistribution(self): shape = [100, 100] expect_mean = 0. @@ -414,6 +440,7 @@ class VarianceScalingInitializationTest(test.TestCase): self.assertNear(np.mean(x), expect_mean, err=1e-2) self.assertNear(np.var(x), expect_var, err=1e-2) + @test_util.run_deprecated_v1 def testUniformDistribution(self): shape = [100, 100] expect_mean = 0. @@ -449,6 +476,7 @@ class RangeTest(test.TestCase): self._Range(100, 500, 100), np.array([100, 200, 300, 400]))) self.assertEqual(math_ops.range(0, 5, 1).dtype, dtypes.int32) + @test_util.run_deprecated_v1 def testLimitOnly(self): with self.session(use_gpu=True): self.assertAllEqual(np.arange(5), math_ops.range(5).eval()) @@ -583,18 +611,21 @@ class DeviceTest(test.TestCase): class OrthogonalInitializerTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.orthogonal_initializer(seed=1, dtype=dtype) init2 = init_ops.orthogonal_initializer(seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2, (10, 10))) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.orthogonal_initializer(seed=1, dtype=dtype) init2 = init_ops.orthogonal_initializer(seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2, (10, 10))) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.orthogonal_initializer() self.assertFalse(duplicated_initializer(self, init, 1, (10, 10))) @@ -608,6 +639,7 @@ class OrthogonalInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertRaises(ValueError, init1, shape=[5]) + @test_util.run_deprecated_v1 def testGain(self): shape = (10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -618,6 +650,7 @@ class OrthogonalInitializerTest(test.TestCase): t2 = init2(shape).eval() self.assertAllClose(t1, t2 / 3.14) + @test_util.run_deprecated_v1 def testShapesValues(self): for dtype in [dtypes.float32, dtypes.float64]: for shape in [(10, 10), (10, 9, 8), (100, 5, 5), (50, 40), (40, 50)]: @@ -639,18 +672,21 @@ class OrthogonalInitializerTest(test.TestCase): class ConvolutionDeltaOrthogonalInitializerTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_delta_orthogonal(seed=1, dtype=dtype) init2 = init_ops.convolutional_delta_orthogonal(seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2, (3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_delta_orthogonal(seed=1, dtype=dtype) init2 = init_ops.convolutional_delta_orthogonal(seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2, (3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.convolutional_delta_orthogonal() self.assertFalse(duplicated_initializer(self, init, 1, (3, 3, 10, 10))) @@ -665,6 +701,7 @@ class ConvolutionDeltaOrthogonalInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertRaises(ValueError, init1, shape=[3, 3, 6, 5]) + @test_util.run_deprecated_v1 def testGain(self): shape = (3, 3, 10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -676,6 +713,7 @@ class ConvolutionDeltaOrthogonalInitializerTest(test.TestCase): t2 = init2(shape).eval() self.assertAllClose(t1, t2 / 3.14) + @test_util.run_deprecated_v1 def testShapesValues(self): gain = 3.14 for dtype in [dtypes.float32]: @@ -711,6 +749,7 @@ class ConvolutionDeltaOrthogonalInitializerTest(test.TestCase): # Check isometry of the delta-orthogonal kernel. self.assertAllClose(self.evaluate(ratio), gain, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testNonuniformity(self): value = 0 abs_value = 0 @@ -738,18 +777,21 @@ class ConvolutionDeltaOrthogonalInitializerTest(test.TestCase): class ConvolutionOrthogonal1dInitializerTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_1d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_1d(seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2, (3, 10, 10))) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_1d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_1d(seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2, (3, 10, 10))) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.convolutional_orthogonal_1d() self.assertFalse(duplicated_initializer(self, init, 1, (3, 10, 10))) @@ -764,6 +806,7 @@ class ConvolutionOrthogonal1dInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertRaises(ValueError, init1, shape=[3, 6, 5]) + @test_util.run_deprecated_v1 def testGain(self): shape = (3, 10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -775,6 +818,7 @@ class ConvolutionOrthogonal1dInitializerTest(test.TestCase): t2 = init2(shape).eval() self.assertAllClose(t1, t2 / 3.14) + @test_util.run_deprecated_v1 def testNonuniformity(self): value = 0 abs_value = 0 @@ -799,6 +843,7 @@ class ConvolutionOrthogonal1dInitializerTest(test.TestCase): # Compute the sum of the absolute values of 'count' determinants self.assertAllClose(abs_value, count, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testShapesValues(self): def circular_pad(input_, width, kernel_size): """Pad input_ for computing (circular) convolution. @@ -852,18 +897,21 @@ class ConvolutionOrthogonal1dInitializerTest(test.TestCase): class ConvolutionOrthogonal2dInitializerTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_2d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_2d(seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2, (3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_2d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_2d(seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2, (3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.convolutional_orthogonal_2d() self.assertFalse(duplicated_initializer(self, init, 1, (3, 3, 10, 10))) @@ -878,6 +926,7 @@ class ConvolutionOrthogonal2dInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertRaises(ValueError, init1, shape=[3, 3, 6, 5]) + @test_util.run_deprecated_v1 def testGain(self): shape = (3, 3, 10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -889,6 +938,7 @@ class ConvolutionOrthogonal2dInitializerTest(test.TestCase): t2 = init2(shape).eval() self.assertAllClose(t1, t2 / 3.14) + @test_util.run_deprecated_v1 def testShapesValues(self): def circular_pad(input_, width, kernel_size): """Pad input_ for computing (circular) convolution. @@ -947,18 +997,21 @@ class ConvolutionOrthogonal2dInitializerTest(test.TestCase): class ConvolutionOrthogonal3dInitializerTest(test.TestCase): + @test_util.run_deprecated_v1 def testInitializerIdentical(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_3d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_3d(seed=1, dtype=dtype) self.assertTrue(identicaltest(self, init1, init2, (3, 3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testInitializerDifferent(self): for dtype in [dtypes.float32, dtypes.float64]: init1 = init_ops.convolutional_orthogonal_3d(seed=1, dtype=dtype) init2 = init_ops.convolutional_orthogonal_3d(seed=2, dtype=dtype) self.assertFalse(identicaltest(self, init1, init2, (3, 3, 3, 10, 10))) + @test_util.run_deprecated_v1 def testDuplicatedInitializer(self): init = init_ops.convolutional_orthogonal_3d() self.assertFalse(duplicated_initializer(self, init, 1, (3, 3, 3, 10, 10))) @@ -973,6 +1026,7 @@ class ConvolutionOrthogonal3dInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertRaises(ValueError, init1, shape=[3, 3, 3, 6, 5]) + @test_util.run_deprecated_v1 def testGain(self): shape = (3, 3, 3, 10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -984,6 +1038,7 @@ class ConvolutionOrthogonal3dInitializerTest(test.TestCase): t2 = init2(shape).eval() self.assertAllClose(t1, t2 / 3.14) + @test_util.run_deprecated_v1 def testNonuniformity(self): value = 0 abs_value = 0 @@ -1008,6 +1063,7 @@ class ConvolutionOrthogonal3dInitializerTest(test.TestCase): # Compute the sum of the absolute values of 'count' determinants self.assertAllClose(abs_value, count, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testShapesValues(self): def circular_pad(input_, width, kernel_size): """Padding input_ for computing circular convolution. @@ -1083,12 +1139,14 @@ class IdentityInitializerTest(test.TestCase): self.assertRaises(ValueError, init, shape=[5]) self.assertRaises(ValueError, init, shape=[]) + @test_util.run_deprecated_v1 def testNonSquare(self): init = init_ops.identity_initializer() shape = (10, 5) with self.session(graph=ops.Graph(), use_gpu=True): self.assertAllClose(init(shape).eval(), np.eye(*shape)) + @test_util.run_deprecated_v1 def testGain(self): shape = (10, 10) for dtype in [dtypes.float32, dtypes.float64]: @@ -1099,6 +1157,7 @@ class IdentityInitializerTest(test.TestCase): with self.session(graph=ops.Graph(), use_gpu=True): self.assertAllClose(init_custom(shape).eval(), np.eye(*shape) * 0.9) + @test_util.run_deprecated_v1 def testPartitions(self): shape = (10, 10) init = init_ops.identity_initializer() diff --git a/tensorflow/python/kernel_tests/inplace_ops_test.py b/tensorflow/python/kernel_tests/inplace_ops_test.py index e0c36d3d2e9..9eaaac7a248 100644 --- a/tensorflow/python/kernel_tests/inplace_ops_test.py +++ b/tensorflow/python/kernel_tests/inplace_ops_test.py @@ -31,6 +31,7 @@ from tensorflow.python.platform import test as test_lib class InplaceOpsTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasicUpdate(self): for dtype in [dtypes.float32, dtypes.int32, dtypes.int64]: with self.session(use_gpu=True): @@ -48,6 +49,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): y[5, :] = 7 self.assertAllClose(x.eval(), y) + @test_util.run_deprecated_v1 def testBasicUpdateBool(self): with self.session(use_gpu=True): x = array_ops.ones([7, 3], dtypes.bool) @@ -65,6 +67,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): y[5, :] = False self.assertAllClose(x.eval(), y) + @test_util.run_deprecated_v1 def testBasicAdd(self): for dtype in [dtypes.float32, dtypes.int32, dtypes.int64]: with self.cached_session(use_gpu=True): @@ -84,6 +87,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): y[:, :] += 99 self.assertAllClose(x.eval(), y) + @test_util.run_deprecated_v1 def testBasicSub(self): for dtype in [dtypes.float32, dtypes.int32, dtypes.int64]: with self.cached_session(use_gpu=True): @@ -103,6 +107,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): y[:, :] -= 99 self.assertAllClose(x.eval(), y) + @test_util.run_deprecated_v1 def testRandom(self): with self.session(use_gpu=True): d0, d1, d2 = 100, 3, 5 @@ -123,6 +128,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): y[idx, :] -= val self.assertAllClose(x.eval(), y) + @test_util.run_deprecated_v1 def testRandom1D(self): with self.session(use_gpu=True): d0 = 100 @@ -164,6 +170,7 @@ class InplaceOpsTest(test_util.TensorFlowTestCase): "i and x shape doesn't match"): _ = inplace_ops.inplace_update([[1.]], [0, 1], [[10]]).eval() + @test_util.run_deprecated_v1 def testEmpty(self): for dtype in [ dtypes.float32, dtypes.float64, dtypes.int32, dtypes.int64, dtypes.bool, diff --git a/tensorflow/python/kernel_tests/io_ops_test.py b/tensorflow/python/kernel_tests/io_ops_test.py index a6b477062eb..c5df5231bf6 100644 --- a/tensorflow/python/kernel_tests/io_ops_test.py +++ b/tensorflow/python/kernel_tests/io_ops_test.py @@ -23,6 +23,7 @@ import os import shutil import tempfile +from tensorflow.python.framework import test_util from tensorflow.python.ops import io_ops from tensorflow.python.platform import test from tensorflow.python.util import compat @@ -30,6 +31,7 @@ from tensorflow.python.util import compat class IoOpsTest(test.TestCase): + @test_util.run_deprecated_v1 def testReadFile(self): cases = ['', 'Some contents', 'Неки садржаји на српском'] for contents in cases: @@ -78,6 +80,7 @@ class IoOpsTest(test.TestCase): compat.as_bytes(files[i].name) for i in range(len(files)) if i in indices) + @test_util.run_deprecated_v1 def testMatchingFiles(self): cases = [ 'ABcDEF.GH', 'ABzDEF.GH', 'ABasdfjklDEF.GH', 'AB3DEF.GH', 'AB4DEF.GH', diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_addition_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_addition_test.py index 628ed998c54..627349c69b3 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_addition_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_addition_test.py @@ -19,6 +19,7 @@ from __future__ import print_function import numpy as np +from tensorflow.python.framework import test_util from tensorflow.python.ops import linalg_ops from tensorflow.python.ops.linalg import linalg as linalg_lib from tensorflow.python.ops.linalg import linear_operator_addition @@ -69,6 +70,7 @@ class LinearOperatorAdditionCorrectnessTest(test.TestCase): with self.assertRaisesRegexp(TypeError, "contain only LinearOperator"): add_operators([1, 2]) + @test_util.run_deprecated_v1 def test_two_diag_operators(self): op_a = linalg.LinearOperatorDiag( [1., 1.], is_positive_definite=True, name="A") @@ -89,6 +91,7 @@ class LinearOperatorAdditionCorrectnessTest(test.TestCase): # Enforce particular name for this simple case self.assertEqual("Add/B__A/", op.name) + @test_util.run_deprecated_v1 def test_three_diag_operators(self): op1 = linalg.LinearOperatorDiag( [1., 1.], is_positive_definite=True, name="op1") @@ -109,6 +112,7 @@ class LinearOperatorAdditionCorrectnessTest(test.TestCase): # Positive definite ==> non-singular self.assertTrue(op.is_non_singular) + @test_util.run_deprecated_v1 def test_diag_tril_diag(self): op1 = linalg.LinearOperatorDiag( [1., 1.], is_non_singular=True, name="diag_a") @@ -134,6 +138,7 @@ class LinearOperatorAdditionCorrectnessTest(test.TestCase): # Since no custom hint was provided, we default to None (unknown). self.assertEqual(None, op.is_non_singular) + @test_util.run_deprecated_v1 def test_matrix_diag_tril_diag_uses_custom_name(self): op0 = linalg.LinearOperatorFullMatrix( [[-1., -1.], [-1., -1.]], name="matrix") @@ -217,6 +222,7 @@ class LinearOperatorOrderOfAdditionTest(test.TestCase): self.assertEqual(1, len(op_sum)) self.assertIsInstance(op_sum[0], linalg.LinearOperatorLowerTriangular) + @test_util.run_deprecated_v1 def test_cannot_add_everything_so_return_more_than_one_operator(self): diag1 = linalg.LinearOperatorDiag([1.]) diag2 = linalg.LinearOperatorDiag([2.]) @@ -261,6 +267,7 @@ class AddAndReturnScaledIdentityTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnScaledIdentity() + @test_util.run_deprecated_v1 def test_identity_plus_identity(self): id1 = linalg.LinearOperatorIdentity(num_rows=2) id2 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) @@ -279,6 +286,7 @@ class AddAndReturnScaledIdentityTest(test.TestCase): self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) + @test_util.run_deprecated_v1 def test_identity_plus_scaled_identity(self): id1 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) id2 = linalg.LinearOperatorScaledIdentity(num_rows=2, multiplier=2.2) @@ -297,6 +305,7 @@ class AddAndReturnScaledIdentityTest(test.TestCase): self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) + @test_util.run_deprecated_v1 def test_scaled_identity_plus_scaled_identity(self): id1 = linalg.LinearOperatorScaledIdentity( num_rows=2, multiplier=[2.2, 2.2, 2.2]) @@ -322,6 +331,7 @@ class AddAndReturnDiagTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnDiag() + @test_util.run_deprecated_v1 def test_identity_plus_identity_returns_diag(self): id1 = linalg.LinearOperatorIdentity(num_rows=2) id2 = linalg.LinearOperatorIdentity(num_rows=2, batch_shape=[3]) @@ -340,6 +350,7 @@ class AddAndReturnDiagTest(test.TestCase): self.assertTrue(operator.is_non_singular) self.assertEqual("my_operator", operator.name) + @test_util.run_deprecated_v1 def test_diag_plus_diag(self): diag1 = rng.rand(2, 3, 4) diag2 = rng.rand(4) @@ -366,6 +377,7 @@ class AddAndReturnTriLTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnTriL() + @test_util.run_deprecated_v1 def test_diag_plus_tril(self): diag = linalg.LinearOperatorDiag([1., 2.]) tril = linalg.LinearOperatorLowerTriangular([[10., 0.], [30., 0.]]) @@ -389,6 +401,7 @@ class AddAndReturnMatrixTest(test.TestCase): def setUp(self): self._adder = linear_operator_addition._AddAndReturnMatrix() + @test_util.run_deprecated_v1 def test_diag_plus_diag(self): diag1 = linalg.LinearOperatorDiag([1., 2.]) diag2 = linalg.LinearOperatorDiag([-1., 3.]) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_circulant_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_circulant_test.py index 09867435a73..6366083ac5b 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_circulant_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_circulant_test.py @@ -21,6 +21,7 @@ import contextlib import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import spectral_ops_test_util @@ -129,6 +130,7 @@ class LinearOperatorCirculantTestSelfAdjointOperator( return operator, mat + @test_util.run_deprecated_v1 def test_simple_hermitian_spectrum_gives_operator_with_zero_imag_part(self): with self.cached_session(): spectrum = math_ops.cast([1., 1j, -1j], dtypes.complex64) @@ -196,6 +198,7 @@ class LinearOperatorCirculantTestHermitianSpectrum( return operator, mat + @test_util.run_deprecated_v1 def test_simple_hermitian_spectrum_gives_operator_with_zero_imag_part(self): with self.cached_session(): spectrum = math_ops.cast([1., 1j, -1j], dtypes.complex64) @@ -251,6 +254,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( return operator, mat + @test_util.run_deprecated_v1 def test_simple_hermitian_spectrum_gives_operator_with_zero_imag_part(self): with self.cached_session(): spectrum = math_ops.cast([1., 1j, -1j], dtypes.complex64) @@ -262,6 +266,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( np.testing.assert_allclose( 0, self.evaluate(imag_matrix), rtol=0, atol=eps * 3) + @test_util.run_deprecated_v1 def test_simple_positive_real_spectrum_gives_self_adjoint_pos_def_oper(self): with self.cached_session() as sess: spectrum = math_ops.cast([6., 4, 2], dtypes.complex64) @@ -274,6 +279,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( operator.assert_positive_definite().run() # Should not fail operator.assert_self_adjoint().run() # Should not fail + @test_util.run_deprecated_v1 def test_defining_operator_using_real_convolution_kernel(self): with self.cached_session(): convolution_kernel = [1., 2., 1.] @@ -304,6 +310,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( np.testing.assert_allclose( 0, self.evaluate(imag_matrix), rtol=0, atol=eps * 3 * 4) + @test_util.run_deprecated_v1 def test_convolution_kernel_same_as_first_row_of_to_dense(self): spectrum = [[3., 2., 1.], [2., 1.5, 1.]] with self.cached_session(): @@ -315,6 +322,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( self.assertAllEqual((2, 3, 3), c.get_shape()) self.assertAllClose(h.eval(), self.evaluate(c)[:, :, 0]) + @test_util.run_deprecated_v1 def test_assert_non_singular_fails_for_singular_operator(self): spectrum = math_ops.cast([0, 4, 2j + 2], dtypes.complex64) operator = linalg.LinearOperatorCirculant(spectrum) @@ -322,12 +330,14 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( with self.assertRaisesOpError("Singular operator"): operator.assert_non_singular().run() + @test_util.run_deprecated_v1 def test_assert_non_singular_does_not_fail_for_non_singular_operator(self): spectrum = math_ops.cast([-3j, 4, 2j + 2], dtypes.complex64) operator = linalg.LinearOperatorCirculant(spectrum) with self.cached_session(): operator.assert_non_singular().run() # Should not fail + @test_util.run_deprecated_v1 def test_assert_positive_definite_fails_for_non_positive_definite(self): spectrum = math_ops.cast([6., 4, 2j], dtypes.complex64) operator = linalg.LinearOperatorCirculant(spectrum) @@ -335,6 +345,7 @@ class LinearOperatorCirculantTestNonHermitianSpectrum( with self.assertRaisesOpError("Not positive definite"): operator.assert_positive_definite().run() + @test_util.run_deprecated_v1 def test_assert_positive_definite_does_not_fail_when_pos_def(self): spectrum = math_ops.cast([6., 4, 2j + 2], dtypes.complex64) operator = linalg.LinearOperatorCirculant(spectrum) @@ -529,6 +540,7 @@ class LinearOperatorCirculant2DTestNonHermitianSpectrum( return operator, mat + @test_util.run_deprecated_v1 def test_real_hermitian_spectrum_gives_real_symmetric_operator(self): with self.cached_session() as sess: # This is a real and hermitian spectrum. @@ -546,6 +558,7 @@ class LinearOperatorCirculant2DTestNonHermitianSpectrum( np.testing.assert_allclose(0, imag_matrix, atol=1e-6) self.assertAllClose(matrix, matrix_transpose, atol=0) + @test_util.run_deprecated_v1 def test_real_spectrum_gives_self_adjoint_operator(self): with self.cached_session() as sess: # This is a real and hermitian spectrum. @@ -560,6 +573,7 @@ class LinearOperatorCirculant2DTestNonHermitianSpectrum( matrix, matrix_h = self.evaluate([matrix_tensor, matrix_h]) self.assertAllClose(matrix, matrix_h, atol=0) + @test_util.run_deprecated_v1 def test_assert_non_singular_fails_for_singular_operator(self): spectrum = math_ops.cast([[0, 4], [2j + 2, 3.]], dtypes.complex64) operator = linalg.LinearOperatorCirculant2D(spectrum) @@ -567,12 +581,14 @@ class LinearOperatorCirculant2DTestNonHermitianSpectrum( with self.assertRaisesOpError("Singular operator"): operator.assert_non_singular().run() + @test_util.run_deprecated_v1 def test_assert_non_singular_does_not_fail_for_non_singular_operator(self): spectrum = math_ops.cast([[-3j, 4], [2j + 2, 3.]], dtypes.complex64) operator = linalg.LinearOperatorCirculant2D(spectrum) with self.cached_session(): operator.assert_non_singular().run() # Should not fail + @test_util.run_deprecated_v1 def test_assert_positive_definite_fails_for_non_positive_definite(self): spectrum = math_ops.cast([[6., 4], [2j, 3.]], dtypes.complex64) operator = linalg.LinearOperatorCirculant2D(spectrum) @@ -580,6 +596,7 @@ class LinearOperatorCirculant2DTestNonHermitianSpectrum( with self.assertRaisesOpError("Not positive definite"): operator.assert_positive_definite().run() + @test_util.run_deprecated_v1 def test_assert_positive_definite_does_not_fail_when_pos_def(self): spectrum = math_ops.cast([[6., 4], [2j + 2, 3.]], dtypes.complex64) operator = linalg.LinearOperatorCirculant2D(spectrum) @@ -618,6 +635,7 @@ class LinearOperatorCirculant3DTest(test.TestCase): with spectral_ops_test_util.fft_kernel_label_map(): yield sess + @test_util.run_deprecated_v1 def test_real_spectrum_gives_self_adjoint_operator(self): with self.cached_session() as sess: # This is a real and hermitian spectrum. @@ -635,6 +653,7 @@ class LinearOperatorCirculant3DTest(test.TestCase): self.assertAllEqual((2, 2 * 3 * 5, 2 * 3 * 5), matrix.shape) self.assertAllClose(matrix, matrix_h) + @test_util.run_deprecated_v1 def test_defining_operator_using_real_convolution_kernel(self): with self.cached_session(): convolution_kernel = linear_operator_test_util.random_normal( @@ -653,6 +672,7 @@ class LinearOperatorCirculant3DTest(test.TestCase): self.assertAllEqual((2, 2 * 3 * 5, 2 * 3 * 5), matrix.shape) np.testing.assert_allclose(0, np.imag(matrix), atol=1e-6) + @test_util.run_deprecated_v1 def test_defining_spd_operator_by_taking_real_part(self): with self.cached_session() as sess: # S is real and positive. diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_composition_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_composition_test.py index 3f19dc4bffe..214b73aa2f3 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_composition_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_composition_test.py @@ -21,6 +21,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops.linalg import linalg as linalg_lib @@ -179,6 +180,7 @@ class NonSquareLinearOperatorCompositionTest( return operator, mat + @test_util.run_deprecated_v1 def test_static_shapes(self): operators = [ linalg.LinearOperatorFullMatrix(rng.rand(2, 3, 4)), @@ -187,6 +189,7 @@ class NonSquareLinearOperatorCompositionTest( operator = linalg.LinearOperatorComposition(operators) self.assertAllEqual((2, 3, 5), operator.shape) + @test_util.run_deprecated_v1 def test_shape_tensors_when_statically_available(self): operators = [ linalg.LinearOperatorFullMatrix(rng.rand(2, 3, 4)), @@ -196,6 +199,7 @@ class NonSquareLinearOperatorCompositionTest( with self.cached_session(): self.assertAllEqual((2, 3, 5), operator.shape_tensor().eval()) + @test_util.run_deprecated_v1 def test_shape_tensors_when_only_dynamically_available(self): mat_1 = rng.rand(1, 2, 3, 4) mat_2 = rng.rand(1, 2, 4, 5) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_diag_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_diag_test.py index 80889a162f8..dcbc0dd7c97 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_diag_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_diag_test.py @@ -17,6 +17,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops @@ -80,6 +81,7 @@ class LinearOperatorDiagTest( with self.assertRaisesOpError("non-positive real.*not positive definite"): operator.assert_positive_definite().run() + @test_util.run_deprecated_v1 def test_assert_positive_definite_does_not_raise_if_pd_and_complex(self): with self.cached_session(): x = [1., 2.] @@ -96,6 +98,7 @@ class LinearOperatorDiagTest( with self.assertRaisesOpError("Singular operator"): operator.assert_non_singular().run() + @test_util.run_deprecated_v1 def test_assert_non_singular_does_not_raise_for_complex_nonsingular(self): with self.cached_session(): x = [1., 0.] @@ -113,6 +116,7 @@ class LinearOperatorDiagTest( with self.assertRaisesOpError("imaginary.*not self-adjoint"): operator.assert_self_adjoint().run() + @test_util.run_deprecated_v1 def test_assert_self_adjoint_does_not_raise_for_diag_with_zero_imag(self): with self.cached_session(): x = [1., 0.] diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_full_matrix_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_full_matrix_test.py index 36575ceec36..aff0b1ae14c 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_full_matrix_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_full_matrix_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops.linalg import linalg as linalg_lib @@ -69,6 +70,7 @@ class SquareLinearOperatorFullMatrixTest( # Auto-detected. self.assertTrue(operator.is_square) + @test_util.run_deprecated_v1 def test_assert_non_singular_raises_if_cond_too_big_but_finite(self): with self.cached_session(): tril = linear_operator_test_util.random_tril_matrix( diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_identity_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_identity_test.py index e9fd91c6cf0..2da5e712d77 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_identity_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_identity_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops @@ -60,16 +61,19 @@ class LinearOperatorIdentityTest( return operator, mat + @test_util.run_deprecated_v1 def test_assert_positive_definite(self): with self.cached_session(): operator = linalg_lib.LinearOperatorIdentity(num_rows=2) operator.assert_positive_definite().run() # Should not fail + @test_util.run_deprecated_v1 def test_assert_non_singular(self): with self.cached_session(): operator = linalg_lib.LinearOperatorIdentity(num_rows=2) operator.assert_non_singular().run() # Should not fail + @test_util.run_deprecated_v1 def test_assert_self_adjoint(self): with self.cached_session(): operator = linalg_lib.LinearOperatorIdentity(num_rows=2) @@ -109,6 +113,7 @@ class LinearOperatorIdentityTest( with self.assertRaisesRegexp(ValueError, "must be non-negative"): linalg_lib.LinearOperatorIdentity(num_rows=2, batch_shape=[-2]) + @test_util.run_deprecated_v1 def test_non_scalar_num_rows_raises_dynamic(self): with self.cached_session(): num_rows = array_ops.placeholder(dtypes.int32) @@ -117,6 +122,7 @@ class LinearOperatorIdentityTest( with self.assertRaisesOpError("must be a 0-D Tensor"): operator.to_dense().eval(feed_dict={num_rows: [2]}) + @test_util.run_deprecated_v1 def test_negative_num_rows_raises_dynamic(self): with self.cached_session(): num_rows = array_ops.placeholder(dtypes.int32) @@ -125,6 +131,7 @@ class LinearOperatorIdentityTest( with self.assertRaisesOpError("must be non-negative"): operator.to_dense().eval(feed_dict={num_rows: -2}) + @test_util.run_deprecated_v1 def test_non_1d_batch_shape_raises_dynamic(self): with self.cached_session(): batch_shape = array_ops.placeholder(dtypes.int32) @@ -133,6 +140,7 @@ class LinearOperatorIdentityTest( with self.assertRaisesOpError("must be a 1-D"): operator.to_dense().eval(feed_dict={batch_shape: 2}) + @test_util.run_deprecated_v1 def test_negative_batch_shape_raises_dynamic(self): with self.cached_session(): batch_shape = array_ops.placeholder(dtypes.int32) @@ -147,6 +155,7 @@ class LinearOperatorIdentityTest( with self.assertRaisesRegexp(ValueError, "Dimensions.*not compatible"): operator.matmul(x) + @test_util.run_deprecated_v1 def test_wrong_matrix_dimensions_raises_dynamic(self): num_rows = array_ops.placeholder(dtypes.int32) x = array_ops.placeholder(dtypes.float32) @@ -172,6 +181,7 @@ class LinearOperatorIdentityTest( self.assertAllEqual(operator_matmul.get_shape(), expected.get_shape()) self.assertAllClose(*self.evaluate([operator_matmul, expected])) + @test_util.run_deprecated_v1 def test_default_batch_shape_broadcasts_with_everything_dynamic(self): # These cannot be done in the automated (base test class) tests since they # test shapes that tf.batch_matmul cannot handle. @@ -209,6 +219,7 @@ class LinearOperatorIdentityTest( self.assertAllEqual(operator_matmul.get_shape(), expected.get_shape()) self.assertAllClose(*self.evaluate([operator_matmul, expected])) + @test_util.run_deprecated_v1 def test_broadcast_matmul_dynamic_shapes(self): # These cannot be done in the automated (base test class) tests since they # test shapes that tf.batch_matmul cannot handle. @@ -309,6 +320,7 @@ class LinearOperatorScaledIdentityTest( return operator, matrix + @test_util.run_deprecated_v1 def test_assert_positive_definite_does_not_raise_when_positive(self): with self.cached_session(): operator = linalg_lib.LinearOperatorScaledIdentity( @@ -322,6 +334,7 @@ class LinearOperatorScaledIdentityTest( with self.assertRaisesOpError("not positive definite"): operator.assert_positive_definite().run() + @test_util.run_deprecated_v1 def test_assert_non_singular_does_not_raise_when_non_singular(self): with self.cached_session(): operator = linalg_lib.LinearOperatorScaledIdentity( @@ -335,6 +348,7 @@ class LinearOperatorScaledIdentityTest( with self.assertRaisesOpError("was singular"): operator.assert_non_singular().run() + @test_util.run_deprecated_v1 def test_assert_self_adjoint_does_not_raise_when_self_adjoint(self): with self.cached_session(): operator = linalg_lib.LinearOperatorScaledIdentity( @@ -372,6 +386,7 @@ class LinearOperatorScaledIdentityTest( with self.assertRaisesRegexp(ValueError, "Dimensions.*not compatible"): operator.matmul(x) + @test_util.run_deprecated_v1 def test_wrong_matrix_dimensions_raises_dynamic(self): num_rows = array_ops.placeholder(dtypes.int32) x = array_ops.placeholder(dtypes.float32) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_kronecker_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_kronecker_test.py index 2b1ae6e1f5a..513b2468032 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_kronecker_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_kronecker_test.py @@ -21,6 +21,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops.linalg import linalg as linalg_lib from tensorflow.python.ops.linalg import linear_operator_kronecker as kronecker @@ -53,6 +54,7 @@ def _kronecker_dense(factors): class KroneckerDenseTest(test.TestCase): + @test_util.run_deprecated_v1 def testKroneckerDenseMatrix(self): x = ops.convert_to_tensor([[2., 3.], [1., 2.]], dtype=dtypes.float32) y = ops.convert_to_tensor([[1., 2.], [5., -1.]], dtype=dtypes.float32) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_test.py index 2f67df408cb..8f8b15e8ed8 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_test.py @@ -22,6 +22,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops @@ -107,6 +108,7 @@ class LinearOperatorTest(test.TestCase): self.assertAllEqual(4, operator.domain_dimension) self.assertAllEqual(3, operator.range_dimension) + @test_util.run_deprecated_v1 def test_all_shape_methods_defined_by_the_one_method_shape(self): with self.cached_session(): shape = (1, 2, 3, 4) @@ -136,6 +138,7 @@ class LinearOperatorTest(test.TestCase): self.assertAllEqual((2, 3, 4), operator_dense.get_shape()) self.assertAllClose(matrix, self.evaluate(operator_dense)) + @test_util.run_deprecated_v1 def test_generic_to_dense_method_non_square_matrix_tensor(self): matrix = rng.randn(2, 3, 4) matrix_ph = array_ops.placeholder(dtypes.float64) @@ -175,6 +178,7 @@ class LinearOperatorTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "but.*was square"): _ = LinearOperatorShape(shape=(2, 4, 4), is_square=False).is_square + @test_util.run_deprecated_v1 def test_is_square_set_inconsistent_with_other_hints_raises(self): with self.assertRaisesRegexp(ValueError, "is always square"): matrix = array_ops.placeholder(dtypes.float32) @@ -185,6 +189,7 @@ class LinearOperatorTest(test.TestCase): LinearOperatorMatmulSolve( matrix, is_positive_definite=True, is_square=False) + @test_util.run_deprecated_v1 def test_non_square_operators_raise_on_determinant_and_solve(self): operator = LinearOperatorShape((2, 3)) with self.assertRaisesRegexp(NotImplementedError, "not be square"): @@ -199,6 +204,7 @@ class LinearOperatorTest(test.TestCase): LinearOperatorMatmulSolve( matrix, is_positive_definite=True, is_square=False) + @test_util.run_deprecated_v1 def test_is_square_manual_set_works(self): matrix = array_ops.placeholder(dtypes.float32) # Default is None. @@ -208,6 +214,7 @@ class LinearOperatorTest(test.TestCase): operator = LinearOperatorMatmulSolve(matrix, is_square=True) self.assertTrue(operator.is_square) + @test_util.run_deprecated_v1 def test_linear_operator_matmul_hints_closed(self): matrix = array_ops.placeholder(dtypes.float32) operator1 = LinearOperatorMatmulSolve(matrix) @@ -234,6 +241,7 @@ class LinearOperatorTest(test.TestCase): self.assertTrue(operator_matmul.is_self_adjoint) self.assertEqual(None, operator_matmul.is_positive_definite) + @test_util.run_deprecated_v1 def test_linear_operator_matmul_hints_false(self): matrix = array_ops.placeholder(dtypes.float32) operator1 = LinearOperatorMatmulSolve( @@ -266,6 +274,7 @@ class LinearOperatorTest(test.TestCase): self.assertEqual(None, operator_matmul.is_self_adjoint) self.assertEqual(None, operator_matmul.is_positive_definite) + @test_util.run_deprecated_v1 def test_linear_operator_matmul_hint_infer_square(self): matrix1 = array_ops.placeholder(shape=[2, 3], dtype=dtypes.float32) matrix2 = array_ops.placeholder(shape=[3, 2], dtype=dtypes.float32) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_util_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_util_test.py index f12714677e2..d1e6c37e35a 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_util_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_util_test.py @@ -21,6 +21,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops @@ -32,12 +33,14 @@ rng = np.random.RandomState(0) class AssertZeroImagPartTest(test.TestCase): + @test_util.run_deprecated_v1 def test_real_tensor_doesnt_raise(self): x = ops.convert_to_tensor([0., 2, 3]) with self.cached_session(): # Should not raise. linear_operator_util.assert_zero_imag_part(x, message="ABC123").run() + @test_util.run_deprecated_v1 def test_complex_tensor_with_imag_zero_doesnt_raise(self): x = ops.convert_to_tensor([1., 0, 3]) y = ops.convert_to_tensor([0., 0, 0]) @@ -57,6 +60,7 @@ class AssertZeroImagPartTest(test.TestCase): class AssertNoEntriesWithModulusZeroTest(test.TestCase): + @test_util.run_deprecated_v1 def test_nonzero_real_tensor_doesnt_raise(self): x = ops.convert_to_tensor([1., 2, 3]) with self.cached_session(): @@ -64,6 +68,7 @@ class AssertNoEntriesWithModulusZeroTest(test.TestCase): linear_operator_util.assert_no_entries_with_modulus_zero( x, message="ABC123").run() + @test_util.run_deprecated_v1 def test_nonzero_complex_tensor_doesnt_raise(self): x = ops.convert_to_tensor([1., 0, 3]) y = ops.convert_to_tensor([1., 2, 0]) @@ -104,6 +109,7 @@ class BroadcastMatrixBatchDimsTest(test.TestCase): with self.cached_session(): self.assertAllClose(arr, self.evaluate(tensor)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast(self): # x.batch_shape = [3, 1, 2] # y.batch_shape = [4, 1] @@ -142,6 +148,7 @@ class BroadcastMatrixBatchDimsTest(test.TestCase): self.assertAllClose(x_bc_expected, x_bc_) self.assertAllClose(y_bc_expected, y_bc_) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_32bit(self): # x.batch_shape = [3, 1, 2] # y.batch_shape = [4, 1] @@ -162,6 +169,7 @@ class BroadcastMatrixBatchDimsTest(test.TestCase): self.assertAllClose(x_bc_expected, x_bc_) self.assertAllClose(y_bc_expected, y_bc_) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_32bit_second_arg_higher_rank(self): # x.batch_shape = [1, 2] # y.batch_shape = [3, 4, 1] @@ -195,6 +203,7 @@ class BroadcastMatrixBatchDimsTest(test.TestCase): class CholeskySolveWithBroadcastTest(test.TestCase): + @test_util.run_deprecated_v1 def test_static_dims_broadcast(self): # batch_shape = [2] chol = rng.rand(3, 3) @@ -207,6 +216,7 @@ class CholeskySolveWithBroadcastTest(test.TestCase): expected = linalg_ops.cholesky_solve(chol_broadcast, rhs) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_64bit(self): # batch_shape = [2, 2] chol = rng.rand(2, 3, 3) @@ -233,6 +243,7 @@ class CholeskySolveWithBroadcastTest(test.TestCase): class MatmulWithBroadcastTest(test.TestCase): + @test_util.run_deprecated_v1 def test_static_dims_broadcast_x_has_extra_dims(self): # batch_shape = [2] # for each batch member, we have a 1x3 matrix times a 3x7 matrix ==> 1x7 @@ -246,6 +257,7 @@ class MatmulWithBroadcastTest(test.TestCase): expected = math_ops.matmul(x, y_broadcast) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_y_has_extra_dims(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -263,6 +275,7 @@ class MatmulWithBroadcastTest(test.TestCase): expected = math_ops.matmul(x_broadcast, y) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_y_has_extra_dims_transpose_a_and_b(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -282,6 +295,7 @@ class MatmulWithBroadcastTest(test.TestCase): x_broadcast, y, transpose_a=True, transpose_b=True) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_y_has_extra_dims_transpose_dynamic(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -308,6 +322,7 @@ class MatmulWithBroadcastTest(test.TestCase): y_ph: y })) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_64bit(self): # batch_shape = [2] # for each batch member, we have a 1x3 matrix times a 3x7 matrix ==> 1x7 @@ -333,6 +348,7 @@ class MatmulWithBroadcastTest(test.TestCase): class MatrixSolveWithBroadcastTest(test.TestCase): + @test_util.run_deprecated_v1 def test_static_dims_broadcast_matrix_has_extra_dims(self): # batch_shape = [2] matrix = rng.rand(2, 3, 3) @@ -346,6 +362,7 @@ class MatrixSolveWithBroadcastTest(test.TestCase): expected = linalg_ops.matrix_solve(matrix, rhs_broadcast) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_rhs_has_extra_dims(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -364,6 +381,7 @@ class MatrixSolveWithBroadcastTest(test.TestCase): expected = linalg_ops.matrix_solve(matrix_broadcast, rhs) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_rhs_has_extra_dims_dynamic(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -391,6 +409,7 @@ class MatrixSolveWithBroadcastTest(test.TestCase): rhs_ph: rhs })) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_rhs_has_extra_dims_and_adjoint(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -410,6 +429,7 @@ class MatrixSolveWithBroadcastTest(test.TestCase): expected = linalg_ops.matrix_solve(matrix_broadcast, rhs, adjoint=True) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_64bit(self): # batch_shape = [2, 2] matrix = rng.rand(2, 3, 3) @@ -436,6 +456,7 @@ class MatrixSolveWithBroadcastTest(test.TestCase): class MatrixTriangularSolveWithBroadcastTest(test.TestCase): + @test_util.run_deprecated_v1 def test_static_dims_broadcast_matrix_has_extra_dims(self): # batch_shape = [2] matrix = rng.rand(2, 3, 3) @@ -449,6 +470,7 @@ class MatrixTriangularSolveWithBroadcastTest(test.TestCase): expected = linalg_ops.matrix_triangular_solve(matrix, rhs_broadcast) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_rhs_has_extra_dims(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -468,6 +490,7 @@ class MatrixTriangularSolveWithBroadcastTest(test.TestCase): expected = linalg_ops.matrix_triangular_solve(matrix_broadcast, rhs) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_static_dims_broadcast_rhs_has_extra_dims_and_adjoint(self): # Since the second arg has extra dims, and the domain dim of the first arg # is larger than the number of linear equations, code will "flip" the extra @@ -488,6 +511,7 @@ class MatrixTriangularSolveWithBroadcastTest(test.TestCase): matrix_broadcast, rhs, adjoint=True) self.assertAllClose(expected.eval(), self.evaluate(result)) + @test_util.run_deprecated_v1 def test_dynamic_dims_broadcast_64bit(self): # batch_shape = [2] matrix = rng.rand(2, 3, 3) @@ -522,6 +546,7 @@ class DomainDimensionStubOperator(object): class AssertCompatibleMatrixDimensionsTest(test.TestCase): + @test_util.run_deprecated_v1 def test_compatible_dimensions_do_not_raise(self): with self.cached_session(): x = ops.convert_to_tensor(rng.rand(2, 3, 4)) diff --git a/tensorflow/python/kernel_tests/linalg/linear_operator_zeros_test.py b/tensorflow/python/kernel_tests/linalg/linear_operator_zeros_test.py index e875579a7af..eb0b8ef1277 100644 --- a/tensorflow/python/kernel_tests/linalg/linear_operator_zeros_test.py +++ b/tensorflow/python/kernel_tests/linalg/linear_operator_zeros_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops.linalg import linalg as linalg_lib from tensorflow.python.ops.linalg import linear_operator_test_util @@ -73,6 +74,7 @@ class LinearOperatorZerosTest( operator = linalg_lib.LinearOperatorZeros(num_rows=2) operator.assert_non_singular() + @test_util.run_deprecated_v1 def test_assert_self_adjoint(self): with self.cached_session(): operator = linalg_lib.LinearOperatorZeros(num_rows=2) @@ -108,6 +110,7 @@ class LinearOperatorZerosTest( with self.assertRaisesRegexp(ValueError, "must be non-negative"): linalg_lib.LinearOperatorZeros(num_rows=2, batch_shape=[-2]) + @test_util.run_deprecated_v1 def test_non_scalar_num_rows_raises_dynamic(self): with self.cached_session(): num_rows = array_ops.placeholder(dtypes.int32) @@ -116,6 +119,7 @@ class LinearOperatorZerosTest( with self.assertRaisesOpError("must be a 0-D Tensor"): operator.to_dense().eval(feed_dict={num_rows: [2]}) + @test_util.run_deprecated_v1 def test_negative_num_rows_raises_dynamic(self): with self.cached_session(): n = array_ops.placeholder(dtypes.int32) @@ -129,6 +133,7 @@ class LinearOperatorZerosTest( with self.assertRaisesOpError("must be non-negative"): operator.to_dense().eval(feed_dict={n: -2}) + @test_util.run_deprecated_v1 def test_non_1d_batch_shape_raises_dynamic(self): with self.cached_session(): batch_shape = array_ops.placeholder(dtypes.int32) @@ -137,6 +142,7 @@ class LinearOperatorZerosTest( with self.assertRaisesOpError("must be a 1-D"): operator.to_dense().eval(feed_dict={batch_shape: 2}) + @test_util.run_deprecated_v1 def test_negative_batch_shape_raises_dynamic(self): with self.cached_session(): batch_shape = array_ops.placeholder(dtypes.int32) @@ -151,6 +157,7 @@ class LinearOperatorZerosTest( with self.assertRaisesRegexp(ValueError, "Dimensions.*not compatible"): operator.matmul(x) + @test_util.run_deprecated_v1 def test_wrong_matrix_dimensions_raises_dynamic(self): num_rows = array_ops.placeholder(dtypes.int32) x = array_ops.placeholder(dtypes.float32) diff --git a/tensorflow/python/kernel_tests/linalg_grad_test.py b/tensorflow/python/kernel_tests/linalg_grad_test.py index 709ecbfc35f..28e1d7e1684 100644 --- a/tensorflow/python/kernel_tests/linalg_grad_test.py +++ b/tensorflow/python/kernel_tests/linalg_grad_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -39,6 +40,7 @@ def _AddTest(test, op_name, testcase_name, fn): class ShapeTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testBatchGradientUnknownSize(self): with self.cached_session(): batch_size = constant_op.constant(3) diff --git a/tensorflow/python/kernel_tests/linalg_ops_test.py b/tensorflow/python/kernel_tests/linalg_ops_test.py index b5eeee09980..028167a7860 100644 --- a/tensorflow/python/kernel_tests/linalg_ops_test.py +++ b/tensorflow/python/kernel_tests/linalg_ops_test.py @@ -25,6 +25,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops @@ -52,6 +53,7 @@ class CholeskySolveTest(test.TestCase): def setUp(self): self.rng = np.random.RandomState(0) + @test_util.run_deprecated_v1 def test_works_with_five_different_random_pos_def_matrices(self): for n in range(1, 6): for np_type, atol in [(np.float32, 0.05), (np.float64, 1e-5)]: @@ -73,6 +75,7 @@ class LogdetTest(test.TestCase): def setUp(self): self.rng = np.random.RandomState(42) + @test_util.run_deprecated_v1 def test_works_with_five_different_random_pos_def_matrices(self): for n in range(1, 6): for np_dtype, atol in [(np.float32, 0.05), (np.float64, 1e-5), @@ -102,6 +105,7 @@ class SlogdetTest(test.TestCase): def setUp(self): self.rng = np.random.RandomState(42) + @test_util.run_deprecated_v1 def test_works_with_five_different_random_pos_def_matrices(self): for n in range(1, 6): for np_dtype, atol in [(np.float32, 0.05), (np.float64, 1e-5), @@ -232,6 +236,7 @@ class EyeTest(parameterized.TestCase, test.TestCase): dtypes.complex128 ]) ) + @test_util.run_deprecated_v1 def test_eye_with_placeholder( self, num_rows, num_columns, batch_shape, dtype): eye_np = np.eye(num_rows, M=num_columns, dtype=dtype.as_numpy_dtype) diff --git a/tensorflow/python/kernel_tests/list_ops_test.py b/tensorflow/python/kernel_tests/list_ops_test.py index 1d9f4032d1a..8df11564389 100644 --- a/tensorflow/python/kernel_tests/list_ops_test.py +++ b/tensorflow/python/kernel_tests/list_ops_test.py @@ -66,6 +66,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): with context.device("gpu:0"): self._testPushPop(max_num_elements) + @test_util.run_deprecated_v1 def testPushInFullListFails(self): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, element_shape=[], max_num_elements=1) @@ -77,6 +78,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 2)) + @test_util.run_deprecated_v1 def testPopFromEmptyTensorListFails(self, max_num_elements): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, @@ -114,6 +116,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 3)) + @test_util.run_deprecated_v1 def testStackWithUnknownElementShape(self, max_num_elements): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, @@ -134,6 +137,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 3)) + @test_util.run_deprecated_v1 def testStackWithPartiallyDefinedElementShape(self, max_num_elements): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, @@ -154,6 +158,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 2)) + @test_util.run_deprecated_v1 def testStackEmptyList(self, max_num_elements): # Should be able to stack empty lists with fully defined element_shape. l = list_ops.empty_tensor_list( @@ -204,6 +209,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 3)) + @test_util.run_deprecated_v1 def testGatherWithUnknownElementShape(self, max_num_elements): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, @@ -227,6 +233,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 3)) + @test_util.run_deprecated_v1 def testGatherWithPartiallyDefinedElementShape(self, max_num_elements): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, @@ -250,6 +257,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.named_parameters(("NoMaxNumElements", None), ("WithMaxNumElements", 3)) + @test_util.run_deprecated_v1 def testGatherEmptyList(self, max_num_elements): # Should be able to gather from empty lists with fully defined # element_shape. @@ -337,6 +345,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertAllEqual(self.evaluate(e), 10.0) self.assertAllEqual(self.evaluate(tape.gradient(e, t)), 2.0) + @test_util.run_deprecated_v1 def testSetOnEmptyListWithMaxNumElementsFails(self): l = list_ops.empty_tensor_list( element_dtype=dtypes.float32, element_shape=[], max_num_elements=3) @@ -572,12 +581,14 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertAllEqual(self.evaluate(grad_c), [0.0, 4.0]) self.assertAllEqual(self.evaluate(grad_c2), 6.0) + @test_util.run_deprecated_v1 def testSetOutOfBounds(self): c = constant_op.constant([1.0, 2.0]) l = list_ops.tensor_list_from_tensor(c, element_shape=[]) with self.assertRaises(errors.InvalidArgumentError): self.evaluate(list_ops.tensor_list_set_item(l, 20, 3.0)) + @test_util.run_deprecated_v1 def testSkipEagerSetItemWithMismatchedShapeFails(self): with self.cached_session() as sess: ph = array_ops.placeholder(dtypes.float32) @@ -612,6 +623,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): [[1.0, 2.0]] * 4) self.assertAllEqual(self.evaluate(updated_v_stacked), expected) + @test_util.run_deprecated_v1 def testConcat(self): c = constant_op.constant([1.0, 2.0], dtype=dtypes.float32) l0 = list_ops.tensor_list_from_tensor(c, element_shape=[]) @@ -670,6 +682,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): list_ops.tensor_list_concat_lists(l_batch_0, l_batch_of_int_tls, element_dtype=dtypes.float32)) + @test_util.run_deprecated_v1 def testPushBackBatch(self): c = constant_op.constant([1.0, 2.0], dtype=dtypes.float32) l0 = list_ops.tensor_list_from_tensor(c, element_shape=[]) @@ -797,6 +810,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertAllEqual(self.evaluate(res_1), [0.]) self.assertAllEqual(self.evaluate(res_2), [0., 0.]) + @test_util.run_deprecated_v1 def testSkipEagerTensorListGetItemGradAggregation(self): l = list_ops.tensor_list_reserve( element_shape=[], num_elements=1, element_dtype=dtypes.float32) @@ -808,6 +822,7 @@ class ListOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.cached_session() as sess: self.assertSequenceEqual(self.evaluate(grad), [2.]) + @test_util.run_deprecated_v1 def testSkipEagerBuildElementShape(self): fn = list_ops._build_element_shape # Unknown shape -> -1. diff --git a/tensorflow/python/kernel_tests/logging_ops_test.py b/tensorflow/python/kernel_tests/logging_ops_test.py index e8fa1cfa28d..85035e5f7d3 100644 --- a/tensorflow/python/kernel_tests/logging_ops_test.py +++ b/tensorflow/python/kernel_tests/logging_ops_test.py @@ -39,6 +39,7 @@ from tensorflow.python.platform import test class LoggingOpsTest(test.TestCase): + @test_util.run_deprecated_v1 def testAssertDivideByZero(self): with self.cached_session() as sess: epsilon = ops.convert_to_tensor(1e-20) @@ -305,12 +306,14 @@ class PrintV2Test(test.TestCase): tensor, output_stream="unknown") self.evaluate(print_op) + @test_util.run_deprecated_v1 def testPrintOpName(self): with self.cached_session(): tensor = math_ops.range(10) print_op = logging_ops.print_v2(tensor, name="print_name") self.assertEqual(print_op.name, "print_name") + @test_util.run_deprecated_v1 def testNoDuplicateFormatOpGraphModeAfterExplicitFormat(self): with self.cached_session(): tensor = math_ops.range(10) @@ -379,6 +382,7 @@ class PrintGradientTest(test.TestCase): inp_printed = logging_ops.Print(inp, ["hello"]) self.assertEqual(inp.get_shape(), inp_printed.get_shape()) + @test_util.run_deprecated_v1 def testPrintGradient(self): with self.cached_session(): inp = constant_op.constant(2.0, shape=[100, 32], name="in") diff --git a/tensorflow/python/kernel_tests/lookup_ops_test.py b/tensorflow/python/kernel_tests/lookup_ops_test.py index 79961d8dd1d..ad81e0be649 100644 --- a/tensorflow/python/kernel_tests/lookup_ops_test.py +++ b/tensorflow/python/kernel_tests/lookup_ops_test.py @@ -37,6 +37,7 @@ from tensorflow.python.training import server_lib class HashTableOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testHashTable(self): with self.cached_session(): default_val = -1 @@ -61,6 +62,7 @@ class HashTableOpTest(test.TestCase): self.evaluate(exported_keys_tensor)) self.assertItemsEqual([0, 1, 2], self.evaluate(exported_values_tensor)) + @test_util.run_deprecated_v1 def testHashTableFindHighRank(self): with self.cached_session(): default_val = -1 @@ -79,6 +81,7 @@ class HashTableOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([[0, 1], [-1, -1]], result) + @test_util.run_deprecated_v1 def testHashTableInitWithPythonArrays(self): with self.cached_session(): default_val = -1 @@ -97,6 +100,7 @@ class HashTableOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testHashTableInitWithNumPyArrays(self): with self.cached_session(): default_val = -1 @@ -114,6 +118,7 @@ class HashTableOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testMultipleHashTables(self): with self.cached_session() as sess: default_val = -1 @@ -142,6 +147,7 @@ class HashTableOpTest(test.TestCase): self.assertAllEqual([0, 1, -1], out2) self.assertAllEqual([0, 1, -1], out3) + @test_util.run_deprecated_v1 def testHashTableWithTensorDefault(self): with self.cached_session(): default_val = constant_op.constant(-1, dtypes.int64) @@ -157,6 +163,7 @@ class HashTableOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testHashTableWithSparseTensorInput(self): with self.cached_session() as sess: default_val = constant_op.constant(-1, dtypes.int64) @@ -180,6 +187,7 @@ class HashTableOpTest(test.TestCase): self.assertAllEqual(sp_indices, out_indices) self.assertAllEqual(sp_shape, out_shape) + @test_util.run_deprecated_v1 def testSignatureMismatch(self): with self.cached_session(): default_val = -1 @@ -210,6 +218,7 @@ class HashTableOpTest(test.TestCase): lookup_ops.KeyValueTensorInitializer(["a"], [1], [dtypes.string], dtypes.int64), default_val) + @test_util.run_deprecated_v1 def testNotInitialized(self): with self.cached_session(): default_val = -1 @@ -223,6 +232,7 @@ class HashTableOpTest(test.TestCase): with self.assertRaisesOpError("Table not initialized"): self.evaluate(output) + @test_util.run_deprecated_v1 def testInitializeTwice(self): with self.cached_session(): default_val = -1 @@ -235,6 +245,7 @@ class HashTableOpTest(test.TestCase): with self.assertRaisesOpError("Table already initialized"): table.initializer.run() + @test_util.run_deprecated_v1 def testInitializationWithInvalidDimensions(self): with self.cached_session(): default_val = -1 @@ -245,6 +256,7 @@ class HashTableOpTest(test.TestCase): lookup_ops.HashTable( lookup_ops.KeyValueTensorInitializer(keys, values), default_val) + @test_util.run_deprecated_v1 def testMultipleSessions(self): # Start a server server = server_lib.Server( @@ -274,6 +286,7 @@ class HashTableOpTest(test.TestCase): table.initializer.run() self.assertAllEqual(3, table.size().eval()) + @test_util.run_deprecated_v1 def testHashTableInt32String(self): with self.cached_session(): default_val = "n/a" @@ -298,6 +311,7 @@ class IndexTableFromFile(test.TestCase): f.write("\n".join(values) + "\n") return vocabulary_file + @test_util.run_deprecated_v1 def test_string_index_table_from_file(self): vocabulary_file = self._createVocabFile("f2i_vocab1.txt") with self.cached_session(): @@ -310,6 +324,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_string_index_table_from_multicolumn_file(self): vocabulary_file = self._createVocabFile( "f2i_vocab1.txt", values=("brain\t300", "salad\t20", "surgery\t1")) @@ -326,6 +341,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_string_index_table_from_multicolumn_file_custom_delimiter(self): vocabulary_file = self._createVocabFile( "f2i_vocab1.txt", values=("brain 300", "salad 20", "surgery 1")) @@ -343,6 +359,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_string_index_table_from_file_tensor_filename(self): vocabulary_file = self._createVocabFile("f2i_vocab1.txt") with self.cached_session(): @@ -358,6 +375,7 @@ class IndexTableFromFile(test.TestCase): self.assertEqual(1, len(ops.get_collection(ops.GraphKeys.ASSET_FILEPATHS))) + @test_util.run_deprecated_v1 def test_string_index_table_from_file_placeholder_filename(self): vocabulary_file = self._createVocabFile("f2i_vocab1.txt") with self.cached_session(): @@ -375,6 +393,7 @@ class IndexTableFromFile(test.TestCase): self.assertEqual(0, len(ops.get_collection(ops.GraphKeys.ASSET_FILEPATHS))) + @test_util.run_deprecated_v1 def test_int32_index_table_from_file(self): vocabulary_file = self._createVocabFile( "f2i_vocab2.txt", values=("42", "1", "-1000")) @@ -391,6 +410,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_int64_index_table_from_file(self): vocabulary_file = self._createVocabFile( "f2i_vocab3.txt", values=("42", "1", "-1000")) @@ -407,6 +427,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_index_table_from_file_with_default_value(self): default_value = -42 vocabulary_file = self._createVocabFile("f2i_vocab4.txt") @@ -420,6 +441,7 @@ class IndexTableFromFile(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, default_value), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_index_table_from_file_with_oov_buckets(self): vocabulary_file = self._createVocabFile("f2i_vocab5.txt") with self.cached_session(): @@ -468,6 +490,7 @@ class IndexTableFromFile(test.TestCase): vocabulary_file=vocabulary_file, vocab_size=0) + @test_util.run_deprecated_v1 def test_index_table_from_file_with_vocab_size_too_small(self): vocabulary_file = self._createVocabFile("f2i_vocab6.txt") with self.cached_session(): @@ -481,6 +504,7 @@ class IndexTableFromFile(test.TestCase): self.assertAllEqual((1, -1, -1), self.evaluate(ids)) self.assertEqual(2, table.size().eval()) + @test_util.run_deprecated_v1 def test_index_table_from_file_with_vocab_size_too_large(self): vocabulary_file = self._createVocabFile("f2i_vocab7.txt") with self.cached_session(): @@ -489,6 +513,7 @@ class IndexTableFromFile(test.TestCase): self.assertRaisesRegexp(errors_impl.InvalidArgumentError, "Invalid vocab_size", table.initializer.run) + @test_util.run_deprecated_v1 def test_index_table_from_file_with_vocab_size(self): vocabulary_file = self._createVocabFile("f2i_vocab8.txt") @@ -577,6 +602,7 @@ class KeyValueTensorInitializerTest(test.TestCase): table = lookup_ops.HashTable(init, default_value=-1) table.initializer.run() + @test_util.run_deprecated_v1 def test_int32(self): with ops.Graph().as_default(), self.cached_session(): init = lookup_ops.KeyValueTensorInitializer((42, 1, -1000), (0, 1, 2), @@ -590,6 +616,7 @@ class KeyValueTensorInitializerTest(test.TestCase): class IndexTableFromTensor(test.TestCase): @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def test_index_table_from_tensor_with_tensor_init(self): table = lookup_ops.index_table_from_tensor( vocabulary_list=("brain", "salad", "surgery"), num_oov_buckets=1) @@ -606,6 +633,7 @@ class IndexTableFromTensor(test.TestCase): ids = table.lookup(constant_op.constant(("salad", "surgery", "tarkus"))) self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_int32_index_table_from_tensor_with_tensor_init(self): with self.cached_session(): table = lookup_ops.index_table_from_tensor( @@ -618,6 +646,7 @@ class IndexTableFromTensor(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_int64_index_table_from_tensor_with_tensor_init(self): with self.cached_session(): table = lookup_ops.index_table_from_tensor( @@ -630,6 +659,7 @@ class IndexTableFromTensor(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((1, 2, 3), self.evaluate(ids)) + @test_util.run_deprecated_v1 def test_index_table_from_tensor_with_default_value(self): default_value = -42 with self.cached_session(): @@ -650,6 +680,7 @@ class IndexTableFromTensor(test.TestCase): lookup_ops.index_table_from_tensor( vocabulary_list=None, num_oov_buckets=1) + @test_util.run_deprecated_v1 def test_index_table_from_tensor_empty_vocabulary_list(self): with self.cached_session(): table = lookup_ops.index_table_from_tensor( @@ -686,6 +717,7 @@ class IndexToStringTableFromFileTest(test.TestCase): f.write("\n".join(values) + "\n") return vocabulary_file + @test_util.run_deprecated_v1 def test_index_to_string_table(self): vocabulary_path = self._createVocabFile("i2f_vocab1.txt") # vocabulary_file supports string and tensor @@ -703,6 +735,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_table_from_multicolumn_file(self): vocabulary_file = self._createVocabFile( "f2i_vocab1.txt", values=("brain\t300", "salad\t20", "surgery\t1")) @@ -718,6 +751,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_table_from_multicolumn_file_custom_delimiter(self): vocabulary_file = self._createVocabFile( "f2i_vocab1.txt", values=("brain 300", "salad 20", "surgery 1")) @@ -734,6 +768,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_table_with_default_value(self): default_value = b"NONE" vocabulary_file = self._createVocabFile("f2i_vocab2.txt") @@ -747,6 +782,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertAllEqual((b"salad", b"surgery", default_value), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_table_with_vocab_size_too_small(self): default_value = b"NONE" vocabulary_file = self._createVocabFile("f2i_vocab2.txt") @@ -762,6 +798,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertAllEqual((b"salad", default_value, default_value), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_table_with_vocab_size_too_large(self): vocabulary_file = self._createVocabFile("f2i_vocab6.txt") with self.cached_session(): @@ -775,6 +812,7 @@ class IndexToStringTableFromFileTest(test.TestCase): self.assertRaisesRegexp(errors_impl.InvalidArgumentError, "Invalid vocab_size", init.run) + @test_util.run_deprecated_v1 def test_index_to_string_table_with_vocab_size(self): vocabulary_file = self._createVocabFile("f2i_vocab7.txt") with self.cached_session(): @@ -791,6 +829,7 @@ class IndexToStringTableFromFileTest(test.TestCase): class IndexToStringTableFromTensorTest(test.TestCase): + @test_util.run_deprecated_v1 def test_index_to_string_table_from_tensor(self): with self.cached_session(): vocabulary_list = constant_op.constant(["brain", "salad", "surgery"]) @@ -806,6 +845,7 @@ class IndexToStringTableFromTensorTest(test.TestCase): self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_duplicate_entries(self): with self.cached_session(): vocabulary_list = constant_op.constant(["hello", "hello"]) @@ -816,6 +856,7 @@ class IndexToStringTableFromTensorTest(test.TestCase): lookup_ops.tables_initializer().run() self.assertAllEqual((b"hello", b"hello", b"UNK"), self.evaluate(features)) + @test_util.run_deprecated_v1 def test_index_to_string_with_default_value(self): default_value = b"NONE" with self.cached_session(): @@ -855,6 +896,7 @@ class InitializeTableFromFileOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testInitializeInt64Table(self): vocabulary_file = self._createVocabFile( "one_column_int64.txt", values=("42", "1", "-1000")) @@ -874,6 +916,7 @@ class InitializeTableFromFileOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testInitializeIndexTable(self): vocabulary_file = self._createVocabFile("one_column_2.txt") @@ -893,6 +936,7 @@ class InitializeTableFromFileOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([b"brain", b"salad", b"surgery", b"UNK"], result) + @test_util.run_deprecated_v1 def testMultiColumn(self): vocabulary_file = os.path.join(self.get_temp_dir(), "three_columns.txt") with open(vocabulary_file, "w") as f: @@ -915,6 +959,7 @@ class InitializeTableFromFileOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([1, 5, 6], result) + @test_util.run_deprecated_v1 def testInvalidDataTypeInMultiColumn(self): vocabulary_file = os.path.join(self.get_temp_dir(), "three_columns.txt") with open(vocabulary_file, "w") as f: @@ -945,6 +990,7 @@ class InitializeTableFromFileOpTest(test.TestCase): key_index, dtypes.string, value_index), default_value) + @test_util.run_deprecated_v1 def testInvalidIndex(self): vocabulary_file = self._createVocabFile("one_column_4.txt") with self.cached_session(): @@ -959,6 +1005,7 @@ class InitializeTableFromFileOpTest(test.TestCase): with self.assertRaisesOpError("Invalid number of columns"): table.initializer.run() + @test_util.run_deprecated_v1 def testInitializeSameTableWithMultipleNodes(self): vocabulary_file = self._createVocabFile("one_column_5.txt") @@ -1010,6 +1057,7 @@ class InitializeTableFromFileOpTest(test.TestCase): dtypes.int64, lookup_ops.TextFileIndex.LINE_NUMBER), default_value) + @test_util.run_deprecated_v1 def testInitializeWithVocabSize(self): with self.cached_session(): default_value = -1 @@ -1056,6 +1104,7 @@ class InitializeTableFromFileOpTest(test.TestCase): table3.initializer.run() self.assertEquals(vocab_size, table3.size().eval()) + @test_util.run_deprecated_v1 def testFeedVocabularyName(self): vocabulary_file = self._createVocabFile("feed_vocabulary.txt") @@ -1082,6 +1131,7 @@ class InitializeTableFromFileOpTest(test.TestCase): result = self.evaluate(output) self.assertAllEqual([0, 1, -1], result) + @test_util.run_deprecated_v1 def testInvalidFilenames(self): vocabulary_file = self._createVocabFile("filename_shape.txt") @@ -1106,6 +1156,7 @@ class InitializeTableFromFileOpTest(test.TestCase): dtypes.int64, lookup_ops.TextFileIndex.LINE_NUMBER), default_value) + @test_util.run_deprecated_v1 def testIdToStringTable(self): vocab_file = self._createVocabFile("feat_to_id_1.txt") with self.cached_session(): @@ -1124,6 +1175,7 @@ class InitializeTableFromFileOpTest(test.TestCase): self.evaluate(out)) self.assertEquals(vocab_size, table.size().eval()) + @test_util.run_deprecated_v1 def testStringToIdTable(self): vocab_file = self._createVocabFile("feat_to_id_2.txt") with self.cached_session(): @@ -1140,6 +1192,7 @@ class InitializeTableFromFileOpTest(test.TestCase): self.assertAllEqual([0, 1, 2, -1], self.evaluate(out)) self.assertEquals(vocab_size, table.size().eval()) + @test_util.run_deprecated_v1 def testInt64ToIdTable(self): vocab_file = self._createVocabFile( "feat_to_id_3.txt", values=("42", "1", "-1000")) @@ -1166,6 +1219,7 @@ class IdTableWithHashBucketsTest(test.TestCase): f.write("\n".join(values) + "\n") return vocabulary_file + @test_util.run_deprecated_v1 def testStringIdTableWithHashBuckets(self): vocab_file = self._createVocabFile("feat_to_id_1.txt") with self.cached_session(): @@ -1186,6 +1240,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([0, 1, 2, 3], self.evaluate(out)) self.assertEquals(vocab_size + oov_buckets, table.size().eval()) + @test_util.run_deprecated_v1 def testInt32IdTableWithHashBuckets(self): vocab_file = self._createVocabFile("feat_to_id_2.txt", ("42", "1", "-1000")) with self.cached_session(): @@ -1208,6 +1263,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([0, 1, 2, 3], self.evaluate(out)) self.assertEquals(vocab_size + oov_buckets, table.size().eval()) + @test_util.run_deprecated_v1 def testInt64IdTableWithHashBuckets(self): vocab_file = self._createVocabFile("feat_to_id_3.txt", ("42", "1", "-1000")) with self.cached_session(): @@ -1228,6 +1284,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([0, 1, 2, 3], self.evaluate(out)) self.assertEquals(vocab_size + oov_buckets, table.size().eval()) + @test_util.run_deprecated_v1 def testStringIdTableWithOnlyHashBucket(self): with self.cached_session(): oov_buckets = 5 @@ -1249,6 +1306,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.evaluate(out)) self.assertEquals(oov_buckets, table.size().eval()) + @test_util.run_deprecated_v1 def testInt32IdTableWithOnlyHashBucket(self): with self.cached_session(): oov_buckets = 5 @@ -1283,6 +1341,7 @@ class IdTableWithHashBucketsTest(test.TestCase): lookup_ops.IdTableWithHashBuckets( None, num_oov_buckets=5, key_dtype=dtypes.bool) + @test_util.run_deprecated_v1 def testIdTableWithHashBucketsWithMultipleInitializers(self): vocab_file = self._createVocabFile("feat_to_id_4.txt") with self.cached_session() as sess: @@ -1323,6 +1382,7 @@ class IdTableWithHashBucketsTest(test.TestCase): "table2_Lookup/hash_bucket": "StringToHashBucketStrong", }, sess.graph) + @test_util.run_deprecated_v1 def testIdTableWithHashBucketsInitializationAcrossSessions(self): vocab_file = self._createVocabFile("feat_to_id_5.txt") shared_name = "across-sessions" @@ -1368,6 +1428,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([3, 1, 3], self.evaluate(out2)) self.assertEquals(vocab_size + oov_buckets, table2.size().eval()) + @test_util.run_deprecated_v1 def testIdTableWithHashBucketsWithMultipleInitializersDifferentDefault(self): vocab_file = self._createVocabFile("feat_to_id_6.txt") with self.cached_session() as sess: @@ -1402,6 +1463,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertEquals(vocab_size + oov_buckets, table1.size().eval()) self.assertEquals(vocab_size + oov_buckets, table2.size().eval()) + @test_util.run_deprecated_v1 def testSparseTensor(self): vocab_file = self._createVocabFile("feat_to_id_7.txt") input_indices = [[0, 0], [0, 1], [2, 0], [2, 2], [3, 0]] @@ -1430,6 +1492,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([0, 1, 0, 2, 3], sp_ids_val) self.assertAllEqual(input_shape, sp_ids_shape) + @test_util.run_deprecated_v1 def testInt32SparseTensor(self): input_indices = [[0, 0], [0, 1], [2, 0], [2, 2], [3, 0]] input_shape = [4, 4] @@ -1458,6 +1521,7 @@ class IdTableWithHashBucketsTest(test.TestCase): self.assertAllEqual([0, 1, 0, 2, 3], sp_ids_val) self.assertAllEqual(input_shape, sp_ids_shape) + @test_util.run_deprecated_v1 def testInt64SparseTensor(self): input_indices = [[0, 0], [0, 1], [2, 0], [2, 2], [3, 0]] input_shape = [4, 4] diff --git a/tensorflow/python/kernel_tests/losses_test.py b/tensorflow/python/kernel_tests/losses_test.py index bda63bcaa92..abff61f81b0 100644 --- a/tensorflow/python/kernel_tests/losses_test.py +++ b/tensorflow/python/kernel_tests/losses_test.py @@ -51,22 +51,26 @@ class AbsoluteDifferenceLossTest(test.TestCase): losses.absolute_difference( self._predictions, self._predictions, weights=None) + @test_util.run_deprecated_v1 def testAllCorrectNoLossWeight(self): loss = losses.absolute_difference(self._predictions, self._predictions) with self.cached_session(): self.assertAlmostEqual(0.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLoss(self): loss = losses.absolute_difference(self._labels, self._predictions) with self.cached_session(): self.assertAlmostEqual(5.5, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.cached_session(): self.assertAlmostEqual(5.5 * weights, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.absolute_difference(self._labels, self._predictions, @@ -123,6 +127,7 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): with self.assertRaises(ValueError): losses.softmax_cross_entropy(labels, logits, weights=None) + @test_util.run_deprecated_v1 def testAllCorrect(self): with self.cached_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], @@ -132,6 +137,7 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals('softmax_cross_entropy_loss/value', loss.op.name) self.assertAlmostEqual(loss.eval(), 0.0, 3) + @test_util.run_deprecated_v1 def testAllWrong(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -142,6 +148,7 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -151,6 +158,7 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): loss = losses.softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(weights * 10.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -200,6 +208,7 @@ class SoftmaxCrossEntropyLossTest(test.TestCase): with self.assertRaises(ValueError): losses.softmax_cross_entropy(labels, logits, weights=weights).eval() + @test_util.run_deprecated_v1 def testSoftmaxLabelSmoothing(self): with self.cached_session(): # Softmax Cross Entropy Loss is: @@ -232,6 +241,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy(labels, logits, weights=None) + @test_util.run_deprecated_v1 def testAllCorrectInt32Labels(self): with self.cached_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], @@ -248,6 +258,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): labels = constant_op.constant([[0], [1], [2]], dtype=dtypes.int32) losses.sparse_softmax_cross_entropy(labels, logits) + @test_util.run_deprecated_v1 def testAllCorrectInt64Labels(self): with self.cached_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], @@ -257,6 +268,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 0.0, 3) + @test_util.run_deprecated_v1 def testAllCorrectNonColumnLabels(self): with self.cached_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], @@ -266,6 +278,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 0.0, 3) + @test_util.run_deprecated_v1 def testAllWrongInt32Labels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -276,6 +289,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) + @test_util.run_deprecated_v1 def testAllWrongInt64Labels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -286,6 +300,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) + @test_util.run_deprecated_v1 def testAllWrongNonColumnLabels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -296,6 +311,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -305,6 +321,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(weights * 10.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) @@ -325,6 +342,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): labels, logits, constant_op.constant((weights,))) self.assertAlmostEqual(weights * 10.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPlaceholderForWeights(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], @@ -337,6 +355,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): feed_dict={weights: ((1.2,), (3.4,), (5.6,))}) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss_val, 3) + @test_util.run_deprecated_v1 def testUnknownShapePlaceholderForLogitsLabelsButScalarWeights(self): logits = array_ops.placeholder(dtypes.float32) labels = array_ops.placeholder(dtypes.int32) @@ -352,6 +371,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): }) self.assertAlmostEqual((1.0 + 1.0 + 1.0) * 10.0 / 3.0, loss_val, 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPlaceholderForLogitsLabelsAndWeights(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 3)) labels = array_ops.placeholder(dtypes.int32, shape=(None, 1)) @@ -406,6 +426,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(12.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testMeasurementSpecificWeightsRaisesException(self): with self.cached_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], @@ -444,6 +465,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() + @test_util.run_deprecated_v1 def testInconsistentWeightShapeRaisesException(self): """The weight tensor has incorrect shape.""" with self.cached_session(): @@ -458,6 +480,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() + @test_util.run_deprecated_v1 def testInconsistentLabelShapeRaisesException(self): """The label tensor has incorrect shape.""" with self.cached_session(): @@ -475,6 +498,7 @@ class SparseSoftmaxCrossEntropyLossTest(test.TestCase): class SigmoidCrossEntropyLossTest(test.TestCase): + @test_util.run_deprecated_v1 def testAllCorrectSigmoid(self): with self.cached_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], @@ -486,6 +510,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): self.assertEquals('sigmoid_cross_entropy_loss/value', loss.op.name) self.assertAlmostEqual(0.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testLossWithSingleDimPlaceholderForLogitsAndWeights1(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 1)) labels = array_ops.placeholder(dtypes.float32, shape=(None, 1)) @@ -502,6 +527,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): }) self.assertAlmostEqual(0.313, loss, 3) + @test_util.run_deprecated_v1 def testLossWithSingleDimPlaceholderForLogitsAndWeights2(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 2)) labels = array_ops.placeholder(dtypes.float32, shape=(None, 2)) @@ -518,6 +544,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): }) self.assertAlmostEqual(0.313, loss, 3) + @test_util.run_deprecated_v1 def testAllWrongSigmoid(self): with self.cached_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], @@ -529,6 +556,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): self.assertEquals('sigmoid_cross_entropy_loss/value', loss.op.name) self.assertAlmostEqual(loss.eval(), 600.0 / 9.0, 3) + @test_util.run_deprecated_v1 def testAllWrongSigmoidWithMeasurementSpecificWeights(self): with self.cached_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], @@ -541,6 +569,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): self.assertEquals('sigmoid_cross_entropy_loss/value', loss.op.name) self.assertAlmostEqual(1700.0 / 7.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testMultiCorrectSigmoid(self): logits = constant_op.constant([[100.0, -100.0, 100.0], [100.0, 100.0, -100.0], @@ -582,6 +611,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): self.assertAllClose(((0., 0., 0.), (0., 100., 100.), (100., 0., 100.)), self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testSigmoidLabelSmoothingCorrect(self): with self.cached_session(): logits = constant_op.constant([[100.0, -100.0, -100.0]]) @@ -605,6 +635,7 @@ class SigmoidCrossEntropyLossTest(test.TestCase): expected_value = (100.0 + 50.0 * label_smoothing) / 3.0 self.assertAlmostEqual(loss.eval(), expected_value, 3) + @test_util.run_deprecated_v1 def testSigmoidLabelSmoothingEqualsSoftmaxTwoLabel(self): with self.cached_session(): label_smoothing = 0.1 @@ -646,11 +677,13 @@ class LogLossTest(test.TestCase): with self.assertRaises(ValueError): losses.log_loss(self._labels, self._labels, weights=None) + @test_util.run_deprecated_v1 def testAllCorrectNoLossWeight(self): loss = losses.log_loss(self._labels, self._labels) with self.cached_session(): self.assertAlmostEqual(0.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testAllCorrectNoLossWeightWithPlaceholder(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._np_labels.shape) @@ -659,12 +692,14 @@ class LogLossTest(test.TestCase): self.assertAlmostEqual( 0.0, loss.eval(feed_dict={tf_predictions: self._np_labels}), 3) + @test_util.run_deprecated_v1 def testNonZeroLoss(self): loss = losses.log_loss(self._labels, self._predictions) with self.cached_session(): self.assertAlmostEqual(-np.sum(self._expected_losses) / 6.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.log_loss(self._labels, self._predictions, weights) @@ -672,6 +707,7 @@ class LogLossTest(test.TestCase): self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.log_loss(self._labels, self._predictions, @@ -680,6 +716,7 @@ class LogLossTest(test.TestCase): self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeightAndPlaceholder(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._np_predictions.shape) @@ -691,6 +728,7 @@ class LogLossTest(test.TestCase): self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, loss, 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeightAndPlaceholderWithRankOnly(self): tf_predictions = array_ops.placeholder(dtypes.float32, shape=[None, None]) weights = 2.3 @@ -750,6 +788,7 @@ class LogLossTest(test.TestCase): self.assertAlmostEqual(-np.sum(expected_losses) / 5.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithMeasurementSpecificWeightsWithPlaceholder(self): weights = np.array([3, 6, 5, 0, 4, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) @@ -777,6 +816,7 @@ class LogLossTest(test.TestCase): with self.cached_session(): self.assertAlmostEqual(-np.sum(expected_losses), self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithSampleSpecificWeightsMostZeroWithPlaceholder(self): weights = np.array([0, 0, 0, 0, 0, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) @@ -805,6 +845,7 @@ class HingeLossTest(test.TestCase): with self.assertRaises(ValueError): _ = losses.hinge_loss(labels, logits).eval() + @test_util.run_deprecated_v1 def testAllOutsideMargin(self): with self.cached_session(): logits = constant_op.constant([1.2, -1.4, -1.0, 2.1]) @@ -812,6 +853,7 @@ class HingeLossTest(test.TestCase): loss = losses.hinge_loss(labels, logits) self.assertAllClose(loss.eval(), 0.0, atol=1e-3) + @test_util.run_deprecated_v1 def testSomeInsideMargin(self): with self.cached_session(): logits = constant_op.constant([[-0.7], [-1.4], [1.4], [0.6]]) @@ -821,6 +863,7 @@ class HingeLossTest(test.TestCase): # the margin so they incur some (small) loss. self.assertAllClose(loss.eval(), 0.175, atol=1e-3) + @test_util.run_deprecated_v1 def testSomeMisclassified(self): with self.cached_session(): logits = constant_op.constant([[[1.2], [0.4], [-1.0], [-1.1]]]) @@ -840,6 +883,7 @@ class HuberLossTest(test.TestCase): with self.assertRaises(ValueError): _ = losses.huber_loss(labels, predictions).eval() + @test_util.run_deprecated_v1 def testAllQuadratic(self): with self.cached_session(): predictions = constant_op.constant([1.5, -1.4, -1.0, 0.0]) @@ -848,6 +892,7 @@ class HuberLossTest(test.TestCase): self.assertAllClose(loss.eval(), 0.5 * (0.25 + 0.16 + 1.0 + 0.25) / 4., atol=1e-5) + @test_util.run_deprecated_v1 def testAllLinear(self): with self.cached_session(): predictions = constant_op.constant([1.5, -1.4, -1.0, 0.0]) @@ -856,6 +901,7 @@ class HuberLossTest(test.TestCase): self.assertAllClose(loss.eval(), (1.5 + 2.4 + 1.0 + 1.5) / 4. - 0.5, atol=1e-5) + @test_util.run_deprecated_v1 def testMixedQuadraticLinear(self): with self.cached_session(): predictions = constant_op.constant([[1.5, -1.4, -1.0, 0.0], @@ -901,6 +947,7 @@ class MeanSquaredErrorTest(test.TestCase): losses.mean_squared_error( self._predictions, self._predictions, weights=None) + @test_util.run_deprecated_v1 def testScalar(self): with self.cached_session(): self.assertEqual( @@ -908,22 +955,26 @@ class MeanSquaredErrorTest(test.TestCase): losses.mean_squared_error(predictions=constant_op.constant(0), labels=constant_op.constant(0)).eval()) + @test_util.run_deprecated_v1 def testAllCorrectNoLossWeight(self): loss = losses.mean_squared_error(self._predictions, self._predictions) with self.cached_session(): self.assertAlmostEqual(0.0, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLoss(self): loss = losses.mean_squared_error(self._labels, self._predictions) with self.cached_session(): self.assertAlmostEqual(49.5, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.cached_session(): self.assertAlmostEqual(49.5 * weights, self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.mean_squared_error(self._labels, self._predictions, @@ -1017,10 +1068,12 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): self.assertAlmostEqual( expected_loss, dynamic_inputs_op.eval(feed_dict=feed_dict), places=3) + @test_util.run_deprecated_v1 def testAllCorrectNoLossWeight(self): self._test_valid_weights( self._labels, self._labels, expected_loss=0.0) + @test_util.run_deprecated_v1 def testNonZeroLoss(self): self._test_valid_weights( self._labels, self._predictions, @@ -1051,6 +1104,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): np_grad = self.evaluate(grad) self.assertFalse(np.isnan(np_grad).any()) + @test_util.run_deprecated_v1 def testNonZeroLossWithPythonScalarWeight(self): weight = 2.3 self._test_valid_weights( @@ -1058,6 +1112,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): expected_loss=weight * np.sum(self._expected_losses), weights=weight) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.mean_pairwise_squared_error( @@ -1068,10 +1123,12 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): self.assertAlmostEqual(weights * np.sum(self._expected_losses), self.evaluate(loss), 3) + @test_util.run_deprecated_v1 def testNonZeroLossWithScalarZeroWeight(self): self._test_valid_weights( self._labels, self._predictions, expected_loss=0.0, weights=0.0) + @test_util.run_deprecated_v1 def test3d(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], @@ -1083,6 +1140,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): ]) self._test_valid_weights(labels, predictions, expected_loss=137.5) + @test_util.run_deprecated_v1 def test3dWeightedScalar(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], @@ -1121,6 +1179,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): weights_placeholder: weights, }) + @test_util.run_deprecated_v1 def testInvalid3dWeighted2x0(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], @@ -1133,6 +1192,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): self._test_invalid_weights( labels, predictions, weights=np.asarray((1.2, 3.4))) + @test_util.run_deprecated_v1 def test3dWeighted2x3x3(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], @@ -1149,6 +1209,7 @@ class MeanPairwiseSquaredErrorTest(test.TestCase): expected_loss=9 * 137.5, weights=np.ones((2, 3, 3))) + @test_util.run_deprecated_v1 def testLossWithAllZeroBatchSpecificWeights(self): self._test_valid_weights( self._labels, self._predictions, expected_loss=0.0, @@ -1268,6 +1329,7 @@ class CosineDistanceLossTest(test.TestCase): with self.cached_session(): self.assertEqual(3.0 / 4.0, self.evaluate(loss)) + @test_util.run_deprecated_v1 def testMeasurementSpecificWeightsWithPlaceholderWithShape(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._labels.shape) diff --git a/tensorflow/python/kernel_tests/lrn_op_test.py b/tensorflow/python/kernel_tests/lrn_op_test.py index 7ebeb91d90e..fbe628c3944 100644 --- a/tensorflow/python/kernel_tests/lrn_op_test.py +++ b/tensorflow/python/kernel_tests/lrn_op_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -92,6 +93,7 @@ class LRNOpTest(test.TestCase): self.assertTrue(err < 1e-2) self.assertShapeEqual(expected, lrn_t) + @test_util.run_deprecated_v1 def testCompute(self): for _ in range(2): self._RunAndVerify(dtypes.float32) @@ -99,6 +101,7 @@ class LRNOpTest(test.TestCase): if not test.is_gpu_available(): self._RunAndVerify(dtypes.float16) + @test_util.run_deprecated_v1 def testGradientsZeroInput(self): with self.session(use_gpu=True): shape = [4, 4, 4, 4] @@ -147,6 +150,7 @@ class LRNOpTest(test.TestCase): else: self.assertLess(err, 1.0) + @test_util.run_deprecated_v1 def testGradients(self): for _ in range(2): self._RunAndVerifyGradients(dtypes.float32) diff --git a/tensorflow/python/kernel_tests/manip_ops_test.py b/tensorflow/python/kernel_tests/manip_ops_test.py index f71857a3cba..5700db4b950 100644 --- a/tensorflow/python/kernel_tests/manip_ops_test.py +++ b/tensorflow/python/kernel_tests/manip_ops_test.py @@ -62,6 +62,7 @@ class RollTest(test_util.TensorFlowTestCase): if np_input.dtype == np.float32: self._testGradient(np_input, shift, axis) + @test_util.run_deprecated_v1 def testIntTypes(self): for t in [np.int32, np.int64]: self._testAll(np.random.randint(-100, 100, (5)).astype(t), 3, 0) @@ -73,6 +74,7 @@ class RollTest(test_util.TensorFlowTestCase): np.random.randint(-100, 100, (4, 2, 1, 3)).astype(t), [0, 1, -2], [1, 2, 3]) + @test_util.run_deprecated_v1 def testFloatTypes(self): for t in [np.float32, np.float64]: self._testAll(np.random.rand(5).astype(t), 2, 0) @@ -80,6 +82,7 @@ class RollTest(test_util.TensorFlowTestCase): self._testAll(np.random.rand(3, 4).astype(t), [1, 2], [1, 0]) self._testAll(np.random.rand(1, 3, 4).astype(t), [1, 0, -3], [0, 1, 2]) + @test_util.run_deprecated_v1 def testComplexTypes(self): for t in [np.complex64, np.complex128]: x = np.random.rand(4, 4).astype(t) @@ -90,6 +93,7 @@ class RollTest(test_util.TensorFlowTestCase): x = np.random.rand(3, 2, 1, 1).astype(t) self._testAll(x + 1j * x, [2, 1, 1, 0], [0, 3, 1, 2]) + @test_util.run_deprecated_v1 def testNegativeAxis(self): self._testAll(np.random.randint(-100, 100, (5)).astype(np.int32), 3, -1) self._testAll(np.random.randint(-100, 100, (4, 4)).astype(np.int32), 3, -2) @@ -100,12 +104,14 @@ class RollTest(test_util.TensorFlowTestCase): manip_ops.roll(np.random.randint(-100, 100, (4, 4)).astype(np.int32), 3, -10).eval() + @test_util.run_deprecated_v1 def testInvalidInputShape(self): # The input should be 1-D or higher, checked in shape function. with self.assertRaisesRegexp( ValueError, "Shape must be at least rank 1 but is rank 0"): manip_ops.roll(7, 1, 0) + @test_util.run_deprecated_v1 def testRollInputMustVectorHigherRaises(self): # The input should be 1-D or higher, checked in kernel. tensor = array_ops.placeholder(dtype=dtypes.int32) @@ -116,12 +122,14 @@ class RollTest(test_util.TensorFlowTestCase): "input must be 1-D or higher"): manip_ops.roll(tensor, shift, axis).eval(feed_dict={tensor: 7}) + @test_util.run_deprecated_v1 def testInvalidAxisShape(self): # The axis should be a scalar or 1-D, checked in shape function. with self.assertRaisesRegexp( ValueError, "Shape must be at most rank 1 but is rank 2"): manip_ops.roll([[1, 2], [3, 4]], 1, [[0, 1]]) + @test_util.run_deprecated_v1 def testRollAxisMustBeScalarOrVectorRaises(self): # The axis should be a scalar or 1-D, checked in kernel. tensor = [[1, 2], [3, 4]] @@ -132,12 +140,14 @@ class RollTest(test_util.TensorFlowTestCase): "axis must be a scalar or a 1-D vector"): manip_ops.roll(tensor, shift, axis).eval(feed_dict={axis: [[0, 1]]}) + @test_util.run_deprecated_v1 def testInvalidShiftShape(self): # The shift should be a scalar or 1-D, checked in shape function. with self.assertRaisesRegexp( ValueError, "Shape must be at most rank 1 but is rank 2"): manip_ops.roll([[1, 2], [3, 4]], [[0, 1]], 1) + @test_util.run_deprecated_v1 def testRollShiftMustBeScalarOrVectorRaises(self): # The shift should be a scalar or 1-D, checked in kernel. tensor = [[1, 2], [3, 4]] @@ -148,11 +158,13 @@ class RollTest(test_util.TensorFlowTestCase): "shift must be a scalar or a 1-D vector"): manip_ops.roll(tensor, shift, axis).eval(feed_dict={shift: [[0, 1]]}) + @test_util.run_deprecated_v1 def testInvalidShiftAndAxisNotEqualShape(self): # The shift and axis must be same size, checked in shape function. with self.assertRaisesRegexp(ValueError, "both shapes must be equal"): manip_ops.roll([[1, 2], [3, 4]], [1], [0, 1]) + @test_util.run_deprecated_v1 def testRollShiftAndAxisMustBeSameSizeRaises(self): # The shift and axis must be same size, checked in kernel. tensor = [[1, 2], [3, 4]] diff --git a/tensorflow/python/kernel_tests/map_stage_op_test.py b/tensorflow/python/kernel_tests/map_stage_op_test.py index d503f3d7c9f..dd16fad6904 100644 --- a/tensorflow/python/kernel_tests/map_stage_op_test.py +++ b/tensorflow/python/kernel_tests/map_stage_op_test.py @@ -19,6 +19,7 @@ from __future__ import print_function from tensorflow.python.framework import errors from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import math_ops @@ -29,6 +30,7 @@ TIMEOUT = 1 class MapStageTest(test.TestCase): + @test_util.run_deprecated_v1 def testSimple(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -50,6 +52,7 @@ class MapStageTest(test.TestCase): _, yval = sess.run([stage, y], feed_dict={x: i, pi: i + 1, gi: i}) self.assertAllClose(4 * (i - 1) * (i - 1) * 128, yval, rtol=1e-4) + @test_util.run_deprecated_v1 def testMultiple(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -72,6 +75,7 @@ class MapStageTest(test.TestCase): self.assertAllClose( 4 * (i - 1) * (i - 1) * (i - 1) * 128, yval, rtol=1e-4) + @test_util.run_deprecated_v1 def testDictionary(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -121,6 +125,7 @@ class MapStageTest(test.TestCase): G.finalize() + @test_util.run_deprecated_v1 def testPeek(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -150,6 +155,7 @@ class MapStageTest(test.TestCase): self.assertTrue(sess.run(size) == 10) + @test_util.run_deprecated_v1 def testSizeAndClear(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -176,6 +182,7 @@ class MapStageTest(test.TestCase): sess.run(clear) self.assertEqual(sess.run(size), 0) + @test_util.run_deprecated_v1 def testCapacity(self): capacity = 3 @@ -239,6 +246,7 @@ class MapStageTest(test.TestCase): self.assertTrue(sess.run(size) == 0) + @test_util.run_deprecated_v1 def testMemoryLimit(self): memory_limit = 512 * 1024 # 512K chunk = 200 * 1024 # 256K @@ -303,6 +311,7 @@ class MapStageTest(test.TestCase): self.assertTrue(sess.run(size) == 0) + @test_util.run_deprecated_v1 def testOrdering(self): import six import random @@ -341,6 +350,7 @@ class MapStageTest(test.TestCase): self.assertTrue(sess.run(size) == 0) + @test_util.run_deprecated_v1 def testPartialDictInsert(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -400,6 +410,7 @@ class MapStageTest(test.TestCase): 'v': 3 }]) + @test_util.run_deprecated_v1 def testPartialIndexInsert(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -443,6 +454,7 @@ class MapStageTest(test.TestCase): # We can now obtain tuple associated with key 1 self.assertTrue(sess.run([key, ret], feed_dict={gi: 1}) == [1, [1, 3, 2]]) + @test_util.run_deprecated_v1 def testPartialDictGetsAndPeeks(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -540,6 +552,7 @@ class MapStageTest(test.TestCase): # Nothing is left self.assertTrue(sess.run([size, isize]) == [0, 0]) + @test_util.run_deprecated_v1 def testPartialIndexGets(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): diff --git a/tensorflow/python/kernel_tests/matmul_op_test.py b/tensorflow/python/kernel_tests/matmul_op_test.py index 6167e01864d..983f463f5e3 100644 --- a/tensorflow/python/kernel_tests/matmul_op_test.py +++ b/tensorflow/python/kernel_tests/matmul_op_test.py @@ -194,6 +194,7 @@ except AttributeError: class MatMulInfixOperatorTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testMismatchedShape(self): with self.assertRaisesWithPredicateMatch(ValueError, lambda e: "Shape must" in str(e)): @@ -201,6 +202,7 @@ class MatMulInfixOperatorTest(test_lib.TestCase): ops.convert_to_tensor([10.0, 20.0, 30.0]), ops.convert_to_tensor([[40.0, 50.0], [60.0, 70.0]])) + @test_util.run_deprecated_v1 def testMismatchedDimensions(self): with self.assertRaisesWithPredicateMatch( ValueError, lambda e: "Dimensions must" in str(e)): @@ -208,12 +210,14 @@ class MatMulInfixOperatorTest(test_lib.TestCase): ops.convert_to_tensor([[10.0, 20.0, 30.0]]), ops.convert_to_tensor([[40.0, 50.0], [60.0, 70.0]])) + @test_util.run_deprecated_v1 def testInfixMatmulIsTfMatmul(self): a = ops.convert_to_tensor([[10.0, 20.0, 30.0]]) b = ops.convert_to_tensor([[40.0, 50.0], [60.0, 70.0], [80.0, 90.0]]) c = infix_matmul(a, b) self.assertEqual(c.op.type, "MatMul") + @test_util.run_deprecated_v1 def testInfixMatmulDoesDotProduct(self): a = ops.convert_to_tensor([[10.0, 20.0, 30.0]]) b = ops.convert_to_tensor([[40.0, 50.0], [60.0, 70.0], [80.0, 90.0]]) diff --git a/tensorflow/python/kernel_tests/matrix_exponential_op_test.py b/tensorflow/python/kernel_tests/matrix_exponential_op_test.py index 83f4216e4d0..372b6dc17f4 100644 --- a/tensorflow/python/kernel_tests/matrix_exponential_op_test.py +++ b/tensorflow/python/kernel_tests/matrix_exponential_op_test.py @@ -122,12 +122,14 @@ class ExponentialOpTest(test.TestCase): # Complex batch self._verifyExponentialComplex(self._makeBatch(matrix1, matrix2)) + @test_util.run_deprecated_v1 def testNonSquareMatrix(self): # When the exponential of a non-square matrix is attempted we should return # an error with self.assertRaises(ValueError): linalg_impl.matrix_exponential(np.array([[1., 2., 3.], [3., 4., 5.]])) + @test_util.run_deprecated_v1 def testWrongDimensions(self): # The input to the exponential should be at least a 2-dimensional tensor. tensor3 = constant_op.constant([1., 2.]) @@ -138,6 +140,7 @@ class ExponentialOpTest(test.TestCase): self._verifyExponentialReal(np.empty([0, 2, 2])) self._verifyExponentialReal(np.empty([2, 0, 0])) + @test_util.run_deprecated_v1 def testDynamic(self): with self.session(use_gpu=True) as sess: inp = array_ops.placeholder(ops.dtypes.float32) @@ -145,6 +148,7 @@ class ExponentialOpTest(test.TestCase): matrix = np.array([[1., 2.], [3., 4.]]) sess.run(expm, feed_dict={inp: matrix}) + @test_util.run_deprecated_v1 def testConcurrentExecutesWithoutError(self): with self.session(use_gpu=True) as sess: matrix1 = random_ops.random_normal([5, 5], seed=42) diff --git a/tensorflow/python/kernel_tests/matrix_solve_ls_op_test.py b/tensorflow/python/kernel_tests/matrix_solve_ls_op_test.py index 13a7df7f95d..a6f5da9d3d7 100644 --- a/tensorflow/python/kernel_tests/matrix_solve_ls_op_test.py +++ b/tensorflow/python/kernel_tests/matrix_solve_ls_op_test.py @@ -24,6 +24,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import linalg_ops @@ -133,6 +134,7 @@ class MatrixSolveLsOpTest(test_lib.TestCase): self.assertEqual(np_ans.shape, tf_ans_val.shape) self.assertAllClose(np_ans, tf_ans_val, atol=2 * tol, rtol=2 * tol) + @test_util.run_deprecated_v1 def testWrongDimensions(self): # The matrix and right-hand sides should have the same number of rows. with self.session(use_gpu=True): @@ -141,6 +143,7 @@ class MatrixSolveLsOpTest(test_lib.TestCase): with self.assertRaises(ValueError): linalg_ops.matrix_solve_ls(matrix, rhs) + @test_util.run_deprecated_v1 def testEmpty(self): full = np.array([[1., 2.], [3., 4.], [5., 6.]]) empty0 = np.empty([3, 0]) @@ -156,6 +159,7 @@ class MatrixSolveLsOpTest(test_lib.TestCase): tf_ans = linalg_ops.matrix_solve_ls(empty1, empty1, fast=fast).eval() self.assertEqual(tf_ans.shape, (2, 2)) + @test_util.run_deprecated_v1 def testBatchResultSize(self): # 3x3x3 matrices, 3x3x1 right-hand sides. matrix = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9.] * 3).reshape(3, 3, 3) diff --git a/tensorflow/python/kernel_tests/matrix_solve_op_test.py b/tensorflow/python/kernel_tests/matrix_solve_op_test.py index 80badee8962..db7c4802f69 100644 --- a/tensorflow/python/kernel_tests/matrix_solve_op_test.py +++ b/tensorflow/python/kernel_tests/matrix_solve_op_test.py @@ -24,6 +24,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import linalg_ops @@ -75,6 +76,7 @@ class MatrixSolveOpTest(test.TestCase): [m, n])) return matrix + @test_util.run_deprecated_v1 def testSolve(self): for n in 1, 2, 4, 9: matrix = self._generateMatrix(n, n) @@ -82,6 +84,7 @@ class MatrixSolveOpTest(test.TestCase): rhs = self._generateMatrix(n, nrhs) self._verifySolve(matrix, rhs) + @test_util.run_deprecated_v1 def testSolveBatch(self): for n in 2, 5: matrix = self._generateMatrix(n, n) @@ -90,6 +93,7 @@ class MatrixSolveOpTest(test.TestCase): for batch_dims in [[2], [2, 2], [7, 4]]: self._verifySolve(matrix, rhs, batch_dims=batch_dims) + @test_util.run_deprecated_v1 def testNonSquareMatrix(self): # When the solve of a non-square matrix is attempted we should return # an error @@ -98,6 +102,7 @@ class MatrixSolveOpTest(test.TestCase): matrix = constant_op.constant([[1., 2., 3.], [3., 4., 5.]]) linalg_ops.matrix_solve(matrix, matrix) + @test_util.run_deprecated_v1 def testWrongDimensions(self): # The matrix and right-hand sides should have the same number of rows. with self.session(use_gpu=True): @@ -115,6 +120,7 @@ class MatrixSolveOpTest(test.TestCase): [0., -1., 1.]]) linalg_ops.matrix_solve(matrix, matrix).eval() + @test_util.run_deprecated_v1 def testConcurrent(self): with self.session(use_gpu=True) as sess: all_ops = [] diff --git a/tensorflow/python/kernel_tests/matrix_triangular_solve_op_test.py b/tensorflow/python/kernel_tests/matrix_triangular_solve_op_test.py index 317b8f8716e..dde83f12f3c 100644 --- a/tensorflow/python/kernel_tests/matrix_triangular_solve_op_test.py +++ b/tensorflow/python/kernel_tests/matrix_triangular_solve_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.platform import test @@ -93,6 +94,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): self.assertEqual(np_ans.shape, tf_val.shape) self.assertAllClose(np_ans, tf_val) + @test_util.run_deprecated_v1 def testSolve(self): # 1x1 matrix, single rhs. matrix = np.array([[0.1]]) @@ -106,6 +108,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): rhs1 = np.array([[1., 0., 1.], [0., 1., 1.]]) self._verifySolveAllWaysReal(matrix, rhs1) + @test_util.run_deprecated_v1 def testSolveComplex(self): # 1x1 matrix, single rhs. matrix = np.array([[0.1 + 1j * 0.1]]) @@ -122,6 +125,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): rhs1 += 1j * rhs1 self._verifySolveAllWaysComplex(matrix, rhs1) + @test_util.run_deprecated_v1 def testSolveBatch(self): matrix = np.array([[1., 2.], [3., 4.]]) rhs = np.array([[1., 0., 1.], [0., 1., 1.]]) @@ -130,6 +134,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): # Batch of 3x2x2x2 matrices, 3x2x2x3 right-hand sides. self._verifySolveAllWaysReal(matrix, rhs, batch_dims=[3, 2]) + @test_util.run_deprecated_v1 def testSolveBatchComplex(self): matrix = np.array([[1., 2.], [3., 4.]]).astype(np.complex64) matrix += 1j * matrix @@ -140,6 +145,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): # Batch of 3x2x2x2 matrices, 3x2x2x3 right-hand sides. self._verifySolveAllWaysComplex(matrix, rhs, batch_dims=[3, 2]) + @test_util.run_deprecated_v1 def testNonSquareMatrix(self): # A non-square matrix should cause an error. matrix = np.array([[1., 2., 3.], [3., 4., 5.]]) @@ -149,6 +155,7 @@ class MatrixTriangularSolveOpTest(test.TestCase): with self.assertRaises(ValueError): self._verifySolve(matrix, matrix, batch_dims=[2, 3]) + @test_util.run_deprecated_v1 def testWrongDimensions(self): # The matrix should have the same number of rows as the # right-hand sides. diff --git a/tensorflow/python/kernel_tests/metrics_test.py b/tensorflow/python/kernel_tests/metrics_test.py index eb5f99582ca..64dd5914552 100644 --- a/tensorflow/python/kernel_tests/metrics_test.py +++ b/tensorflow/python/kernel_tests/metrics_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import math_ops @@ -175,22 +176,26 @@ class MeanTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean(array_ops.ones([4, 3])) _assert_metric_variables(self, ('mean/count:0', 'mean/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean( array_ops.ones([4, 3]), metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean( array_ops.ones([4, 3]), updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session() as sess: values_queue = data_flow_ops.FIFOQueue( @@ -208,6 +213,7 @@ class MeanTest(test.TestCase): self.evaluate(update_op) self.assertAlmostEqual(1.65, self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testUpdateOpsReturnsCurrentValue(self): with self.cached_session() as sess: values_queue = data_flow_ops.FIFOQueue( @@ -229,6 +235,7 @@ class MeanTest(test.TestCase): self.assertAlmostEqual(1.65, self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testUnweighted(self): values = _test_values((3, 2, 4, 1)) mean_results = ( @@ -271,37 +278,44 @@ class MeanTest(test.TestCase): self.assertAlmostEqual(expected, update_op.eval(), places=5) self.assertAlmostEqual(expected, mean.eval(), places=5) + @test_util.run_deprecated_v1 def test1x1x1Weighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray((5,)).reshape((1, 1, 1))) + @test_util.run_deprecated_v1 def test1x1xNWeighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray((5, 7, 11, 3)).reshape((1, 1, 4))) + @test_util.run_deprecated_v1 def test1xNx1Weighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray((5, 11)).reshape((1, 2, 1))) + @test_util.run_deprecated_v1 def test1xNxNWeighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray((5, 7, 11, 3, 2, 13, 7, 5)).reshape((1, 2, 4))) + @test_util.run_deprecated_v1 def testNx1x1Weighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray((5, 7, 11)).reshape((3, 1, 1))) + @test_util.run_deprecated_v1 def testNx1xNWeighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), weights=np.asarray(( 5, 7, 11, 3, 2, 12, 7, 5, 2, 17, 11, 3)).reshape((3, 1, 4))) + @test_util.run_deprecated_v1 def testNxNxNWeighted(self): self._test_3d_weighted( _test_values((3, 2, 4)), @@ -309,6 +323,7 @@ class MeanTest(test.TestCase): 5, 7, 11, 3, 2, 12, 7, 5, 2, 17, 11, 3, 2, 17, 11, 3, 5, 7, 11, 3, 2, 12, 7, 5)).reshape((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidWeights(self): values_placeholder = array_ops.placeholder(dtype=dtypes_lib.float32) values = _test_values((3, 2, 4, 1)) @@ -341,23 +356,27 @@ class MeanTensorTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_tensor(array_ops.ones([4, 3])) _assert_metric_variables(self, ('mean/total_tensor:0', 'mean/count_tensor:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean_tensor( array_ops.ones([4, 3]), metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_tensor( array_ops.ones([4, 3]), updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session() as sess: values_queue = data_flow_ops.FIFOQueue( @@ -375,6 +394,7 @@ class MeanTensorTest(test.TestCase): self.evaluate(update_op) self.assertAllClose([[-0.9 / 4., 3.525]], self.evaluate(mean)) + @test_util.run_deprecated_v1 def testMultiDimensional(self): with self.cached_session() as sess: values_queue = data_flow_ops.FIFOQueue( @@ -397,6 +417,7 @@ class MeanTensorTest(test.TestCase): self.assertAllClose([[[1, 2], [1, 2]], [[2, 3], [5, 6]]], self.evaluate(mean)) + @test_util.run_deprecated_v1 def testUpdateOpsReturnsCurrentValue(self): with self.cached_session() as sess: values_queue = data_flow_ops.FIFOQueue( @@ -418,6 +439,7 @@ class MeanTensorTest(test.TestCase): self.assertAllClose([[-0.9 / 4., 3.525]], self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testBinaryWeighted1d(self): with self.cached_session() as sess: # Create the queue that populates the values. @@ -445,6 +467,7 @@ class MeanTensorTest(test.TestCase): self.evaluate(update_op) self.assertAllClose([[3.25, 0.5]], self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testWeighted1d(self): with self.cached_session() as sess: # Create the queue that populates the values. @@ -472,6 +495,7 @@ class MeanTensorTest(test.TestCase): self.evaluate(update_op) self.assertAllClose([[0.8, 3.52]], self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testWeighted2d_1(self): with self.cached_session() as sess: # Create the queue that populates the values. @@ -499,6 +523,7 @@ class MeanTensorTest(test.TestCase): self.evaluate(update_op) self.assertAllClose([[-2.1, 0.5]], self.evaluate(mean), 5) + @test_util.run_deprecated_v1 def testWeighted2d_2(self): with self.cached_session() as sess: # Create the queue that populates the values. @@ -532,6 +557,7 @@ class AccuracyTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.accuracy( predictions=array_ops.ones((10, 1)), @@ -540,6 +566,7 @@ class AccuracyTest(test.TestCase): _assert_metric_variables(self, ('my_accuracy/count:0', 'my_accuracy/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.accuracy( @@ -548,6 +575,7 @@ class AccuracyTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.accuracy( @@ -556,12 +584,14 @@ class AccuracyTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testPredictionsAndLabelsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones((10, 3)) labels = array_ops.ones((10, 4)) with self.assertRaises(ValueError): metrics.accuracy(labels, predictions) + @test_util.run_deprecated_v1 def testPredictionsAndWeightsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones((10, 3)) labels = array_ops.ones((10, 3)) @@ -569,6 +599,7 @@ class AccuracyTest(test.TestCase): with self.assertRaises(ValueError): metrics.accuracy(labels, predictions, weights) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=3, dtype=dtypes_lib.int64, seed=1) @@ -588,6 +619,7 @@ class AccuracyTest(test.TestCase): for _ in range(10): self.assertEqual(initial_accuracy, accuracy.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdates(self): with self.cached_session() as sess: # Create the queue that populates the predictions. @@ -616,6 +648,7 @@ class AccuracyTest(test.TestCase): self.assertEqual(0.5, self.evaluate(update_op)) self.assertEqual(0.5, accuracy.eval()) + @test_util.run_deprecated_v1 def testEffectivelyEquivalentSizes(self): predictions = array_ops.ones((40, 1)) labels = array_ops.ones((40,)) @@ -626,6 +659,7 @@ class AccuracyTest(test.TestCase): self.assertEqual(1.0, update_op.eval()) self.assertEqual(1.0, accuracy.eval()) + @test_util.run_deprecated_v1 def testEffectivelyEquivalentSizesWithScalarWeight(self): predictions = array_ops.ones((40, 1)) labels = array_ops.ones((40,)) @@ -636,6 +670,7 @@ class AccuracyTest(test.TestCase): self.assertEqual(1.0, update_op.eval()) self.assertEqual(1.0, accuracy.eval()) + @test_util.run_deprecated_v1 def testEffectivelyEquivalentSizesWithStaticShapedWeight(self): predictions = ops.convert_to_tensor([1, 1, 1]) # shape 3, labels = array_ops.expand_dims(ops.convert_to_tensor([1, 0, 0]), @@ -653,6 +688,7 @@ class AccuracyTest(test.TestCase): self.assertGreater(update_op.eval(), .95) self.assertGreater(accuracy.eval(), .95) + @test_util.run_deprecated_v1 def testEffectivelyEquivalentSizesWithDynamicallyShapedWeight(self): predictions = ops.convert_to_tensor([1, 1, 1]) # shape 3, labels = array_ops.expand_dims(ops.convert_to_tensor([1, 0, 0]), @@ -674,6 +710,7 @@ class AccuracyTest(test.TestCase): self.assertGreater(update_op.eval(feed_dict=feed_dict), .95) self.assertGreater(accuracy.eval(feed_dict=feed_dict), .95) + @test_util.run_deprecated_v1 def testMultipleUpdatesWithWeightedValues(self): with self.cached_session() as sess: # Create the queue that populates the predictions. @@ -718,12 +755,14 @@ class PrecisionTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.precision( predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) _assert_metric_variables(self, ('precision/false_positives/count:0', 'precision/true_positives/count:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.precision( @@ -732,6 +771,7 @@ class PrecisionTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.precision( @@ -740,6 +780,7 @@ class PrecisionTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.int64, seed=1) @@ -759,6 +800,7 @@ class PrecisionTest(test.TestCase): for _ in range(10): self.assertEqual(initial_precision, precision.eval()) + @test_util.run_deprecated_v1 def testAllCorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -771,6 +813,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual(1, self.evaluate(update_op)) self.assertAlmostEqual(1, precision.eval()) + @test_util.run_deprecated_v1 def testSomeCorrect_multipleInputDtypes(self): for dtype in (dtypes_lib.bool, dtypes_lib.int32, dtypes_lib.float32): predictions = math_ops.cast( @@ -784,6 +827,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual(0.5, update_op.eval()) self.assertAlmostEqual(0.5, precision.eval()) + @test_util.run_deprecated_v1 def testWeighted1d(self): predictions = constant_op.constant([[1, 0, 1, 0], [1, 0, 1, 0]]) labels = constant_op.constant([[0, 1, 1, 0], [1, 0, 0, 1]]) @@ -798,6 +842,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual(expected_precision, update_op.eval()) self.assertAlmostEqual(expected_precision, precision.eval()) + @test_util.run_deprecated_v1 def testWeightedScalar_placeholders(self): predictions = array_ops.placeholder(dtype=dtypes_lib.float32) labels = array_ops.placeholder(dtype=dtypes_lib.float32) @@ -817,6 +862,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual( expected_precision, precision.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testWeighted1d_placeholders(self): predictions = array_ops.placeholder(dtype=dtypes_lib.float32) labels = array_ops.placeholder(dtype=dtypes_lib.float32) @@ -837,6 +883,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual( expected_precision, precision.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testWeighted2d(self): predictions = constant_op.constant([[1, 0, 1, 0], [1, 0, 1, 0]]) labels = constant_op.constant([[0, 1, 1, 0], [1, 0, 0, 1]]) @@ -853,6 +900,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual(expected_precision, update_op.eval()) self.assertAlmostEqual(expected_precision, precision.eval()) + @test_util.run_deprecated_v1 def testWeighted2d_placeholders(self): predictions = array_ops.placeholder(dtype=dtypes_lib.float32) labels = array_ops.placeholder(dtype=dtypes_lib.float32) @@ -875,6 +923,7 @@ class PrecisionTest(test.TestCase): self.assertAlmostEqual( expected_precision, precision.eval(feed_dict=feed_dict)) + @test_util.run_deprecated_v1 def testAllIncorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -887,6 +936,7 @@ class PrecisionTest(test.TestCase): self.evaluate(update_op) self.assertAlmostEqual(0, precision.eval()) + @test_util.run_deprecated_v1 def testZeroTrueAndFalsePositivesGivesZeroPrecision(self): predictions = constant_op.constant([0, 0, 0, 0]) labels = constant_op.constant([0, 0, 0, 0]) @@ -904,6 +954,7 @@ class RecallTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.recall( predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) @@ -911,6 +962,7 @@ class RecallTest(test.TestCase): self, ('recall/false_negatives/count:0', 'recall/true_positives/count:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.recall( @@ -919,6 +971,7 @@ class RecallTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.recall( @@ -927,6 +980,7 @@ class RecallTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.int64, seed=1) @@ -946,6 +1000,7 @@ class RecallTest(test.TestCase): for _ in range(10): self.assertEqual(initial_recall, recall.eval()) + @test_util.run_deprecated_v1 def testAllCorrect(self): np_inputs = np.random.randint(0, 2, size=(100, 1)) @@ -958,6 +1013,7 @@ class RecallTest(test.TestCase): self.evaluate(update_op) self.assertEqual(1, recall.eval()) + @test_util.run_deprecated_v1 def testSomeCorrect_multipleInputDtypes(self): for dtype in (dtypes_lib.bool, dtypes_lib.int32, dtypes_lib.float32): predictions = math_ops.cast( @@ -971,6 +1027,7 @@ class RecallTest(test.TestCase): self.assertAlmostEqual(0.5, update_op.eval()) self.assertAlmostEqual(0.5, recall.eval()) + @test_util.run_deprecated_v1 def testWeighted1d(self): predictions = constant_op.constant([[1, 0, 1, 0], [0, 1, 0, 1]]) labels = constant_op.constant([[0, 1, 1, 0], [1, 0, 0, 1]]) @@ -985,6 +1042,7 @@ class RecallTest(test.TestCase): self.assertAlmostEqual(expected_precision, update_op.eval()) self.assertAlmostEqual(expected_precision, recall.eval()) + @test_util.run_deprecated_v1 def testWeighted2d(self): predictions = constant_op.constant([[1, 0, 1, 0], [0, 1, 0, 1]]) labels = constant_op.constant([[0, 1, 1, 0], [1, 0, 0, 1]]) @@ -999,6 +1057,7 @@ class RecallTest(test.TestCase): self.assertAlmostEqual(expected_precision, update_op.eval()) self.assertAlmostEqual(expected_precision, recall.eval()) + @test_util.run_deprecated_v1 def testAllIncorrect(self): np_inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1011,6 +1070,7 @@ class RecallTest(test.TestCase): self.evaluate(update_op) self.assertEqual(0, recall.eval()) + @test_util.run_deprecated_v1 def testZeroTruePositivesAndFalseNegativesGivesZeroRecall(self): predictions = array_ops.zeros((1, 4)) labels = array_ops.zeros((1, 4)) @@ -1028,6 +1088,7 @@ class AUCTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.auc(predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) @@ -1035,6 +1096,7 @@ class AUCTest(test.TestCase): ('auc/true_positives:0', 'auc/false_negatives:0', 'auc/false_positives:0', 'auc/true_negatives:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.auc(predictions=array_ops.ones((10, 1)), @@ -1042,6 +1104,7 @@ class AUCTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.auc(predictions=array_ops.ones((10, 1)), @@ -1049,6 +1112,7 @@ class AUCTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.float32, seed=1) @@ -1068,6 +1132,7 @@ class AUCTest(test.TestCase): for _ in range(10): self.assertAlmostEqual(initial_auc, auc.eval(), 5) + @test_util.run_deprecated_v1 def testAllCorrect(self): self.allCorrectAsExpected('ROC') @@ -1084,6 +1149,7 @@ class AUCTest(test.TestCase): self.assertEqual(1, auc.eval()) + @test_util.run_deprecated_v1 def testSomeCorrect_multipleLabelDtypes(self): with self.cached_session() as sess: for label_dtype in ( @@ -1099,6 +1165,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0.5, auc.eval()) + @test_util.run_deprecated_v1 def testWeighted1d(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1112,6 +1179,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0.5, auc.eval(), 5) + @test_util.run_deprecated_v1 def testWeighted2d(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1127,6 +1195,7 @@ class AUCTest(test.TestCase): # Regarding the AUC-PR tests: note that the preferred method when # calculating AUC-PR is summation_method='careful_interpolation'. + @test_util.run_deprecated_v1 def testCorrectAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1141,6 +1210,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(expected, self.evaluate(update_op), delta=1e-3) self.assertAlmostEqual(expected, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testCorrectAnotherAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1157,6 +1227,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(expected, self.evaluate(update_op), delta=1e-3) self.assertAlmostEqual(expected, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testThirdCorrectAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1173,6 +1244,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(expected, self.evaluate(update_op), delta=1e-3) self.assertAlmostEqual(expected, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testIncorrectAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1186,6 +1258,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0.79166, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testAnotherIncorrectAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1201,6 +1274,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0.610317, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testThirdIncorrectAUCPRSpecialCase(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1216,6 +1290,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0.90277, auc.eval(), delta=1e-3) + @test_util.run_deprecated_v1 def testAllIncorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1229,6 +1304,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(0, auc.eval()) + @test_util.run_deprecated_v1 def testZeroTruePositivesAndFalseNegativesGivesOneAUC(self): with self.cached_session() as sess: predictions = array_ops.zeros([4], dtype=dtypes_lib.float32) @@ -1240,6 +1316,7 @@ class AUCTest(test.TestCase): self.assertAlmostEqual(1, auc.eval(), 6) + @test_util.run_deprecated_v1 def testRecallOneAndPrecisionOneGivesOnePRAUC(self): with self.cached_session() as sess: predictions = array_ops.ones([4], dtype=dtypes_lib.float32) @@ -1278,6 +1355,7 @@ class AUCTest(test.TestCase): tp = np.cumsum(sorted_weights * is_positive) / num_positives return np.sum((sorted_weights * tp)[~is_positive]) / num_negatives + @test_util.run_deprecated_v1 def testWithMultipleUpdates(self): num_samples = 1000 batch_size = 10 @@ -1334,6 +1412,7 @@ class SpecificityAtSensitivityTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.specificity_at_sensitivity( predictions=array_ops.ones((10, 1)), @@ -1345,6 +1424,7 @@ class SpecificityAtSensitivityTest(test.TestCase): 'specificity_at_sensitivity/false_positives:0', 'specificity_at_sensitivity/true_negatives:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.specificity_at_sensitivity( @@ -1354,6 +1434,7 @@ class SpecificityAtSensitivityTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.specificity_at_sensitivity( @@ -1363,6 +1444,7 @@ class SpecificityAtSensitivityTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.float32, seed=1) @@ -1383,6 +1465,7 @@ class SpecificityAtSensitivityTest(test.TestCase): for _ in range(10): self.assertAlmostEqual(initial_specificity, specificity.eval(), 5) + @test_util.run_deprecated_v1 def testAllCorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1396,6 +1479,7 @@ class SpecificityAtSensitivityTest(test.TestCase): self.assertEqual(1, self.evaluate(update_op)) self.assertEqual(1, specificity.eval()) + @test_util.run_deprecated_v1 def testSomeCorrectHighSensitivity(self): predictions_values = [0.1, 0.2, 0.4, 0.3, 0.0, 0.1, 0.45, 0.5, 0.8, 0.9] labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] @@ -1411,6 +1495,7 @@ class SpecificityAtSensitivityTest(test.TestCase): self.assertAlmostEqual(1.0, self.evaluate(update_op)) self.assertAlmostEqual(1.0, specificity.eval()) + @test_util.run_deprecated_v1 def testSomeCorrectLowSensitivity(self): predictions_values = [0.1, 0.2, 0.4, 0.3, 0.0, 0.1, 0.2, 0.2, 0.26, 0.26] labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] @@ -1427,6 +1512,7 @@ class SpecificityAtSensitivityTest(test.TestCase): self.assertAlmostEqual(0.6, self.evaluate(update_op)) self.assertAlmostEqual(0.6, specificity.eval()) + @test_util.run_deprecated_v1 def testWeighted1d_multipleLabelDtypes(self): for label_dtype in (dtypes_lib.bool, dtypes_lib.int32, dtypes_lib.float32): predictions_values = [0.1, 0.2, 0.4, 0.3, 0.0, 0.1, 0.2, 0.2, 0.26, 0.26] @@ -1446,6 +1532,7 @@ class SpecificityAtSensitivityTest(test.TestCase): self.assertAlmostEqual(0.6, self.evaluate(update_op)) self.assertAlmostEqual(0.6, specificity.eval()) + @test_util.run_deprecated_v1 def testWeighted2d(self): predictions_values = [0.1, 0.2, 0.4, 0.3, 0.0, 0.1, 0.2, 0.2, 0.26, 0.26] labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] @@ -1471,6 +1558,7 @@ class SensitivityAtSpecificityTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.sensitivity_at_specificity( predictions=array_ops.ones((10, 1)), @@ -1482,6 +1570,7 @@ class SensitivityAtSpecificityTest(test.TestCase): 'sensitivity_at_specificity/false_positives:0', 'sensitivity_at_specificity/true_negatives:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.sensitivity_at_specificity( @@ -1491,6 +1580,7 @@ class SensitivityAtSpecificityTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.sensitivity_at_specificity( @@ -1500,6 +1590,7 @@ class SensitivityAtSpecificityTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.float32, seed=1) @@ -1520,6 +1611,7 @@ class SensitivityAtSpecificityTest(test.TestCase): for _ in range(10): self.assertAlmostEqual(initial_sensitivity, sensitivity.eval(), 5) + @test_util.run_deprecated_v1 def testAllCorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1533,6 +1625,7 @@ class SensitivityAtSpecificityTest(test.TestCase): self.assertEqual(1, self.evaluate(update_op)) self.assertEqual(1, specificity.eval()) + @test_util.run_deprecated_v1 def testSomeCorrectHighSpecificity(self): predictions_values = [0.0, 0.1, 0.2, 0.3, 0.4, 0.1, 0.45, 0.5, 0.8, 0.9] labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] @@ -1548,6 +1641,7 @@ class SensitivityAtSpecificityTest(test.TestCase): self.assertAlmostEqual(0.8, self.evaluate(update_op)) self.assertAlmostEqual(0.8, specificity.eval()) + @test_util.run_deprecated_v1 def testSomeCorrectLowSpecificity(self): predictions_values = [0.0, 0.1, 0.2, 0.3, 0.4, 0.01, 0.02, 0.25, 0.26, 0.26] labels_values = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] @@ -1563,6 +1657,7 @@ class SensitivityAtSpecificityTest(test.TestCase): self.assertAlmostEqual(0.6, self.evaluate(update_op)) self.assertAlmostEqual(0.6, specificity.eval()) + @test_util.run_deprecated_v1 def testWeighted_multipleLabelDtypes(self): for label_dtype in (dtypes_lib.bool, dtypes_lib.int32, dtypes_lib.float32): predictions_values = [ @@ -1590,6 +1685,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.precision_at_thresholds( predictions=array_ops.ones((10, 1)), @@ -1600,6 +1696,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): 'precision_at_thresholds/false_positives:0', )) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' prec, _ = metrics.precision_at_thresholds( @@ -1614,6 +1711,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [prec, rec]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, precision_op = metrics.precision_at_thresholds( @@ -1629,6 +1727,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertListEqual( ops.get_collection(my_collection_name), [precision_op, recall_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_uniform( (10, 3), maxval=1, dtype=dtypes_lib.float32, seed=1) @@ -1652,6 +1751,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAllClose(initial_rec, rec.eval()) # TODO(nsilberman): fix tests (passing but incorrect). + @test_util.run_deprecated_v1 def testAllCorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1670,6 +1770,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertEqual(1, prec.eval()) self.assertEqual(1, rec.eval()) + @test_util.run_deprecated_v1 def testSomeCorrect_multipleLabelDtypes(self): with self.cached_session() as sess: for label_dtype in ( @@ -1690,6 +1791,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(0.5, prec.eval()) self.assertAlmostEqual(0.5, rec.eval()) + @test_util.run_deprecated_v1 def testAllIncorrect(self): inputs = np.random.randint(0, 2, size=(100, 1)) @@ -1708,6 +1810,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(0, prec.eval()) self.assertAlmostEqual(0, rec.eval()) + @test_util.run_deprecated_v1 def testWeights1d(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1738,6 +1841,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(1.0, rec_low.eval(), places=5) self.assertAlmostEqual(0.0, rec_high.eval(), places=5) + @test_util.run_deprecated_v1 def testWeights2d(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1768,6 +1872,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(1.0, rec_low.eval(), places=5) self.assertAlmostEqual(0.0, rec_high.eval(), places=5) + @test_util.run_deprecated_v1 def testExtremeThresholds(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -1792,6 +1897,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(1.0, rec_low.eval()) self.assertAlmostEqual(0.0, rec_high.eval()) + @test_util.run_deprecated_v1 def testZeroLabelsPredictions(self): with self.cached_session() as sess: predictions = array_ops.zeros([4], dtype=dtypes_lib.float32) @@ -1808,6 +1914,7 @@ class PrecisionRecallThresholdsTest(test.TestCase): self.assertAlmostEqual(0, prec.eval(), 6) self.assertAlmostEqual(0, rec.eval(), 6) + @test_util.run_deprecated_v1 def testWithMultipleUpdates(self): num_samples = 1000 batch_size = 10 @@ -1990,6 +2097,7 @@ class SingleLabelPrecisionAtKTest(test.TestCase): self._test_average_precision_at_k = functools.partial( _test_average_precision_at_k, test_case=self) + @test_util.run_deprecated_v1 def test_at_k1_nan(self): for labels in self._labels: # Classes 0,1,2 have 0 predictions, classes -1 and 4 are out of range. @@ -1999,6 +2107,7 @@ class SingleLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( self._predictions_idx, labels, k=1, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_at_k1(self): for labels in self._labels: # Class 3: 1 label, 2 predictions, 1 correct. @@ -2026,6 +2135,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_average_precision_at_k = functools.partial( _test_average_precision_at_k, test_case=self) + @test_util.run_deprecated_v1 def test_average_precision(self): # Example 1. # Matches example here: @@ -2101,6 +2211,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): expected=streaming_average_precision[i], weights=weights) + @test_util.run_deprecated_v1 def test_average_precision_some_labels_out_of_range(self): """Tests that labels outside the [0, n_classes) range are ignored.""" labels_ex1 = (-1, 0, 1, 2, 3, 4, 7) @@ -2120,6 +2231,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_average_precision_at_k( predictions, labels, k, expected=avg_precision_ex1[i]) + @test_util.run_deprecated_v1 def test_three_labels_at_k5_no_predictions(self): predictions = [[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]] @@ -2136,6 +2248,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_three_labels_at_k5_no_labels(self): predictions = [[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]] @@ -2152,6 +2265,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=0.0, class_id=class_id) + @test_util.run_deprecated_v1 def test_three_labels_at_k5(self): predictions = [[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]] @@ -2185,6 +2299,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=3.0 / 10) + @test_util.run_deprecated_v1 def test_three_labels_at_k5_some_out_of_range(self): """Tests that labels outside the [0, n_classes) range are ignored.""" predictions = [[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], @@ -2221,6 +2336,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, sp_labels, k=5, expected=3.0 / 10) + @test_util.run_deprecated_v1 def test_3d_nan(self): predictions = [[[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]], @@ -2239,6 +2355,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_3d_no_labels(self): predictions = [[[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]], @@ -2257,6 +2374,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=0.0, class_id=class_id) + @test_util.run_deprecated_v1 def test_3d(self): predictions = [[[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]], @@ -2292,6 +2410,7 @@ class MultiLabelPrecisionAtKTest(test.TestCase): self._test_precision_at_top_k( predictions_idx, labels, k=5, expected=7.0 / 20) + @test_util.run_deprecated_v1 def test_3d_ignore_some(self): predictions = [[[0.5, 0.1, 0.6, 0.3, 0.8, 0.0, 0.7, 0.2, 0.4, 0.9], [0.3, 0.0, 0.7, 0.2, 0.4, 0.9, 0.5, 0.8, 0.1, 0.6]], @@ -2433,6 +2552,7 @@ class SingleLabelRecallAtKTest(test.TestCase): self._test_recall_at_top_k = functools.partial( _test_recall_at_top_k, test_case=self) + @test_util.run_deprecated_v1 def test_at_k1_nan(self): # Classes 0,1 have 0 labels, 0 predictions, classes -1 and 4 are out of # range. @@ -2443,6 +2563,7 @@ class SingleLabelRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=1, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_at_k1_no_predictions(self): for labels in self._labels: # Class 2: 0 predictions. @@ -2451,6 +2572,7 @@ class SingleLabelRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=1, expected=0.0, class_id=2) + @test_util.run_deprecated_v1 def test_one_label_at_k1(self): for labels in self._labels: # Class 3: 1 label, 2 predictions, 1 correct. @@ -2464,6 +2586,7 @@ class SingleLabelRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=1, expected=1.0 / 2) + @test_util.run_deprecated_v1 def test_one_label_at_k1_weighted_class_id3(self): predictions = self._predictions predictions_idx = self._predictions_idx @@ -2505,6 +2628,7 @@ class SingleLabelRecallAtKTest(test.TestCase): predictions_idx, labels, k=1, expected=2.0 / 2, class_id=3, weights=(2.0, 3.0)) + @test_util.run_deprecated_v1 def test_one_label_at_k1_weighted(self): predictions = self._predictions predictions_idx = self._predictions_idx @@ -2554,6 +2678,7 @@ class MultiLabel2dRecallAtKTest(test.TestCase): self._test_recall_at_top_k = functools.partial( _test_recall_at_top_k, test_case=self) + @test_util.run_deprecated_v1 def test_at_k5_nan(self): for labels in self._labels: # Classes 0,3,4,6,9 have 0 labels, class 10 is out of range. @@ -2563,6 +2688,7 @@ class MultiLabel2dRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=5, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_at_k5_no_predictions(self): for labels in self._labels: # Class 8: 1 label, no predictions. @@ -2571,6 +2697,7 @@ class MultiLabel2dRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=5, expected=0.0 / 1, class_id=8) + @test_util.run_deprecated_v1 def test_at_k5(self): for labels in self._labels: # Class 2: 2 labels, both correct. @@ -2596,6 +2723,7 @@ class MultiLabel2dRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, labels, k=5, expected=3.0 / 6) + @test_util.run_deprecated_v1 def test_at_k5_some_out_of_range(self): """Tests that labels outside the [0, n_classes) count in denominator.""" labels = sparse_tensor.SparseTensorValue( @@ -2648,6 +2776,7 @@ class MultiLabel3dRecallAtKTest(test.TestCase): self._test_recall_at_top_k = functools.partial( _test_recall_at_top_k, test_case=self) + @test_util.run_deprecated_v1 def test_3d_nan(self): # Classes 0,3,4,6,9 have 0 labels, class 10 is out of range. for class_id in (0, 3, 4, 6, 9, 10): @@ -2657,6 +2786,7 @@ class MultiLabel3dRecallAtKTest(test.TestCase): self._predictions_idx, self._labels, k=5, expected=NAN, class_id=class_id) + @test_util.run_deprecated_v1 def test_3d_no_predictions(self): # Classes 1,8 have 0 predictions, >=1 label. for class_id in (1, 8): @@ -2666,6 +2796,7 @@ class MultiLabel3dRecallAtKTest(test.TestCase): self._predictions_idx, self._labels, k=5, expected=0.0, class_id=class_id) + @test_util.run_deprecated_v1 def test_3d(self): # Class 2: 4 labels, all correct. self._test_recall_at_k( @@ -2694,6 +2825,7 @@ class MultiLabel3dRecallAtKTest(test.TestCase): self._test_recall_at_top_k( self._predictions_idx, self._labels, k=5, expected=7.0 / 12) + @test_util.run_deprecated_v1 def test_3d_ignore_all(self): for class_id in xrange(10): self._test_recall_at_k( @@ -2720,6 +2852,7 @@ class MultiLabel3dRecallAtKTest(test.TestCase): self._predictions_idx, self._labels, k=5, expected=NAN, weights=[[0, 0], [0, 0]]) + @test_util.run_deprecated_v1 def test_3d_ignore_some(self): # Class 2: 2 labels, both correct. self._test_recall_at_k( @@ -2775,12 +2908,14 @@ class MeanAbsoluteErrorTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_absolute_error( predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) _assert_metric_variables( self, ('mean_absolute_error/count:0', 'mean_absolute_error/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean_absolute_error( @@ -2789,6 +2924,7 @@ class MeanAbsoluteErrorTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_absolute_error( @@ -2797,6 +2933,7 @@ class MeanAbsoluteErrorTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_normal((10, 3), seed=1) labels = random_ops.random_normal((10, 3), seed=2) @@ -2814,6 +2951,7 @@ class MeanAbsoluteErrorTest(test.TestCase): for _ in range(10): self.assertEqual(initial_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithErrorAndWeights(self): predictions = constant_op.constant( [2, 4, 6, 8], shape=(1, 4), dtype=dtypes_lib.float32) @@ -2834,6 +2972,7 @@ class MeanRelativeErrorTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_relative_error( predictions=array_ops.ones((10, 1)), @@ -2842,6 +2981,7 @@ class MeanRelativeErrorTest(test.TestCase): _assert_metric_variables( self, ('mean_relative_error/count:0', 'mean_relative_error/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean_relative_error( @@ -2851,6 +2991,7 @@ class MeanRelativeErrorTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_relative_error( @@ -2860,6 +3001,7 @@ class MeanRelativeErrorTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_normal((10, 3), seed=1) labels = random_ops.random_normal((10, 3), seed=2) @@ -2879,6 +3021,7 @@ class MeanRelativeErrorTest(test.TestCase): for _ in range(10): self.assertEqual(initial_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateNormalizedByLabels(self): np_predictions = np.asarray([2, 4, 6, 8], dtype=np.float32) np_labels = np.asarray([1, 3, 2, 3], dtype=np.float32) @@ -2897,6 +3040,7 @@ class MeanRelativeErrorTest(test.TestCase): self.assertEqual(expected_error, self.evaluate(update_op)) self.assertEqual(expected_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateNormalizedByZeros(self): np_predictions = np.asarray([2, 4, 6, 8], dtype=np.float32) @@ -2919,12 +3063,14 @@ class MeanSquaredErrorTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_squared_error( predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) _assert_metric_variables( self, ('mean_squared_error/count:0', 'mean_squared_error/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean_squared_error( @@ -2933,6 +3079,7 @@ class MeanSquaredErrorTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_squared_error( @@ -2941,6 +3088,7 @@ class MeanSquaredErrorTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_normal((10, 3), seed=1) labels = random_ops.random_normal((10, 3), seed=2) @@ -2958,6 +3106,7 @@ class MeanSquaredErrorTest(test.TestCase): for _ in range(10): self.assertEqual(initial_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateZeroError(self): predictions = array_ops.zeros((1, 3), dtype=dtypes_lib.float32) labels = array_ops.zeros((1, 3), dtype=dtypes_lib.float32) @@ -2969,6 +3118,7 @@ class MeanSquaredErrorTest(test.TestCase): self.assertEqual(0, self.evaluate(update_op)) self.assertEqual(0, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithError(self): predictions = constant_op.constant( [2, 4, 6], shape=(1, 3), dtype=dtypes_lib.float32) @@ -2982,6 +3132,7 @@ class MeanSquaredErrorTest(test.TestCase): self.assertEqual(6, self.evaluate(update_op)) self.assertEqual(6, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithErrorAndWeights(self): predictions = constant_op.constant( [2, 4, 6, 8], shape=(1, 4), dtype=dtypes_lib.float32) @@ -2996,6 +3147,7 @@ class MeanSquaredErrorTest(test.TestCase): self.assertEqual(13, self.evaluate(update_op)) self.assertEqual(13, error.eval()) + @test_util.run_deprecated_v1 def testMultipleBatchesOfSizeOne(self): with self.cached_session() as sess: # Create the queue that populates the predictions. @@ -3020,6 +3172,7 @@ class MeanSquaredErrorTest(test.TestCase): self.assertAlmostEqual(208.0 / 6, error.eval(), 5) + @test_util.run_deprecated_v1 def testMetricsComputedConcurrently(self): with self.cached_session() as sess: # Create the queue that populates one set of predictions. @@ -3063,6 +3216,7 @@ class MeanSquaredErrorTest(test.TestCase): self.assertAlmostEqual(208.0 / 6, mse0, 5) self.assertAlmostEqual(79.0 / 6, mse1, 5) + @test_util.run_deprecated_v1 def testMultipleMetricsOnMultipleBatchesOfSizeOne(self): with self.cached_session() as sess: # Create the queue that populates the predictions. @@ -3095,6 +3249,7 @@ class RootMeanSquaredErrorTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.root_mean_squared_error( predictions=array_ops.ones((10, 1)), labels=array_ops.ones((10, 1))) @@ -3102,6 +3257,7 @@ class RootMeanSquaredErrorTest(test.TestCase): self, ('root_mean_squared_error/count:0', 'root_mean_squared_error/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.root_mean_squared_error( @@ -3110,6 +3266,7 @@ class RootMeanSquaredErrorTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.root_mean_squared_error( @@ -3118,6 +3275,7 @@ class RootMeanSquaredErrorTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_normal((10, 3), seed=1) labels = random_ops.random_normal((10, 3), seed=2) @@ -3135,6 +3293,7 @@ class RootMeanSquaredErrorTest(test.TestCase): for _ in range(10): self.assertEqual(initial_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateZeroError(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -3148,6 +3307,7 @@ class RootMeanSquaredErrorTest(test.TestCase): self.assertEqual(0, rmse.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithError(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -3161,6 +3321,7 @@ class RootMeanSquaredErrorTest(test.TestCase): self.assertAlmostEqual(math.sqrt(6), update_op.eval(), 5) self.assertAlmostEqual(math.sqrt(6), rmse.eval(), 5) + @test_util.run_deprecated_v1 def testSingleUpdateWithErrorAndWeights(self): with self.cached_session() as sess: predictions = constant_op.constant( @@ -3188,6 +3349,7 @@ class MeanCosineDistanceTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_cosine_distance( predictions=array_ops.ones((10, 3)), @@ -3198,6 +3360,7 @@ class MeanCosineDistanceTest(test.TestCase): 'mean_cosine_distance/total:0', )) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.mean_cosine_distance( @@ -3207,6 +3370,7 @@ class MeanCosineDistanceTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_cosine_distance( @@ -3216,6 +3380,7 @@ class MeanCosineDistanceTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): predictions = random_ops.random_normal((10, 3), seed=1) labels = random_ops.random_normal((10, 3), seed=2) @@ -3233,6 +3398,7 @@ class MeanCosineDistanceTest(test.TestCase): for _ in range(10): self.assertEqual(initial_error, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateZeroError(self): np_labels = np.matrix(('1 0 0;' '0 0 1;' '0 1 0')) @@ -3248,6 +3414,7 @@ class MeanCosineDistanceTest(test.TestCase): self.assertEqual(0, self.evaluate(update_op)) self.assertEqual(0, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithError1(self): np_labels = np.matrix(('1 0 0;' '0 0 1;' '0 1 0')) np_predictions = np.matrix(('1 0 0;' '0 0 -1;' '1 0 0')) @@ -3264,6 +3431,7 @@ class MeanCosineDistanceTest(test.TestCase): self.assertAlmostEqual(1, self.evaluate(update_op), 5) self.assertAlmostEqual(1, error.eval(), 5) + @test_util.run_deprecated_v1 def testSingleUpdateWithError2(self): np_predictions = np.matrix( ('0.819031913261206 0.567041924552012 0.087465312324590;' @@ -3285,6 +3453,7 @@ class MeanCosineDistanceTest(test.TestCase): self.assertAlmostEqual(1.0, self.evaluate(update_op), 5) self.assertAlmostEqual(1.0, error.eval(), 5) + @test_util.run_deprecated_v1 def testSingleUpdateWithErrorAndWeights1(self): np_predictions = np.matrix(('1 0 0;' '0 0 -1;' '1 0 0')) np_labels = np.matrix(('1 0 0;' '0 0 1;' '0 1 0')) @@ -3304,6 +3473,7 @@ class MeanCosineDistanceTest(test.TestCase): self.assertEqual(0, self.evaluate(update_op)) self.assertEqual(0, error.eval()) + @test_util.run_deprecated_v1 def testSingleUpdateWithErrorAndWeights2(self): np_predictions = np.matrix(('1 0 0;' '0 0 -1;' '1 0 0')) np_labels = np.matrix(('1 0 0;' '0 0 1;' '0 1 0')) @@ -3329,6 +3499,7 @@ class PcntBelowThreshTest(test.TestCase): def setUp(self): ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.percentage_below(values=array_ops.ones((10,)), threshold=2) _assert_metric_variables(self, ( @@ -3336,6 +3507,7 @@ class PcntBelowThreshTest(test.TestCase): 'percentage_below_threshold/total:0', )) + @test_util.run_deprecated_v1 def testMetricsCollection(self): my_collection_name = '__metrics__' mean, _ = metrics.percentage_below( @@ -3344,6 +3516,7 @@ class PcntBelowThreshTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.percentage_below( @@ -3352,6 +3525,7 @@ class PcntBelowThreshTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testOneUpdate(self): with self.cached_session() as sess: values = constant_op.constant( @@ -3369,6 +3543,7 @@ class PcntBelowThreshTest(test.TestCase): self.assertAlmostEqual(0.75, pcnt1, 5) self.assertAlmostEqual(0.0, pcnt2, 5) + @test_util.run_deprecated_v1 def testSomePresentOneUpdate(self): with self.cached_session() as sess: values = constant_op.constant( @@ -3399,6 +3574,7 @@ class MeanIOUTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_iou( predictions=array_ops.ones([10, 1]), @@ -3406,6 +3582,7 @@ class MeanIOUTest(test.TestCase): num_classes=2) _assert_metric_variables(self, ('mean_iou/total_confusion_matrix:0',)) + @test_util.run_deprecated_v1 def testMetricsCollections(self): my_collection_name = '__metrics__' mean_iou, _ = metrics.mean_iou( @@ -3415,6 +3592,7 @@ class MeanIOUTest(test.TestCase): metrics_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [mean_iou]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_iou( @@ -3424,12 +3602,14 @@ class MeanIOUTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testPredictionsAndLabelsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones([10, 3]) labels = array_ops.ones([10, 4]) with self.assertRaises(ValueError): metrics.mean_iou(labels, predictions, num_classes=2) + @test_util.run_deprecated_v1 def testLabelsAndWeightsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones([10]) labels = array_ops.ones([10]) @@ -3437,6 +3617,7 @@ class MeanIOUTest(test.TestCase): with self.assertRaises(ValueError): metrics.mean_iou(labels, predictions, num_classes=2, weights=weights) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): num_classes = 3 predictions = random_ops.random_uniform( @@ -3458,6 +3639,7 @@ class MeanIOUTest(test.TestCase): for _ in range(10): self.assertEqual(initial_mean_iou, mean_iou.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdates(self): num_classes = 3 with self.cached_session() as sess: @@ -3489,6 +3671,7 @@ class MeanIOUTest(test.TestCase): desired_output = np.mean([1.0 / 2.0, 1.0 / 4.0, 0.]) self.assertEqual(desired_output, miou.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdatesWithWeights(self): num_classes = 2 with self.cached_session() as sess: @@ -3534,6 +3717,7 @@ class MeanIOUTest(test.TestCase): desired_output = np.mean([2.0 / 3.0, 1.0 / 2.0]) self.assertAlmostEqual(desired_output, mean_iou.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdatesWithMissingClass(self): # Test the case where there are no predicions and labels for # one class, and thus there is one row and one column with @@ -3570,6 +3754,7 @@ class MeanIOUTest(test.TestCase): desired_output = np.mean([1.0 / 3.0, 2.0 / 4.0]) self.assertAlmostEqual(desired_output, miou.eval()) + @test_util.run_deprecated_v1 def testUpdateOpEvalIsAccumulatedConfusionMatrix(self): predictions = array_ops.concat( [ @@ -3594,6 +3779,7 @@ class MeanIOUTest(test.TestCase): desired_miou = np.mean([3. / 5., 5. / 7.]) self.assertAlmostEqual(desired_miou, miou.eval()) + @test_util.run_deprecated_v1 def testAllCorrect(self): predictions = array_ops.zeros([40]) labels = array_ops.zeros([40]) @@ -3604,6 +3790,7 @@ class MeanIOUTest(test.TestCase): self.assertEqual(40, update_op.eval()[0]) self.assertEqual(1.0, miou.eval()) + @test_util.run_deprecated_v1 def testAllWrong(self): predictions = array_ops.zeros([40]) labels = array_ops.ones([40]) @@ -3614,6 +3801,7 @@ class MeanIOUTest(test.TestCase): self.assertAllEqual([[0, 0], [40, 0]], update_op.eval()) self.assertEqual(0., miou.eval()) + @test_util.run_deprecated_v1 def testResultsWithSomeMissing(self): predictions = array_ops.concat( [ @@ -3646,6 +3834,7 @@ class MeanIOUTest(test.TestCase): desired_miou = np.mean([2. / 4., 4. / 6.]) self.assertAlmostEqual(desired_miou, miou.eval()) + @test_util.run_deprecated_v1 def testMissingClassInLabels(self): labels = constant_op.constant([ [[0, 0, 1, 1, 0, 0], @@ -3666,6 +3855,7 @@ class MeanIOUTest(test.TestCase): 1 / 3 * (7 / (7 + 3 + 7) + 5 / (5 + 4 + 5) + 0 / (0 + 5 + 0)), miou.eval()) + @test_util.run_deprecated_v1 def testMissingClassOverallSmall(self): labels = constant_op.constant([0]) predictions = constant_op.constant([0]) @@ -3676,6 +3866,7 @@ class MeanIOUTest(test.TestCase): self.assertAllEqual([[1, 0], [0, 0]], update_op.eval()) self.assertAlmostEqual(1, miou.eval()) + @test_util.run_deprecated_v1 def testMissingClassOverallLarge(self): labels = constant_op.constant([ [[0, 0, 1, 1, 0, 0], @@ -3702,6 +3893,7 @@ class MeanPerClassAccuracyTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.mean_per_class_accuracy( predictions=array_ops.ones([10, 1]), @@ -3710,6 +3902,7 @@ class MeanPerClassAccuracyTest(test.TestCase): _assert_metric_variables(self, ('mean_accuracy/count:0', 'mean_accuracy/total:0')) + @test_util.run_deprecated_v1 def testMetricsCollections(self): my_collection_name = '__metrics__' mean_accuracy, _ = metrics.mean_per_class_accuracy( @@ -3720,6 +3913,7 @@ class MeanPerClassAccuracyTest(test.TestCase): self.assertListEqual( ops.get_collection(my_collection_name), [mean_accuracy]) + @test_util.run_deprecated_v1 def testUpdatesCollection(self): my_collection_name = '__updates__' _, update_op = metrics.mean_per_class_accuracy( @@ -3729,12 +3923,14 @@ class MeanPerClassAccuracyTest(test.TestCase): updates_collections=[my_collection_name]) self.assertListEqual(ops.get_collection(my_collection_name), [update_op]) + @test_util.run_deprecated_v1 def testPredictionsAndLabelsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones([10, 3]) labels = array_ops.ones([10, 4]) with self.assertRaises(ValueError): metrics.mean_per_class_accuracy(labels, predictions, num_classes=2) + @test_util.run_deprecated_v1 def testLabelsAndWeightsOfDifferentSizeRaisesValueError(self): predictions = array_ops.ones([10]) labels = array_ops.ones([10]) @@ -3743,6 +3939,7 @@ class MeanPerClassAccuracyTest(test.TestCase): metrics.mean_per_class_accuracy( labels, predictions, num_classes=2, weights=weights) + @test_util.run_deprecated_v1 def testValueTensorIsIdempotent(self): num_classes = 3 predictions = random_ops.random_uniform( @@ -3795,6 +3992,7 @@ class MeanPerClassAccuracyTest(test.TestCase): desired_output = np.mean([1.0, 1.0 / 3.0, 0.0]) self.assertAlmostEqual(desired_output, mean_accuracy.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdatesWithWeights(self): num_classes = 2 with self.cached_session() as sess: @@ -3840,6 +4038,7 @@ class MeanPerClassAccuracyTest(test.TestCase): desired_output = np.mean([2.0 / 2.0, 0.5 / 1.5]) self.assertAlmostEqual(desired_output, mean_accuracy.eval()) + @test_util.run_deprecated_v1 def testMultipleUpdatesWithMissingClass(self): # Test the case where there are no predicions and labels for # one class, and thus there is one row and one column with @@ -3877,6 +4076,7 @@ class MeanPerClassAccuracyTest(test.TestCase): desired_output = np.mean([1.0 / 2.0, 2.0 / 3.0, 0.]) self.assertAlmostEqual(desired_output, mean_accuracy.eval()) + @test_util.run_deprecated_v1 def testAllCorrect(self): predictions = array_ops.zeros([40]) labels = array_ops.zeros([40]) @@ -3888,6 +4088,7 @@ class MeanPerClassAccuracyTest(test.TestCase): self.assertEqual(1.0, update_op.eval()[0]) self.assertEqual(1.0, mean_accuracy.eval()) + @test_util.run_deprecated_v1 def testAllWrong(self): predictions = array_ops.zeros([40]) labels = array_ops.ones([40]) @@ -3899,6 +4100,7 @@ class MeanPerClassAccuracyTest(test.TestCase): self.assertAllEqual([0.0, 0.0], update_op.eval()) self.assertEqual(0., mean_accuracy.eval()) + @test_util.run_deprecated_v1 def testResultsWithSomeMissing(self): predictions = array_ops.concat([ constant_op.constant(0, shape=[5]), constant_op.constant(1, shape=[5]) @@ -3927,12 +4129,14 @@ class FalseNegativesTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.false_negatives( labels=(0, 1, 0, 1), predictions=(0, 0, 1, 1)) _assert_metric_variables(self, ('false_negatives/count:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -3951,6 +4155,7 @@ class FalseNegativesTest(test.TestCase): self.assertAllClose(3., tn_update_op.eval()) self.assertAllClose(3., tn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -3977,6 +4182,7 @@ class FalseNegativesAtThresholdsTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.false_negatives_at_thresholds( predictions=array_ops.ones((10, 1)), @@ -3984,6 +4190,7 @@ class FalseNegativesAtThresholdsTest(test.TestCase): thresholds=[0.15, 0.5, 0.85]) _assert_metric_variables(self, ('false_negatives/false_negatives:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4000,6 +4207,7 @@ class FalseNegativesAtThresholdsTest(test.TestCase): self.assertAllEqual((0, 2, 3), fn_update_op.eval()) self.assertAllEqual((0, 2, 3), fn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4026,12 +4234,14 @@ class FalsePositivesTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.false_positives( labels=(0, 1, 0, 1), predictions=(0, 0, 1, 1)) _assert_metric_variables(self, ('false_positives/count:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4050,6 +4260,7 @@ class FalsePositivesTest(test.TestCase): self.assertAllClose(7., tn_update_op.eval()) self.assertAllClose(7., tn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4076,6 +4287,7 @@ class FalsePositivesAtThresholdsTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.false_positives_at_thresholds( predictions=array_ops.ones((10, 1)), @@ -4083,6 +4295,7 @@ class FalsePositivesAtThresholdsTest(test.TestCase): thresholds=[0.15, 0.5, 0.85]) _assert_metric_variables(self, ('false_positives/false_positives:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4099,6 +4312,7 @@ class FalsePositivesAtThresholdsTest(test.TestCase): self.assertAllEqual((7, 4, 2), fp_update_op.eval()) self.assertAllEqual((7, 4, 2), fp.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4127,12 +4341,14 @@ class TrueNegativesTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.true_negatives( labels=(0, 1, 0, 1), predictions=(0, 0, 1, 1)) _assert_metric_variables(self, ('true_negatives/count:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4151,6 +4367,7 @@ class TrueNegativesTest(test.TestCase): self.assertAllClose(3., tn_update_op.eval()) self.assertAllClose(3., tn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4177,6 +4394,7 @@ class TrueNegativesAtThresholdsTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.true_negatives_at_thresholds( predictions=array_ops.ones((10, 1)), @@ -4184,6 +4402,7 @@ class TrueNegativesAtThresholdsTest(test.TestCase): thresholds=[0.15, 0.5, 0.85]) _assert_metric_variables(self, ('true_negatives/true_negatives:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4200,6 +4419,7 @@ class TrueNegativesAtThresholdsTest(test.TestCase): self.assertAllEqual((2, 5, 7), tn_update_op.eval()) self.assertAllEqual((2, 5, 7), tn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4226,12 +4446,14 @@ class TruePositivesTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.true_positives( labels=(0, 1, 0, 1), predictions=(0, 0, 1, 1)) _assert_metric_variables(self, ('true_positives/count:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4250,6 +4472,7 @@ class TruePositivesTest(test.TestCase): self.assertAllClose(7., tn_update_op.eval()) self.assertAllClose(7., tn.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): labels = constant_op.constant(((0, 1, 0, 1, 0), (0, 0, 1, 1, 1), @@ -4276,6 +4499,7 @@ class TruePositivesAtThresholdsTest(test.TestCase): np.random.seed(1) ops.reset_default_graph() + @test_util.run_deprecated_v1 def testVars(self): metrics.true_positives_at_thresholds( predictions=array_ops.ones((10, 1)), @@ -4283,6 +4507,7 @@ class TruePositivesAtThresholdsTest(test.TestCase): thresholds=[0.15, 0.5, 0.85]) _assert_metric_variables(self, ('true_positives/true_positives:0',)) + @test_util.run_deprecated_v1 def testUnweighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), @@ -4299,6 +4524,7 @@ class TruePositivesAtThresholdsTest(test.TestCase): self.assertAllEqual((3, 1, 0), tp_update_op.eval()) self.assertAllEqual((3, 1, 0), tp.eval()) + @test_util.run_deprecated_v1 def testWeighted(self): predictions = constant_op.constant(((0.9, 0.2, 0.8, 0.1), (0.2, 0.9, 0.7, 0.6), diff --git a/tensorflow/python/kernel_tests/morphological_ops_test.py b/tensorflow/python/kernel_tests/morphological_ops_test.py index 4ee04209ccb..f54aaf30d0a 100644 --- a/tensorflow/python/kernel_tests/morphological_ops_test.py +++ b/tensorflow/python/kernel_tests/morphological_ops_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import @@ -291,6 +292,7 @@ class DilationTest(test.TestCase): padding="SAME", use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testDilationGrad(self): for use_gpu in True, False: self._testDilationGradValidPadding_1x1x1(use_gpu) @@ -566,6 +568,7 @@ class ErosionTest(test.TestCase): padding="SAME", use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testErosionGrad(self): for use_gpu in True, False: self._testErosionGradValidPadding_1x1x1(use_gpu) diff --git a/tensorflow/python/kernel_tests/neon_depthwise_conv_op_test.py b/tensorflow/python/kernel_tests/neon_depthwise_conv_op_test.py index 87f1991aa78..380d2860da4 100644 --- a/tensorflow/python/kernel_tests/neon_depthwise_conv_op_test.py +++ b/tensorflow/python/kernel_tests/neon_depthwise_conv_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import nn_impl from tensorflow.python.ops import nn_ops @@ -153,6 +154,7 @@ class DepthwiseConv2DTest(test.TestCase): self.assertShapeEqual(native_result, conv_native) self.assertShapeEqual(native_result, conv_interface) + @test_util.run_deprecated_v1 def testDepthwiseConv2D(self): for index, (input_size, filter_size, _, stride, padding) in enumerate(ConfigsToTest()): @@ -216,6 +218,7 @@ class DepthwiseConv2DTest(test.TestCase): self.assertAllClose(expected, np.ravel(value), 1e-5) self.assertShapeEqual(value, conv) + @test_util.run_deprecated_v1 def testConv2D2x2Filter(self): # The inputs look like this (it's a 3 x 2 matrix, each of depth 2): # diff --git a/tensorflow/python/kernel_tests/nth_element_op_test.py b/tensorflow/python/kernel_tests/nth_element_op_test.py index 6cd49746710..4be78b2d5ca 100644 --- a/tensorflow/python/kernel_tests/nth_element_op_test.py +++ b/tensorflow/python/kernel_tests/nth_element_op_test.py @@ -22,6 +22,7 @@ import numpy as np import tensorflow.python.ops.nn_grad # pylint: disable=unused-import from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import nn_ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl @@ -111,17 +112,20 @@ class NthElementTest(test.TestCase): self._testEnumerateN([10, 10, 10]) self._testEnumerateN([10, 10, 10, 10]) + @test_util.run_deprecated_v1 def testInvalidInput(self): with self.assertRaisesRegexp(ValueError, "at least rank 1 but is rank 0"): nn_ops.nth_element(5, 0) + @test_util.run_deprecated_v1 def testInvalidInputAtEval(self): with self.session(use_gpu=False): v = array_ops.placeholder(dtype=dtypes.float32) with self.assertRaisesOpError("Input must be >= 1-D"): nn_ops.nth_element(v, 0).eval(feed_dict={v: 5.0}) + @test_util.run_deprecated_v1 def testInvalidN(self): with self.assertRaisesRegexp(ValueError, "non-negative but is -1"): @@ -130,6 +134,7 @@ class NthElementTest(test.TestCase): "scalar but has rank 1"): nn_ops.nth_element([5, 6, 3], [1]) + @test_util.run_deprecated_v1 def testInvalidNAtEval(self): inputs = [[0.1, 0.2], [0.3, 0.4]] with self.session(use_gpu=False): @@ -138,12 +143,14 @@ class NthElementTest(test.TestCase): with self.assertRaisesOpError("Need n >= 0, got -7"): values.eval(feed_dict={n: -7}) + @test_util.run_deprecated_v1 def testNTooLarge(self): inputs = [[0.1, 0.2], [0.3, 0.4]] with self.assertRaisesRegexp(ValueError, "must have last dimension > n = 2"): nn_ops.nth_element(inputs, 2) + @test_util.run_deprecated_v1 def testNTooLargeAtEval(self): inputs = [[0.1, 0.2], [0.3, 0.4]] with self.session(use_gpu=False): @@ -152,6 +159,7 @@ class NthElementTest(test.TestCase): with self.assertRaisesOpError(r"Input must have at least n\+1 columns"): values.eval(feed_dict={n: 2}) + @test_util.run_deprecated_v1 def testGradients(self): with self.session(use_gpu=False) as sess: inputs = array_ops.placeholder(dtypes.float32, shape=[3, 5]) diff --git a/tensorflow/python/kernel_tests/numerics_test.py b/tensorflow/python/kernel_tests/numerics_test.py index e3210dcddc4..5751f3fe767 100644 --- a/tensorflow/python/kernel_tests/numerics_test.py +++ b/tensorflow/python/kernel_tests/numerics_test.py @@ -66,6 +66,7 @@ class VerifyTensorAllFiniteTest(test.TestCase): class NumericsTest(test.TestCase): + @test_util.run_deprecated_v1 def testInf(self): with self.session(graph=ops.Graph()): t1 = constant_op.constant(1.0) @@ -76,6 +77,7 @@ class NumericsTest(test.TestCase): with self.assertRaisesOpError("Inf"): self.evaluate(a) + @test_util.run_deprecated_v1 def testNaN(self): with self.session(graph=ops.Graph()): t1 = constant_op.constant(0.0) @@ -86,6 +88,7 @@ class NumericsTest(test.TestCase): with self.assertRaisesOpError("NaN"): self.evaluate(a) + @test_util.run_deprecated_v1 def testBoth(self): with self.session(graph=ops.Graph()): t1 = constant_op.constant([1.0, 0.0]) @@ -104,6 +107,7 @@ class NumericsTest(test.TestCase): self.assertAllEqual(np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]), value) self.assertEqual([2, 3], checked.get_shape()) + @test_util.run_deprecated_v1 def testControlFlowCond(self): predicate = array_ops.placeholder(dtypes.bool, shape=[]) _ = control_flow_ops.cond(predicate, @@ -116,6 +120,7 @@ class NumericsTest(test.TestCase): r"or `tf.while_loop\(\)`\."): numerics.add_check_numerics_ops() + @test_util.run_deprecated_v1 def testControlFlowWhile(self): predicate = array_ops.placeholder(dtypes.bool, shape=[]) _ = control_flow_ops.while_loop(lambda _: predicate, diff --git a/tensorflow/python/kernel_tests/pad_op_test.py b/tensorflow/python/kernel_tests/pad_op_test.py index 6fe98d2559a..7b1b054ae06 100644 --- a/tensorflow/python/kernel_tests/pad_op_test.py +++ b/tensorflow/python/kernel_tests/pad_op_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.platform import test @@ -116,6 +117,7 @@ class PadOpTest(test.TestCase): self._testGradient(np_inputs, paddings, mode=mode, constant_values=constant_values) + @test_util.run_deprecated_v1 def testInputDims(self): with self.session(use_gpu=True): with self.assertRaises(ValueError): @@ -124,6 +126,7 @@ class PadOpTest(test.TestCase): array_ops.reshape( [1, 2], shape=[1, 2])) + @test_util.run_deprecated_v1 def testPaddingsDim(self): with self.session(use_gpu=True): with self.assertRaises(ValueError): @@ -132,6 +135,7 @@ class PadOpTest(test.TestCase): array_ops.reshape( [1, 2], shape=[2])) + @test_util.run_deprecated_v1 def testPaddingsDim2(self): with self.session(use_gpu=True): with self.assertRaises(ValueError): @@ -140,6 +144,7 @@ class PadOpTest(test.TestCase): array_ops.reshape( [1, 2], shape=[2, 1])) + @test_util.run_deprecated_v1 def testPaddingsDim3(self): with self.session(use_gpu=True): with self.assertRaises(ValueError): @@ -148,6 +153,7 @@ class PadOpTest(test.TestCase): array_ops.reshape( [1, 2], shape=[1, 2])) + @test_util.run_deprecated_v1 def testPaddingsDim4(self): with self.session(use_gpu=True): with self.assertRaises(ValueError): @@ -156,6 +162,7 @@ class PadOpTest(test.TestCase): array_ops.reshape( [1, 2, 3, 4, 5, 6], shape=[3, 2])) + @test_util.run_deprecated_v1 def testPaddingsNonNegative(self): with self.session(use_gpu=True): with self.assertRaisesRegexp(ValueError, "must be non-negative"): @@ -164,6 +171,7 @@ class PadOpTest(test.TestCase): constant_op.constant( [-1, 0], shape=[1, 2])) + @test_util.run_deprecated_v1 def testPaddingsNonNegative2(self): with self.session(use_gpu=True): with self.assertRaisesRegexp(ValueError, "must be non-negative"): @@ -223,6 +231,7 @@ class PadOpTest(test.TestCase): np.random.randint(-100, 100, (4, 2, 1, 3)).astype(t), [[0, 0], [0, 0], [0, 0], [0, 0]], -123) + @test_util.run_deprecated_v1 def testFloatTypes(self): for t in [np.float32, np.float64]: self._testAll(np.random.rand(2, 5).astype(t), [[1, 0], [2, 0]], 0.0) @@ -261,6 +270,7 @@ class PadOpTest(test.TestCase): [[b"Hello", b"World", b"World"], [b"Hello", b"World", b"World"], [b"Goodnight", b"Moon", b"Moon"]], self.evaluate(symmetric)) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): # Unknown paddings shape. inp = constant_op.constant(0.0, shape=[4, 4, 4, 4]) @@ -277,6 +287,7 @@ class PadOpTest(test.TestCase): padded = array_ops.pad(inp, array_ops.placeholder(dtypes.int32)) self.assertAllEqual(None, padded.get_shape().ndims) + @test_util.run_deprecated_v1 def testPartialShapeInformation(self): unknown = array_ops.placeholder(dtypes.int32) @@ -341,6 +352,7 @@ class PadOpTest(test.TestCase): self.assertAllEqual(inp, out) self.assertShapeEqual(inp, tf_val) + @test_util.run_deprecated_v1 def testCollapseAdjacentNonPaddedDimensions(self): # pyformat: disable paddings_values = [[[0, 0], [0, 0], [0, 0], [0, 1]], diff --git a/tensorflow/python/kernel_tests/parameterized_truncated_normal_op_test.py b/tensorflow/python/kernel_tests/parameterized_truncated_normal_op_test.py index c9221f8c209..f87f5170539 100644 --- a/tensorflow/python/kernel_tests/parameterized_truncated_normal_op_test.py +++ b/tensorflow/python/kernel_tests/parameterized_truncated_normal_op_test.py @@ -29,6 +29,7 @@ from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import random_ops from tensorflow.python.platform import test @@ -166,30 +167,39 @@ class ParameterizedTruncatedNormalTest(test.TestCase): except ImportError as e: tf_logging.warn("Cannot test truncated normal op: %s" % str(e)) + @test_util.run_deprecated_v1 def testDefaults(self): self.validateMoments([10**5], 0.0, 1.0, -2.0, 2.0) + @test_util.run_deprecated_v1 def testShifted(self): self.validateMoments([10**5], -1.0, 1.0, -2.0, 2.0) + @test_util.run_deprecated_v1 def testRightTail(self): self.validateMoments([10**5], 0.0, 1.0, 4.0, np.infty) + @test_util.run_deprecated_v1 def testLeftTail(self): self.validateMoments([10**5], 0.0, 1.0, -np.infty, -4.0) + @test_util.run_deprecated_v1 def testLeftTailTwoSidedBounds(self): self.validateMoments([10**5], 0.0, 1.0, -6.0, -3.0) + @test_util.run_deprecated_v1 def testTwoSidedLeftTailShifted(self): self.validateKolmogorovSmirnov([10**5], 6.0, 1.0, -1.0, 1.0) + @test_util.run_deprecated_v1 def testRightTailShifted(self): self.validateMoments([10**5], -5.0, 1.0, 2.0, np.infty) + @test_util.run_deprecated_v1 def testSmallStddev(self): self.validateKolmogorovSmirnov([10**5], 0.0, 0.1, 0.05, 0.10) + @test_util.run_deprecated_v1 def testSamplingWithSmallStdDevFarFromBound(self): sample_op = random_ops.parameterized_truncated_normal( shape=(int(1e5),), means=0.8, stddevs=0.05, minvals=-1., maxvals=1.) @@ -202,6 +212,7 @@ class ParameterizedTruncatedNormalTest(test.TestCase): no_neg_samples = np.sum(samples < 0.) self.assertEqual(no_neg_samples, 0.) + @test_util.run_deprecated_v1 def testSamplingAtRandnSwitchover(self): # The randn sampler is used as the bounds are moved farther from the mean, # and the probability of accepting a sample increases the farther the diff --git a/tensorflow/python/kernel_tests/parse_single_example_op_test.py b/tensorflow/python/kernel_tests/parse_single_example_op_test.py index 3f500872827..43c8fa4ab5c 100644 --- a/tensorflow/python/kernel_tests/parse_single_example_op_test.py +++ b/tensorflow/python/kernel_tests/parse_single_example_op_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import parsing_ops from tensorflow.python.platform import test from tensorflow.python.platform import tf_logging @@ -121,6 +122,7 @@ class ParseExampleTest(test.TestCase): self.assertEqual( tuple(out[k].dense_shape.get_shape().as_list()), (1,)) + @test_util.run_deprecated_v1 def testEmptySerializedWithAllDefaults(self): sparse_name = "st_a" a_name = "a" @@ -229,6 +231,7 @@ class ParseExampleTest(test.TestCase): }, expected_err=(ValueError, "Missing shape for feature a")) + @test_util.run_deprecated_v1 def testSerializedContainingSparse(self): original = [ example(features=features({ @@ -552,6 +555,7 @@ class ParseExampleTest(test.TestCase): } }, expected_output) + @test_util.run_deprecated_v1 def testSerializedContainingSparseAndSparseFeatureAndDenseWithNoDefault(self): original = [ example(features=features({ @@ -618,6 +622,7 @@ class ParseExampleTest(test.TestCase): }, expected_output) + @test_util.run_deprecated_v1 def testSerializedContainingSparseAndSparseFeatureWithReuse(self): original = [ example(features=features({ @@ -658,6 +663,7 @@ class ParseExampleTest(test.TestCase): } }, expected_output) + @test_util.run_deprecated_v1 def testSerializedContainingVarLenDense(self): aname = "a" bname = "b" @@ -869,6 +875,7 @@ class ParseSingleExampleTest(test.TestCase): self.assertEqual( tuple(out[k].dense_shape.get_shape().as_list()), (1,)) + @test_util.run_deprecated_v1 def testSingleExampleWithSparseAndSparseFeatureAndDense(self): original = example(features=features({ "c": float_feature([3, 4]), diff --git a/tensorflow/python/kernel_tests/parsing_ops_test.py b/tensorflow/python/kernel_tests/parsing_ops_test.py index 1f677103dc6..af76e09f393 100644 --- a/tensorflow/python/kernel_tests/parsing_ops_test.py +++ b/tensorflow/python/kernel_tests/parsing_ops_test.py @@ -33,6 +33,7 @@ from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.framework import tensor_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import parsing_ops @@ -121,6 +122,7 @@ class ParseExampleTest(test.TestCase): self.assertEqual( tuple(out[k].dense_shape.get_shape().as_list()), (2,)) + @test_util.run_deprecated_v1 def testEmptySerializedWithAllDefaults(self): sparse_name = "st_a" a_name = "a" @@ -243,6 +245,7 @@ class ParseExampleTest(test.TestCase): }, expected_err=(ValueError, "Missing shape for feature a")) + @test_util.run_deprecated_v1 def testSerializedContainingSparse(self): original = [ example(features=features({ @@ -571,6 +574,7 @@ class ParseExampleTest(test.TestCase): } }, expected_output) + @test_util.run_deprecated_v1 def testSerializedContainingSparseAndSparseFeatureAndDenseWithNoDefault(self): expected_st_a = ( # indices, values, shape np.empty((0, 2), dtype=np.int64), # indices @@ -631,6 +635,7 @@ class ParseExampleTest(test.TestCase): }, expected_output) + @test_util.run_deprecated_v1 def testSerializedContainingSparseAndSparseFeatureWithReuse(self): expected_idx = ( # indices, values, shape np.array([[0, 0], [0, 1], [1, 0], [1, 1]], dtype=np.int64), @@ -740,6 +745,7 @@ class ParseExampleTest(test.TestCase): for batch_size in (1, 10, 20, 100, 256): self._testSerializedContainingVarLenDenseLargerBatch(batch_size) + @test_util.run_deprecated_v1 def testSerializedContainingVarLenDense(self): aname = "a" bname = "b" @@ -962,6 +968,7 @@ class ParseSingleExampleTest(test.TestCase): self.assertEqual( tuple(out[k].dense_shape.get_shape().as_list()), (1,)) + @test_util.run_deprecated_v1 def testSingleExampleWithSparseAndSparseFeatureAndDense(self): original = example( features=features({ @@ -1180,6 +1187,7 @@ class ParseSequenceExampleTest(test.TestCase): expected_err=expected_err, batch=True) + @test_util.run_deprecated_v1 def testSequenceExampleWithSparseAndDenseContext(self): original = sequence_example( context=features({ @@ -1223,6 +1231,7 @@ class ParseSequenceExampleTest(test.TestCase): }, expected_context_values=expected_context_output) + @test_util.run_deprecated_v1 def testSequenceExampleWithMultipleSizeFeatureLists(self): original = sequence_example( feature_lists=feature_lists({ @@ -1286,6 +1295,7 @@ class ParseSequenceExampleTest(test.TestCase): }, expected_feat_list_values=expected_feature_list_output) + @test_util.run_deprecated_v1 def testSequenceExampleWithoutDebugName(self): original = sequence_example( feature_lists=feature_lists({ @@ -1343,6 +1353,7 @@ class ParseSequenceExampleTest(test.TestCase): }, expected_feat_list_values=expected_feature_list_output) + @test_util.run_deprecated_v1 def testSequenceExampleWithSparseAndDenseFeatureLists(self): original = sequence_example( feature_lists=feature_lists({ @@ -1401,6 +1412,7 @@ class ParseSequenceExampleTest(test.TestCase): }, expected_feat_list_values=expected_feature_list_output) + @test_util.run_deprecated_v1 def testSequenceExampleWithEmptyFeatureInFeatureLists(self): original = sequence_example( feature_lists=feature_lists({ @@ -1541,6 +1553,7 @@ class ParseSequenceExampleTest(test.TestCase): " feature_list_dense_missing_assumed_empty or" " feature_list_dense_defaults?")) + @test_util.run_deprecated_v1 def testSequenceExampleBatch(self): first = sequence_example( feature_lists=feature_lists({ @@ -1695,6 +1708,7 @@ class DecodeJSONExampleTest(test.TestCase): })), ]) + @test_util.run_deprecated_v1 def testInvalidSyntax(self): with self.cached_session() as sess: json_tensor = constant_op.constant(["{]"]) @@ -1705,6 +1719,7 @@ class DecodeJSONExampleTest(test.TestCase): class ParseTensorOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testToFloat32(self): with self.cached_session(): expected = np.random.rand(3, 4, 5).astype(np.float32) @@ -1718,6 +1733,7 @@ class ParseTensorOpTest(test.TestCase): self.assertAllEqual(expected, result) + @test_util.run_deprecated_v1 def testToUint8(self): with self.cached_session(): expected = np.random.rand(3, 4, 5).astype(np.uint8) @@ -1731,6 +1747,7 @@ class ParseTensorOpTest(test.TestCase): self.assertAllEqual(expected, result) + @test_util.run_deprecated_v1 def testTypeMismatch(self): with self.cached_session(): expected = np.random.rand(3, 4, 5).astype(np.uint8) @@ -1744,6 +1761,7 @@ class ParseTensorOpTest(test.TestCase): r"\(uint16\)"): tensor.eval(feed_dict={serialized: tensor_proto.SerializeToString()}) + @test_util.run_deprecated_v1 def testInvalidInput(self): with self.cached_session(): serialized = array_ops.placeholder(dtypes.string) diff --git a/tensorflow/python/kernel_tests/partitioned_variables_test.py b/tensorflow/python/kernel_tests/partitioned_variables_test.py index 0c046561969..48655391fa7 100644 --- a/tensorflow/python/kernel_tests/partitioned_variables_test.py +++ b/tensorflow/python/kernel_tests/partitioned_variables_test.py @@ -26,6 +26,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import partitioned_variables @@ -322,6 +323,7 @@ class PartitionedVariablesTestCase(test.TestCase): for i in xrange(len(expected_specs)): self.assertEquals(expected_specs[i], slices[i]._save_slice_info.spec) + @test_util.run_deprecated_v1 def testVecConstantInit(self): with self.cached_session(): rnd_par = constant_op.constant([1, 2, 3, 4]) @@ -333,6 +335,7 @@ class PartitionedVariablesTestCase(test.TestCase): self.assertEqual([dtypes.int32] * 4, [v.dtype.base_dtype for v in vs]) self._TestSaveSpec(vs, ["4 0,1", "4 1,1", "4 2,1", "4 3,1"]) + @test_util.run_deprecated_v1 def testConstantInit(self): with self.cached_session(): rnd_par = constant_op.constant([[1, 2, 3, 4], [5, 6, 7, 8]]) @@ -401,12 +404,15 @@ class PartitionedVariablesTestCase(test.TestCase): self.assertEqual(var2_name + "/part_0:0", vs2[0].name) self.assertEqual(var2_name + "/part_1:0", vs2[1].name) + @test_util.run_deprecated_v1 def testName(self): self._testNameHelper(use_resource=False) + @test_util.run_deprecated_v1 def testResourceName(self): self._testNameHelper(use_resource=True) + @test_util.run_deprecated_v1 def testRandomInitValue(self): with self.cached_session(): rnd = variables.Variable(random_ops.random_uniform([200, 40])) @@ -424,6 +430,7 @@ class PartitionedVariablesTestCase(test.TestCase): "200 40 0,200:36,4" ]) + @test_util.run_deprecated_v1 def testRandomInitUnevenPartitions(self): with self.cached_session(): rnd = variables.Variable( @@ -462,6 +469,7 @@ class PartitionedVariablesTestCase(test.TestCase): if i < len(save_specs): self._TestSaveSpec(vs, save_specs[i]) + @test_util.run_deprecated_v1 def testDegenerate(self): with self.cached_session(): rnd = variables.Variable(random_ops.random_uniform([10, 43])) @@ -473,6 +481,7 @@ class PartitionedVariablesTestCase(test.TestCase): self.assertAllClose(rnd, val) self._TestSaveSpec(vs, ["10 43 0,10:0,43"]) + @test_util.run_deprecated_v1 def testSliceSizeOne(self): with self.cached_session(): rnd = variables.Variable(random_ops.random_uniform([10, 43])) @@ -488,6 +497,7 @@ class PartitionedVariablesTestCase(test.TestCase): "10 43 6,1:0,43", "10 43 7,1:0,43", "10 43 8,1:0,43", "10 43 9,1:0,43" ]) + @test_util.run_deprecated_v1 def testIotaInitializer(self): self.assertAllClose([0., 1., 2., 3.], _IotaInitializer([4])) self.assertAllClose([[0., 1.], [0., 10.], [0., 100.], [0., 1000.]], @@ -503,6 +513,7 @@ class PartitionedVariablesTestCase(test.TestCase): self.assertAllClose(slice0 + slice1 + slice2, val) self._TestSaveSpec(vs, ["13 5 0,5:0,5", "13 5 5,4:0,5", "13 5 9,4:0,5"]) + @test_util.run_deprecated_v1 def testRandomInitializer(self): # Sanity check that the slices uses a different seed when using a random # initializer function. @@ -546,6 +557,7 @@ class PartitionedVariablesTestCase(test.TestCase): partitioned_variables.create_partitioned_variables( [10, 43], [1, 50], rnd.initialized_value()) + @test_util.run_deprecated_v1 def testControlDepsNone(self): with self.cached_session() as session: c = constant_op.constant(1.0) @@ -572,6 +584,7 @@ class PartitionedVariablesTestCase(test.TestCase): for op in reading_ops: self.assertEqual([], op.control_inputs) + @test_util.run_deprecated_v1 def testConcat(self): with self.cached_session() as session: var_x = variable_scope.get_variable( diff --git a/tensorflow/python/kernel_tests/pool_test.py b/tensorflow/python/kernel_tests/pool_test.py index 92016a49a27..78e786f01ca 100644 --- a/tensorflow/python/kernel_tests/pool_test.py +++ b/tensorflow/python/kernel_tests/pool_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import @@ -301,6 +302,7 @@ class PoolingTest(test.TestCase): err_tolerance = 1e-2 self.assertLess(err, err_tolerance) + @test_util.run_deprecated_v1 def testGradient1D(self): with self.session(use_gpu=test.is_gpu_available()): for padding in ["SAME", "VALID"]: @@ -327,6 +329,7 @@ class PoolingTest(test.TestCase): dilation_rate=[1], strides=strides) + @test_util.run_deprecated_v1 def testGradient2D(self): with self.session(use_gpu=test.is_gpu_available()): for padding in ["SAME", "VALID"]: @@ -353,6 +356,7 @@ class PoolingTest(test.TestCase): dilation_rate=[1, 1], strides=strides) + @test_util.run_deprecated_v1 def testGradient3D(self): with self.session(use_gpu=test.is_gpu_available()): for padding in ["SAME", "VALID"]: diff --git a/tensorflow/python/kernel_tests/pooling_ops_3d_test.py b/tensorflow/python/kernel_tests/pooling_ops_3d_test.py index a8e962bc3a6..24fb51fc477 100644 --- a/tensorflow/python/kernel_tests/pooling_ops_3d_test.py +++ b/tensorflow/python/kernel_tests/pooling_ops_3d_test.py @@ -294,6 +294,7 @@ class PoolingTest(test.TestCase): use_gpu=use_gpu, **kwargs) + @test_util.run_deprecated_v1 def testMaxPoolGradValidPadding1_1_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -303,6 +304,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="VALID") + @test_util.run_deprecated_v1 def testMaxPoolGradValidPadding2_1_6_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -312,6 +314,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="VALID") + @test_util.run_deprecated_v1 def testMaxPoolGradValidPadding2_1_7_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -321,6 +324,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="VALID") + @test_util.run_deprecated_v1 def testMaxPoolGradValidPadding1_2_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -330,6 +334,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="VALID") + @test_util.run_deprecated_v1 def testMaxPoolGradValidPadding2_2_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -339,6 +344,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="VALID") + @test_util.run_deprecated_v1 def testMaxPoolGradSamePadding1_1_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -348,6 +354,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="SAME") + @test_util.run_deprecated_v1 def testMaxPoolGradSamePadding1_2_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -357,6 +364,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="SAME") + @test_util.run_deprecated_v1 def testMaxPoolGradSamePadding2_1_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -366,6 +374,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="SAME") + @test_util.run_deprecated_v1 def testMaxPoolGradSamePadding2_2_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -375,6 +384,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="SAME") + @test_util.run_deprecated_v1 def testMaxPoolGradSamePadding3_1_3d(self): self._ConstructAndTestGradient( nn_ops.max_pool3d, @@ -384,6 +394,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="SAME") + @test_util.run_deprecated_v1 def testAvgPoolGradValidPadding1_1_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -393,6 +404,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="VALID") + @test_util.run_deprecated_v1 def testAvgPoolGradValidPadding1_2_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -402,6 +414,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="VALID") + @test_util.run_deprecated_v1 def testAvgPoolGradValidPadding2_1_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -411,6 +424,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="VALID") + @test_util.run_deprecated_v1 def testAvgPoolGradValidPadding2_2_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -420,6 +434,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="VALID") + @test_util.run_deprecated_v1 def testAvgPoolGradSamePadding1_1_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -429,6 +444,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="SAME") + @test_util.run_deprecated_v1 def testAvgPoolGradSamePadding1_2_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -438,6 +454,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="SAME") + @test_util.run_deprecated_v1 def testAvgPoolGradSamePadding2_1_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -447,6 +464,7 @@ class PoolingTest(test.TestCase): strides=(1, 1, 1), padding="SAME") + @test_util.run_deprecated_v1 def testAvgPoolGradSamePadding2_2_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, @@ -456,6 +474,7 @@ class PoolingTest(test.TestCase): strides=(2, 2, 2), padding="SAME") + @test_util.run_deprecated_v1 def testAvgPoolGradSamePadding3_1_3d(self): self._ConstructAndTestGradient( nn_ops.avg_pool3d, diff --git a/tensorflow/python/kernel_tests/pooling_ops_test.py b/tensorflow/python/kernel_tests/pooling_ops_test.py index 81222719f2a..c33b59bb99b 100644 --- a/tensorflow/python/kernel_tests/pooling_ops_test.py +++ b/tensorflow/python/kernel_tests/pooling_ops_test.py @@ -384,6 +384,7 @@ class PoolingTest(test.TestCase): expected=[], use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testAvgPooling(self): for use_gpu in True, False: self._testAvgPoolValidPadding(use_gpu) @@ -577,6 +578,7 @@ class PoolingTest(test.TestCase): expected=[], use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testMaxPooling(self): for use_gpu in True, False: self._testMaxPoolValidPadding(use_gpu) @@ -588,6 +590,7 @@ class PoolingTest(test.TestCase): self._testMaxPoolEmptyInput(use_gpu) # Tests for DepthwiseMaxPooling on CPU only. + @test_util.run_deprecated_v1 def testDepthwiseMaxPool1x1DepthWindow1(self): # input is: # [1.0, ..., 10.0] along depth, @@ -613,6 +616,7 @@ class PoolingTest(test.TestCase): use_gpu=False, v2=v2) + @test_util.run_deprecated_v1 def testDepthwiseMaxPool2x2DepthWindow3(self): # input is: # @@ -639,6 +643,7 @@ class PoolingTest(test.TestCase): use_gpu=False, v2=v2) + @test_util.run_deprecated_v1 def testKernelSmallerThanStrideValid(self): for use_gpu in [True, False]: self._VerifyValues( @@ -670,6 +675,7 @@ class PoolingTest(test.TestCase): expected=[5, 8, 26, 29], use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testKernelSmallerThanStrideSame(self): for use_gpu in [True, False]: for pool_func in [nn_ops.max_pool, nn_ops.avg_pool]: @@ -1167,6 +1173,7 @@ class PoolingTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testMaxPoolGrad(self): for (data_format, use_gpu) in GetTestConfigs(): self._testMaxPoolGradValidPadding1_1(data_format, use_gpu) @@ -1497,6 +1504,7 @@ class PoolingTest(test.TestCase): else: del os.environ["TF_ENABLE_MAXPOOL_NANPROP"] + @test_util.run_deprecated_v1 def testMaxPoolGradDirect(self): self._testMaxPoolGradDirect1_1() self._testMaxPoolGradDirect1_2() @@ -1616,6 +1624,7 @@ class PoolingTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testMaxPoolGradGrad(self): for (data_format, use_gpu) in GetTestConfigs(): self._testMaxPoolGradGradValidPadding1_1(data_format, use_gpu) @@ -1649,6 +1658,7 @@ class PoolingTest(test.TestCase): orig_input, orig_output, grad, [1, window_rows, window_cols, 1], [1, row_stride, col_stride, 1], padding) + @test_util.run_deprecated_v1 def testAvgPoolGrad(self): for (data_format, use_gpu) in GetTestConfigs(): self._testAvgPoolGradValidPadding1_1(data_format, use_gpu) @@ -1778,6 +1788,7 @@ class PoolingTest(test.TestCase): data_format=data_format, use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): # All shapes unknown. for pool_func in [nn_ops.max_pool, nn_ops.avg_pool]: @@ -1806,6 +1817,7 @@ class PoolingTest(test.TestCase): strides=[1, 1, 1, 1], padding="SAME") + @test_util.run_deprecated_v1 def testOpEdgeCases(self): with self.session(use_gpu=test.is_gpu_available()) as sess: pool_funcs = [nn_ops.max_pool, nn_ops.avg_pool] diff --git a/tensorflow/python/kernel_tests/py_func_test.py b/tensorflow/python/kernel_tests/py_func_test.py index c9cbe44a7f3..1f3f02a9f01 100644 --- a/tensorflow/python/kernel_tests/py_func_test.py +++ b/tensorflow/python/kernel_tests/py_func_test.py @@ -514,6 +514,7 @@ class PyFuncTest(test.TestCase): self.assertAllEqual(ret, [[3.0], [3.0], [3.0]]) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testEagerExceptionHandling(self): with test_util.device(use_gpu=True): self._testExceptionHandling( @@ -533,6 +534,7 @@ class PyFuncTest(test.TestCase): self._testExceptionHandling(WeirdError, errors.UnknownError, eager=True) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testEagerReturningVariableRaisesError(self): def return_variable(): return resource_variable_ops.ResourceVariable(0.0) diff --git a/tensorflow/python/kernel_tests/qr_op_test.py b/tensorflow/python/kernel_tests/qr_op_test.py index 305b5aa3645..0f2537b3711 100644 --- a/tensorflow/python/kernel_tests/qr_op_test.py +++ b/tensorflow/python/kernel_tests/qr_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import linalg_ops @@ -49,6 +50,7 @@ class QrOpTest(test.TestCase): "Shape must be at least rank 2 but is rank 1"): linalg_ops.qr(vector) + @test_util.run_deprecated_v1 def testConcurrentExecutesWithoutError(self): with self.session(use_gpu=True) as sess: all_ops = [] diff --git a/tensorflow/python/kernel_tests/random/multinomial_op_big_test.py b/tensorflow/python/kernel_tests/random/multinomial_op_big_test.py index cab841741e7..576720528e2 100644 --- a/tensorflow/python/kernel_tests/random/multinomial_op_big_test.py +++ b/tensorflow/python/kernel_tests/random/multinomial_op_big_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.ops import random_ops from tensorflow.python.platform import test @@ -66,6 +67,7 @@ class MultinomialTest(test.TestCase): counts_by_indices[index] = count self.assertEqual(counts_by_indices[0], 100000000) + @test_util.run_deprecated_v1 def testLargeDynamicRange3(self): random_seed.set_random_seed(10) counts_by_indices = {} diff --git a/tensorflow/python/kernel_tests/random/multinomial_op_test.py b/tensorflow/python/kernel_tests/random/multinomial_op_test.py index 031a1c281c2..5d123307a8e 100644 --- a/tensorflow/python/kernel_tests/random/multinomial_op_test.py +++ b/tensorflow/python/kernel_tests/random/multinomial_op_test.py @@ -66,6 +66,7 @@ class MultinomialTest(test.TestCase): logits, num_samples, output_dtype=output_dtype)) self.assertAllEqual([[1] * num_samples, [2] * num_samples], samples) + @test_util.run_deprecated_v1 def testOneOpMultipleStepsIndependent(self): with test_util.use_gpu(): sample_op1, _ = self._make_ops(10) @@ -88,6 +89,7 @@ class MultinomialTest(test.TestCase): # 1 in 2^32 chance of this assertion failing. self.assertFalse(np.equal(sample1, sample2).all()) + @test_util.run_deprecated_v1 def testTwoOpsSameSeedDrawSameSequences(self): with test_util.use_gpu(): sample_op1, sample_op2 = self._make_ops(1000, seed=1) @@ -194,6 +196,7 @@ class MultinomialTest(test.TestCase): array_ops.zeros([batch, classes]), samples)) self.assertEqual(x.shape, (batch, samples)) + @test_util.run_deprecated_v1 def testEmptyClasses(self): with test_util.use_gpu(): x = random_ops.multinomial(array_ops.zeros([5, 0]), 7) diff --git a/tensorflow/python/kernel_tests/random/random_crop_test.py b/tensorflow/python/kernel_tests/random/random_crop_test.py index 491d19d6a00..724bee07157 100644 --- a/tensorflow/python/kernel_tests/random/random_crop_test.py +++ b/tensorflow/python/kernel_tests/random/random_crop_test.py @@ -20,12 +20,14 @@ from __future__ import print_function import numpy as np +from tensorflow.python.framework import test_util from tensorflow.python.ops import random_ops from tensorflow.python.platform import test class RandomCropTest(test.TestCase): + @test_util.run_deprecated_v1 def testNoOp(self): # No random cropping is performed since the size is value.shape. for shape in (2, 1, 1), (2, 1, 3), (4, 5, 3): @@ -48,6 +50,7 @@ class RandomCropTest(test.TestCase): self.assertAllEqual(y.shape, target) self.assertTrue(tuple(y.ravel()) in value_set) + @test_util.run_deprecated_v1 def testRandomization(self): # Run 1x1 crop num_samples times in an image and ensure that one finds each # pixel 1/size of the time. diff --git a/tensorflow/python/kernel_tests/random/random_gamma_test.py b/tensorflow/python/kernel_tests/random/random_gamma_test.py index d18e3feb045..a5952a21968 100644 --- a/tensorflow/python/kernel_tests/random/random_gamma_test.py +++ b/tensorflow/python/kernel_tests/random/random_gamma_test.py @@ -26,6 +26,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops @@ -53,9 +54,11 @@ class RandomGammaTest(test.TestCase): return func + @test_util.run_deprecated_v1 def testMomentsFloat32(self): self._testMoments(dtypes.float32) + @test_util.run_deprecated_v1 def testMomentsFloat64(self): self._testMoments(dtypes.float64) @@ -208,6 +211,7 @@ class RandomGammaTest(test.TestCase): sy = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=use_gpu, seed=345) self.assertAllEqual(sx(), sy()) + @test_util.run_deprecated_v1 def testNoCSE(self): """CSE = constant subexpression eliminator. @@ -222,6 +226,7 @@ class RandomGammaTest(test.TestCase): diff = rnd2 - rnd1 self.assertGreater(np.linalg.norm(diff.eval()), 0.1) + @test_util.run_deprecated_v1 def testShape(self): # Fully known shape. rnd = random_ops.random_gamma([150], 2.0) @@ -253,6 +258,7 @@ class RandomGammaTest(test.TestCase): rnd = random_ops.random_gamma([50], array_ops.placeholder(dtypes.float32)) self.assertIs(None, rnd.get_shape().ndims) + @test_util.run_deprecated_v1 def testPositive(self): n = int(10e3) for dt in [dtypes.float16, dtypes.float32, dtypes.float64]: diff --git a/tensorflow/python/kernel_tests/random/random_grad_test.py b/tensorflow/python/kernel_tests/random/random_grad_test.py index d89056c485a..aac6eeac06a 100644 --- a/tensorflow/python/kernel_tests/random/random_grad_test.py +++ b/tensorflow/python/kernel_tests/random/random_grad_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops @@ -45,6 +46,7 @@ class AddLeadingUnitDimensionsTest(test.TestCase): ret = random_grad.add_leading_unit_dimensions(1.0, 2) self.assertAllEqual(ret.shape, [1, 1]) + @test_util.run_deprecated_v1 def testUnknownShape(self): x = array_ops.placeholder(dtypes.float32) num_dimensions = array_ops.placeholder(dtypes.int32) @@ -72,6 +74,7 @@ class RandomGammaGradTest(test.TestCase): some statistical properties of the derivative. """ + @test_util.run_deprecated_v1 def testGradientsShape(self): shape = [2, 3] alpha = array_ops.ones([2, 2]) @@ -81,6 +84,7 @@ class RandomGammaGradTest(test.TestCase): self.assertAllEqual(grads_alpha.shape, alpha.shape) self.assertAllEqual(grads_beta.shape, beta.shape) + @test_util.run_deprecated_v1 def testGradientsShapeWithOneSamplePerParameter(self): shape = [] alpha = array_ops.ones([2, 2]) @@ -90,6 +94,7 @@ class RandomGammaGradTest(test.TestCase): self.assertAllEqual(grads_alpha.shape, alpha.shape) self.assertAllEqual(grads_beta.shape, beta.shape) + @test_util.run_deprecated_v1 def testGradientsUnknownShape(self): shape = array_ops.placeholder(dtypes.int32) alpha = array_ops.placeholder(dtypes.float32) @@ -138,9 +143,11 @@ class RandomGammaGradTest(test.TestCase): except ImportError as e: tf_logging.warn("Cannot use special functions in a test: %s" % str(e)) + @test_util.run_deprecated_v1 def testCompareToExplicitDerivativeFloat(self): self._testCompareToExplicitDerivative(dtypes.float32) + @test_util.run_deprecated_v1 def testCompareToExplicitDerivativeDouble(self): self._testCompareToExplicitDerivative(dtypes.float64) @@ -182,12 +189,15 @@ class RandomGammaGradTest(test.TestCase): self.assertAllClose(actual_val, expected_val, rtol=1e-3, atol=1e-3) + @test_util.run_deprecated_v1 def testCompareToImplicitDerivativeFloat(self): self._testCompareToImplicitDerivative(dtypes.float32) + @test_util.run_deprecated_v1 def testCompareToImplicitDerivativeDouble(self): self._testCompareToImplicitDerivative(dtypes.float64) + @test_util.run_deprecated_v1 def testAverageAlphaGradient(self): """Statistical test for the gradient. @@ -207,6 +217,7 @@ class RandomGammaGradTest(test.TestCase): dsample_dalpha_val = self.evaluate(dsample_dalpha) self.assertAllClose(dsample_dalpha_val, [1.0] * 3, atol=1e-1, rtol=1e-1) + @test_util.run_deprecated_v1 def testQuadraticLoss(self): """Statistical test for the gradient. diff --git a/tensorflow/python/kernel_tests/random/random_ops_test.py b/tensorflow/python/kernel_tests/random/random_ops_test.py index 76618316b24..1384c3f446f 100644 --- a/tensorflow/python/kernel_tests/random/random_ops_test.py +++ b/tensorflow/python/kernel_tests/random/random_ops_test.py @@ -25,6 +25,7 @@ from tensorflow.python.eager import context from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variables @@ -92,6 +93,7 @@ class RandomNormalTest(RandomOpTestCommon): # Checks that the CPU and GPU implementation returns the same results, # given the same random seed + @test_util.run_deprecated_v1 def testCPUGPUMatch(self): for dt in dtypes.float16, dtypes.float32, dtypes.float64: results = {} @@ -104,12 +106,14 @@ class RandomNormalTest(RandomOpTestCommon): else: self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6) + @test_util.run_deprecated_v1 def testSeed(self): for dt in dtypes.float16, dtypes.float32, dtypes.float64: sx = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=True, seed=345) sy = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=True, seed=345) self.assertAllEqual(sx(), sy()) + @test_util.run_deprecated_v1 def testNoCSE(self): for use_gpu in [False, True]: with self.session(use_gpu=use_gpu): @@ -119,12 +123,14 @@ class RandomNormalTest(RandomOpTestCommon): diff = rnd2 - rnd1 self.assertTrue(np.linalg.norm(diff.eval()) > 0.1) + @test_util.run_deprecated_v1 def testSingleSessionNotConstant(self): for use_gpu in [False, True]: for dt in dtypes.float16, dtypes.float32, dtypes.float64: self._testSingleSessionNotConstant( random_ops.random_normal, 100, dt, 0.0, 1.0, use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testSingleSessionOpSeedNotConstant(self): for use_gpu in [False, True]: for dt in dtypes.float16, dtypes.float32, dtypes.float64: @@ -137,6 +143,7 @@ class RandomNormalTest(RandomOpTestCommon): use_gpu=use_gpu, op_seed=1345) + @test_util.run_deprecated_v1 def testSingleSessionGraphSeedNotConstant(self): for use_gpu in [False, True]: for dt in dtypes.float16, dtypes.float32, dtypes.float64: @@ -185,6 +192,7 @@ class TruncatedNormalTest(test.TestCase): # Checks that the CPU and GPU implementation returns the same results, # given the same random seed + @test_util.run_deprecated_v1 def testCPUGPUMatch(self): # Skip the test if there is no GPU. if not test.is_gpu_available(): @@ -203,6 +211,7 @@ class TruncatedNormalTest(test.TestCase): else: self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6) + @test_util.run_deprecated_v1 def testSeed(self): for dt in dtypes.float16, dtypes.float32, dtypes.float64: sx = self._Sampler(1000, 0.0, 1.0, dt, use_gpu=True, seed=345) @@ -219,6 +228,7 @@ class TruncatedNormalTest(test.TestCase): print("std(x)", np.std(x), abs(np.std(x) / stddev - 0.85)) self.assertTrue(abs(np.std(x) / stddev - 0.85) < 0.04) + @test_util.run_deprecated_v1 def testLargeShape(self): with self.session(use_gpu=True): v = variables.Variable( @@ -226,6 +236,7 @@ class TruncatedNormalTest(test.TestCase): n = random_ops.truncated_normal(v.shape) self.assertEqual([8589934592, 1], n.shape.as_list()) + @test_util.run_deprecated_v1 def testNoCSE(self): with self.session(use_gpu=True): shape = [2, 3, 4] @@ -287,6 +298,7 @@ class RandomUniformTest(RandomOpTestCommon): print("count = ", count) self.assertTrue(count < count_limit) + @test_util.run_deprecated_v1 def testUniformIntsWithInvalidShape(self): for dtype in dtypes.int32, dtypes.int64: with self.assertRaisesRegexp( @@ -299,6 +311,7 @@ class RandomUniformTest(RandomOpTestCommon): [1000], minval=1, maxval=[2, 3], dtype=dtype) # Check that uniform ints actually follow a uniform distribution. + @test_util.run_deprecated_v1 def testUniformInts(self): minv = -2 maxv = 15 @@ -331,6 +344,7 @@ class RandomUniformTest(RandomOpTestCommon): # Checks that the CPU and GPU implementation returns the same results, # given the same random seed + @test_util.run_deprecated_v1 def testCPUGPUMatch(self): for dt in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32, dtypes.int64): @@ -342,6 +356,7 @@ class RandomUniformTest(RandomOpTestCommon): results[use_gpu] = sampler() self.assertAllEqual(results[False], results[True]) + @test_util.run_deprecated_v1 def testSeed(self): for dt in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32, dtypes.int64): @@ -350,6 +365,7 @@ class RandomUniformTest(RandomOpTestCommon): sy = self._Sampler(1000, 0, 17, dtype=dt, use_gpu=True, seed=seed) self.assertAllEqual(sx(), sy()) + @test_util.run_deprecated_v1 def testNoCSE(self): shape = [2, 3, 4] for dtype in dtypes.float16, dtypes.float32, dtypes.int32: @@ -359,6 +375,7 @@ class RandomUniformTest(RandomOpTestCommon): diff = (rnd2 - rnd1).eval() self.assertTrue(np.linalg.norm(diff) > 0.1) + @test_util.run_deprecated_v1 def testSingleSessionNotConstant(self): for use_gpu in [False, True]: for dt in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32, @@ -366,6 +383,7 @@ class RandomUniformTest(RandomOpTestCommon): self._testSingleSessionNotConstant( random_ops.random_uniform, 100, dt, 0, 17, use_gpu=use_gpu) + @test_util.run_deprecated_v1 def testSingleSessionOpSeedNotConstant(self): for use_gpu in [False, True]: for dt in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32, @@ -379,6 +397,7 @@ class RandomUniformTest(RandomOpTestCommon): use_gpu=use_gpu, op_seed=1345) + @test_util.run_deprecated_v1 def testSingleSessionGraphSeedNotConstant(self): for use_gpu in [False, True]: for dt in (dtypes.float16, dtypes.float32, dtypes.float64, dtypes.int32, @@ -395,6 +414,7 @@ class RandomUniformTest(RandomOpTestCommon): class RandomShapeTest(test.TestCase): + @test_util.run_deprecated_v1 def testTruncatedNormal(self): # Fully known shape. rnd1 = random_ops.truncated_normal([1, 2, 3]) @@ -407,6 +427,7 @@ class RandomShapeTest(test.TestCase): rnd3 = random_ops.truncated_normal(array_ops.placeholder(dtypes.int32)) self.assertIs(None, rnd3.get_shape().ndims) + @test_util.run_deprecated_v1 def testRandomNormal(self): # Fully known shape. rnd1 = random_ops.random_normal([1, 2, 3]) @@ -419,6 +440,7 @@ class RandomShapeTest(test.TestCase): rnd3 = random_ops.random_normal(array_ops.placeholder(dtypes.int32)) self.assertIs(None, rnd3.get_shape().ndims) + @test_util.run_deprecated_v1 def testRandomUniform(self): # Fully known shape. rnd1 = random_ops.random_uniform([1, 2, 3]) diff --git a/tensorflow/python/kernel_tests/random/random_poisson_test.py b/tensorflow/python/kernel_tests/random/random_poisson_test.py index 47c0858db74..0a6b004d682 100644 --- a/tensorflow/python/kernel_tests/random/random_poisson_test.py +++ b/tensorflow/python/kernel_tests/random/random_poisson_test.py @@ -23,6 +23,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.platform import test @@ -104,6 +105,7 @@ class RandomPoissonTest(test.TestCase): # Checks that the CPU and GPU implementation returns the same results, # given the same random seed + @test_util.run_deprecated_v1 def testCPUGPUMatch(self): for dt in _SUPPORTED_DTYPES: results = {} @@ -115,12 +117,14 @@ class RandomPoissonTest(test.TestCase): else: self.assertAllClose(results[False], results[True], rtol=1e-6, atol=1e-6) + @test_util.run_deprecated_v1 def testSeed(self): for dt in dtypes.float16, dtypes.float32, dtypes.float64: sx = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345) sy = self._Sampler(1000, 1.0, dt, use_gpu=True, seed=345) self.assertAllEqual(sx(), sy()) + @test_util.run_deprecated_v1 def testNoCSE(self): """CSE = constant subexpression eliminator. @@ -142,6 +146,7 @@ class RandomPoissonTest(test.TestCase): self.assertEqual([0], rnd.get_shape().as_list()) self.assertAllClose(np.array([], dtype=np.float32), self.evaluate(rnd)) + @test_util.run_deprecated_v1 def testShape(self): # Fully known shape rnd = random_ops.random_poisson(2.0, [150], seed=12345) @@ -184,6 +189,7 @@ class RandomPoissonTest(test.TestCase): seed=12345) self.assertIs(None, rnd.get_shape().ndims) + @test_util.run_deprecated_v1 def testDTypeCombinationsV2(self): """Tests random_poisson_v2() for all supported dtype combinations.""" with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/random/stateless_random_ops_test.py b/tensorflow/python/kernel_tests/random/stateless_random_ops_test.py index 071d6c29984..898f38444b7 100644 --- a/tensorflow/python/kernel_tests/random/stateless_random_ops_test.py +++ b/tensorflow/python/kernel_tests/random/stateless_random_ops_test.py @@ -129,23 +129,29 @@ class StatelessOpsTest(test.TestCase): yield (functools.partial(stateless.stateless_multinomial, **kwds), functools.partial(random_ops.multinomial, **kwds)) + @test_util.run_deprecated_v1 def testMatchFloat(self): self._test_match(self._float_cases()) + @test_util.run_deprecated_v1 def testMatchInt(self): self._test_match(self._int_cases()) + @test_util.run_deprecated_v1 def testMatchMultinomial(self): self._test_match(self._multinomial_cases()) + @test_util.run_deprecated_v1 def testDeterminismFloat(self): self._test_determinism( self._float_cases(shape_dtypes=(dtypes.int32, dtypes.int64))) + @test_util.run_deprecated_v1 def testDeterminismInt(self): self._test_determinism( self._int_cases(shape_dtypes=(dtypes.int32, dtypes.int64))) + @test_util.run_deprecated_v1 def testDeterminismMultinomial(self): self._test_determinism(self._multinomial_cases()) diff --git a/tensorflow/python/kernel_tests/reader_ops_test.py b/tensorflow/python/kernel_tests/reader_ops_test.py index a4a18c52194..43d15817e97 100644 --- a/tensorflow/python/kernel_tests/reader_ops_test.py +++ b/tensorflow/python/kernel_tests/reader_ops_test.py @@ -28,6 +28,7 @@ import zlib from tensorflow.core.protobuf import config_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.lib.io import tf_record from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import io_ops @@ -145,6 +146,7 @@ class IdentityReaderTest(test.TestCase): self.assertAllEqual(expected, k) self.assertAllEqual(expected, v) + @test_util.run_deprecated_v1 def testOneEpoch(self): reader = io_ops.IdentityReader("test_reader") work_completed = reader.num_work_units_completed() @@ -178,6 +180,7 @@ class IdentityReaderTest(test.TestCase): self.assertAllEqual(3, self.evaluate(produced)) self.assertAllEqual(0, self.evaluate(queued_length)) + @test_util.run_deprecated_v1 def testMultipleEpochs(self): reader = io_ops.IdentityReader("test_reader") queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=()) @@ -198,6 +201,7 @@ class IdentityReaderTest(test.TestCase): "\\(requested 1, current size 0\\)"): self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testSerializeRestore(self): reader = io_ops.IdentityReader("test_reader") produced = reader.num_records_produced() @@ -252,6 +256,7 @@ class IdentityReaderTest(test.TestCase): "Could not parse state for IdentityReader 'test_reader'"): self.evaluate(reader.restore_state(b"BOGUS" + state[5:])) + @test_util.run_deprecated_v1 def testReset(self): reader = io_ops.IdentityReader("test_reader") work_completed = reader.num_work_units_completed() @@ -302,6 +307,7 @@ class WholeFileReaderTest(test.TestCase): self.assertAllEqual(compat.as_bytes(self._filenames[index]), k) self.assertAllEqual(self._content[index], v) + @test_util.run_deprecated_v1 def testOneEpoch(self): reader = io_ops.WholeFileReader("test_reader") queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=()) @@ -317,6 +323,7 @@ class WholeFileReaderTest(test.TestCase): "\\(requested 1, current size 0\\)"): self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testInfiniteEpochs(self): reader = io_ops.WholeFileReader("test_reader") queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=()) @@ -376,12 +383,15 @@ class TextLineReaderTest(test.TestCase): "\\(requested 1, current size 0\\)"): k, v = self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testOneEpochLF(self): self._testOneEpoch(self._CreateFiles(crlf=False)) + @test_util.run_deprecated_v1 def testOneEpochCRLF(self): self._testOneEpoch(self._CreateFiles(crlf=True)) + @test_util.run_deprecated_v1 def testSkipHeaderLines(self): files = self._CreateFiles() reader = io_ops.TextLineReader(skip_header_lines=1, name="test_reader") @@ -562,6 +572,7 @@ class FixedLengthRecordReaderTest(TFCompressionTestCase): "\\(requested 1, current size 0\\)"): k, v = self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testOneEpoch(self): for num_records in [0, 7]: # gap_bytes=0: hop_bytes=0 @@ -570,6 +581,7 @@ class FixedLengthRecordReaderTest(TFCompressionTestCase): files = self._CreateFiles(num_records, gap_bytes) self._TestOneEpoch(files, num_records, gap_bytes) + @test_util.run_deprecated_v1 def testGzipOneEpoch(self): for num_records in [0, 7]: # gap_bytes=0: hop_bytes=0 @@ -578,6 +590,7 @@ class FixedLengthRecordReaderTest(TFCompressionTestCase): files = self._CreateGzipFiles(num_records, gap_bytes) self._TestOneEpoch(files, num_records, gap_bytes, encoding="GZIP") + @test_util.run_deprecated_v1 def testZlibOneEpoch(self): for num_records in [0, 7]: # gap_bytes=0: hop_bytes=0 @@ -586,17 +599,20 @@ class FixedLengthRecordReaderTest(TFCompressionTestCase): files = self._CreateZlibFiles(num_records, gap_bytes) self._TestOneEpoch(files, num_records, gap_bytes, encoding="ZLIB") + @test_util.run_deprecated_v1 def testOneEpochWithHopBytes(self): for num_overlapped_records in [0, 2]: files = self._CreateOverlappedRecordFiles(num_overlapped_records) self._TestOneEpochWithHopBytes(files, num_overlapped_records) + @test_util.run_deprecated_v1 def testGzipOneEpochWithHopBytes(self): for num_overlapped_records in [0, 2]: files = self._CreateGzipOverlappedRecordFiles(num_overlapped_records,) self._TestOneEpochWithHopBytes( files, num_overlapped_records, encoding="GZIP") + @test_util.run_deprecated_v1 def testZlibOneEpochWithHopBytes(self): for num_overlapped_records in [0, 2]: files = self._CreateZlibOverlappedRecordFiles(num_overlapped_records) @@ -609,6 +625,7 @@ class TFRecordReaderTest(TFCompressionTestCase): def setUp(self): super(TFRecordReaderTest, self).setUp() + @test_util.run_deprecated_v1 def testOneEpoch(self): files = self._CreateFiles() reader = io_ops.TFRecordReader(name="test_reader") @@ -627,6 +644,7 @@ class TFRecordReaderTest(TFCompressionTestCase): "\\(requested 1, current size 0\\)"): k, v = self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testReadUpTo(self): files = self._CreateFiles() reader = io_ops.TFRecordReader(name="test_reader") @@ -654,6 +672,7 @@ class TFRecordReaderTest(TFCompressionTestCase): self.assertEqual(self._num_files * self._num_records, num_k) self.assertEqual(self._num_files * self._num_records, num_v) + @test_util.run_deprecated_v1 def testReadZlibFiles(self): options = tf_record.TFRecordOptions(TFRecordCompressionType.ZLIB) files = self._CreateFiles(options) @@ -670,6 +689,7 @@ class TFRecordReaderTest(TFCompressionTestCase): self.assertTrue(compat.as_text(k).startswith("%s:" % files[i])) self.assertAllEqual(self._Record(i, j), v) + @test_util.run_deprecated_v1 def testReadGzipFiles(self): options = tf_record.TFRecordOptions(TFRecordCompressionType.GZIP) files = self._CreateFiles(options) @@ -689,6 +709,7 @@ class TFRecordReaderTest(TFCompressionTestCase): class AsyncReaderTest(test.TestCase): + @test_util.run_deprecated_v1 def testNoDeadlockFromQueue(self): """Tests that reading does not block main execution threads.""" config = config_pb2.ConfigProto( @@ -737,6 +758,7 @@ class LMDBReaderTest(test.TestCase): self.db_path = os.path.join(self.get_temp_dir(), "data.mdb") shutil.copy(path, self.db_path) + @test_util.run_deprecated_v1 def testReadFromFile(self): reader = io_ops.LMDBReader(name="test_read_from_file") queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=()) @@ -754,6 +776,7 @@ class LMDBReaderTest(test.TestCase): "\\(requested 1, current size 0\\)"): k, v = self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testReadFromSameFile(self): with self.cached_session() as sess: reader1 = io_ops.LMDBReader(name="test_read_from_same_file1") @@ -773,6 +796,7 @@ class LMDBReaderTest(test.TestCase): coord.request_stop() coord.join(threads) + @test_util.run_deprecated_v1 def testReadFromFolder(self): reader = io_ops.LMDBReader(name="test_read_from_folder") queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=()) @@ -790,6 +814,7 @@ class LMDBReaderTest(test.TestCase): "\\(requested 1, current size 0\\)"): k, v = self.evaluate([key, value]) + @test_util.run_deprecated_v1 def testReadFromFileRepeatedly(self): with self.cached_session() as sess: reader = io_ops.LMDBReader(name="test_read_from_file_repeated") diff --git a/tensorflow/python/kernel_tests/record_input_test.py b/tensorflow/python/kernel_tests/record_input_test.py index 74020667d93..ad8188b372f 100644 --- a/tensorflow/python/kernel_tests/record_input_test.py +++ b/tensorflow/python/kernel_tests/record_input_test.py @@ -20,6 +20,7 @@ from __future__ import print_function import os +from tensorflow.python.framework import test_util from tensorflow.python.framework.errors_impl import NotFoundError from tensorflow.python.lib.io import tf_record from tensorflow.python.ops import data_flow_ops @@ -94,6 +95,7 @@ class RecordInputOpTest(test.TestCase): self.assertEqual(self.evaluate(yield_op), b"0000000000") + @test_util.run_deprecated_v1 def testRecordInputEpochs(self): files = 100 records_per_file = 100 @@ -140,6 +142,7 @@ class RecordInputOpTest(test.TestCase): for _ in range(50): self.evaluate(yield_op) + @test_util.run_deprecated_v1 def testEmptyGlob(self): with self.cached_session() as sess: record_input = data_flow_ops.RecordInput(file_pattern="foo") @@ -148,6 +151,7 @@ class RecordInputOpTest(test.TestCase): with self.assertRaises(NotFoundError): self.evaluate(yield_op) + @test_util.run_deprecated_v1 def testBufferTooSmall(self): files = 10 records_per_file = 10 diff --git a/tensorflow/python/kernel_tests/reduce_join_op_test.py b/tensorflow/python/kernel_tests/reduce_join_op_test.py index c26e62738c1..49b6620779e 100644 --- a/tensorflow/python/kernel_tests/reduce_join_op_test.py +++ b/tensorflow/python/kernel_tests/reduce_join_op_test.py @@ -25,6 +25,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -230,6 +231,7 @@ class ReduceJoinTest(UnicodeTestCase): axis=1, separator=" ") + @test_util.run_deprecated_v1 def testUnknownShape(self): input_array = [["a"], ["b"]] truth = ["ab"] @@ -241,6 +243,7 @@ class ReduceJoinTest(UnicodeTestCase): self.assertAllEqualUnicode(truth, output_array) self.assertAllEqual(truth_shape, reduced.get_shape()) + @test_util.run_deprecated_v1 def testUnknownIndices(self): input_array = [["this", "is", "a", "test"], ["please", "do", "not", "panic"]] @@ -297,6 +300,7 @@ class ReduceJoinTest(UnicodeTestCase): for permutation in itertools.permutations(xrange(num_dims), i): self._testMultipleReduceJoin(input_array, axis=permutation) + @test_util.run_deprecated_v1 def testInvalidReductionIndices(self): with self.cached_session(): with self.assertRaisesRegexp(ValueError, "Invalid reduction dim"): @@ -325,6 +329,7 @@ class ReduceJoinTest(UnicodeTestCase): output_shape = self.evaluate(output).shape self.assertAllEqual([0], output_shape) + @test_util.run_deprecated_v1 def testInvalidArgsUnknownShape(self): with self.cached_session(): placeholder = array_ops.placeholder(dtypes.string, name="placeholder") @@ -335,6 +340,7 @@ class ReduceJoinTest(UnicodeTestCase): with self.assertRaisesOpError("Duplicate reduction dimension 1"): duplicate_index.eval(feed_dict={placeholder.name: [[""]]}) + @test_util.run_deprecated_v1 def testInvalidArgsUnknownIndices(self): with self.cached_session(): placeholder = array_ops.placeholder(dtypes.int32, name="placeholder") diff --git a/tensorflow/python/kernel_tests/reduction_ops_test.py b/tensorflow/python/kernel_tests/reduction_ops_test.py index 4eb329796e1..67a89461f3a 100644 --- a/tensorflow/python/kernel_tests/reduction_ops_test.py +++ b/tensorflow/python/kernel_tests/reduction_ops_test.py @@ -27,6 +27,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops @@ -60,6 +61,7 @@ class ReducedShapeTest(test.TestCase): output = math_ops.reduced_shape(shape, axes=axes) self.assertAllEqual(output.eval(), result) + @test_util.run_deprecated_v1 def testSimple(self): with self.cached_session(): self._check([3], [], [3]) @@ -69,6 +71,7 @@ class ReducedShapeTest(test.TestCase): self._check([5, 3], [1], [5, 1]) self._check([5, 3], [0, 1], [1, 1]) + @test_util.run_deprecated_v1 def testZeros(self): """Check that reduced_shape does the right thing with zero dimensions.""" with self.cached_session(): @@ -83,6 +86,7 @@ class ReducedShapeTest(test.TestCase): self._check([3, 0], [1], [3, 1]) self._check([3, 0], [0, 1], [1, 1]) + @test_util.run_deprecated_v1 def testNegAxes(self): with self.cached_session(): self._check([10, 10, 10], [-1], [10, 10, 1]) @@ -94,6 +98,7 @@ class ReducedShapeTest(test.TestCase): class ReductionUnknownShape(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session(): for dtype, reductions in [(dtypes.float32, @@ -188,6 +193,7 @@ class SumReductionTest(BaseReductionTest): tf_v = self.evaluate(v) self.assertAllEqual(tf_v, 0) + @test_util.run_deprecated_v1 def testInfinity(self): for dtype in [np.float32, np.float64]: for special_value_x in [-np.inf, np.inf]: @@ -195,11 +201,13 @@ class SumReductionTest(BaseReductionTest): np_arr = np.array([special_value_x, special_value_y]).astype(dtype) self._compareAll(np_arr, None) + @test_util.run_deprecated_v1 def testInt32(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.int32) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testFloat16(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float16) @@ -219,6 +227,7 @@ class SumReductionTest(BaseReductionTest): tf_out_mean = self.evaluate(tf_mean) self.assertAllClose(tf_out_mean, 1.) + @test_util.run_deprecated_v1 def testFloat32(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float32) @@ -256,21 +265,25 @@ class SumReductionTest(BaseReductionTest): self.assertAllClose(sum_y, tf_out_sum_y) self.assertAllClose(sum_xz, tf_out_sum_xz) + @test_util.run_deprecated_v1 def testFloat64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex128(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex128) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testInvalidIndex(self): np_arr = np.arange(0, 10).reshape([2, 5]).astype(np.float32) input_tensor = ops.convert_to_tensor(np_arr) @@ -284,6 +297,7 @@ class SumReductionTest(BaseReductionTest): ValueError, lambda e: "Invalid reduction dimension" in str(e)): math_ops.reduce_sum(input_tensor, [0, 2]) + @test_util.run_deprecated_v1 def testPartialShapes(self): np.random.seed(1618) @@ -317,6 +331,7 @@ class SumReductionTest(BaseReductionTest): c_unknown_indices, unknown_indices, keepdims=True) self.assertEqual(2, s_unknown_indices_keep.get_shape().rank) + @test_util.run_deprecated_v1 def testWrongShapeForReductionIndices(self): reduction_axes = [[1], [2]] c_unknown = array_ops.placeholder(dtypes.float32) @@ -326,6 +341,7 @@ class SumReductionTest(BaseReductionTest): # Int64?? + @test_util.run_deprecated_v1 def testGradient(self): for dtype in [ dtypes.float32, dtypes.float64, dtypes.complex64, dtypes.complex128 @@ -333,6 +349,7 @@ class SumReductionTest(BaseReductionTest): x = self._makeIncremental([2, 3, 4, 2], dtype) self._compareGradientAxes(x) + @test_util.run_deprecated_v1 def testHighRank(self): # Do a bunch of random high dimensional reductions np.random.seed(42) @@ -350,11 +367,13 @@ class SumReductionTest(BaseReductionTest): np.arange(1, rank, 2)): self._compareAll(data, axes) + @test_util.run_deprecated_v1 def testExpand(self): # Reduce an empty tensor to a nonempty tensor x = np.zeros((5, 0)) self._compareAll(x, [1]) + @test_util.run_deprecated_v1 def testEmptyGradients(self): with self.session(use_gpu=True): x = array_ops.zeros([0, 3]) @@ -362,6 +381,7 @@ class SumReductionTest(BaseReductionTest): error = gradient_checker.compute_gradient_error(x, [0, 3], y, [0]) self.assertEqual(error, 0) + @test_util.run_deprecated_v1 def testDegenerate(self): with self.session(use_gpu=True): for dtype in (dtypes.float16, dtypes.float32, dtypes.float64, @@ -403,6 +423,7 @@ class MeanReductionTest(BaseReductionTest): tf_v = self.evaluate(v) self.assertAllEqual(tf_v, 0) + @test_util.run_deprecated_v1 def testInfinity(self): for dtype in [np.float32, np.float64]: for special_value_x in [-np.inf, np.inf]: @@ -410,37 +431,44 @@ class MeanReductionTest(BaseReductionTest): np_arr = np.array([special_value_x, special_value_y]).astype(dtype) self._compareAll(np_arr, None) + @test_util.run_deprecated_v1 def testInt32(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.int32) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testFloat32(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float32) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testFloat64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex128(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex128) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testGradient(self): s = [2, 3, 4, 2] for dtype in [dtypes.float32, dtypes.float64]: x = self._makeIncremental(s, dtype) self._compareGradientAxes(x, rtol=1e-3, atol=1e-3) + @test_util.run_deprecated_v1 def testEmptyGradients(self): with self.session(use_gpu=True): x = array_ops.zeros([0, 3]) @@ -448,6 +476,7 @@ class MeanReductionTest(BaseReductionTest): error = gradient_checker.compute_gradient_error(x, [0, 3], y, [0]) self.assertEqual(error, 0) + @test_util.run_deprecated_v1 def testDegenerate(self): with self.session(use_gpu=True): for dtype in (dtypes.float16, dtypes.float32, dtypes.float64): @@ -476,6 +505,7 @@ class ProdReductionTest(BaseReductionTest): tf_v = self.evaluate(v) self.assertAllEqual(tf_v, 0) + @test_util.run_deprecated_v1 def testInfinity(self): for dtype in [np.float32, np.float64]: for special_value_x in [-np.inf, np.inf]: @@ -483,6 +513,7 @@ class ProdReductionTest(BaseReductionTest): np_arr = np.array([special_value_x, special_value_y]).astype(dtype) self._compareAll(np_arr, None) + @test_util.run_deprecated_v1 def testInt32(self): # Numpy automatically upgrades the type of np.prod from int32 to int64, so # Numpy does not overflow an int32 np.prod while TensorFlow does. To avoid @@ -491,26 +522,31 @@ class ProdReductionTest(BaseReductionTest): np_arr = self._makeIncremental((2,) * rank, dtypes.int32) / 2 self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testFloat32(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float32) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testFloat64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.float64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex64(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex64) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testComplex128(self): for rank in range(1, _MAX_RANK + 1): np_arr = self._makeIncremental((2,) * rank, dtypes.complex128) self._compareAllAxes(np_arr) + @test_util.run_deprecated_v1 def testGradientWithZeros(self): s = [2, 3, 4, 2] x = self._makeIncremental(s, dtypes.float32) / 20. @@ -533,6 +569,7 @@ class ProdReductionTest(BaseReductionTest): x4[:, :, :, :] = 0 self._compareGradientAxes(x4, rtol=1e-3, atol=1e-3) + @test_util.run_deprecated_v1 def testEmptyGradients(self): with self.session(use_gpu=True): x = array_ops.zeros([0, 3]) @@ -540,6 +577,7 @@ class ProdReductionTest(BaseReductionTest): error = gradient_checker.compute_gradient_error(x, [0, 3], y, [0]) self.assertEqual(error, 0) + @test_util.run_deprecated_v1 def testDegenerate(self): with self.session(use_gpu=True): for dtype in (dtypes.float16, dtypes.float32, dtypes.float64): @@ -579,6 +617,7 @@ class MinReductionTest(test.TestCase): tf_v = self.evaluate(v) self.assertAllEqual(tf_v, 0) + @test_util.run_deprecated_v1 def testInfinity(self): for dtype in [np.float32, np.float64]: for special_value_x in [-np.inf, np.inf]: @@ -614,6 +653,7 @@ class MinReductionTest(test.TestCase): self._compareAll(np_arr, [0, 2]) self._compareAll(np_arr, [0, 1, 2]) + @test_util.run_deprecated_v1 def testGradient(self): s = [2, 3, 4, 2] x = np.arange(1.0, 49.0).reshape(s).astype(np.float64) @@ -624,6 +664,7 @@ class MinReductionTest(test.TestCase): t, s, su, [2, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient2(self): s = [2, 3, 4, 2] x = np.arange(1.0, 49.0).reshape(s).astype(np.float64) @@ -634,6 +675,7 @@ class MinReductionTest(test.TestCase): t, s, su, [2, 4, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient3(self): s = [2, 3, 4, 2] x = np.arange(1.0, 49.0).reshape(s).astype(np.float64) @@ -644,6 +686,7 @@ class MinReductionTest(test.TestCase): t, s, su, [2, 3, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient4(self): s = [2, 3, 4, 2] x = np.arange(1.0, 49.0).reshape(s).astype(np.float64) @@ -654,6 +697,7 @@ class MinReductionTest(test.TestCase): t, s, su, [1], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testEmptyGradients(self): with self.cached_session(): x = array_ops.zeros([0, 3]) @@ -692,6 +736,7 @@ class MaxReductionTest(test.TestCase): tf_v = self.evaluate(v) self.assertAllEqual(tf_v, 0) + @test_util.run_deprecated_v1 def testInfinity(self): for dtype in [np.float32, np.float64]: for special_value_x in [-np.inf, np.inf]: @@ -741,6 +786,7 @@ class MaxReductionTest(test.TestCase): self._compareAll(np_arr, [0, 2]) self._compareAll(np_arr, [0, 1, 2]) + @test_util.run_deprecated_v1 def testGradient(self): s = [2, 3, 4, 2] x = np.arange(-49.0, -1.0).reshape(s).astype(np.float64) @@ -751,6 +797,7 @@ class MaxReductionTest(test.TestCase): t, s, su, [2, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient2(self): s = [2, 3, 4, 2] x = np.arange(-49.0, -1.0).reshape(s).astype(np.float64) @@ -761,6 +808,7 @@ class MaxReductionTest(test.TestCase): t, s, su, [2, 4, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient3(self): s = [2, 3, 4, 2] x = np.arange(-49.0, -1.0).reshape(s).astype(np.float64) @@ -771,6 +819,7 @@ class MaxReductionTest(test.TestCase): t, s, su, [2, 3, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient4(self): s = [2, 3, 4, 2] x = np.arange(-49.0, -1.0).reshape(s).astype(np.float64) @@ -781,6 +830,7 @@ class MaxReductionTest(test.TestCase): t, s, su, [1], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testEmptyGradients(self): with self.cached_session(): x = array_ops.zeros([0, 3]) @@ -913,6 +963,7 @@ class CountNonzeroReductionTest(test.TestCase): self._compare(x, reduction_axes, True, use_gpu=True, feed_dict=feed_dict) self._compare(x, reduction_axes, True, use_gpu=False, feed_dict=feed_dict) + @test_util.run_deprecated_v1 def testBoolReduce1D(self): # Create a 1D array of floats np_arr = np.asarray([False, False, True, False, False, True]) @@ -920,11 +971,13 @@ class CountNonzeroReductionTest(test.TestCase): self._compareAll(np_arr, []) self._compareAll(np_arr, [0]) + @test_util.run_deprecated_v1 def testFloatReduce1D(self): # Create a 1D array of floats np_arr = np.asarray([0.0, 1.0, -1.0, 0.0, 0.0, 3.0]).astype(np.float32) self._compareAll(np_arr, [0]) + @test_util.run_deprecated_v1 def testFloatReduce4D(self): # Create a 4D array of floats and reduce across some # dimensions @@ -944,11 +997,13 @@ class CountNonzeroReductionTest(test.TestCase): self._compareAll(np_arr, [1, 2, 3]) self._compareAll(np_arr, [0, 1, 2, 3]) + @test_util.run_deprecated_v1 def testExpand(self): # Reduce an empty tensor to a nonempty tensor x = np.zeros((5, 0)) self._compareAll(x, [1]) + @test_util.run_deprecated_v1 def testDegenerate(self): for use_gpu in False, True: with self.cached_session(use_gpu=use_gpu): @@ -964,6 +1019,7 @@ class CountNonzeroReductionTest(test.TestCase): v = math_ops.count_nonzero(constant_op.constant(["test"])) self.assertAllClose(self.evaluate(v), 1) + @test_util.run_deprecated_v1 def testStringReduce1D(self): # Create a 1D array of strings x = np.asarray(["", "", "a", "", "", "b"]) @@ -974,6 +1030,7 @@ class CountNonzeroReductionTest(test.TestCase): self._compare(x, [], keepdims=True, zero=np.str("")) self._compare(x, [0], keepdims=True, zero=np.str("")) + @test_util.run_deprecated_v1 def testStringReduce2D(self): # Create a 2D array of strings x = np.asarray([["", "", "a", "", "", "b"], diff --git a/tensorflow/python/kernel_tests/regex_full_match_op_test.py b/tensorflow/python/kernel_tests/regex_full_match_op_test.py index 4edd3e98d9b..488ec85ab2c 100644 --- a/tensorflow/python/kernel_tests/regex_full_match_op_test.py +++ b/tensorflow/python/kernel_tests/regex_full_match_op_test.py @@ -23,6 +23,7 @@ from absl.testing import parameterized from tensorflow.python.compat import compat from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_string_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -33,6 +34,7 @@ from tensorflow.python.platform import test (gen_string_ops.static_regex_full_match)) class RegexFullMatchOpVariantsTest(test.TestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testRegexFullMatch(self, op): values = ["abaaba", "abcdabcde"] with self.cached_session(): @@ -40,6 +42,7 @@ class RegexFullMatchOpVariantsTest(test.TestCase, parameterized.TestCase): matched = op(input_tensor, "a.*a").eval() self.assertAllEqual([True, False], matched) + @test_util.run_deprecated_v1 def testRegexFullMatchTwoDims(self, op): values = [["abaaba", "abcdabcde"], ["acdcba", "ebcda"]] with self.cached_session(): @@ -47,6 +50,7 @@ class RegexFullMatchOpVariantsTest(test.TestCase, parameterized.TestCase): matched = op(input_tensor, "a.*a").eval() self.assertAllEqual([[True, False], [True, False]], matched) + @test_util.run_deprecated_v1 def testEmptyMatch(self, op): values = ["abc", "1"] with self.cached_session(): @@ -54,6 +58,7 @@ class RegexFullMatchOpVariantsTest(test.TestCase, parameterized.TestCase): matched = op(input_tensor, "").eval() self.assertAllEqual([False, False], matched) + @test_util.run_deprecated_v1 def testInvalidPattern(self, op): values = ["abc", "1"] with self.cached_session(): @@ -66,6 +71,7 @@ class RegexFullMatchOpVariantsTest(test.TestCase, parameterized.TestCase): class RegexFullMatchOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testRegexFullMatchDelegation(self): with compat.forward_compatibility_horizon(2018, 11, 1): with self.cached_session(): @@ -78,6 +84,7 @@ class RegexFullMatchOpTest(test.TestCase): op_tensor = string_ops.regex_full_match(input_tensor, pattern_tensor) self.assertTrue(op_tensor.name.startswith("RegexFullMatch"), op.name) + @test_util.run_deprecated_v1 def testStaticRegexFullMatchDelegation(self): with compat.forward_compatibility_horizon(2018, 11, 20): with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/regex_replace_op_test.py b/tensorflow/python/kernel_tests/regex_replace_op_test.py index ce9a1b5279f..6c7dfee7b40 100644 --- a/tensorflow/python/kernel_tests/regex_replace_op_test.py +++ b/tensorflow/python/kernel_tests/regex_replace_op_test.py @@ -22,6 +22,7 @@ from absl.testing import parameterized from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_string_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -32,6 +33,7 @@ from tensorflow.python.platform import test (gen_string_ops.static_regex_replace)) class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testForwarding(self, op): with self.cached_session(): # Generate an input that is uniquely consumed by the regex op. @@ -45,6 +47,7 @@ class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): stripped = op(inp, "\\p{Ll}", ".").eval() self.assertAllEqual([b"A.C.E", b"H.J.L"], stripped) + @test_util.run_deprecated_v1 def testRemovePrefix(self, op): values = ["a:foo", "a:bar", "a:foo", "b:baz", "b:qux", "ca:b"] with self.cached_session(): @@ -53,6 +56,7 @@ class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): self.assertAllEqual([b"foo", b"bar", b"foo", b"baz", b"qux", b"ca:b"], stripped) + @test_util.run_deprecated_v1 def testRegexReplace(self, op): values = ["aba\naba", "abcdabcde"] with self.cached_session(): @@ -60,6 +64,7 @@ class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): stripped = op(input_vector, "a.*a", "(\\0)").eval() self.assertAllEqual([b"(aba)\n(aba)", b"(abcda)bcde"], stripped) + @test_util.run_deprecated_v1 def testEmptyMatch(self, op): values = ["abc", "1"] with self.cached_session(): @@ -67,6 +72,7 @@ class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): stripped = op(input_vector, "", "x").eval() self.assertAllEqual([b"xaxbxcx", b"x1x"], stripped) + @test_util.run_deprecated_v1 def testInvalidPattern(self, op): values = ["abc", "1"] with self.cached_session(): @@ -76,6 +82,7 @@ class RegexReplaceOpVariantsTest(test.TestCase, parameterized.TestCase): with self.assertRaisesOpError("Invalid pattern"): self.evaluate(replace) + @test_util.run_deprecated_v1 def testGlobal(self, op): values = ["ababababab", "abcabcabc", ""] with self.cached_session(): @@ -98,6 +105,7 @@ class RegexReplaceTest(test.TestCase, parameterized.TestCase): (as_string, as_tensor), (as_tensor, as_string), (as_tensor, as_tensor)) + @test_util.run_deprecated_v1 def testRegexReplaceDelegation(self, pattern_fn, rewrite_fn): with self.cached_session(): input_vector = constant_op.constant("foo", dtypes.string) @@ -106,6 +114,7 @@ class RegexReplaceTest(test.TestCase, parameterized.TestCase): op = string_ops.regex_replace(input_vector, pattern, replace) self.assertTrue(op.name.startswith("RegexReplace")) + @test_util.run_deprecated_v1 def testStaticRegexReplaceDelegation(self): with self.cached_session(): input_vector = constant_op.constant("foo", dtypes.string) diff --git a/tensorflow/python/kernel_tests/relu_op_test.py b/tensorflow/python/kernel_tests/relu_op_test.py index 30cef908853..55e68f4884c 100644 --- a/tensorflow/python/kernel_tests/relu_op_test.py +++ b/tensorflow/python/kernel_tests/relu_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -105,6 +106,7 @@ class ReluTest(test.TestCase): # The gradient test for ReLU is a bit tricky as the derivative is not well # defined at around zero and we want to avoid that in terms of input values. + @test_util.run_deprecated_v1 def testGradientFloat32(self): with self.cached_session(): x = constant_op.constant( @@ -124,6 +126,7 @@ class ReluTest(test.TestCase): # The gradient for fp16 is inaccurate due to the low-precision. # Instead of relying on compute_gradient_error, we compare the fp16 analytical # gradient against their fp32 counterpart. + @test_util.run_deprecated_v1 def testGradientFloat16(self): with self.session(use_gpu=True) as sess: # Randomly construct a 1D shape from [1, 40) @@ -150,6 +153,7 @@ class ReluTest(test.TestCase): dx_f32_v, dx_f16_v = self.evaluate([dx_f32, dx_f16]) self.assertAllClose(dx_f32_v, dx_f16_v, atol=3e-4) + @test_util.run_deprecated_v1 def testGradientFloat64(self): with self.cached_session(): x = constant_op.constant( @@ -167,6 +171,7 @@ class ReluTest(test.TestCase): print("relu (float64) gradient err = ", err) self.assertLess(err, 1e-10) + @test_util.run_deprecated_v1 def testGradGradFloat32(self): with self.cached_session(): x = constant_op.constant( @@ -184,6 +189,7 @@ class ReluTest(test.TestCase): print("relu (float32) gradient of gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGradFloat64(self): with self.cached_session(): x = constant_op.constant( @@ -252,6 +258,7 @@ class Relu6Test(test.TestCase): # The gradient test for ReLU6 is a bit tricky as the derivative is # not well defined at around zero and six and we want to avoid that # in terms of input values. + @test_util.run_deprecated_v1 def testGradientFloat32(self): with self.cached_session(): x = constant_op.constant( @@ -268,6 +275,7 @@ class Relu6Test(test.TestCase): print("relu6 (float32) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientFloat64(self): with self.cached_session(): x = constant_op.constant( @@ -325,6 +333,7 @@ class LeakyReluTest(test.TestCase): # The gradient test for Leaky ReLU is a bit tricky as the derivative is not # well defined at around zero and we want to avoid that in terms of input # values. + @test_util.run_deprecated_v1 def testGradientFloat32(self): with self.test_session(): x = constant_op.constant( @@ -341,6 +350,7 @@ class LeakyReluTest(test.TestCase): print("leaky_relu (float32) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientFloat64(self): with self.test_session(): x = constant_op.constant( @@ -358,6 +368,7 @@ class LeakyReluTest(test.TestCase): print("leaky_relu (float64) gradient err = ", err) self.assertLess(err, 1e-10) + @test_util.run_deprecated_v1 def testGradGradFloat32(self): with compat.forward_compatibility_horizon(2018, 11, 2): with self.test_session(): @@ -376,6 +387,7 @@ class LeakyReluTest(test.TestCase): print("leaky_relu (float32) gradient of gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGradFloat64(self): with compat.forward_compatibility_horizon(2018, 11, 2): with self.test_session(): @@ -439,6 +451,7 @@ class EluTest(test.TestCase): for t in [np.float16, np.float32, np.float64]: self._testElu(np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t)) + @test_util.run_deprecated_v1 def testGradientFloat32(self): with self.cached_session(): x_val = [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]] @@ -450,6 +463,7 @@ class EluTest(test.TestCase): print("elu (float32) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientFloat64(self): with self.cached_session(): x_val = [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]] @@ -461,6 +475,7 @@ class EluTest(test.TestCase): print("elu (float64) gradient err = ", err) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testGradGrad(self): with self.cached_session(): x = array_ops.placeholder(dtype=dtypes.float32) @@ -472,6 +487,7 @@ class EluTest(test.TestCase): err = np.abs(gg.eval(feed_dict={x: x_val}) - _elu_grad_grad(x_val)) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGradFloat32(self): with self.cached_session(): x = constant_op.constant( @@ -489,6 +505,7 @@ class EluTest(test.TestCase): print("elu (float32) gradient of gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGradFloat64(self): with self.cached_session(): x = constant_op.constant( @@ -539,6 +556,7 @@ class SeluTest(test.TestCase): self._testSelu( np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t)) + @test_util.run_deprecated_v1 def testGradientFloat32(self): with self.cached_session(): x_val = [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]] @@ -550,6 +568,7 @@ class SeluTest(test.TestCase): print("selu (float32) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradientFloat64(self): with self.cached_session(): x_val = [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]] @@ -561,6 +580,7 @@ class SeluTest(test.TestCase): print("selu (float64) gradient err = ", err) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testGradGradFloat32(self): with self.cached_session(): x = constant_op.constant( @@ -578,6 +598,7 @@ class SeluTest(test.TestCase): print("selu (float32) gradient of gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGradFloat64(self): with self.cached_session(): x = constant_op.constant( diff --git a/tensorflow/python/kernel_tests/reshape_op_test.py b/tensorflow/python/kernel_tests/reshape_op_test.py index 84539c2b02a..db3e88a104f 100644 --- a/tensorflow/python/kernel_tests/reshape_op_test.py +++ b/tensorflow/python/kernel_tests/reshape_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.platform import test @@ -91,6 +92,7 @@ class ReshapeTest(test.TestCase): # TODO(vrv): Add tests for failure conditions once python test_util # reports errors. + @test_util.run_deprecated_v1 def testFloatReshapeGradThreeDimensions(self): x = np.arange(1., 25.).reshape([2, 3, 4]).astype(np.float32) s = list(np.shape(x)) @@ -111,6 +113,7 @@ class ReshapeTest(test.TestCase): self._testBothReshape(x, [0, 0, 0]) self._testBothReshape(x, [1, -1, 5]) + @test_util.run_deprecated_v1 def testErrors(self): y = constant_op.constant(0.0, shape=[23, 29, 31]) with self.assertRaisesRegexp(ValueError, "must be evenly divisible by 17"): @@ -121,6 +124,7 @@ class ReshapeTest(test.TestCase): "Cannot reshape a tensor with 4096 elements"): array_ops.reshape(z, [4095]) + @test_util.run_deprecated_v1 def testPartialShapes(self): x = array_ops.placeholder(dtypes.float32) diff --git a/tensorflow/python/kernel_tests/resource_variable_ops_test.py b/tensorflow/python/kernel_tests/resource_variable_ops_test.py index d30ab6a9c29..b57d9d47aa3 100644 --- a/tensorflow/python/kernel_tests/resource_variable_ops_test.py +++ b/tensorflow/python/kernel_tests/resource_variable_ops_test.py @@ -54,6 +54,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): # involving objects with __del__ defined. self.assertEqual(0, len(gc.garbage)) + @test_util.run_deprecated_v1 def testHandleDtypeShapeMatch(self): with self.cached_session(): handle = resource_variable_ops.var_handle_op(dtype=dtypes.int32, shape=[]) @@ -123,6 +124,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): # values. self.assertFalse(np.allclose(variable.numpy(), copied_variable.numpy())) + @test_util.run_deprecated_v1 def testGraphDeepCopy(self): with self.cached_session(): init_value = np.ones((4, 4, 4)) @@ -146,6 +148,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): resource_variable_ops.variable_shape(v.handle)), [2]) + @test_util.run_deprecated_v1 def testDifferentAssignGraph(self): with ops.Graph().as_default(): v = resource_variable_ops.ResourceVariable(1.0) @@ -153,12 +156,14 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): v.assign(2.0) # Note: this fails if we run convert_to_tensor on not the # variable graph. + @test_util.run_deprecated_v1 def testFetchHandle(self): with self.cached_session(): handle = resource_variable_ops.var_handle_op( dtype=dtypes.int32, shape=[1], name="foo") self.assertGreater(len(handle.eval()), 0) + @test_util.run_deprecated_v1 def testCachedValueReadBeforeWrite(self): with self.cached_session() as sess: v = resource_variable_ops.ResourceVariable(0.0, caching_device="cpu:0") @@ -435,6 +440,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): read = resource_variable_ops.read_variable_op(handle, dtype=dtypes.int32) self.assertEqual(self.evaluate(read), [[6]]) + @test_util.run_deprecated_v1 def testScatterUpdateString(self): handle = resource_variable_ops.var_handle_op( dtype=dtypes.string, shape=[1, 1]) @@ -446,6 +452,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): self.assertEqual(compat.as_bytes(self.evaluate(read)[0][0]), compat.as_bytes("b")) + @test_util.run_deprecated_v1 def testScatterUpdateStringScalar(self): handle = resource_variable_ops.var_handle_op( dtype=dtypes.string, shape=[1, 1]) @@ -500,6 +507,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): initial_value=lambda: 1, constraint=constraint, name="var1") # TODO(alive): how should this work in Eager mode? + @test_util.run_deprecated_v1 def testInitFn(self): with self.cached_session(): v = resource_variable_ops.ResourceVariable( @@ -591,6 +599,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): variable_def=other_v_def) self.assertTrue(other_v_prime._cached_value is not None) + @test_util.run_deprecated_v1 def testVariableDefInitializedInstances(self): with ops.Graph().as_default(), self.cached_session() as sess: v_def = resource_variable_ops.ResourceVariable( @@ -646,6 +655,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): value = self.evaluate(v.sparse_read([0, 3, 1, 2])) self.assertAllEqual(init_value[[0, 3, 1, 2], ...], value) + @test_util.run_deprecated_v1 def testToFromProto(self): with self.cached_session(): v = resource_variable_ops.ResourceVariable(1.0) @@ -694,6 +704,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): self.assertEqual(0.0, self.evaluate(v.value())) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testDestroyResource(self): v = resource_variable_ops.ResourceVariable(3.0, name="var0") self.evaluate(variables.global_variables_initializer()) @@ -707,6 +718,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): self.evaluate(resource_variable_ops.destroy_resource_op( handle, ignore_lookup_error=True)) + @test_util.run_deprecated_v1 def testAssignDifferentShapes(self): with self.cached_session() as sess, variable_scope.variable_scope( "foo", use_resource=True): @@ -727,6 +739,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): assign = var.assign(np.zeros(shape=[2, 2])) self.evaluate(assign) + @test_util.run_deprecated_v1 def testDtypeAfterFromProto(self): v = resource_variable_ops.ResourceVariable(2.0) w = resource_variable_ops.ResourceVariable.from_proto(v.to_proto()) @@ -734,6 +747,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): self.assertEqual(v.dtype, w.dtype) # TODO(alive): get caching to work in eager mode. + @test_util.run_deprecated_v1 def testCachingDevice(self): with ops.device("/job:server/task:1"): v = resource_variable_ops.ResourceVariable( @@ -749,6 +763,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): with self.assertRaises(ValueError): _ = w.value().op.get_attr("_class") + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): v = resource_variable_ops.ResourceVariable(300.0, name="var4") @@ -767,6 +782,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): with self.assertRaisesOpError("Resource .*/var5/.* does not exist"): resource_variable_ops.read_variable_op(x, v.dtype.base_dtype).eval() + @test_util.run_deprecated_v1 def testSharedNameWithNamescope(self): with self.cached_session(): with ops.name_scope("foo"): @@ -795,6 +811,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): "<unknown>", str(v.sparse_read(array_ops.placeholder(dtypes.int32)).shape)) + @test_util.run_deprecated_v1 def testSetInitialValue(self): with self.cached_session(): # Initialize variable with a value different from the initial value passed @@ -803,6 +820,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): v.initializer.run(feed_dict={v.initial_value: 3.0}) self.assertEqual(3.0, v.value().eval()) + @test_util.run_deprecated_v1 def testControlFlowInitialization(self): """Expects an error if an initializer is in a control-flow scope.""" @@ -939,6 +957,7 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(self.evaluate(v.assign_add(1)), [1, 2, 3, 4]) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testCopyToGraphUninitialized(self): v = resource_variable_ops.ResourceVariable([0, 1, 2, 3]) copy_to_graph = ops.Graph() diff --git a/tensorflow/python/kernel_tests/reverse_sequence_op_test.py b/tensorflow/python/kernel_tests/reverse_sequence_op_test.py index 91d054ad9ad..05307c9834a 100644 --- a/tensorflow/python/kernel_tests/reverse_sequence_op_test.py +++ b/tensorflow/python/kernel_tests/reverse_sequence_op_test.py @@ -23,6 +23,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.platform import test @@ -107,6 +108,7 @@ class ReverseSequenceTest(test.TestCase): def testComplex128Basic(self): self._testBasic(np.complex128) + @test_util.run_deprecated_v1 def testFloatReverseSequenceGrad(self): x = np.asarray( [[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]], @@ -133,6 +135,7 @@ class ReverseSequenceTest(test.TestCase): print("ReverseSequence gradient error = %g" % err) self.assertLess(err, 1e-8) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): t = array_ops.reverse_sequence( array_ops.placeholder( diff --git a/tensorflow/python/kernel_tests/rnn_test.py b/tensorflow/python/kernel_tests/rnn_test.py index 0090b7332f9..3bc457f8fb6 100644 --- a/tensorflow/python/kernel_tests/rnn_test.py +++ b/tensorflow/python/kernel_tests/rnn_test.py @@ -262,6 +262,7 @@ class RNNTest(test.TestCase): rnn.dynamic_rnn(cell, inputs, dtype=dtypes.float32, sequence_length=[4]) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testTensorArrayStateIsAccepted(self): cell = TensorArrayStateRNNCell() in_eager_mode = context.executing_eagerly() @@ -285,6 +286,7 @@ class RNNTest(test.TestCase): self.assertAllEqual(4, state[0]) self.assertAllEqual([[[1]], [[2]], [[3]], [[4]]], state[1]) + @test_util.run_deprecated_v1 def testCellGetInitialState(self): cell = rnn_cell_impl.BasicRNNCell(5) with self.assertRaisesRegexp( @@ -345,6 +347,7 @@ class RNNTest(test.TestCase): self._assert_cell_builds(contrib_rnn.IndyLSTMCell, f32, 5, 7, 3) self._assert_cell_builds(contrib_rnn.IndyLSTMCell, f64, 5, 7, 3) + @test_util.run_deprecated_v1 def testRNNWithKerasSimpleRNNCell(self): with self.cached_session() as sess: input_shape = 10 @@ -378,6 +381,7 @@ class RNNTest(test.TestCase): self.assertEqual(len(outputs), batch) self.assertEqual(len(state), batch) + @test_util.run_deprecated_v1 def testRNNWithKerasGRUCell(self): with self.cached_session() as sess: input_shape = 10 @@ -411,6 +415,7 @@ class RNNTest(test.TestCase): self.assertEqual(len(outputs), batch) self.assertEqual(len(state), batch) + @test_util.run_deprecated_v1 def testRNNWithKerasLSTMCell(self): with self.cached_session() as sess: input_shape = 10 @@ -448,6 +453,7 @@ class RNNTest(test.TestCase): self.assertEqual(len(state[0]), batch) self.assertEqual(len(state[1]), batch) + @test_util.run_deprecated_v1 def testRNNWithStackKerasCell(self): with self.cached_session() as sess: input_shape = 10 @@ -491,6 +497,7 @@ class RNNTest(test.TestCase): for s in state: self.assertEqual(len(s), batch) + @test_util.run_deprecated_v1 def testStaticRNNWithKerasSimpleRNNCell(self): with self.cached_session() as sess: input_shape = 10 @@ -529,6 +536,7 @@ class RNNTest(test.TestCase): self.assertEqual(len(outputs[0]), batch) self.assertEqual(len(state), batch) + @test_util.run_deprecated_v1 def testKerasAndTFRNNLayerOutputComparison(self): input_shape = 10 output_shape = 5 @@ -562,6 +570,7 @@ class RNNTest(test.TestCase): self.assertAllClose(tf_out, k_out) self.assertAllClose(tf_state, k_state) + @test_util.run_deprecated_v1 def testSimpleRNNCellAndBasicRNNCellComparison(self): input_shape = 10 output_shape = 5 @@ -601,6 +610,7 @@ class RNNTest(test.TestCase): self.assertAllClose(tf_out, k_out, atol=1e-5) self.assertAllClose(tf_state, k_state, atol=1e-5) + @test_util.run_deprecated_v1 def testBasicLSTMCellInterchangeWithLSTMCell(self): with self.session(graph=ops_lib.Graph()) as sess: basic_cell = rnn_cell_impl.BasicLSTMCell(1) diff --git a/tensorflow/python/kernel_tests/save_restore_ops_test.py b/tensorflow/python/kernel_tests/save_restore_ops_test.py index be117c4350c..fecc9a3800f 100644 --- a/tensorflow/python/kernel_tests/save_restore_ops_test.py +++ b/tensorflow/python/kernel_tests/save_restore_ops_test.py @@ -55,6 +55,7 @@ class ShardedFileOpsTest(test.TestCase): class ShapeInferenceTest(test.TestCase): + @test_util.run_deprecated_v1 def testRestoreV2WithSliceInput(self): op = io_ops.restore_v2("model", ["var1", "var2"], ["", "3 4 0,1:-"], [dtypes.float32, dtypes.float32]) @@ -62,11 +63,13 @@ class ShapeInferenceTest(test.TestCase): self.assertFalse(op[0].get_shape().is_fully_defined()) self.assertEqual([1, 4], op[1].get_shape()) + @test_util.run_deprecated_v1 def testRestoreV2NumSlicesNotMatch(self): with self.assertRaises(ValueError): io_ops.restore_v2("model", ["var1", "var2", "var3"], ["", "3 4 0,1:-"], [dtypes.float32, dtypes.float32]) + @test_util.run_deprecated_v1 def testRestoreSlice(self): op = gen_io_ops.restore_slice("model", "var", "3 4 0,1:-", dtypes.float32) self.assertEqual([1, 4], op.get_shape()) diff --git a/tensorflow/python/kernel_tests/scan_ops_test.py b/tensorflow/python/kernel_tests/scan_ops_test.py index c48e0e2e674..33e491fee1d 100644 --- a/tensorflow/python/kernel_tests/scan_ops_test.py +++ b/tensorflow/python/kernel_tests/scan_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -88,12 +89,14 @@ class CumsumTest(test.TestCase): for reverse in [True, False]: self._compare(x, axis, exclusive, reverse) + @test_util.run_deprecated_v1 def testEmpty(self): for dtype in self.valid_dtypes: x = np.zeros([0]).astype(dtype) for axis in (-1, 0): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def testAxisType(self): for dtype in self.valid_dtypes: x = np.arange(1, 6).reshape([5]).astype(dtype) @@ -102,30 +105,35 @@ class CumsumTest(test.TestCase): axis = constant_op.constant(0, axis_dtype) tf_out = math_ops.cumsum(x, axis).eval() + @test_util.run_deprecated_v1 def test1D(self): for dtype in self.valid_dtypes: x = np.arange(1, 6).reshape([5]).astype(dtype) for axis in (-1, 0): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test2D(self): for dtype in self.valid_dtypes: x = np.arange(0, 10).reshape([2, 5]).astype(dtype) for axis in (-2, -1, 0, 1): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test3D(self): for dtype in self.valid_dtypes: x = np.arange(0, 20).reshape([2, 2, 5]).astype(dtype) for axis in (-3, -2, -1, 0, 1, 2): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test6D(self): for dtype in self.valid_dtypes: x = np.arange(1, 145).reshape([2, 2, 3, 3, 2, 2]).astype(dtype) for axis in range(-6, 6, 3): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def testLarge(self): for dtype in self.valid_dtypes: x = np.ones([1000000], dtype=dtype) / 1024 @@ -157,22 +165,27 @@ class CumsumTest(test.TestCase): t, shape, result, shape, x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient(self): for axis in (-1, 0): self._compareGradient([50], axis, False, False) + @test_util.run_deprecated_v1 def testGradientReverse(self): for axis in (-1, 0): self._compareGradient([50], axis, False, True) + @test_util.run_deprecated_v1 def testGradientExclusive(self): for axis in (-1, 0): self._compareGradient([50], axis, True, False) + @test_util.run_deprecated_v1 def testGradientExclusiveReverse(self): for axis in (-1, 0): self._compareGradient([50], axis, True, True) + @test_util.run_deprecated_v1 def testGradient2D(self): for axis in (-1, 0, 1): for exclusive in [True, False]: @@ -199,12 +212,14 @@ class CumprodTest(test.TestCase): for reverse in [True, False]: self._compare(x, axis, exclusive, reverse) + @test_util.run_deprecated_v1 def testEmpty(self): for dtype in self.valid_dtypes: x = np.zeros([0]).astype(dtype) for axis in (-1, 0): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def testAxisType(self): for dtype in self.valid_dtypes: x = np.arange(1, 6).reshape([5]).astype(dtype) @@ -213,24 +228,28 @@ class CumprodTest(test.TestCase): axis = constant_op.constant(0, axis_dtype) tf_out = math_ops.cumprod(x, axis).eval() + @test_util.run_deprecated_v1 def test1D(self): for dtype in self.valid_dtypes: x = np.arange(1, 6).reshape([5]).astype(dtype) for axis in (-1, 0): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test2D(self): for dtype in self.valid_dtypes: x = np.arange(1, 11).reshape([2, 5]).astype(dtype) for axis in (-2, -1, 0, 1): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test3D(self): for dtype in self.valid_dtypes: x = np.arange(1, 21).reshape([2, 2, 5]).astype(dtype) for axis in (-3, -2, -1, 0, 1, 2): self._compareAll(x, axis) + @test_util.run_deprecated_v1 def test6D(self): for dtype in self.valid_dtypes: x = np.arange(1, 145).reshape([2, 2, 3, 3, 2, 2]).astype(dtype) @@ -263,22 +282,27 @@ class CumprodTest(test.TestCase): t, shape, result, shape, x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-8, atol=1e-8) + @test_util.run_deprecated_v1 def testGradient(self): for axis in (-1, 0): self._compareGradient([8], axis, False, False) + @test_util.run_deprecated_v1 def testGradientReverse(self): for axis in (-1, 0): self._compareGradient([8], axis, False, True) + @test_util.run_deprecated_v1 def testGradientExclusive(self): for axis in (-1, 0): self._compareGradient([8], axis, True, False) + @test_util.run_deprecated_v1 def testGradientExclusiveReverse(self): for axis in (-1, 0): self._compareGradient([8], axis, True, True) + @test_util.run_deprecated_v1 def testGradient2D(self): for axis in (-2, -1, 0, 1): for exclusive in [True, False]: diff --git a/tensorflow/python/kernel_tests/scatter_nd_ops_test.py b/tensorflow/python/kernel_tests/scatter_nd_ops_test.py index c3881219828..298db1547ad 100644 --- a/tensorflow/python/kernel_tests/scatter_nd_ops_test.py +++ b/tensorflow/python/kernel_tests/scatter_nd_ops_test.py @@ -165,6 +165,7 @@ class StatefulScatterNdTest(test.TestCase): result = self.evaluate(scatter) self.assertAllClose(result, expected) + @test_util.run_deprecated_v1 def testSimpleResource(self): indices = constant_op.constant([[4], [3], [1], [7]], dtype=dtypes.int32) updates = constant_op.constant([9, 10, 11, 12], dtype=dtypes.float32) @@ -207,12 +208,15 @@ class StatefulScatterNdTest(test.TestCase): result = self.evaluate(scatter) self.assertAllClose(result, expected) + @test_util.run_deprecated_v1 def testVariableRankUpdate(self): self._VariableRankTests(_NumpyUpdate, state_ops.scatter_nd_update) + @test_util.run_deprecated_v1 def testVariableRankAdd(self): self._VariableRankTests(_NumpyAdd, state_ops.scatter_nd_add) + @test_util.run_deprecated_v1 def testVariableRankSub(self): self._VariableRankTests(_NumpySub, state_ops.scatter_nd_sub) @@ -230,6 +234,7 @@ class StatefulScatterNdTest(test.TestCase): self._VariableRankTest( np_scatter, tf_scatter, vtype, itype, repeat_indices=True) + @test_util.run_deprecated_v1 def testScatterRepeatIndices(self): """This tests scatter_add using indices that repeat.""" self._ScatterRepeatIndicesTest(_NumpyAdd, state_ops.scatter_nd_add) @@ -251,6 +256,7 @@ class StatefulScatterNdTest(test.TestCase): # session.run([update0, update1]) # self.assertAllEqual([False, True], self.evaluate(var)) + @test_util.run_deprecated_v1 def testScatterOutOfRangeCpu(self): # TODO(simister): Re-enable once binary size increase due to # scatter_nd ops is under control. @@ -287,6 +293,7 @@ class StatefulScatterNdTest(test.TestCase): state_ops.scatter_nd_update(ref, indices, updates).get_shape().as_list(), shape) + @test_util.run_deprecated_v1 def testResVarInvalidOutputShape(self): res = variables.Variable( initial_value=lambda: array_ops.zeros(shape=[], dtype=dtypes.float32), @@ -296,6 +303,7 @@ class StatefulScatterNdTest(test.TestCase): with self.assertRaisesOpError("Output must be at least 1-D"): state_ops.scatter_nd_update(res, [[0]], [0.22]).eval() + @test_util.run_deprecated_v1 def testExtraIndicesDimensions(self): indices = array_ops.zeros([1, 1, 2], dtypes.int32) updates = array_ops.zeros([1, 1], dtypes.int32) @@ -309,6 +317,7 @@ class StatefulScatterNdTest(test.TestCase): ref.initializer.run() self.assertAllEqual(expected_result, self.evaluate(scatter_update)) + @test_util.run_deprecated_v1 def testRank3InvalidShape1(self): indices = array_ops.zeros([3, 2, 2], dtypes.int32) updates = array_ops.zeros([2, 2, 2], dtypes.int32) @@ -318,6 +327,7 @@ class StatefulScatterNdTest(test.TestCase): ValueError, "The outer \\d+ dimensions of indices\\.shape="): state_ops.scatter_nd_update(ref, indices, updates) + @test_util.run_deprecated_v1 def testRank3InvalidShape2(self): indices = array_ops.zeros([2, 2, 1], dtypes.int32) updates = array_ops.zeros([2, 2], dtypes.int32) @@ -327,6 +337,7 @@ class StatefulScatterNdTest(test.TestCase): ValueError, "The inner \\d+ dimensions of input\\.shape="): state_ops.scatter_nd_update(ref, indices, updates) + @test_util.run_deprecated_v1 def testConcurrentUpdates(self): num_updates = 10000 update_values = np.random.rand(num_updates) @@ -455,6 +466,7 @@ class ScatterNdTest(test.TestCase): self.assertAllEqual( self.scatter_nd(indices, updates, shape).get_shape().as_list(), shape) + @test_util.run_deprecated_v1 def testExtraIndicesDimensions(self): indices = array_ops.zeros([1, 1, 2], dtypes.int32) updates = array_ops.zeros([1, 1], dtypes.int32) @@ -465,24 +477,28 @@ class ScatterNdTest(test.TestCase): with self.cached_session(): self.assertAllEqual(expected_result, self.evaluate(scatter)) + @test_util.run_deprecated_v1 def testUndefinedIndicesShape(self): indices = array_ops.placeholder(dtypes.int32, shape=None) updates = array_ops.placeholder(dtypes.int32, shape=[2, 2, 2]) shape = constant_op.constant([2, 2, 2], dtypes.int32) self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testUndefinedUpdatesShape(self): indices = array_ops.placeholder(dtypes.int32, shape=[2, 2, 2]) updates = array_ops.placeholder(dtypes.int32, shape=None) shape = constant_op.constant([2, 2, 2], dtypes.int32) self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testUndefinedOutputShape(self): indices = array_ops.placeholder(dtypes.int32, shape=[2, 2, 2]) updates = array_ops.placeholder(dtypes.int32, shape=[2, 2, 2]) shape = array_ops.placeholder(dtypes.int32, shape=[None]) self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testEmptyOutputShape1(self): indices = array_ops.zeros([2, 2, 2], dtypes.int32) updates = array_ops.zeros([2, 2, 2], dtypes.int32) @@ -492,6 +508,7 @@ class ScatterNdTest(test.TestCase): ValueError, "Indices and updates specified for empty output shape"): self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testEmptyOutputShape2(self): indices = array_ops.placeholder(dtypes.int32, shape=None) updates = array_ops.placeholder(dtypes.int32, shape=None) @@ -505,6 +522,7 @@ class ScatterNdTest(test.TestCase): updates: np.zeros([2, 2, 2], dtype=np.int32) }) + @test_util.run_deprecated_v1 def testEmptyOutputShape3(self): indices = array_ops.zeros([0], dtypes.int32) updates = array_ops.zeros([0], dtypes.int32) @@ -514,6 +532,7 @@ class ScatterNdTest(test.TestCase): with self.cached_session(): self.assertEqual(scatter.eval().size, 0) + @test_util.run_deprecated_v1 def testRank3InvalidShape1(self): indices = array_ops.zeros([3, 2, 2], dtypes.int32) updates = array_ops.zeros([2, 2, 2], dtypes.int32) @@ -522,6 +541,7 @@ class ScatterNdTest(test.TestCase): ValueError, "The outer \\d+ dimensions of indices\\.shape="): self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testRank3InvalidShape2(self): indices = array_ops.zeros([2, 2, 1], dtypes.int32) updates = array_ops.zeros([2, 2], dtypes.int32) @@ -530,6 +550,7 @@ class ScatterNdTest(test.TestCase): ValueError, "The inner \\d+ dimensions of (input|output)\\.shape="): self.scatter_nd(indices, updates, shape) + @test_util.run_deprecated_v1 def testGradientsRank2ElementUpdate(self): for dtype in GRADIENT_TESTS_DTYPES: indices = constant_op.constant([[0, 0], [1, 1]], dtype=dtypes.int32) @@ -549,6 +570,7 @@ class ScatterNdTest(test.TestCase): if self.non_aliasing_add_test: self.assertAllEqual(expected_input_grad, self.evaluate(input_grad)) + @test_util.run_deprecated_v1 def testGradientsRank2SliceUpdate(self): for dtype in GRADIENT_TESTS_DTYPES: indices = constant_op.constant([[1], [0]], dtype=dtypes.int32) @@ -569,6 +591,7 @@ class ScatterNdTest(test.TestCase): if self.non_aliasing_add_test: self.assertAllEqual(expected_input_grad, self.evaluate(input_grad)) + @test_util.run_deprecated_v1 def testGradientsRank3SliceUpdate(self): for dtype in GRADIENT_TESTS_DTYPES: indices = constant_op.constant([[[0, 1], [1, 0]], [[0, 0], [1, 1]]], @@ -592,6 +615,7 @@ class ScatterNdTest(test.TestCase): if self.non_aliasing_add_test: self.assertAllEqual(expected_input_grad, self.evaluate(input_grad)) + @test_util.run_deprecated_v1 def testGradientsRank7SliceUpdate(self): for dtype in GRADIENT_TESTS_DTYPES: indices = constant_op.constant( @@ -619,6 +643,7 @@ class ScatterNdTest(test.TestCase): if self.non_aliasing_add_test: self.assertAllEqual(expected_input_grad, self.evaluate(input_grad)) + @test_util.run_deprecated_v1 def testScatterNdRepatedIndicesAdd(self): indices = array_ops.zeros([100000, 1], dtypes.int32) values = np.random.randn(100000) @@ -627,6 +652,7 @@ class ScatterNdTest(test.TestCase): val = self.scatter_nd(indices, values, shape).eval() self.assertAllClose([np.sum(values)], val) + @test_util.run_deprecated_v1 def testSmokeScatterNdBatch2DSliceDim2(self): with self.cached_session(): indices = array_ops.zeros([3, 5, 2], dtype=dtypes.int32) @@ -634,6 +660,7 @@ class ScatterNdTest(test.TestCase): shape = [4, 6, 7] self.scatter_nd(indices, values, shape).eval() + @test_util.run_deprecated_v1 def testSmokeScatterNdBatch1DSliceDim2(self): with self.cached_session(): indices = array_ops.zeros([0, 2], dtype=dtypes.int32) @@ -641,6 +668,7 @@ class ScatterNdTest(test.TestCase): shape = [4, 6, 7] self.scatter_nd(indices, values, shape).eval() + @test_util.run_deprecated_v1 def testSmokeScatterNdBatch1DSliceDim3ShapeRank7(self): with self.cached_session(): indices = array_ops.zeros([1, 3], dtype=dtypes.int32) @@ -648,6 +676,7 @@ class ScatterNdTest(test.TestCase): shape = [3, 4, 5, 6, 7, 8, 9] self.scatter_nd(indices, values, shape).eval() + @test_util.run_deprecated_v1 def testSmokeScatterNdBatch2DSliceDim3ShapeRank7(self): with self.cached_session(): indices = array_ops.zeros([1, 2, 3], dtype=dtypes.int32) diff --git a/tensorflow/python/kernel_tests/scatter_ops_test.py b/tensorflow/python/kernel_tests/scatter_ops_test.py index a4daad7adcc..623c17d373c 100644 --- a/tensorflow/python/kernel_tests/scatter_ops_test.py +++ b/tensorflow/python/kernel_tests/scatter_ops_test.py @@ -197,84 +197,111 @@ class ScatterTest(test.TestCase): self._VariableRankTest(tf_scatter, vtype, itype, repeat_indices, updates_are_scalar) + @test_util.run_deprecated_v1 def testVariableRankUpdate(self): self._VariableRankTests(state_ops.scatter_update, False) + @test_util.run_deprecated_v1 def testVariableRankAdd(self): self._VariableRankTests(state_ops.scatter_add, False) + @test_util.run_deprecated_v1 def testVariableRankSub(self): self._VariableRankTests(state_ops.scatter_sub, False) + @test_util.run_deprecated_v1 def testVariableRankMul(self): self._VariableRankTests(state_ops.scatter_mul, False) + @test_util.run_deprecated_v1 def testVariableRankDiv(self): self._VariableRankTests(state_ops.scatter_div, False) + @test_util.run_deprecated_v1 def testVariableRankMin(self): self._VariableRankTests(state_ops.scatter_min, False) + @test_util.run_deprecated_v1 def testVariableRankMax(self): self._VariableRankTests(state_ops.scatter_max, False) + @test_util.run_deprecated_v1 def testRepeatIndicesAdd(self): self._VariableRankTests(state_ops.scatter_add, True) + @test_util.run_deprecated_v1 def testRepeatIndicesSub(self): self._VariableRankTests(state_ops.scatter_sub, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMul(self): self._VariableRankTests(state_ops.scatter_mul, True) + @test_util.run_deprecated_v1 def testRepeatIndicesDiv(self): self._VariableRankTests(state_ops.scatter_div, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMin(self): self._VariableRankTests(state_ops.scatter_min, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMax(self): self._VariableRankTests(state_ops.scatter_max, True) + @test_util.run_deprecated_v1 def testVariableRankUpdateScalar(self): self._VariableRankTests(state_ops.scatter_update, False, True) + @test_util.run_deprecated_v1 def testVariableRankAddScalar(self): self._VariableRankTests(state_ops.scatter_add, False, True) + @test_util.run_deprecated_v1 def testVariableRankSubScalar(self): self._VariableRankTests(state_ops.scatter_sub, False, True) + @test_util.run_deprecated_v1 def testVariableRankMulScalar(self): self._VariableRankTests(state_ops.scatter_mul, False, True) + @test_util.run_deprecated_v1 def testVariableRankDivScalar(self): self._VariableRankTests(state_ops.scatter_div, False, True) + @test_util.run_deprecated_v1 def testVariableRankMinScalar(self): self._VariableRankTests(state_ops.scatter_min, False, True) + @test_util.run_deprecated_v1 def testVariableRankMaxScalar(self): self._VariableRankTests(state_ops.scatter_max, False, True) + @test_util.run_deprecated_v1 def testRepeatIndicesAddScalar(self): self._VariableRankTests(state_ops.scatter_add, True, True) + @test_util.run_deprecated_v1 def testRepeatIndicesSubScalar(self): self._VariableRankTests(state_ops.scatter_sub, True, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMulScalar(self): self._VariableRankTests(state_ops.scatter_mul, True, True) + @test_util.run_deprecated_v1 def testRepeatIndicesDivScalar(self): self._VariableRankTests(state_ops.scatter_div, True, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMinScalar(self): self._VariableRankTests(state_ops.scatter_min, True, True) + @test_util.run_deprecated_v1 def testRepeatIndicesMaxScalar(self): self._VariableRankTests(state_ops.scatter_max, True, True) + @test_util.run_deprecated_v1 def testBooleanScatterUpdate(self): if not test.is_gpu_available(): with self.session(use_gpu=False) as session: @@ -289,6 +316,7 @@ class ScatterTest(test.TestCase): self.assertAllEqual([False, True], self.evaluate(var)) + @test_util.run_deprecated_v1 def testScatterOutOfRangeCpu(self): for op, _ in _TF_OPS_TO_NUMPY.items(): params = np.array([1, 2, 3, 4, 5, 6]).astype(np.float32) diff --git a/tensorflow/python/kernel_tests/segment_reduction_ops_test.py b/tensorflow/python/kernel_tests/segment_reduction_ops_test.py index 5ab889895ec..8af1b47e83c 100644 --- a/tensorflow/python/kernel_tests/segment_reduction_ops_test.py +++ b/tensorflow/python/kernel_tests/segment_reduction_ops_test.py @@ -26,6 +26,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables @@ -126,6 +127,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): # and may therefore vary dynamically. self.assertAllEqual(np_ans.shape[1:], tf_ans.shape[1:]) + @test_util.run_deprecated_v1 def testSegmentIdsShape(self): shape = [4, 4] tf_x, _ = self._input(shape) @@ -133,6 +135,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): with self.assertRaises(ValueError): math_ops.segment_sum(data=tf_x, segment_ids=indices) + @test_util.run_deprecated_v1 def testSegmentIdsSize(self): shape = [4, 4] for use_gpu in [True, False]: @@ -143,6 +146,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): with self.assertRaisesOpError("segment_ids should be the same size"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentIdsValid(self): # This is a baseline for the following SegmentIdsInvalid* tests. shape = [4, 4] @@ -175,6 +179,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): tf_ans = self.evaluate(s) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testSegmentIdsInvalid1(self): shape = [4, 4] with self.cached_session(): @@ -186,6 +191,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): "'segment_ids' input is not sorted."): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentIdsInvalid2(self): shape = [4, 4] with self.cached_session(): @@ -195,6 +201,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): with self.assertRaisesOpError("segment ids are not increasing"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentIdsInvalid3(self): shape = [4, 4] with self.cached_session(): @@ -206,6 +213,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): "because 'segment_ids' input is not sorted."): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentIdsInvalid4(self): shape = [4, 4] for use_gpu in [True, False]: @@ -216,6 +224,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): with self.assertRaisesOpError("segment ids must be >= 0"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentIdsInvalid5(self): shape = [4, 4] for use_gpu in [True, False]: @@ -226,6 +235,7 @@ class SegmentReductionOpTest(SegmentReductionHelper): with self.assertRaisesOpError("segment ids must be >= 0"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradient(self): shape = [4, 4] indices = [0, 1, 2, 2] @@ -324,6 +334,7 @@ class UnsortedSegmentTest(SegmentReductionHelper): self.assertAllClose(np_ans, tf_ans) self.assertShapeEqual(np_ans, s) + @test_util.run_deprecated_v1 def testGradients(self): num_cols = 2 indices_flat = np.array([0, 4, 0, -1, 3, -1, 4, 7, 7, 3]) @@ -346,6 +357,7 @@ class UnsortedSegmentTest(SegmentReductionHelper): delta=1) self.assertAllClose(jacob_t, jacob_n) + @test_util.run_deprecated_v1 def testProdGrad(self): # additional test for the prod gradient to ensure correct handling of zeros values = np.array([0, 0, 1, 0, 2, 2, 3, 3, 3], dtype=np.float32) @@ -370,6 +382,7 @@ class UnsortedSegmentTest(SegmentReductionHelper): self.assertAllClose(jacob_t, jacob_n) self.assertAllClose(jacob_t, grad_gt) + @test_util.run_deprecated_v1 def testGradientMatchesSegmentSum(self): # Strategy: compute the gradient for UnsortedSegmentSum and SegmentSum # and compare the outputs, which should be identical. @@ -403,6 +416,7 @@ class UnsortedSegmentTest(SegmentReductionHelper): self.assertAllClose(unsorted_jacob_t, sorted_jacob_t) self.assertAllClose(unsorted_jacob_n, sorted_jacob_n) + @test_util.run_deprecated_v1 def testBadIndices(self): # Note: GPU kernel does not return the out-of-range error needed for this # test, so this test is marked as cpu-only. @@ -414,6 +428,7 @@ class UnsortedSegmentTest(SegmentReductionHelper): r"segment_ids\[0,0\] = %d is out of range \[0, 2\)" % bad[0][0]): self.evaluate(unsorted) + @test_util.run_deprecated_v1 def testEmptySecondDimension(self): dtypes = [np.float16, np.float32, np.float64, np.int64, np.int32, np.complex64, np.complex128] @@ -590,6 +605,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): s = tf_op(data=tf_x, indices=tf_indices, segment_ids=segment_indices) self.evaluate(s) + @test_util.run_deprecated_v1 def testIndicesInvalid1(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -602,6 +618,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): r"indices\[1\] == -1 out of range \[0, 10\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testIndicesInvalid2(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -614,6 +631,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): r"indices\[3\] == 10 out of range \[0, 10\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentsInvalid2(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -625,6 +643,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError("segment ids are not increasing"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentsInvalid3(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -638,6 +657,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): "'segment_ids' input is not sorted"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentsInvalid4(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -651,6 +671,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): "'segment_ids' input is not sorted"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentsInvalid6(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -662,6 +683,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError("segment ids must be >= 0"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentsInvalid7(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [math_ops.sparse_segment_sum, math_ops.sparse_segment_mean] @@ -692,6 +714,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): num_segments=num_segments) self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentWithNumSegmentsInvalid1(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -711,6 +734,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError("segment ids must be < num_segments"): self.evaluate(s) + @test_util.run_deprecated_v1 def testSegmentWithNumSegmentsInvalid2(self): tf_x, _ = self._input([10, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -730,6 +754,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): segment_ids=segment_indices, num_segments=num_segments) + @test_util.run_deprecated_v1 def testGradient(self): shape = [10, 4] @@ -748,6 +773,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): delta=1) self.assertAllClose(jacob_t, jacob_n) + @test_util.run_deprecated_v1 def testGradientWithEmptySegmentsAtEnd(self): shape = [10, 4] @@ -787,6 +813,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): s = tf_op(tf_x, tf_indices, segment_indices, 10) self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientIndicesInvalid1(self): tf_x, _ = self._input([3, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -800,6 +827,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError(r"Index 10 out of range \[0, 10\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientIndicesInvalid2(self): tf_x, _ = self._input([3, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -813,6 +841,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError(r"Index -1 out of range \[0, 10\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientSegmentsInvalid1(self): tf_x, _ = self._input( [3, 4], dtype=dtypes_lib.float32) # expecting 3 segments @@ -827,6 +856,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError("Invalid number of segments"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientSegmentsInvalid2(self): tf_x, _ = self._input([1, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -840,6 +870,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError(r"Segment id 1 out of range \[0, 1\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientSegmentsInvalid3(self): tf_x, _ = self._input([2, 4], dtype=dtypes_lib.float32) ops_list = [ @@ -853,6 +884,7 @@ class SparseSegmentReductionOpTest(SparseSegmentReductionHelper): with self.assertRaisesOpError(r"Segment id -1 out of range \[0, 2\)"): self.evaluate(s) + @test_util.run_deprecated_v1 def testGradientSegmentsInvalid4(self): tf_x, _ = self._input([0, 4], dtype=dtypes_lib.float32) ops_list = [ diff --git a/tensorflow/python/kernel_tests/sets_test.py b/tensorflow/python/kernel_tests/sets_test.py index ba3d32b192d..b4f23229348 100644 --- a/tensorflow/python/kernel_tests/sets_test.py +++ b/tensorflow/python/kernel_tests/sets_test.py @@ -70,6 +70,7 @@ def _dense_to_sparse(dense, dtype): class SetOpsTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def test_set_size_2d(self): for dtype in _DTYPES: self._test_set_size_2d(dtype) @@ -83,6 +84,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual( [0, 3], self._set_size(_dense_to_sparse([[], [1, 9, 2]], dtype))) + @test_util.run_deprecated_v1 def test_set_size_duplicates_2d(self): for dtype in _DTYPES: self._test_set_size_duplicates_2d(dtype) @@ -96,6 +98,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): 6, 7, 8, 8, 6, 7, 5, 3, 3, 0, 6, 6, 9, 0, 0, 0 ], [999, 1, -1000], [], [-1]], dtype))) + @test_util.run_deprecated_v1 def test_set_size_3d(self): for dtype in _DTYPES: self._test_set_size_3d(dtype) @@ -163,6 +166,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(results[0], results[1]) return results[0] + @test_util.run_deprecated_v1 def test_set_intersection_multirow_2d(self): for dtype in _DTYPES: self._test_set_intersection_multirow_2d(dtype) @@ -199,6 +203,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_intersection_count(sp_a, sp_b)) + @test_util.run_deprecated_v1 def test_dense_set_intersection_multirow_2d(self): for dtype in _DTYPES: self._test_dense_set_intersection_multirow_2d(dtype) @@ -223,6 +228,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): dtype=dtype) self.assertAllEqual(expected_counts, self._set_intersection_count(a, b)) + @test_util.run_deprecated_v1 def test_set_intersection_duplicates_2d(self): for dtype in _DTYPES: self._test_set_intersection_duplicates_2d(dtype) @@ -270,6 +276,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_intersection_count(sp_a, sp_b)) + @test_util.run_deprecated_v1 def test_set_intersection_3d(self): for dtype in _DTYPES: self._test_set_intersection_3d(dtype=dtype) @@ -536,6 +543,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): with self.cached_session() as sess: return self.evaluate(op) + @test_util.run_deprecated_v1 def test_set_difference_multirow_2d(self): for dtype in _DTYPES: self._test_set_difference_multirow_2d(dtype) @@ -604,6 +612,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_difference_count(sp_a, sp_b, False)) + @test_util.run_deprecated_v1 def test_dense_set_difference_multirow_2d(self): for dtype in _DTYPES: self._test_dense_set_difference_multirow_2d(dtype) @@ -647,6 +656,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_difference_count(a, b, False)) + @test_util.run_deprecated_v1 def test_sparse_set_difference_multirow_2d(self): for dtype in _DTYPES: self._test_sparse_set_difference_multirow_2d(dtype) @@ -688,6 +698,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_difference_count(sp_a, sp_b, False)) + @test_util.run_deprecated_v1 def test_set_difference_duplicates_2d(self): for dtype in _DTYPES: self._test_set_difference_duplicates_2d(dtype) @@ -755,6 +766,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): self.assertAllEqual(expected_counts, self._set_difference_count(a, sp_b, False)) + @test_util.run_deprecated_v1 def test_sparse_set_difference_3d(self): for dtype in _DTYPES: self._test_sparse_set_difference_3d(dtype) @@ -974,6 +986,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): with self.cached_session() as sess: return self.evaluate(op) + @test_util.run_deprecated_v1 def test_set_union_multirow_2d(self): for dtype in _DTYPES: self._test_set_union_multirow_2d(dtype) @@ -1001,6 +1014,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): expected_indices, expected_values, expected_shape, union, dtype=dtype) self.assertAllEqual(expected_counts, self._set_union_count(sp_a, sp_b)) + @test_util.run_deprecated_v1 def test_dense_set_union_multirow_2d(self): for dtype in _DTYPES: self._test_dense_set_union_multirow_2d(dtype) @@ -1021,6 +1035,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): expected_indices, expected_values, expected_shape, union, dtype=dtype) self.assertAllEqual(expected_counts, self._set_union_count(a, b)) + @test_util.run_deprecated_v1 def test_set_union_duplicates_2d(self): for dtype in _DTYPES: self._test_set_union_duplicates_2d(dtype) @@ -1047,6 +1062,7 @@ class SetOpsTest(test_util.TensorFlowTestCase): expected_indices, expected_values, expected_shape, union, dtype=dtype) self.assertAllEqual([2], self._set_union_count(sp_a, sp_b)) + @test_util.run_deprecated_v1 def test_sparse_set_union_3d(self): for dtype in _DTYPES: self._test_sparse_set_union_3d(dtype) diff --git a/tensorflow/python/kernel_tests/shape_ops_test.py b/tensorflow/python/kernel_tests/shape_ops_test.py index a0506fbfc57..c8e7c143ade 100644 --- a/tensorflow/python/kernel_tests/shape_ops_test.py +++ b/tensorflow/python/kernel_tests/shape_ops_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import importer from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl @@ -227,6 +228,7 @@ class ShapeOpsTest(test.TestCase): self._compareExpandDimsAll(choice([2, 3, 5]), -3) self._compareExpandDimsAll(choice([2, 3, 5]), -4) + @test_util.run_deprecated_v1 def testExpandDimsErrors(self): with self.cached_session(): self.assertRaises(ValueError, array_ops.expand_dims, @@ -238,6 +240,7 @@ class ShapeOpsTest(test.TestCase): self.assertRaises(ValueError, array_ops.expand_dims, [False, True, True], 4) + @test_util.run_deprecated_v1 def testExpandDimsGradient(self): with self.cached_session(): inp = constant_op.constant( @@ -248,6 +251,7 @@ class ShapeOpsTest(test.TestCase): [4, 1, 2]) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testExpandDimsScalar(self): with self.cached_session(): inp = constant_op.constant(7) @@ -353,6 +357,7 @@ class ShapeOpsTest(test.TestCase): tf_ans = self.evaluate(tensor) self.assertEqual(np.shape(1), tf_ans.shape) + @test_util.run_deprecated_v1 def testSqueezeOnlyOnes(self): for use_gpu in [False, True]: with self.cached_session(use_gpu=use_gpu): @@ -362,6 +367,7 @@ class ShapeOpsTest(test.TestCase): self._compareSqueezeAll(input_1x1x3, [1]) self.assertRaises(ValueError, array_ops.squeeze, input_1x1x3, [2]) + @test_util.run_deprecated_v1 def testSqueezeErrors(self): for use_gpu in [False, True]: with self.cached_session(use_gpu=use_gpu): @@ -374,6 +380,7 @@ class ShapeOpsTest(test.TestCase): self.assertRaises(ValueError, array_ops.squeeze, np.zeros([1, 2, 1]), [2, 3]) + @test_util.run_deprecated_v1 def testSqueezeGradient(self): with self.cached_session(): inp = np.random.rand(4, 2).astype("f") @@ -384,6 +391,7 @@ class ShapeOpsTest(test.TestCase): [4, 2]) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testSqueezeGradientWithSqueezeDims(self): with self.cached_session(): inp = np.random.rand(4, 2).astype("f") @@ -394,6 +402,7 @@ class ShapeOpsTest(test.TestCase): [4, 2, 1]) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testSqueezeWithUnknownShape(self): with self.cached_session(): a = array_ops.placeholder(dtypes.float32, shape=[2, None]) @@ -451,6 +460,7 @@ class TileTest(test.TestCase): self.assertEqual(result.shape, (10, 0)) self.assertEqual([10, 0], tiled.get_shape()) + @test_util.run_deprecated_v1 def testUnknownInputShape(self): """Importing can call _TileShape without shape of <multiples> known.""" with self.cached_session(): @@ -502,6 +512,7 @@ class TileTest(test.TestCase): self.assertEqual([4, 4], tiled.get_shape()) self.assertAllEqual(result, np.tile(inp, (1, 4))) + @test_util.run_deprecated_v1 def testInvalidDim(self): with self.cached_session(): inp = np.random.rand(4, 1).astype("f") @@ -545,6 +556,7 @@ class TileTest(test.TestCase): for _ in range(5): self._RunAndVerifyResult(10, use_gpu=True) + @test_util.run_deprecated_v1 def testGradientSimpleReduction(self): with self.cached_session(): inp = np.random.rand(4, 1).astype("f") @@ -560,6 +572,7 @@ class TileTest(test.TestCase): result = self.evaluate(grad) self.assertAllClose(np.sum(grad_inp, axis=1).reshape(4, 1), result, 1e-3) + @test_util.run_deprecated_v1 def testGradientStridedReduction(self): with self.cached_session(): inp = np.random.rand(4, 2).astype("f") @@ -579,6 +592,7 @@ class TileTest(test.TestCase): expected[:, 1] = grad_inp[:, 1] + grad_inp[:, 3] self.assertTrue((np.abs(expected - result) < 1e-3).all()) + @test_util.run_deprecated_v1 def testGradientSimpleReductionOnGPU(self): with self.session(use_gpu=True): inp = np.random.rand(4, 1).astype("f") @@ -593,6 +607,7 @@ class TileTest(test.TestCase): result = self.evaluate(grad) self.assertAllClose(np.sum(grad_inp, axis=1).reshape(4, 1), result, 1e-3) + @test_util.run_deprecated_v1 def testGradientStridedReductionOnGPU(self): with self.session(use_gpu=True): inp = np.random.rand(4, 2).astype("f") @@ -624,15 +639,18 @@ class TileTest(test.TestCase): print("tile(float) error = ", err) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradientRandomScalar(self): self._RunAndVerifyGradientResult([], []) + @test_util.run_deprecated_v1 def testGradientRandom(self): self._RunAndVerifyGradientResult([2, 2, 1, 1, 3], [1, 1, 1, 1, 1]) self._RunAndVerifyGradientResult([2, 2, 1, 1, 3], [1, 2, 1, 3, 1]) self._RunAndVerifyGradientResult([2, 3, 1, 1, 3], [3, 1, 1, 2, 2]) self._RunAndVerifyGradientResult([2, 1, 3, 3, 2], [1, 3, 3, 1, 2]) + @test_util.run_deprecated_v1 def testGradientStridedReductionGC(self): with self.cached_session(): inp = np.random.rand(4, 2).astype("f") @@ -642,6 +660,7 @@ class TileTest(test.TestCase): err = gradient_checker.compute_gradient_error(a, [4, 2], tiled, [4, 4]) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradientWithSparseGradWithRank1(self): inputs = constant_op.constant([1.0, 2.0, 3.0, 4.0], dtype=dtypes.float32) @@ -653,6 +672,7 @@ class TileTest(test.TestCase): outputs, outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testGradientWithSparseGradWithRank3(self): inputs = constant_op.constant([1.0, 2.0, 3.0, 4.0], dtype=dtypes.float32) @@ -665,6 +685,7 @@ class TileTest(test.TestCase): outputs, outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): # Unknown multiples shape. inp = constant_op.constant(0.0, shape=[4, 4, 4, 4]) diff --git a/tensorflow/python/kernel_tests/signal/dct_ops_test.py b/tensorflow/python/kernel_tests/signal/dct_ops_test.py index af4939332fd..a3ac15bab8a 100644 --- a/tensorflow/python/kernel_tests/signal/dct_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/dct_ops_test.py @@ -23,6 +23,7 @@ import importlib from absl.testing import parameterized import numpy as np +from tensorflow.python.framework import test_util from tensorflow.python.ops import spectral_ops_test_util from tensorflow.python.ops.signal import dct_ops from tensorflow.python.platform import test @@ -132,6 +133,7 @@ class DCTOpsTest(parameterized.TestCase, test.TestCase): @parameterized.parameters([ [[2]], [[3]], [[10]], [[2, 20]], [[2, 3, 25]]]) + @test_util.run_deprecated_v1 def test_random(self, shape): """Test randomly generated batches of data.""" with spectral_ops_test_util.fft_kernel_label_map(): diff --git a/tensorflow/python/kernel_tests/signal/fft_ops_test.py b/tensorflow/python/kernel_tests/signal/fft_ops_test.py index 3eeecc12a88..5b1053428c0 100644 --- a/tensorflow/python/kernel_tests/signal/fft_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/fft_ops_test.py @@ -25,6 +25,7 @@ from tensorflow.core.protobuf import config_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_spectral_ops from tensorflow.python.ops import gradient_checker @@ -157,6 +158,7 @@ class FFTOpsTest(BaseFFTOpsTest): else: raise ValueError("invalid rank") + @test_util.run_deprecated_v1 def testEmpty(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type in (np.complex64, np.complex128): @@ -166,6 +168,7 @@ class FFTOpsTest(BaseFFTOpsTest): self.assertEqual(x.shape, self._tfFFT(x, rank).shape) self.assertEqual(x.shape, self._tfIFFT(x, rank).shape) + @test_util.run_deprecated_v1 def testBasic(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type, tol in ((np.complex64, 1e-4), (np.complex128, 1e-8)): @@ -194,6 +197,7 @@ class FFTOpsTest(BaseFFTOpsTest): # np.mod(np.arange(np.power(128, dims)), 64).reshape( # (128,) * dims).astype(np.complex64), rank) + @test_util.run_deprecated_v1 def testBasicPlaceholder(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type, tol in ((np.complex64, 1e-4), (np.complex128, 1e-8)): @@ -204,6 +208,7 @@ class FFTOpsTest(BaseFFTOpsTest): (4,) * dims).astype(np_type), rank, use_placeholder=True, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testRandom(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type, tol in ((np.complex64, 1e-4), (np.complex128, 5e-6)): @@ -218,6 +223,7 @@ class FFTOpsTest(BaseFFTOpsTest): self._compare(gen((4,) * dims).astype(np_type), rank, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testRandom1D(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type in (np.complex64, np.complex128): @@ -240,6 +246,7 @@ class FFTOpsTest(BaseFFTOpsTest): for dim in (127, 255, 511, 1023): self._compare(gen((dim,)).astype(np_type), 1, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testError(self): for rank in VALID_FFT_RANKS: for dims in xrange(0, rank): @@ -251,6 +258,7 @@ class FFTOpsTest(BaseFFTOpsTest): ValueError, "Shape must be .*rank {}.*".format(rank)): self._tfIFFT(x, rank) + @test_util.run_deprecated_v1 def testGrad_Simple(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type, tol in ((np.float32, 1e-4), (np.float64, 1e-10)): @@ -263,6 +271,7 @@ class FFTOpsTest(BaseFFTOpsTest): self._checkGradComplex(self._tfIFFTForRank(rank), re, im, rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testGrad_Random(self): with spectral_ops_test_util.fft_kernel_label_map(): for np_type, tol in ((np.float32, 1e-2), (np.float64, 1e-10)): @@ -330,6 +339,7 @@ class RFFTOpsTest(BaseFFTOpsTest): else: raise ValueError("invalid rank") + @test_util.run_deprecated_v1 def testEmpty(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: @@ -339,6 +349,7 @@ class RFFTOpsTest(BaseFFTOpsTest): x = np.zeros((0,) * dims).astype(np.complex64) self.assertEqual(x.shape, self._tfIFFT(x, rank).shape) + @test_util.run_deprecated_v1 def testBasic(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: @@ -366,6 +377,7 @@ class RFFTOpsTest(BaseFFTOpsTest): 10).reshape((size,) * (dims - 1) + (inner_dim,)) self._compareBackward(c2r.astype(np.complex64), rank, (size,) * rank) + @test_util.run_deprecated_v1 def testBasicPlaceholder(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: @@ -427,6 +439,7 @@ class RFFTOpsTest(BaseFFTOpsTest): fft_length, use_placeholder=True) + @test_util.run_deprecated_v1 def testRandom(self): with spectral_ops_test_util.fft_kernel_label_map(): def gen_real(shape): @@ -451,6 +464,7 @@ class RFFTOpsTest(BaseFFTOpsTest): self._compareBackward( gen_complex(complex_dims), rank, (size,) * rank) + @test_util.run_deprecated_v1 def testError(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: @@ -507,6 +521,7 @@ class RFFTOpsTest(BaseFFTOpsTest): with self.cached_session(): irfft_fn(x, fft_length).eval() + @test_util.run_deprecated_v1 def testGrad_Simple(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: @@ -521,6 +536,7 @@ class RFFTOpsTest(BaseFFTOpsTest): self._checkGradComplex( self._tfIFFTForRank(rank), re, im, result_is_complex=False) + @test_util.run_deprecated_v1 def testGrad_Random(self): with spectral_ops_test_util.fft_kernel_label_map(): for rank in VALID_FFT_RANKS: diff --git a/tensorflow/python/kernel_tests/signal/mel_ops_test.py b/tensorflow/python/kernel_tests/signal/mel_ops_test.py index 2b3dde30f39..3134503daec 100644 --- a/tensorflow/python/kernel_tests/signal/mel_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/mel_ops_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util as tf_test_util from tensorflow.python.kernel_tests.signal import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops.signal import mel_ops @@ -143,12 +144,14 @@ class LinearToMelTest(test.TestCase): mel_matrix = mel_ops.linear_to_mel_weight_matrix(*config) self.assertAllClose(mel_matrix_np, self.evaluate(mel_matrix), atol=3e-6) + @tf_test_util.run_deprecated_v1 def test_dtypes(self): # LinSpace is not supported for tf.float16. for dtype in (dtypes.bfloat16, dtypes.float32, dtypes.float64): self.assertEqual(dtype, mel_ops.linear_to_mel_weight_matrix(dtype=dtype).dtype) + @tf_test_util.run_deprecated_v1 def test_error(self): with self.assertRaises(ValueError): mel_ops.linear_to_mel_weight_matrix(num_mel_bins=0) @@ -177,6 +180,7 @@ class LinearToMelTest(test.TestCase): rewritten_graph = test_util.grappler_optimize(g, [mel_matrix]) self.assertEqual(1, len(rewritten_graph.node)) + @tf_test_util.run_deprecated_v1 def test_num_spectrogram_bins_dynamic(self): with self.session(use_gpu=True): num_spectrogram_bins = array_ops.placeholder(shape=(), diff --git a/tensorflow/python/kernel_tests/signal/mfcc_ops_test.py b/tensorflow/python/kernel_tests/signal/mfcc_ops_test.py index 79d23d77d1e..935922657cd 100644 --- a/tensorflow/python/kernel_tests/signal/mfcc_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/mfcc_ops_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import spectral_ops_test_util @@ -32,6 +33,7 @@ from tensorflow.python.platform import test # HTK conventions. class MFCCTest(test.TestCase): + @test_util.run_deprecated_v1 def test_error(self): # num_mel_bins must be positive. with self.assertRaises(ValueError): @@ -43,6 +45,7 @@ class MFCCTest(test.TestCase): signal = array_ops.zeros((2, 3, 5), dtype=dtypes.float64) mfcc_ops.mfccs_from_log_mel_spectrograms(signal) + @test_util.run_deprecated_v1 def test_basic(self): """A basic test that the op runs on random input.""" with spectral_ops_test_util.fft_kernel_label_map(): @@ -50,6 +53,7 @@ class MFCCTest(test.TestCase): signal = random_ops.random_normal((2, 3, 5)) mfcc_ops.mfccs_from_log_mel_spectrograms(signal).eval() + @test_util.run_deprecated_v1 def test_unknown_shape(self): """A test that the op runs when shape and rank are unknown.""" with spectral_ops_test_util.fft_kernel_label_map(): diff --git a/tensorflow/python/kernel_tests/signal/reconstruction_ops_test.py b/tensorflow/python/kernel_tests/signal/reconstruction_ops_test.py index de3351e543c..d9b45f67c3b 100644 --- a/tensorflow/python/kernel_tests/signal/reconstruction_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/reconstruction_ops_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops @@ -62,6 +63,7 @@ class ReconstructionOpsTest(test.TestCase): self.assertAllClose(output, expected_output) + @test_util.run_deprecated_v1 def test_simple(self): def make_input(frame_length, num_frames=3): """Generate a tensor of num_frames frames of frame_length.""" @@ -133,6 +135,7 @@ class ReconstructionOpsTest(test.TestCase): self.assertEqual(output.shape, (1, 9)) self.assertEqual(string_output, self.expected_string) + @test_util.run_deprecated_v1 def test_gradient(self): configurations = [ ((1, 128), 1), @@ -154,6 +157,7 @@ class ReconstructionOpsTest(test.TestCase): gradient = sess.run(gradients_impl.gradients([loss], [signal])[0]) self.assertTrue((gradient == 1.0).all()) + @test_util.run_deprecated_v1 def test_gradient_batch(self): with self.session(use_gpu=True) as sess: signal = array_ops.zeros((2, 10, 10)) @@ -176,6 +180,7 @@ class ReconstructionOpsTest(test.TestCase): np.reshape(np.arange(100).astype(np.float32), (10, 10))]) self.assertAllEqual(expected_gradient, gradient) + @test_util.run_deprecated_v1 def test_gradient_numerical(self): with self.session(use_gpu=True): shape = (2, 10, 10) diff --git a/tensorflow/python/kernel_tests/signal/shape_ops_test.py b/tensorflow/python/kernel_tests/signal/shape_ops_test.py index 21a6b23b304..32ac76e80d0 100644 --- a/tensorflow/python/kernel_tests/signal/shape_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/shape_ops_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util as tf_test_util from tensorflow.python.kernel_tests.signal import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops @@ -32,6 +33,7 @@ from tensorflow.python.platform import test class FrameTest(test.TestCase): + @tf_test_util.run_deprecated_v1 def test_mapping_of_indices_without_padding(self): with self.session(use_gpu=True): tensor = constant_op.constant(np.arange(9152), dtypes.int32) @@ -47,6 +49,7 @@ class FrameTest(test.TestCase): self.assertAllEqual(expected, result) + @tf_test_util.run_deprecated_v1 def test_mapping_of_indices_with_padding(self): with self.session(use_gpu=True): tensor = constant_op.constant(np.arange(10000), dtypes.int32) @@ -64,6 +67,7 @@ class FrameTest(test.TestCase): self.assertAllEqual(expected, result) + @tf_test_util.run_deprecated_v1 def test_invalid_inputs(self): # Rank 0 input signal. with self.assertRaises(ValueError): @@ -84,6 +88,7 @@ class FrameTest(test.TestCase): with self.assertRaises(ValueError): shape_ops.frame([1], 1, 1, pad_end=True, pad_value=[1]) + @tf_test_util.run_deprecated_v1 def test_length_zero(self): signal = constant_op.constant([], dtype=dtypes.float32) frame_length = 2 @@ -98,6 +103,7 @@ class FrameTest(test.TestCase): pad_end=False).eval() self.assertEqual((0, 2), result.shape) + @tf_test_util.run_deprecated_v1 def test_shape_inference(self): signal = array_ops.placeholder(dtypes.int32, shape=[1, 1]) frame_length = 2 @@ -153,6 +159,7 @@ class FrameTest(test.TestCase): result = self.evaluate(op) self.assertEqual(op.shape.as_list(), list(result.shape)) + @tf_test_util.run_deprecated_v1 def test_basic_mono(self): signal = np.arange(6) frame_length = 3 @@ -178,6 +185,7 @@ class FrameTest(test.TestCase): pad_end=False).eval() self.assertAllEqual(expected, result) + @tf_test_util.run_deprecated_v1 def test_basic_stereo(self): signal = np.vstack([np.arange(6), np.arange(6) + 10]) @@ -207,6 +215,7 @@ class FrameTest(test.TestCase): pad_end=False).eval() self.assertAllEqual(expected, result) + @tf_test_util.run_deprecated_v1 def test_complex_shape(self): signal = np.vstack([np.arange(6), np.arange(6) + 10, @@ -274,6 +283,7 @@ class FrameTest(test.TestCase): [[14, 15], [0, 0], [0, 0]]]] self.assertAllEqual(expected, self.evaluate(result)) + @tf_test_util.run_deprecated_v1 def test_window_larger_than_signal(self): signal = constant_op.constant([[1, 2], [11, 12]], dtype=dtypes.float32) frame_length = 4 @@ -307,6 +317,7 @@ class FrameTest(test.TestCase): result = shape_ops.frame(signal, frame_length, frame_step) self.assertEqual(result.dtype, signal.dtype) + @tf_test_util.run_deprecated_v1 def test_dynamic_tensor(self): # Show that frame works even when the dimensions of its input are # not known at graph creation time. @@ -325,6 +336,7 @@ class FrameTest(test.TestCase): [[10, 11], [12, 13]], [[20, 21], [22, 23]]], result) + @tf_test_util.run_deprecated_v1 def test_gradient_numerical(self): with self.session(use_gpu=True): signal_shape = (2, 128) diff --git a/tensorflow/python/kernel_tests/signal/window_ops_test.py b/tensorflow/python/kernel_tests/signal/window_ops_test.py index 2f19134f5a8..a72cdb288bb 100644 --- a/tensorflow/python/kernel_tests/signal/window_ops_test.py +++ b/tensorflow/python/kernel_tests/signal/window_ops_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util as tf_test_util from tensorflow.python.kernel_tests.signal import test_util from tensorflow.python.ops.signal import window_ops from tensorflow.python.platform import test @@ -75,6 +76,7 @@ class WindowOpsTest(test.TestCase): dtype=tf_dtype).eval() self.assertAllClose(expected, actual, tol, tol) + @tf_test_util.run_deprecated_v1 def test_hann_window(self): """Check that hann_window matches scipy.signal.hann behavior.""" # The Hann window is a raised cosine window with parameters alpha=0.5 and @@ -84,6 +86,7 @@ class WindowOpsTest(test.TestCase): functools.partial(_scipy_raised_cosine, a=0.5, b=0.5), window_ops.hann_window) + @tf_test_util.run_deprecated_v1 def test_hamming_window(self): """Check that hamming_window matches scipy.signal.hamming's behavior.""" # The Hamming window is a raised cosine window with parameters alpha=0.54 diff --git a/tensorflow/python/kernel_tests/slice_op_test.py b/tensorflow/python/kernel_tests/slice_op_test.py index ee48c6eb0ed..8f7245214a2 100644 --- a/tensorflow/python/kernel_tests/slice_op_test.py +++ b/tensorflow/python/kernel_tests/slice_op_test.py @@ -24,6 +24,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops @@ -145,6 +146,7 @@ class SliceTest(test.TestCase): slice_val = self.evaluate(slice_t) self.assertAllEqual(slice_val, inp[lo:hi]) + @test_util.run_deprecated_v1 def testScalarInput(self): input_val = 0 with self.cached_session() as sess: @@ -159,6 +161,7 @@ class SliceTest(test.TestCase): "out of range"): sess.run([slice_t], feed_dict={input_t: input_val}) + @test_util.run_deprecated_v1 def testInvalidIndex(self): input_val = [1, 2] with self.cached_session() as sess: @@ -179,6 +182,7 @@ class SliceTest(test.TestCase): np_ans = x[begin:begin + size, :] self.assertAllEqual(tf_ans, np_ans) + @test_util.run_deprecated_v1 def testSliceMatrixDim0(self): x = np.random.rand(8, 4).astype("f") self._testSliceMatrixDim0(x, 1, 2) @@ -213,6 +217,7 @@ class SliceTest(test.TestCase): self.assertEqual(slice_val.shape, slice_t.get_shape()) self.assertEqual(slice2_val.shape, slice2_t.get_shape()) + @test_util.run_deprecated_v1 def testComplex(self): with self.session(use_gpu=True): inp = np.random.rand(4, 10, 10, 4).astype("f") @@ -316,6 +321,7 @@ class SliceTest(test.TestCase): g1_val, g2_val = self.evaluate([g1, g2]) self.assertAllEqual(g1_val, g2_val) + @test_util.run_deprecated_v1 def testGradientsAll(self): # Slice the middle square out of a 4x4 input self._testGradientSlice([4, 4], [1, 1], [2, 2]) @@ -335,6 +341,7 @@ class SliceTest(test.TestCase): # Use -1 as a slice dimension on a 2D tensor. self._testGradientVariableSize2D() + @test_util.run_deprecated_v1 def testNotIterable(self): # NOTE(mrry): If we register __getitem__ as an overloaded # operator, Python will valiantly attempt to iterate over the @@ -346,6 +353,7 @@ class SliceTest(test.TestCase): for _ in c: pass + @test_util.run_deprecated_v1 def testComputedShape(self): # NOTE(mrry): We cannot currently handle partially-known values, # because `tf.slice()` uses -1 to specify a wildcard size, and diff --git a/tensorflow/python/kernel_tests/softmax_op_test.py b/tensorflow/python/kernel_tests/softmax_op_test.py index 8b1a2e4c4e3..707b8a429f2 100644 --- a/tensorflow/python/kernel_tests/softmax_op_test.py +++ b/tensorflow/python/kernel_tests/softmax_op_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import nn_ops from tensorflow.python.platform import test @@ -206,6 +207,7 @@ class SoftmaxTest(test.TestCase): [[5., 4., 3., 2.], [1., 2., 3., 4.]]]) self.assertEqual([3, 2, 4], op.get_shape()) + @test_util.run_deprecated_v1 def testEmptyInput(self): with self.cached_session(): x = array_ops.placeholder(dtypes.float32, shape=[0, 3]) @@ -229,6 +231,7 @@ class SoftmaxTest(test.TestCase): with self.assertRaises(errors_impl.InvalidArgumentError): nn_ops.softmax(ones, axis=2).eval() + @test_util.run_deprecated_v1 def testLargeDims(self): # Make sure that we properly handle large inputs. See # https://github.com/tensorflow/tensorflow/issues/4425 for details diff --git a/tensorflow/python/kernel_tests/softplus_op_test.py b/tensorflow/python/kernel_tests/softplus_op_test.py index 48445a73808..5273dd7ffc7 100644 --- a/tensorflow/python/kernel_tests/softplus_op_test.py +++ b/tensorflow/python/kernel_tests/softplus_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import nn_ops @@ -70,6 +71,7 @@ class SoftplusTest(test.TestCase): ], use_gpu=True) + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): x = constant_op.constant( @@ -86,6 +88,7 @@ class SoftplusTest(test.TestCase): print("softplus (float) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testGradGrad(self): with self.cached_session(): x = constant_op.constant( @@ -103,6 +106,7 @@ class SoftplusTest(test.TestCase): print("softplus (float) gradient of gradient err = ", err) self.assertLess(err, 5e-5) + @test_util.run_deprecated_v1 def testGradGradGrad(self): with self.cached_session(): x = constant_op.constant( @@ -121,6 +125,7 @@ class SoftplusTest(test.TestCase): print("softplus (float) third-order gradient err = ", err) self.assertLess(err, 5e-5) + @test_util.run_deprecated_v1 def testNoInts(self): with self.cached_session(): with self.assertRaisesRegexp( diff --git a/tensorflow/python/kernel_tests/softsign_op_test.py b/tensorflow/python/kernel_tests/softsign_op_test.py index 71aac7e48e1..5554240c826 100644 --- a/tensorflow/python/kernel_tests/softsign_op_test.py +++ b/tensorflow/python/kernel_tests/softsign_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import nn_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import @@ -49,6 +50,7 @@ class SoftsignTest(test.TestCase): np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]).astype(t), use_gpu=True) + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session(): x = constant_op.constant( @@ -65,6 +67,7 @@ class SoftsignTest(test.TestCase): print("softsign (float) gradient err = ", err) self.assertLess(err, 1e-4) + @test_util.run_deprecated_v1 def testNoInts(self): with self.cached_session(): with self.assertRaisesRegexp( diff --git a/tensorflow/python/kernel_tests/spacetobatch_op_test.py b/tensorflow/python/kernel_tests/spacetobatch_op_test.py index 21134adf2ca..8641156604c 100644 --- a/tensorflow/python/kernel_tests/spacetobatch_op_test.py +++ b/tensorflow/python/kernel_tests/spacetobatch_op_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import gradient_checker @@ -115,6 +116,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): self._testPad(inputs, paddings, block_size, outputs) # [1, 2, 2, 1] <-> [4, 1, 1, 1] + @test_util.run_deprecated_v1 def testSmallInput2x2(self): x_np = [[[[1], [2]], [[3], [4]]]] block_size = 2 @@ -122,6 +124,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): self._testOne(x_np, block_size, x_out) # [1, 2, 2, 1] <-> [1, 3, 3, 1] (padding) <-> [9, 1, 1, 1] + @test_util.run_deprecated_v1 def testSmallInput2x2Pad1x0(self): x_np = [[[[1], [2]], [[3], [4]]]] paddings = np.array([[1, 0], [1, 0]], dtype=np.int32) @@ -132,6 +135,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): # Test with depth larger than 1. # [1, 2, 2, 3] <-> [4, 1, 1, 3] + @test_util.run_deprecated_v1 def testDepthInput2x2(self): x_np = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] block_size = 2 @@ -140,6 +144,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): # Test for larger input dimensions. # [1, 4, 4, 1] <-> [4, 2, 2, 1] + @test_util.run_deprecated_v1 def testLargerInput2x2(self): x_np = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] @@ -150,6 +155,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): # Test with batch larger than 1. # [2, 2, 4, 1] <-> [8, 1, 2, 1] + @test_util.run_deprecated_v1 def testBatchInput2x2(self): x_np = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] @@ -162,6 +168,7 @@ class SpaceToBatchTest(test.TestCase, PythonOpImpl): # that elements are correctly laid out spatially and properly interleaved # along the batch dimension. # [2, 4, 4, 1] <-> [8, 2, 2, 1] + @test_util.run_deprecated_v1 def testLargerInputBatch2x2(self): x_np = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]], @@ -206,6 +213,7 @@ class SpaceToBatchNDTest(test.TestCase): self._testPad(inputs, block_shape, paddings, space_to_batch_direct(inputs, block_shape, paddings)) + @test_util.run_deprecated_v1 def testZeroBlockDimsZeroRemainingDims(self): self._testPad( inputs=[1, 2], @@ -213,6 +221,7 @@ class SpaceToBatchNDTest(test.TestCase): paddings=[], outputs=[1, 2],) + @test_util.run_deprecated_v1 def testZeroBlockDimsOneRemainingDim(self): self._testPad( inputs=[[1, 2], [3, 4]], @@ -227,6 +236,7 @@ class SpaceToBatchNDTest(test.TestCase): paddings=[[0, 0]], outputs=[[1, 2], [3, 4]]) + @test_util.run_deprecated_v1 def testZeroBlockDimsTwoRemainingDims(self): self._testPad( inputs=[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], @@ -248,6 +258,7 @@ class SpaceToBatchNDTest(test.TestCase): paddings=[[0, 0], [0, 0]], outputs=[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) + @test_util.run_deprecated_v1 def testOneBlockDimZeroRemainingDims(self): self._testPad( inputs=[[1, 2, 3], [4, 5, 6]], @@ -255,6 +266,7 @@ class SpaceToBatchNDTest(test.TestCase): paddings=[1, 0], outputs=[[0, 2], [0, 5], [1, 3], [4, 6]]) + @test_util.run_deprecated_v1 def testOneBlockDimOneRemainingDim(self): self._testPad( inputs=[[[1, 11], [2, 21], [3, 31]], [[4, 41], [5, 51], [6, 61]]], @@ -263,6 +275,7 @@ class SpaceToBatchNDTest(test.TestCase): outputs=[[[0, 0], [2, 21]], [[0, 0], [5, 51]], [[1, 11], [3, 31]], [[4, 41], [6, 61]]]) + @test_util.run_deprecated_v1 def testDirect(self): # Test with zero-size remaining dimension. self._testDirect( @@ -300,6 +313,7 @@ class SpaceToBatchNDTest(test.TestCase): class SpaceToBatchSpaceToDepth(test.TestCase, PythonOpImpl): # Verifies that: space_to_batch(x) = transpose(space_to_depth(transpose(x))) + @test_util.run_deprecated_v1 def testSpaceToDepthTranspose(self): x = np.arange(5 * 10 * 16 * 7, dtype=np.float32).reshape([5, 10, 16, 7]) block_size = 2 @@ -319,6 +333,7 @@ class SpaceToBatchSpaceToDepthCpp(SpaceToBatchSpaceToDepth, CppOpImpl): class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): + @test_util.run_deprecated_v1 def testInputWrongDimMissingBatch(self): # The input is missing the first dimension ("batch") x_np = [[[1], [2]], [[3], [4]]] @@ -327,6 +342,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.space_to_batch(x_np, paddings, block_size) + @test_util.run_deprecated_v1 def testBlockSize0(self): # The block size is 0. x_np = [[[[1], [2]], [[3], [4]]]] @@ -336,6 +352,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.space_to_batch(x_np, paddings, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeOne(self): # The block size is 1. The block size needs to be > 1. x_np = [[[[1], [2]], [[3], [4]]]] @@ -345,6 +362,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.space_to_batch(x_np, paddings, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeLarger(self): # The block size is too large for this input. x_np = [[[[1], [2]], [[3], [4]]]] @@ -354,6 +372,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): out_tf = self.space_to_batch(x_np, paddings, block_size) out_tf.eval() + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleWidth(self): # The block size divides width but not height. x_np = [[[[1], [2], [3]], [[3], [4], [7]]]] @@ -362,6 +381,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.space_to_batch(x_np, paddings, block_size) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleHeight(self): # The block size divides height but not width. x_np = [[[[1], [2]], [[3], [4]], [[5], [6]]]] @@ -370,6 +390,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.space_to_batch(x_np, paddings, block_size) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleBoth(self): # The block size does not divide neither width or height. x_np = [[[[1], [2]], [[3], [4]]]] @@ -378,6 +399,7 @@ class SpaceToBatchErrorHandlingTest(test.TestCase, PythonOpImpl): with self.assertRaises(ValueError): _ = self.space_to_batch(x_np, paddings, block_size) + @test_util.run_deprecated_v1 def testUnknownShape(self): t = self.space_to_batch( array_ops.placeholder(dtypes.float32), @@ -424,25 +446,31 @@ class SpaceToBatchNDErrorHandlingTest(test.TestCase): self._testStaticShape(input_shape, block_shape, paddings, error) self._testDynamicShape(input_shape, block_shape, paddings) + @test_util.run_deprecated_v1 def testBlockSize0(self): # The block size is 0. self._testShape([1, 2, 2], [0, 2], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockSizeNegative(self): self._testShape([1, 2, 2], [-1, 2], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testNegativePadding(self): # The padding is negative. self._testShape([1, 2, 2], [1, 1], [[0, -1], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisible(self): # The padded size is not divisible by the block size. self._testShape([1, 2, 3, 1], [3, 3], [[0, 0], [0, 0]], ValueError) + @test_util.run_deprecated_v1 def testBlockDimsMismatch(self): # Shape of block_shape does not match shape of paddings. self._testStaticShape([1, 3, 3, 1], [3, 3], [[0, 0]], ValueError) + @test_util.run_deprecated_v1 def testUnknown(self): # Verify that input shape and paddings shape can be unknown. _ = array_ops.space_to_batch_nd( @@ -522,18 +550,21 @@ class SpaceToBatchGradientTest(test.TestCase, PythonOpImpl): # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): block_size = 2 pad_beg = 0 pad_end = 0 self._compare(1, 2, 3, 5, block_size, pad_beg, pad_end) + @test_util.run_deprecated_v1 def testSmall2(self): block_size = 2 pad_beg = 0 pad_end = 0 self._compare(2, 4, 3, 2, block_size, pad_beg, pad_end) + @test_util.run_deprecated_v1 def testSmallPad1x1(self): block_size = 2 pad_beg = 1 @@ -572,15 +603,19 @@ class SpaceToBatchNDGradientTest(test.TestCase): # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): self._compare([1, 4, 6, 5], [2, 2], [[0, 0], [0, 0]]) + @test_util.run_deprecated_v1 def testSmall2(self): self._compare([2, 8, 6, 2], [2, 2], [[0, 0], [0, 0]]) + @test_util.run_deprecated_v1 def testSmallPad1(self): self._compare([2, 4, 6, 2], [2, 2], [[1, 1], [1, 1]]) + @test_util.run_deprecated_v1 def testSmallPadThreeBlockDims(self): self._compare([2, 2, 4, 3, 2], [2, 2, 2], [[1, 1], [1, 1], [1, 0]]) @@ -644,6 +679,7 @@ class RequiredSpaceToBatchPaddingsTest(test.TestCase): self.assertAllEqual(paddings_result, paddings_const) self.assertAllEqual(crops_result, crops_const) + @test_util.run_deprecated_v1 def testSimple(self): self._test( input_shape=np.zeros((0,), np.int32), diff --git a/tensorflow/python/kernel_tests/spacetodepth_op_test.py b/tensorflow/python/kernel_tests/spacetodepth_op_test.py index c9aaa68971a..e96bc09f365 100644 --- a/tensorflow/python/kernel_tests/spacetodepth_op_test.py +++ b/tensorflow/python/kernel_tests/spacetodepth_op_test.py @@ -159,6 +159,7 @@ class SpaceToDepthTest(test.TestCase): # Error handling: + @test_util.run_deprecated_v1 def testInputWrongDimMissingDepth(self): # The input is missing the last dimension ("depth") x_np = [[[1, 2], [3, 4]]] @@ -167,6 +168,7 @@ class SpaceToDepthTest(test.TestCase): out_tf = array_ops.space_to_depth(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testInputWrongDimMissingBatch(self): # The input is missing the first dimension ("batch") x_np = [[[1], [2]], [[3], [4]]] @@ -174,6 +176,7 @@ class SpaceToDepthTest(test.TestCase): with self.assertRaises(ValueError): _ = array_ops.space_to_depth(x_np, block_size) + @test_util.run_deprecated_v1 def testBlockSize0(self): # The block size is 0. x_np = [[[[1], [2]], [[3], [4]]]] @@ -182,6 +185,7 @@ class SpaceToDepthTest(test.TestCase): out_tf = array_ops.space_to_depth(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testBlockSizeOne(self): # The block size is 1. The block size needs to be > 1. x_np = [[[[1], [2]], [[3], [4]]]] @@ -190,6 +194,7 @@ class SpaceToDepthTest(test.TestCase): out_tf = array_ops.space_to_depth(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testBlockSizeLarger(self): # The block size is too large for this input. x_np = [[[[1], [2]], [[3], [4]]]] @@ -198,6 +203,7 @@ class SpaceToDepthTest(test.TestCase): out_tf = array_ops.space_to_depth(x_np, block_size) self.evaluate(out_tf) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleWidth(self): # The block size divides width but not height. x_np = [[[[1], [2], [3]], [[3], [4], [7]]]] @@ -205,6 +211,7 @@ class SpaceToDepthTest(test.TestCase): with self.assertRaises(ValueError): _ = array_ops.space_to_depth(x_np, block_size) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleHeight(self): # The block size divides height but not width. x_np = [[[[1], [2]], [[3], [4]], [[5], [6]]]] @@ -212,6 +219,7 @@ class SpaceToDepthTest(test.TestCase): with self.assertRaises(ValueError): _ = array_ops.space_to_depth(x_np, block_size) + @test_util.run_deprecated_v1 def testBlockSizeNotDivisibleBoth(self): # The block size does not divide neither width or height. x_np = [[[[1], [2]], [[3], [4]]]] @@ -219,6 +227,7 @@ class SpaceToDepthTest(test.TestCase): with self.assertRaises(ValueError): _ = array_ops.space_to_depth(x_np, block_size) + @test_util.run_deprecated_v1 def testUnknownShape(self): t = array_ops.space_to_depth( array_ops.placeholder(dtypes.float32), block_size=4) @@ -334,11 +343,13 @@ class SpaceToDepthGradientTest(test.TestCase): # Don't use very large numbers as dimensions here as the result is tensor # with cartesian product of the dimensions. + @test_util.run_deprecated_v1 def testSmall(self): block_size = 2 self._compare(1, 2, 3, 5, block_size, "NHWC") self._compare(1, 2, 3, 5, block_size, "NCHW") + @test_util.run_deprecated_v1 def testSmall2(self): block_size = 2 self._compare(2, 4, 3, 2, block_size, "NHWC") diff --git a/tensorflow/python/kernel_tests/sparse_add_op_test.py b/tensorflow/python/kernel_tests/sparse_add_op_test.py index c61f8633558..00eff54077c 100644 --- a/tensorflow/python/kernel_tests/sparse_add_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_add_op_test.py @@ -140,6 +140,7 @@ class SparseAddTest(test.TestCase): self.assertAllClose(sum_out.values, [2, 6, -.2]) self.assertAllEqual(sum_out.dense_shape, [3, 3]) + @test_util.run_deprecated_v1 def testGradients(self): np.random.seed(1618) # Make it reproducible. with self.session(use_gpu=False): @@ -176,6 +177,7 @@ class SparseAddTest(test.TestCase): self.assertAllEqual(dense_np + rand_vals_np, s) self.assertTrue(s.dtype == dtype) + @test_util.run_deprecated_v1 def testSparseTensorDenseAddGradients(self): np.random.seed(1618) # Make it reproducible. n, m = np.random.randint(30, size=2) @@ -191,6 +193,7 @@ class SparseAddTest(test.TestCase): [(nnz,), (n, m)], s, (n, m)) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testInvalidSparseTensor(self): with test_util.force_cpu(): shape = [2, 2] diff --git a/tensorflow/python/kernel_tests/sparse_concat_op_test.py b/tensorflow/python/kernel_tests/sparse_concat_op_test.py index 368a533e569..04b6b9b8d20 100644 --- a/tensorflow/python/kernel_tests/sparse_concat_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_concat_op_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test @@ -253,6 +254,7 @@ class SparseConcatTest(test.TestCase): [b"a", b"b", b"e", b"c", b"d", b"f", b"g", b"h"]) self.assertAllEqual(concat_out.dense_shape, [3, 8]) + @test_util.run_deprecated_v1 def testMismatchedRank(self): with self.session(use_gpu=False): sp_a = self._SparseTensor_3x3() @@ -263,6 +265,7 @@ class SparseConcatTest(test.TestCase): with self.assertRaises(ValueError): sparse_ops.sparse_concat(concat_dim, [sp_a, sp_e]) + @test_util.run_deprecated_v1 def testMismatchedRankExpandNonconcatDim(self): with self.session(use_gpu=False): sp_a = self._SparseTensor_3x3() @@ -275,6 +278,7 @@ class SparseConcatTest(test.TestCase): sparse_ops.sparse_concat( concat_dim, [sp_a, sp_e], expand_nonconcat_dim=True) + @test_util.run_deprecated_v1 def testMismatchedShapes(self): with self.session(use_gpu=False) as sess: sp_a = self._SparseTensor_3x3() @@ -321,6 +325,7 @@ class SparseConcatTest(test.TestCase): [1, 1, 2, 1, 1, 1, 2, 3, 4, 2, 1, 0, 2]) self.assertAllEqual(sp_concat_dim1_out.dense_shape, [3, 13]) + @test_util.run_deprecated_v1 def testShapeInferenceUnknownShapes(self): with self.session(use_gpu=False): sp_inputs = [ diff --git a/tensorflow/python/kernel_tests/sparse_conditional_accumulator_test.py b/tensorflow/python/kernel_tests/sparse_conditional_accumulator_test.py index 66589fa315d..275c86e5349 100644 --- a/tensorflow/python/kernel_tests/sparse_conditional_accumulator_test.py +++ b/tensorflow/python/kernel_tests/sparse_conditional_accumulator_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.platform import test @@ -98,12 +99,14 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): attr { key: 'reduction_type' value {s: 'MEAN'} } """, q.accumulator_ref.op.node_def) + @test_util.run_deprecated_v1 def testAccumulatorSizeEmpty(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( dtypes_lib.float32, name="Q") self.assertEqual(q.num_accumulated().eval(), 0) + @test_util.run_deprecated_v1 def testAccumulatorSetGlobalStep(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -111,6 +114,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): set_global_step_op = q.set_global_step(1) set_global_step_op.run() + @test_util.run_deprecated_v1 def testAccumulatorApplyGradFloat32(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -122,6 +126,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): accum_op.run() self.assertEqual(q.num_accumulated().eval(), 1) + @test_util.run_deprecated_v1 def testDtypes(self): with self.cached_session() as sess: dtypes = [dtypes_lib.float16, dtypes_lib.float32, dtypes_lib.float64] @@ -144,6 +149,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): self._assertEqual_nparray(sum_elems / len(elems), result, sess) + @test_util.run_deprecated_v1 def testAccumulatorMultipleAccumulators(self): with self.cached_session() as sess: q_f32_0 = data_flow_ops.SparseConditionalAccumulator( @@ -174,6 +180,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): result = sess.run(accums[i].take_indexed_slices_grad(1)) self._assertEqual_indexedslices(expected_tensors[i], result) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradMean(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -194,6 +201,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): self.assertAllEqual([[0.5, 0.5], [0, 2], [3, 0]], val.values) self.assertAllEqual([-1, 2], val.dense_shape) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradSum(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -214,11 +222,13 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): self.assertAllEqual([[1, 1], [0, 2], [3, 0]], val.values) self.assertAllEqual([-1, 2], val.dense_shape) + @test_util.run_deprecated_v1 def testAccumulatorTakeGradInvalidReductionType(self): with self.assertRaises(ValueError): data_flow_ops.SparseConditionalAccumulator( dtypes_lib.float32, name="Q", shape=(), reduction_type="Invalid") + @test_util.run_deprecated_v1 def testAccumulatorRepeatedTakeGrad(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -257,6 +267,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): self.assertAllEqual(val.values, [[5, 5], [0, 20], [30, 0]]) self.assertAllEqual(val.dense_shape, [-1, 2]) + @test_util.run_deprecated_v1 def testParallelApplyGradMean(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -288,6 +299,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): np.array([[expected_val, 0], [0, expected_val]]).astype(np.float32), val, sess) + @test_util.run_deprecated_v1 def testParallelApplyGradSum(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -322,6 +334,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): np.array([[expected_val, 0], [0, expected_val]]).astype(np.float32), val, sess) + @test_util.run_deprecated_v1 def testParallelTakeGrad(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -361,6 +374,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): self._assertEqual_nparray( np.array([[0, 0], [elems[i], 0]]), results[i], sess) + @test_util.run_deprecated_v1 def testAccumulatorApplyAndBlockingTake(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -396,6 +410,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): with self.assertRaisesOpError("was cancelled"): self.evaluate(takeg_op) + @test_util.run_deprecated_v1 def testAccumulatorCancel(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -415,6 +430,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): takeg_thread.join() + @test_util.run_deprecated_v1 def testNonVectorIndices(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -427,6 +443,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): grad_indices=[[0, 1], [1, 0]], grad_values=np.array([1, 2]).astype(np.float32)).run() + @test_util.run_deprecated_v1 def testZeroDimensionValues(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -437,6 +454,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): q.apply_grad( grad_indices=[0], grad_values=np.array(1).astype(np.float32)).run() + @test_util.run_deprecated_v1 def testWrongNonEmptyInputValues(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -448,6 +466,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): grad_indices=[0, 1], grad_values=np.array([[0, 1, 1]]).astype(np.float32)).run() + @test_util.run_deprecated_v1 def testDynamicNonVectorIndices(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -467,6 +486,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): x_values: np.array([1, 2]).astype(np.float32) }) + @test_util.run_deprecated_v1 def testDynamicWrongNonEmptyInputValues(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -485,6 +505,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): x_values: np.array([[0, 1, 1]]).astype(np.float32) }) + @test_util.run_deprecated_v1 def testEmptyShapeApply(self): with self.cached_session(): q = data_flow_ops.SparseConditionalAccumulator( @@ -510,6 +531,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): q.apply_grad(grad_indices=[0], grad_values=[1.0], grad_shape=[]).run() q.apply_grad(grad_indices=[0], grad_values=[1.0]).run() + @test_util.run_deprecated_v1 def testValidateShape(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -605,6 +627,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]]).astype(np.float32), local_step=1).run() + @test_util.run_deprecated_v1 def testReturnShape(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( @@ -630,6 +653,7 @@ class IndexedSlicesConditionalAccumulatorTest(test.TestCase): val = self.evaluate(q.take_indexed_slices_grad(1)) self.assertAllEqual(val.dense_shape, [-1, 2, 2, 3]) + @test_util.run_deprecated_v1 def testApplyGradtInt32IndicesAndShape(self): with self.cached_session() as sess: q = data_flow_ops.SparseConditionalAccumulator( diff --git a/tensorflow/python/kernel_tests/sparse_cross_op_test.py b/tensorflow/python/kernel_tests/sparse_cross_op_test.py index 8451b96c564..566bbb56f00 100644 --- a/tensorflow/python/kernel_tests/sparse_cross_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_cross_op_test.py @@ -24,12 +24,14 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test class SparseCrossOpTest(test.TestCase): + @test_util.run_deprecated_v1 def test_simple(self): """Tests a simple scenario.""" op = sparse_ops.sparse_cross([ @@ -45,6 +47,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_dense(self): """Tests only dense inputs.""" op = sparse_ops.sparse_cross([ @@ -65,6 +68,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_integer_mixed_string_sparse(self): """Tests mixed type.""" op = sparse_ops.sparse_cross([ @@ -79,6 +83,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_integer_mixed_string_dense(self): """Tests mixed dense inputs.""" op = sparse_ops.sparse_cross([ @@ -97,6 +102,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_sparse_cross_dense(self): """Tests sparse and dense inputs.""" op = sparse_ops.sparse_cross([ @@ -114,6 +120,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_integer_sparse_input(self): """Tests mixed type sparse and dense inputs.""" op = sparse_ops.sparse_cross([ @@ -130,6 +137,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_permutation_3x3x3(self): """Tests 3x3x3 permutation.""" op = sparse_ops.sparse_cross([ @@ -172,6 +180,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_permutation_3x1x2(self): """Tests 3x1x2 permutation.""" op = sparse_ops.sparse_cross([ @@ -191,6 +200,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_large_batch(self): """Tests with large batch size to force multithreading.""" batch_size = 5000 @@ -224,6 +234,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_one_column_empty(self): """Tests when one column is empty. @@ -237,6 +248,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_empty(self.evaluate(op)) + @test_util.run_deprecated_v1 def test_some_columns_empty(self): """Tests when more than one columns are empty. @@ -256,6 +268,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_all_columns_empty(self): """Tests when all columns are empty. @@ -269,6 +282,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_empty(self.evaluate(op)) + @test_util.run_deprecated_v1 def test_hashed_zero_bucket_no_hash_key(self): op = sparse_ops.sparse_cross_hashed([ self._sparse_tensor([['batch1-FC1-F1']]), @@ -280,6 +294,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_hashed_zero_bucket(self): op = sparse_ops.sparse_cross_hashed( [ @@ -294,6 +309,7 @@ class SparseCrossOpTest(test.TestCase): self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) # TODO(sibyl-Aix6ihai): Add benchmark to compare Hashed vs Non-hashed. + @test_util.run_deprecated_v1 def test_hashed_no_hash_key(self): op = sparse_ops.sparse_cross_hashed( [ @@ -307,6 +323,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_hashed_output(self): op = sparse_ops.sparse_cross_hashed( [ @@ -321,6 +338,7 @@ class SparseCrossOpTest(test.TestCase): with self.cached_session() as sess: self._assert_sparse_tensor_equals(expected_out, self.evaluate(op)) + @test_util.run_deprecated_v1 def test_hashed__has_no_collision(self): """Tests that fingerprint concatenation has no collisions.""" # Although the last 10 bits of 359 and 1024+359 are identical. diff --git a/tensorflow/python/kernel_tests/sparse_matmul_op_test.py b/tensorflow/python/kernel_tests/sparse_matmul_op_test.py index 4de69a26e32..2e17a9c608f 100644 --- a/tensorflow/python/kernel_tests/sparse_matmul_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_matmul_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -71,6 +72,7 @@ class SparseMatMulTest(test.TestCase): self.assertShapeEqual(np_ans, tf_ans) self.assertAllCloseAccordingToType(np_ans, out, rtol=1e-4, atol=1e-4) + @test_util.run_deprecated_v1 def testBasic(self): x = np.arange(0., 4.).reshape([4, 1]).astype(np.float32) y = np.arange(-1., 1.).reshape([1, 2]).astype(np.float32) @@ -78,6 +80,7 @@ class SparseMatMulTest(test.TestCase): for y_dtype in (dtypes.float32, dtypes.bfloat16): self._testCpuMatmul(x, y, x_dtype=x_dtype, y_dtype=y_dtype) + @test_util.run_deprecated_v1 def testZeroDim(self): x = np.ones((4, 0)).astype(np.float32) y = np.ones((0, 3)).astype(np.float32) @@ -85,6 +88,7 @@ class SparseMatMulTest(test.TestCase): for y_dtype in (dtypes.float32, dtypes.bfloat16): self._testCpuMatmul(x, y, x_dtype=x_dtype, y_dtype=y_dtype) + @test_util.run_deprecated_v1 def testEmpty(self): x = np.ones((0, 0)).astype(np.float32) y = np.ones((0, 0)).astype(np.float32) @@ -93,6 +97,7 @@ class SparseMatMulTest(test.TestCase): self._testCpuMatmul(x, y, x_dtype=x_dtype, y_dtype=y_dtype) # Tests setting one dimension to be a high value. + @test_util.run_deprecated_v1 def testLarge(self): r1 = np.random.randint(6000, 20000) r2 = np.random.randint(1, 10) @@ -105,6 +110,7 @@ class SparseMatMulTest(test.TestCase): self._testCpuMatmul(x, y, x_dtype=x_dtype, y_dtype=y_dtype) # Tests random sized matrices. + @test_util.run_deprecated_v1 def testRandom(self): for tr_a in [True, False]: for tr_b in [True, False]: @@ -159,6 +165,7 @@ class MatMulGradientTest(test.TestCase): delta=delta)) self.assertLessEqual(err, delta / 2.) + @test_util.run_deprecated_v1 def testGradientInput(self): for tr_a in [True, False]: for tr_b in [True, False]: diff --git a/tensorflow/python/kernel_tests/sparse_ops_test.py b/tensorflow/python/kernel_tests/sparse_ops_test.py index 605aaf3dd12..75f65e62517 100644 --- a/tensorflow/python/kernel_tests/sparse_ops_test.py +++ b/tensorflow/python/kernel_tests/sparse_ops_test.py @@ -71,6 +71,7 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase): constant_op.constant(val, dtype), constant_op.constant(shape, dtypes.int64)) + @test_util.run_deprecated_v1 def testInt32(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_5x6(dtypes.int32) @@ -83,6 +84,7 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase): self.assertAllEqual(output, expected_output) + @test_util.run_deprecated_v1 def testInt64(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_5x6(dtypes.int64) @@ -95,6 +97,7 @@ class SparseToIndicatorTest(test_util.TensorFlowTestCase): self.assertAllEqual(output, expected_output) + @test_util.run_deprecated_v1 def testHigherRank(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_2x3x4(dtypes.int64) @@ -296,6 +299,7 @@ class SparseRetainTest(test_util.TensorFlowTestCase): def _SparseTensor_5x6(self): return sparse_tensor.SparseTensor.from_value(self._SparseTensorValue_5x6()) + @test_util.run_deprecated_v1 def testBasic(self): with self.session(use_gpu=False) as sess: for sp_input in (self._SparseTensorValue_5x6(), self._SparseTensor_5x6()): @@ -353,12 +357,14 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): return sparse_tensor.SparseTensorValue(self._IND_2_5_6, self._VAL_2_5_6, self._SHP_2_5_6) + @test_util.run_deprecated_v1 def testStaticShapeInfoPreservedWhenNewShapeIsProvidedAndStatic(self): sp_input = self._SparseTensor_2x5x6() new_shape = np.array([3, 6, 7], dtype=np.int64) sp_output = sparse_ops.sparse_reset_shape(sp_input, new_shape) self.assertAllEqual([3, 6, 7], sp_output.get_shape()) + @test_util.run_deprecated_v1 def testBasic(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensor_2x5x6() @@ -372,6 +378,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): self.assertAllEqual(output.values, [0, 10, 13, 14, 32, 33]) self.assertAllEqual(output.dense_shape, [3, 6, 7]) + @test_util.run_deprecated_v1 def testInputUnavailableInGraphConstructionOk(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorValue_2x5x6() @@ -385,6 +392,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): self.assertAllEqual(output.values, [0, 10, 13, 14, 32, 33]) self.assertAllEqual(output.dense_shape, [3, 6, 7]) + @test_util.run_deprecated_v1 def testFeedInputUnavailableInGraphConstructionOk(self): with self.session(use_gpu=False) as sess: sp_input = array_ops.sparse_placeholder(dtype=dtypes.int32) @@ -422,6 +430,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): self.assertAllEqual(output.values.shape, [0]) self.assertAllEqual(output.dense_shape, [0, 0, 0]) + @test_util.run_deprecated_v1 def testInvalidRank(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_2x5x6() @@ -430,6 +439,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): with self.assertRaises(ValueError): sparse_ops.sparse_reset_shape(sp_input, new_shape) + @test_util.run_deprecated_v1 def testInvalidRankNewShapeUnavailableInGraphConstruction(self): with self.session(use_gpu=False) as sess: new_shape = array_ops.placeholder(dtype=dtypes.int64) @@ -439,6 +449,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): with self.assertRaisesOpError("x == y did not hold element-wise"): sess.run(out, feed_dict={new_shape: np.array([3, 7], dtype=np.int64)}) + @test_util.run_deprecated_v1 def testInvalidDimensionSizeStatic(self): sp_input = self._SparseTensor_2x5x6() new_shape = np.array([3, 7, 5], dtype=np.int64) @@ -446,6 +457,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): with self.assertRaisesRegexp(ValueError, "should have dimension sizes"): sparse_ops.sparse_reset_shape(sp_input, new_shape) + @test_util.run_deprecated_v1 def testInvalidDimensionSizeDynamic(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensor_2x5x6() @@ -455,6 +467,7 @@ class SparseResetShapeTest(test_util.TensorFlowTestCase): with self.assertRaisesOpError("x <= y did not hold element-wise"): sess.run(out, feed_dict={new_shape: [3, 7, 5]}) + @test_util.run_deprecated_v1 def testInvalidDimensionSizeInputUnavailableInGraphConstruction(self): sp_input = array_ops.sparse_placeholder(dtype=dtypes.int32) with self.session(use_gpu=False) as sess: @@ -496,6 +509,7 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase): constant_op.constant(val, dtypes.int32), constant_op.constant(shape, dtypes.int64)) + @test_util.run_deprecated_v1 def testFillNumber(self): with self.session(use_gpu=False) as sess: for sp_input in (self._SparseTensorValue_5x6(), self._SparseTensor_5x6()): @@ -513,6 +527,7 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase): self.assertAllEqual(empty_row_indicator_out, np.array([0, 0, 1, 0, 1]).astype(np.bool)) + @test_util.run_deprecated_v1 def testFillFloat(self): with self.session(use_gpu=False) as sess: values = constant_op.constant( @@ -547,6 +562,7 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase): self.assertGreater(default_value_grad_err, 0) self.assertLess(default_value_grad_err, 1e-8) + @test_util.run_deprecated_v1 def testFillString(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensor_String5x6() @@ -565,6 +581,7 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase): self.assertAllEqual(empty_row_indicator_out, np.array([0, 0, 1, 0, 1]).astype(np.bool)) + @test_util.run_deprecated_v1 def testNoEmptyRows(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensor_2x6() @@ -582,6 +599,7 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase): class SparseAddTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testValuesInVariable(self): indices = constant_op.constant([[1]], dtype=dtypes.int64) values = variables.Variable([1], trainable=False, dtype=dtypes.float32) @@ -657,6 +675,7 @@ class SparseReduceTest(test_util.TensorFlowTestCase): self._compare(sp_t, reduction_axes, ndims, True, False) self._compare(sp_t, reduction_axes, ndims, True, True) + @test_util.run_deprecated_v1 def testSimpleAndRandomInputs(self): if np.__version__ == "1.13.0": self.skipTest("numpy 1.13.0 bug") @@ -696,6 +715,7 @@ class SparseReduceTest(test_util.TensorFlowTestCase): with self.assertRaisesOpError("Invalid reduction dimension 2"): sparse_ops.sparse_reduce_max(sp_t, 2).eval() + @test_util.run_deprecated_v1 def testGradient(self): if np.__version__ == "1.13.0": self.skipTest("numpy 1.13.0 bug") @@ -778,6 +798,7 @@ class SparseMathOpsTest(test_util.TensorFlowTestCase): result_tensor.values).eval() self.assertAllEqual(result_np, res_densified) + @test_util.run_deprecated_v1 def testCwiseDivAndMul(self): np.random.seed(1618) sp_shapes = [(10, 10, 10), (5, 5), (1618,), (3, 3, 7)] @@ -801,6 +822,7 @@ class SparseMathOpsTest(test_util.TensorFlowTestCase): res = sp_t / dense_t # should invoke "__truediv__" self.assertEqual(res.values.eval().dtype, np.float64) + @test_util.run_deprecated_v1 def testCwiseAdd(self): with self.session(use_gpu=False): # Identity(2) + AllOnes(2,2). Should be equal to 2 * Identity(2). @@ -820,6 +842,7 @@ class SparseMathOpsTest(test_util.TensorFlowTestCase): sparse_ops.sparse_dense_cwise_add(sp_t, dense_t), np.identity(2) * 2, sp_t) + @test_util.run_deprecated_v1 def testGradients(self): np.random.seed(1618) sp_shapes = [(10, 10, 10), (5, 5), (1618,), (3, 3, 7)] @@ -853,6 +876,7 @@ class SparseMathOpsTest(test_util.TensorFlowTestCase): class SparseSoftmaxTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testEquivalentToDensified(self): np.random.seed(1618) n, m = np.random.choice(20, size=2) @@ -872,6 +896,7 @@ class SparseSoftmaxTest(test_util.TensorFlowTestCase): self.assertAllClose(dense_result.eval(), sp_result) + @test_util.run_deprecated_v1 def testHigherRanks(self): # For the first shape: # First batch: @@ -901,6 +926,7 @@ class SparseSoftmaxTest(test_util.TensorFlowTestCase): self.assertAllEqual(sp_t.indices.eval(), result.indices) self.assertAllEqual(shape, result.dense_shape) + @test_util.run_deprecated_v1 def testGradient(self): x_shape = [2, 5, 10] with self.cached_session(use_gpu=False): @@ -920,6 +946,7 @@ class SparseMinimumMaximumTest(test_util.TensorFlowTestCase): self.assertAllEqual(a.values, b.values) self.assertAllEqual(a.dense_shape, b.dense_shape) + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session(use_gpu=False): # 1-D, values at index 0. @@ -939,6 +966,7 @@ class SparseMinimumMaximumTest(test_util.TensorFlowTestCase): self._assertSparseTensorValueEqual(expected.eval(), max_tf) self._assertSparseTensorValueEqual(expected.eval(), min_tf) + @test_util.run_deprecated_v1 def testRandom(self): np.random.seed(1618) shapes = [(13,), (6, 8), (1, 7, 1)] @@ -980,6 +1008,7 @@ class SparseMinimumMaximumTest(test_util.TensorFlowTestCase): class SparseTransposeTest(test.TestCase): + @test_util.run_deprecated_v1 def testTranspose(self): if np.__version__ == "1.13.0": self.skipTest("numpy 1.13.0 bug") @@ -1002,16 +1031,19 @@ class SparseTransposeTest(test.TestCase): class SparsePlaceholderTest(test.TestCase): + @test_util.run_deprecated_v1 def testPlaceholder(self): foo = array_ops.sparse_placeholder(dtypes.float32, shape=(10, 47)) self.assertAllEqual([10, 47], foo.get_shape()) self.assertAllEqual([None, 2], foo.indices.get_shape().as_list()) + @test_util.run_deprecated_v1 def testPartialShapePlaceholder(self): foo = array_ops.sparse_placeholder(dtypes.float32, shape=(None, 47)) self.assertAllEqual([None, None], foo.get_shape().as_list()) self.assertAllEqual([None, 2], foo.indices.get_shape().as_list()) + @test_util.run_deprecated_v1 def testNoShapePlaceholder(self): foo = array_ops.sparse_placeholder(dtypes.float32, shape=None) self.assertAllEqual(None, foo.get_shape()) diff --git a/tensorflow/python/kernel_tests/sparse_reorder_op_test.py b/tensorflow/python/kernel_tests/sparse_reorder_op_test.py index bbf2f392026..93fcc6a18e6 100644 --- a/tensorflow/python/kernel_tests/sparse_reorder_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_reorder_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import sparse_ops @@ -65,6 +66,7 @@ class SparseReorderTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) + @test_util.run_deprecated_v1 def testFeedAlreadyInOrder(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -89,6 +91,7 @@ class SparseReorderTest(test.TestCase): self.assertAllEqual(output_val.dense_shape, expected_output_val.dense_shape) + @test_util.run_deprecated_v1 def testFeedOutOfOrder(self): expected_output_val = self._SparseTensorValue_5x6(np.arange(6)) with self.session(use_gpu=False) as sess: @@ -103,6 +106,7 @@ class SparseReorderTest(test.TestCase): self.assertAllEqual(output_val.dense_shape, expected_output_val.dense_shape) + @test_util.run_deprecated_v1 def testGradients(self): with self.session(use_gpu=False): for _ in range(5): # To test various random permutations diff --git a/tensorflow/python/kernel_tests/sparse_reshape_op_test.py b/tensorflow/python/kernel_tests/sparse_reshape_op_test.py index 918af27091b..9341228d57e 100644 --- a/tensorflow/python/kernel_tests/sparse_reshape_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_reshape_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test @@ -64,12 +65,14 @@ class SparseReshapeTest(test.TestCase): sp_output = sparse_ops.sparse_reshape(sp_input, shape=(2, -1)) self.assertAllEqual((2, 3 * 4), sp_output.get_shape()) + @test_util.run_deprecated_v1 def testRaisesIfMoreThanOneInferredDim(self): sp_input = sparse_tensor.SparseTensor.from_value( self._SparseTensorValue_2x3x4()) with self.assertRaisesRegexp(ValueError, "At most one dimension can"): sparse_ops.sparse_reshape(sp_input, shape=(-1, 2, -1)) + @test_util.run_deprecated_v1 def testRaisesIfInferredShapeNotPossible(self): sp_input = sparse_tensor.SparseTensor.from_value( self._SparseTensorValue_2x3x4()) @@ -86,6 +89,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) + @test_util.run_deprecated_v1 def testFeedSameShape(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -97,6 +101,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) + @test_util.run_deprecated_v1 def testWorksWellWithTfShape(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -109,6 +114,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) + @test_util.run_deprecated_v1 def testFeedSameShapeWithInferredDim(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -120,6 +126,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) + @test_util.run_deprecated_v1 def testFeedNewShapeSameRank(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -133,6 +140,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [3, 10]) + @test_util.run_deprecated_v1 def testFeedNewShapeSameRankWithInferredDim(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -158,6 +166,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [2, 3, 5]) + @test_util.run_deprecated_v1 def testFeedUpRank(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -171,6 +180,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [2, 3, 5]) + @test_util.run_deprecated_v1 def testFeedUpRankWithInferredDim(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -184,6 +194,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [2, 3, 5]) + @test_util.run_deprecated_v1 def testFeedDownRank(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -197,6 +208,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [6, 4]) + @test_util.run_deprecated_v1 def testFeedDownRankWithInferredDim(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -210,6 +222,7 @@ class SparseReshapeTest(test.TestCase): self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, [6, 4]) + @test_util.run_deprecated_v1 def testFeedMultipleInferredDims(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -218,12 +231,14 @@ class SparseReshapeTest(test.TestCase): with self.assertRaisesOpError("only one output dimension may be -1"): sess.run(sp_output, {sp_input: input_val}) + @test_util.run_deprecated_v1 def testProvideStaticallyMismatchedSizes(self): input_val = self._SparseTensorValue_5x6() sp_input = sparse_tensor.SparseTensor.from_value(input_val) with self.assertRaisesRegexp(ValueError, "Cannot reshape"): sparse_ops.sparse_reshape(sp_input, [4, 7]) + @test_util.run_deprecated_v1 def testFeedMismatchedSizes(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -233,6 +248,7 @@ class SparseReshapeTest(test.TestCase): "Input to reshape is a tensor with 30 dense values"): sess.run(sp_output, {sp_input: input_val}) + @test_util.run_deprecated_v1 def testFeedMismatchedSizesWithInferredDim(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -241,6 +257,7 @@ class SparseReshapeTest(test.TestCase): with self.assertRaisesOpError("requested shape requires a multiple"): sess.run(sp_output, {sp_input: input_val}) + @test_util.run_deprecated_v1 def testFeedPartialShapes(self): with self.session(use_gpu=False): # Incorporate new rank into shape information if known @@ -266,6 +283,7 @@ class SparseReshapeTest(test.TestCase): self.assertListEqual(sp_output.indices.get_shape().as_list(), [5, None]) self.assertListEqual(sp_output.dense_shape.get_shape().as_list(), [None]) + @test_util.run_deprecated_v1 def testFeedDenseReshapeSemantics(self): with self.session(use_gpu=False) as sess: # Compute a random rank-5 initial shape and new shape, randomly sparsify diff --git a/tensorflow/python/kernel_tests/sparse_serialization_ops_test.py b/tensorflow/python/kernel_tests/sparse_serialization_ops_test.py index 39a9ab9b491..5a48eb825db 100644 --- a/tensorflow/python/kernel_tests/sparse_serialization_ops_test.py +++ b/tensorflow/python/kernel_tests/sparse_serialization_ops_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor as sparse_tensor_lib +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test @@ -110,14 +111,17 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(combined_values[6:], sp_input[1]) self.assertAllEqual(combined_shape, [2, 5, 6]) + @test_util.run_deprecated_v1 def testSerializeDeserializeBatch(self): self._testSerializeDeserializeBatchHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testSerializeDeserializeManyBatch(self): self._testSerializeDeserializeBatchHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_many_sparse) + @test_util.run_deprecated_v1 def testVariantSerializeDeserializeBatch(self): self._testSerializeDeserializeBatchHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -145,10 +149,12 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(combined_values[6:], sp_input1[1]) self.assertAllEqual(combined_shape, [2, 5, 6]) + @test_util.run_deprecated_v1 def testSerializeDeserializeBatchInconsistentShape(self): self._testSerializeDeserializeBatchInconsistentShapeHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testVariantSerializeDeserializeBatchInconsistentShape(self): self._testSerializeDeserializeBatchInconsistentShapeHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -188,10 +194,12 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(combined_shape, [2, 2, 5, 6]) + @test_util.run_deprecated_v1 def testSerializeDeserializeNestedBatch(self): self._testSerializeDeserializeNestedBatchHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testVariantSerializeDeserializeNestedBatch(self): self._testSerializeDeserializeNestedBatchHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -224,14 +232,17 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(combined_values[6:], input1_val[1]) self.assertAllEqual(combined_shape, [2, 5, 6]) + @test_util.run_deprecated_v1 def testFeedSerializeDeserializeBatch(self): self._testFeedSerializeDeserializeBatchHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testFeedSerializeDeserializeManyBatch(self): self._testFeedSerializeDeserializeBatchHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_many_sparse) + @test_util.run_deprecated_v1 def testFeedVariantSerializeDeserializeBatch(self): self._testFeedSerializeDeserializeBatchHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -256,6 +267,7 @@ class SerializeSparseTest(test.TestCase): }) self.assertEqual(serialized_value.shape, (4, 3)) + @test_util.run_deprecated_v1 def testSerializeManyShape(self): self._testSerializeManyShapeHelper(sparse_ops.serialize_many_sparse) @@ -287,19 +299,23 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(deserialized_value.values, values_value) self.assertAllEqual(deserialized_value.dense_shape, shape_value) + @test_util.run_deprecated_v1 def testSerializeManyDeserializeBatch(self): self._testSerializeManyDeserializeBatchHelper( sparse_ops.serialize_many_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testSerializeManyDeserializeManyBatch(self): self._testSerializeManyDeserializeBatchHelper( sparse_ops.serialize_many_sparse, sparse_ops.deserialize_many_sparse) + @test_util.run_deprecated_v1 def testVariantSerializeManyDeserializeBatch(self): self._testSerializeManyDeserializeBatchHelper( sparse_ops.serialize_many_sparse, sparse_ops.deserialize_sparse, dtypes.variant) + @test_util.run_deprecated_v1 def testVariantSerializeDeserializeScalar(self): with self.session(use_gpu=False) as sess: indices_value = np.array([[]], dtype=np.int64) @@ -321,6 +337,7 @@ class SerializeSparseTest(test.TestCase): self.assertAllEqual(deserialized_value.values, values_value) self.assertAllEqual(deserialized_value.dense_shape, shape_value) + @test_util.run_deprecated_v1 def testVariantSerializeDeserializeScalarBatch(self): with self.session(use_gpu=False) as sess: indices_value = np.array([[]], dtype=np.int64) @@ -367,14 +384,17 @@ class SerializeSparseTest(test.TestCase): {sp_input0: input0_val, sp_input1: input1_val}) + @test_util.run_deprecated_v1 def testDeserializeFailsWrongType(self): self._testDeserializeFailsWrongTypeHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testDeserializeManyFailsWrongType(self): self._testDeserializeFailsWrongTypeHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_many_sparse) + @test_util.run_deprecated_v1 def testVariantDeserializeFailsWrongType(self): self._testDeserializeFailsWrongTypeHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -402,14 +422,17 @@ class SerializeSparseTest(test.TestCase): {sp_input0: input0_val, sp_input1: input1_val}) + @test_util.run_deprecated_v1 def testDeserializeFailsInconsistentRank(self): self._testDeserializeFailsInconsistentRankHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testDeserializeManyFailsInconsistentRank(self): self._testDeserializeFailsInconsistentRankHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_many_sparse) + @test_util.run_deprecated_v1 def testVariantDeserializeFailsInconsistentRank(self): self._testDeserializeFailsInconsistentRankHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse, @@ -431,10 +454,12 @@ class SerializeSparseTest(test.TestCase): with self.assertRaisesOpError(r"Could not parse serialized proto"): sess.run(sp_deserialized, {sp_input0: input0_val}) + @test_util.run_deprecated_v1 def testDeserializeFailsInvalidProto(self): self._testDeserializeFailsInvalidProtoHelper(sparse_ops.serialize_sparse, sparse_ops.deserialize_sparse) + @test_util.run_deprecated_v1 def testDeserializeManyFailsInvalidProto(self): self._testDeserializeFailsInvalidProtoHelper( sparse_ops.serialize_sparse, sparse_ops.deserialize_many_sparse) diff --git a/tensorflow/python/kernel_tests/sparse_slice_op_test.py b/tensorflow/python/kernel_tests/sparse_slice_op_test.py index 098353741f3..7f8c91bde67 100644 --- a/tensorflow/python/kernel_tests/sparse_slice_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_slice_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import sparse_ops import tensorflow.python.ops.sparse_grad # pylint: disable=unused-import @@ -79,6 +80,7 @@ class SparseSliceOpTest(test.TestCase): return sparse_tensor.SparseTensor.from_value( self._SparseTensorValue_3x4x2()) + @test_util.run_deprecated_v1 def testSliceMatrixRows(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_4x6() @@ -96,6 +98,7 @@ class SparseSliceOpTest(test.TestCase): [20, 23, 25, 30, 32, 33, 35]) self.assertAllEqual(sp_tensor1.dense_shape.eval(), [2, 6]) + @test_util.run_deprecated_v1 def testSliceMatrixUnevenCols(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_5x7() @@ -137,6 +140,7 @@ class SparseSliceOpTest(test.TestCase): self.assertAllEqual(sp_tensor3.values.eval(), [16, 46]) self.assertAllEqual(sp_tensor3.dense_shape.eval(), [5, 1]) + @test_util.run_deprecated_v1 def testSliceMatrixUnevenRows(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_5x7() @@ -173,6 +177,7 @@ class SparseSliceOpTest(test.TestCase): self.assertAllEqual(sp_tensor2.dense_shape.eval(), [1, 7]) return + @test_util.run_deprecated_v1 def testSliceAllRows(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_4x6() @@ -195,6 +200,7 @@ class SparseSliceOpTest(test.TestCase): self.assertAllEqual(sp_tensor3.values.eval(), [30, 32, 33, 35]) self.assertAllEqual(sp_tensor3.dense_shape.eval(), [1, 6]) + @test_util.run_deprecated_v1 def testSliceColumns(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_4x6() @@ -215,6 +221,7 @@ class SparseSliceOpTest(test.TestCase): self.assertAllEqual(sparse_tensor2.values.eval(), [4, 5, 14, 25, 35]) self.assertAllEqual(sparse_tensor2.dense_shape.eval(), [4, 2]) + @test_util.run_deprecated_v1 def testSliceAllColumns(self): with self.session(use_gpu=False): sp_input = self._SparseTensor_4x6() @@ -246,6 +253,7 @@ class SparseSliceOpTest(test.TestCase): self.assertAllEqual(sparse_tensor5.values.eval(), [5, 25, 35]) self.assertAllEqual(sparse_tensor5.dense_shape.eval(), [4, 1]) + @test_util.run_deprecated_v1 def testGradients(self): sp_input = self._SparseTensor_4x6(val_dtype=np.float32) start_and_size = [([0, 0], [4, 2]), diff --git a/tensorflow/python/kernel_tests/sparse_split_op_test.py b/tensorflow/python/kernel_tests/sparse_split_op_test.py index 95661ded4be..f4bb7498b02 100644 --- a/tensorflow/python/kernel_tests/sparse_split_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_split_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test @@ -75,6 +76,7 @@ class SparseSplitOpTest(test.TestCase): return sparse_tensor.SparseTensor.from_value(self._SparseTensorValue_3x4x2( )) + @test_util.run_deprecated_v1 def testSplitMatrixRows(self): with self.session(use_gpu=False): sp_tensors = sparse_ops.sparse_split( @@ -92,6 +94,7 @@ class SparseSplitOpTest(test.TestCase): [20, 23, 25, 30, 32, 33, 35]) self.assertAllEqual(sp_tensors[1].dense_shape.eval(), [2, 6]) + @test_util.run_deprecated_v1 def testSplitMatrixUnevenCols(self): with self.session(use_gpu=False): sp_tensors_3 = sparse_ops.sparse_split( @@ -131,6 +134,7 @@ class SparseSplitOpTest(test.TestCase): self.assertAllEqual(sp_tensors_4[3].values.eval(), [16, 46]) self.assertAllEqual(sp_tensors_4[3].dense_shape.eval(), [5, 1]) + @test_util.run_deprecated_v1 def testSplitMatrixUnevenRows(self): with self.session(use_gpu=False): sp_tensors_2 = sparse_ops.sparse_split( @@ -167,6 +171,7 @@ class SparseSplitOpTest(test.TestCase): self.assertAllEqual(sp_tensors_3[2].dense_shape.eval(), [1, 7]) return + @test_util.run_deprecated_v1 def testSplitAllRows(self): with self.session(use_gpu=False): sp_tensors = sparse_ops.sparse_split( @@ -189,6 +194,7 @@ class SparseSplitOpTest(test.TestCase): self.assertAllEqual(sp_tensors[3].values.eval(), [30, 32, 33, 35]) self.assertAllEqual(sp_tensors[3].dense_shape.eval(), [1, 6]) + @test_util.run_deprecated_v1 def testSplitColumns(self): with self.session(use_gpu=False): sparse_tensors = sparse_ops.sparse_split( @@ -207,6 +213,7 @@ class SparseSplitOpTest(test.TestCase): self.assertAllEqual(sparse_tensors[2].values.eval(), [4, 5, 14, 25, 35]) self.assertAllEqual(sparse_tensors[2].dense_shape.eval(), [4, 2]) + @test_util.run_deprecated_v1 def testSplitAllColumns(self): with self.session(use_gpu=False): sparse_tensors = sparse_ops.sparse_split( @@ -234,6 +241,7 @@ class SparseSplitOpTest(test.TestCase): self.assertAllEqual(sparse_tensors[5].values.eval(), [5, 25, 35]) self.assertAllEqual(sparse_tensors[5].dense_shape.eval(), [4, 1]) + @test_util.run_deprecated_v1 def testSliceConcat(self): for sp_input in (self._SparseTensorValue_3x4x2(), self._SparseTensor_3x4x2()): diff --git a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_grad_test.py b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_grad_test.py index b8f33d6a813..fa2bab1fca6 100644 --- a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_grad_test.py +++ b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_grad_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import sparse_ops import tensorflow.python.ops.sparse_grad # pylint: disable=unused-import @@ -89,6 +90,7 @@ class SparseTensorDenseMatMulGradientTest(test.TestCase): self._testGradients(adjoint_a, adjoint_b, name, values_dtype, indices_dtype) + @test_util.run_deprecated_v1 def testGradients(self): np.random.seed(5) # Fix seed to avoid flakiness self._testGradientsType(np.float32, np.int64) diff --git a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py index e605cb1c358..637cfaec990 100644 --- a/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_tensor_dense_matmul_op_test.py @@ -30,6 +30,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops @@ -96,6 +97,7 @@ class SparseTensorDenseMatMulTest(test.TestCase): self._testMatmul(x, y, indices_dtype=indices_dtype) + @test_util.run_deprecated_v1 def testBasic(self): np.random.seed(127) # Repeatable results self._testBasic(np.int32) @@ -106,6 +108,7 @@ class SparseTensorDenseMatMulTest(test.TestCase): self._testBasic(np.int32, indices_dtype=np.int32) self._testBasic(np.float32, indices_dtype=np.int32) + @test_util.run_deprecated_v1 def testShapeInference(self): x = np.random.rand(10, 10) x[np.abs(x) < 0.5] = 0 # Make it sparse @@ -229,6 +232,7 @@ class SparseTensorDenseMatMulTest(test.TestCase): self._testLarge(np.complex128) # Tests random sized matrices. + @test_util.run_deprecated_v1 def testFloatRandom(self): np.random.seed(127) # Repeatable results for _ in range(8): diff --git a/tensorflow/python/kernel_tests/sparse_tensors_map_ops_test.py b/tensorflow/python/kernel_tests/sparse_tensors_map_ops_test.py index 538e7c69b57..6039ff1afa7 100644 --- a/tensorflow/python/kernel_tests/sparse_tensors_map_ops_test.py +++ b/tensorflow/python/kernel_tests/sparse_tensors_map_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor as sparse_tensor_lib +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.ops import variables @@ -76,6 +77,7 @@ class SparseTensorsMapTest(test.TestCase): shape = np.array([3, 4, 5]).astype(np.int64) return sparse_tensor_lib.SparseTensorValue(ind, val, shape) + @test_util.run_deprecated_v1 def testAddTakeMany(self): with self.session(graph=ops.Graph(), use_gpu=False) as sess: sp_input0 = self._SparseTensorValue_5x6(np.arange(6)) @@ -98,6 +100,7 @@ class SparseTensorsMapTest(test.TestCase): self.assertAllEqual(combined_values[6:], sp_input1[1]) self.assertAllEqual(combined_shape, [2, 5, 6]) + @test_util.run_deprecated_v1 def testFeedAddTakeMany(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -125,6 +128,7 @@ class SparseTensorsMapTest(test.TestCase): self.assertAllEqual(combined_values[6:], input1_val[1]) self.assertAllEqual(combined_shape, [2, 5, 6]) + @test_util.run_deprecated_v1 def testAddManyTakeManyRoundTrip(self): with self.session(use_gpu=False) as sess: # N == 4 because shape_value == [4, 5] @@ -147,6 +151,7 @@ class SparseTensorsMapTest(test.TestCase): self.assertAllEqual(roundtrip_value.values, values_value) self.assertAllEqual(roundtrip_value.dense_shape, shape_value) + @test_util.run_deprecated_v1 def testDeserializeFailsInconsistentRank(self): with self.session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() @@ -168,6 +173,7 @@ class SparseTensorsMapTest(test.TestCase): r"SparseTensor\[1\] was: 3 but rank of SparseTensor\[1\] is: 4"): self.evaluate(sp_roundtrip) + @test_util.run_deprecated_v1 def testTakeManyFailsWrongInputOp(self): with self.session(use_gpu=False) as sess: input_val = self._SparseTensorValue_5x6(np.arange(6)) diff --git a/tensorflow/python/kernel_tests/sparse_to_dense_op_py_test.py b/tensorflow/python/kernel_tests/sparse_to_dense_op_py_test.py index fa6cb134327..c6c45db4f9a 100644 --- a/tensorflow/python/kernel_tests/sparse_to_dense_op_py_test.py +++ b/tensorflow/python/kernel_tests/sparse_to_dense_op_py_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.platform import test @@ -41,36 +42,42 @@ def _SparseToDense(sparse_indices, class SparseToDenseTest(test.TestCase): + @test_util.run_deprecated_v1 def testInt(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([1, 3], [5], 1, 0).eval() np_ans = np.array([0, 1, 0, 1, 0]).astype(np.int32) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testFloat(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([1, 3], [5], 1.0, 0.0).eval() np_ans = np.array([0, 1, 0, 1, 0]).astype(np.float32) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testString(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([1, 3], [5], "a", "b").eval() np_ans = np.array(["b", "a", "b", "a", "b"]).astype(np.string_) self.assertAllEqual(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testSetValue(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([1, 3], [5], [1, 2], -1).eval() np_ans = np.array([-1, 1, -1, 2, -1]).astype(np.int32) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testSetSingleValue(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([1, 3], [5], 1, -1).eval() np_ans = np.array([-1, 1, -1, 1, -1]).astype(np.int32) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def test2d(self): # pylint: disable=bad-whitespace with self.session(use_gpu=False): @@ -80,11 +87,13 @@ class SparseToDenseTest(test.TestCase): [ 1, -1, -1, -1]]).astype(np.int32) self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testZeroDefault(self): with self.cached_session(): x = sparse_ops.sparse_to_dense(2, [4], 7).eval() self.assertAllEqual(x, [0, 0, 7, 0]) + @test_util.run_deprecated_v1 def test3d(self): with self.session(use_gpu=False): tf_ans = _SparseToDense([[1, 3, 0], [2, 0, 1]], [3, 4, 2], 1, -1).eval() @@ -93,11 +102,13 @@ class SparseToDenseTest(test.TestCase): np_ans[2, 0, 1] = 1 self.assertAllClose(np_ans, tf_ans) + @test_util.run_deprecated_v1 def testBadShape(self): with self.cached_session(): with self.assertRaisesWithPredicateMatch(ValueError, "must be rank 1"): _SparseToDense([1, 3], [[5], [3]], 1, -1) + @test_util.run_deprecated_v1 def testBadValue(self): with self.cached_session(): dense = _SparseToDense([1, 3], [5], [[5], [3]], -1) @@ -106,6 +117,7 @@ class SparseToDenseTest(test.TestCase): r"should be \[\] or \[2\]"): self.evaluate(dense) + @test_util.run_deprecated_v1 def testBadNumValues(self): with self.cached_session(): dense = _SparseToDense([1, 3], [5], [1, 2, 3], -1) @@ -113,12 +125,14 @@ class SparseToDenseTest(test.TestCase): r"sparse_values has incorrect shape \[3\], should be \[\] or \[2\]"): self.evaluate(dense) + @test_util.run_deprecated_v1 def testBadDefault(self): with self.cached_session(): dense = _SparseToDense([1, 3], [5], [1, 2], [0]) with self.assertRaisesOpError("default_value should be a scalar"): self.evaluate(dense) + @test_util.run_deprecated_v1 def testOutOfBoundsIndicesWithWithoutValidation(self): with self.cached_session(): dense = _SparseToDense( @@ -139,6 +153,7 @@ class SparseToDenseTest(test.TestCase): validate_indices=False) self.evaluate(dense_without_validation) + @test_util.run_deprecated_v1 def testRepeatingIndicesWithWithoutValidation(self): with self.cached_session(): dense = _SparseToDense( @@ -157,6 +172,7 @@ class SparseToDenseTest(test.TestCase): validate_indices=False) self.evaluate(dense_without_validation) + @test_util.run_deprecated_v1 def testUnsortedIndicesWithWithoutValidation(self): with self.cached_session(): dense = _SparseToDense( @@ -175,6 +191,7 @@ class SparseToDenseTest(test.TestCase): validate_indices=False) self.evaluate(dense_without_validation) + @test_util.run_deprecated_v1 def testShapeInferenceKnownShape(self): with self.session(use_gpu=False): indices = array_ops.placeholder(dtypes.int64) @@ -187,6 +204,7 @@ class SparseToDenseTest(test.TestCase): output = sparse_ops.sparse_to_dense(indices, shape, 1, 0) self.assertEqual(output.get_shape().as_list(), [None, None, None]) + @test_util.run_deprecated_v1 def testShapeInferenceUnknownShape(self): with self.session(use_gpu=False): indices = array_ops.placeholder(dtypes.int64) diff --git a/tensorflow/python/kernel_tests/sparse_xent_op_test.py b/tensorflow/python/kernel_tests/sparse_xent_op_test.py index cc8c7c238f9..8f0842f7f50 100644 --- a/tensorflow/python/kernel_tests/sparse_xent_op_test.py +++ b/tensorflow/python/kernel_tests/sparse_xent_op_test.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops as ops_lib +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker @@ -80,6 +81,7 @@ class SparseXentTest(test.TestCase): self.assertAllClose([0.0, 0.0, 0.0], tf_loss) self.assertAllClose([[0.0], [0.0], [0.0]], tf_backprop) + @test_util.run_deprecated_v1 def testInvalidLabel(self): features = [[1., 1., 1., 1.], [1., 1., 1., 1.], [1., 2., 3., 4.], [1., 2., 3., 4.]] @@ -152,6 +154,7 @@ class SparseXentTest(test.TestCase): nn_ops.sparse_softmax_cross_entropy_with_logits( labels=constant_op.constant(0), logits=constant_op.constant(1.0)) + @test_util.run_deprecated_v1 def testLabelsPlaceholderScalar(self): with self.session(use_gpu=True): labels = array_ops.placeholder(np.int32) @@ -187,6 +190,7 @@ class SparseXentTest(test.TestCase): def testEmpty(self): self._testXent(np.zeros((0, 3)), np.zeros((0,), dtype=np.int32)) + @test_util.run_deprecated_v1 def testGradient(self): with self.session(use_gpu=True): l = constant_op.constant([3, 0, 1], name="l") @@ -201,6 +205,7 @@ class SparseXentTest(test.TestCase): print("cross entropy gradient err = ", err) self.assertLess(err, 5e-8) + @test_util.run_deprecated_v1 def testSecondGradient(self): images_placeholder = array_ops.placeholder(dtypes.float32, shape=(3, 2)) labels_placeholder = array_ops.placeholder(dtypes.int32, shape=(3)) @@ -230,17 +235,20 @@ class SparseXentTest(test.TestCase): self.assertAllCloseAccordingToType(np_loss, tf_loss) self.assertAllCloseAccordingToType(np_backprop, tf_backprop) + @test_util.run_deprecated_v1 def testHighDim(self): features = [[[1., 1., 1., 1.]], [[1., 2., 3., 4.]]] labels = [[3], [0]] self._testHighDim(features, labels) + @test_util.run_deprecated_v1 def testHighDim2(self): features = [[[1., 1., 1., 1.], [2., 2., 2., 2.]], [[1., 2., 3., 4.], [5., 6., 7., 8.]]] labels = [[3, 2], [0, 3]] self._testHighDim(features, labels) + @test_util.run_deprecated_v1 def testScalarHandling(self): with self.session(use_gpu=False) as sess: with self.assertRaisesRegexp(errors_impl.InvalidArgumentError, @@ -318,7 +326,7 @@ def sparse_vs_dense_xent_benchmark(batch_size, num_entries, use_gpu): # Using sparse_softmax_cross_entropy_with_logits with session.Session(config=config) as sess: if not use_gpu: - with ops_lib.device("/cpu:0"): + with test_util.device("/cpu:0"): ops = _sparse_vs_dense_xent_benchmark_sparse(labels, logits) else: ops = _sparse_vs_dense_xent_benchmark_sparse(labels, logits) diff --git a/tensorflow/python/kernel_tests/sparsemask_op_test.py b/tensorflow/python/kernel_tests/sparsemask_op_test.py index 6f5dd45b616..b1cd0227bc0 100644 --- a/tensorflow/python/kernel_tests/sparsemask_op_test.py +++ b/tensorflow/python/kernel_tests/sparsemask_op_test.py @@ -20,12 +20,14 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.platform import test class SparseMaskTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): values = np.random.rand(4, 4).astype(np.single) indices = np.array([0, 2, 3, 4], dtype=np.int32) diff --git a/tensorflow/python/kernel_tests/split_op_test.py b/tensorflow/python/kernel_tests/split_op_test.py index af90e03966e..517db3450f3 100644 --- a/tensorflow/python/kernel_tests/split_op_test.py +++ b/tensorflow/python/kernel_tests/split_op_test.py @@ -42,6 +42,7 @@ class SplitOpTest(test.TestCase): data -= 1j * data return data + @test_util.run_deprecated_v1 def testShapeInference(self): model_input = array_ops.placeholder(dtypes.float32, shape=(1, 10)) @@ -85,6 +86,7 @@ class SplitOpTest(test.TestCase): with self.cached_session(use_gpu=True) as sess: sess.run(result, feed_dict={model_input2: np.ones([4, 2])}) + @test_util.run_deprecated_v1 def testFailWithoutExplicitNum(self): size_splits = array_ops.placeholder(dtype=dtypes.int32, shape=[None]) @@ -209,6 +211,7 @@ class SplitOpTest(test.TestCase): self.assertAllEqual(result[:, 0:1], inp_grads[0]) self.assertAllEqual(result[:, 1:4], inp_grads[1]) + @test_util.run_deprecated_v1 def testOutputShape(self): for axis in [1, -1]: with self.cached_session(use_gpu=True): @@ -322,11 +325,13 @@ class SplitOpTest(test.TestCase): for i in range(4): self.assertAllEqual(result[:, i:i + 1], inp_grads[i]) + @test_util.run_deprecated_v1 def testGradientsAll(self): for dtype in _TEST_DTYPES: self._testGradientsSimple(dtype) self._testGradientsSimpleVariable(dtype) + @test_util.run_deprecated_v1 def testShapeFunctionEdgeCases(self): # split_dim greater than rank of input. with self.assertRaises(ValueError): @@ -356,6 +361,7 @@ class SplitOpTest(test.TestCase): for s in splits: self.assertEqual(None, s.get_shape().ndims) + @test_util.run_deprecated_v1 def testVariableShapeFunction(self): # size_splits too big with self.assertRaises(ValueError): @@ -366,6 +372,7 @@ class SplitOpTest(test.TestCase): assert s0.shape.as_list() == [2] assert s1.shape.as_list() == [1] + @test_util.run_deprecated_v1 def testNonexistentDimTensor(self): x = array_ops.placeholder(dtypes.int32) values = np.zeros([5, 30]) diff --git a/tensorflow/python/kernel_tests/stack_op_test.py b/tensorflow/python/kernel_tests/stack_op_test.py index 0f1fa97c384..ca3357a0ed8 100644 --- a/tensorflow/python/kernel_tests/stack_op_test.py +++ b/tensorflow/python/kernel_tests/stack_op_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import variables @@ -41,6 +42,7 @@ def np_split_squeeze(array, axis): class StackOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testSimple(self): np.random.seed(7) with self.session(use_gpu=True): @@ -54,6 +56,7 @@ class StackOpTest(test.TestCase): c = array_ops.stack(xs) self.assertAllEqual(c.eval(), data) + @test_util.run_deprecated_v1 def testSimpleParallelCPU(self): np.random.seed(7) with self.session(use_gpu=False): @@ -63,6 +66,7 @@ class StackOpTest(test.TestCase): c = array_ops.parallel_stack(xs) self.assertAllEqual(c.eval(), data) + @test_util.run_deprecated_v1 def testSimpleParallelGPU(self): np.random.seed(7) with self.session(use_gpu=True): @@ -72,6 +76,7 @@ class StackOpTest(test.TestCase): c = array_ops.parallel_stack(xs) self.assertAllEqual(c.eval(), data) + @test_util.run_deprecated_v1 def testConst(self): np.random.seed(7) with self.session(use_gpu=True): @@ -96,6 +101,7 @@ class StackOpTest(test.TestCase): b = array_ops.reshape(a, array_ops.stack([2, 3])) self.assertAllEqual(b.get_shape(), [2, 3]) + @test_util.run_deprecated_v1 def testConstParallelCPU(self): np.random.seed(7) with self.session(use_gpu=False): @@ -110,6 +116,7 @@ class StackOpTest(test.TestCase): c = array_ops.parallel_stack(data) self.assertAllEqual(c.eval(), data) + @test_util.run_deprecated_v1 def testConstParallelGPU(self): np.random.seed(7) with self.session(use_gpu=True): @@ -124,6 +131,7 @@ class StackOpTest(test.TestCase): c = array_ops.parallel_stack(data) self.assertAllEqual(c.eval(), data) + @test_util.run_deprecated_v1 def testGradientsAxis0(self): np.random.seed(7) for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2): @@ -136,6 +144,7 @@ class StackOpTest(test.TestCase): err = gradient_checker.compute_gradient_error(xs, shapes, c, shape) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testGradientsAxis1(self): np.random.seed(7) for shape in (2, 3), (3, 2), (4, 3, 2): @@ -150,6 +159,7 @@ class StackOpTest(test.TestCase): err = gradient_checker.compute_gradient_error(xs, shapes, c, out_shape) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testZeroSizeCPU(self): # Verify that stack doesn't crash for zero size inputs with self.session(use_gpu=False): @@ -161,6 +171,7 @@ class StackOpTest(test.TestCase): p = array_ops.parallel_stack(list(x)).eval() self.assertAllEqual(p, x) + @test_util.run_deprecated_v1 def testZeroSizeGPU(self): # Verify that stack doesn't crash for zero size inputs with self.session(use_gpu=True): @@ -172,6 +183,7 @@ class StackOpTest(test.TestCase): p = array_ops.parallel_stack(list(x)).eval() self.assertAllEqual(p, x) + @test_util.run_deprecated_v1 def testAxis0DefaultCPU(self): with self.session(use_gpu=False): t = [constant_op.constant([1, 2, 3]), constant_op.constant([4, 5, 6])] @@ -182,6 +194,7 @@ class StackOpTest(test.TestCase): self.assertAllEqual(stacked, expected) self.assertAllEqual(parallel_stacked, expected) + @test_util.run_deprecated_v1 def testAxis0DefaultGPU(self): with self.session(use_gpu=True): t = [constant_op.constant([1, 2, 3]), constant_op.constant([4, 5, 6])] @@ -225,6 +238,7 @@ class StackOpTest(test.TestCase): class AutomaticStackingTest(test.TestCase): + @test_util.run_deprecated_v1 def testSimple(self): with self.session(use_gpu=True): self.assertAllEqual( @@ -255,6 +269,7 @@ class AutomaticStackingTest(test.TestCase): self.assertAllEqual([[[0., 0.], [1., 1.]], [[2., 2.], [3., 3.]]], self.evaluate(result)) + @test_util.run_deprecated_v1 def testVariable(self): with self.session(use_gpu=True): v = variables.Variable(17) @@ -308,6 +323,7 @@ class AutomaticStackingTest(test.TestCase): t_2 = ops.convert_to_tensor([t_0, t_0, t_1], dtype=dtypes.float64) self.assertEqual(dtypes.float64, t_2.dtype) + @test_util.run_deprecated_v1 def testPlaceholder(self): with self.session(use_gpu=True): # Test using placeholder with a defined shape. @@ -326,6 +342,7 @@ class AutomaticStackingTest(test.TestCase): self.assertAllEqual( [[0, 0, 0], [0, 2, 0], [0, 0, 0]], result_1.eval(feed_dict={ph_1: 2})) + @test_util.run_deprecated_v1 def testShapeErrors(self): # Static shape error. ph_0 = array_ops.placeholder(dtypes.int32, shape=[1]) diff --git a/tensorflow/python/kernel_tests/stack_ops_test.py b/tensorflow/python/kernel_tests/stack_ops_test.py index dffb260b5fa..d50f3f46806 100644 --- a/tensorflow/python/kernel_tests/stack_ops_test.py +++ b/tensorflow/python/kernel_tests/stack_ops_test.py @@ -24,6 +24,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_data_flow_ops from tensorflow.python.ops import math_ops @@ -41,6 +42,7 @@ class StackOpTest(test.TestCase): c1 = gen_data_flow_ops.stack_pop_v2(h, dtypes.float32) self.assertAllClose([[4.0, 5.0]], self.evaluate(c1)) + @test_util.run_deprecated_v1 def testStackPushPop(self): self._testStackPushPop(use_gpu=False) self._testStackPushPop(use_gpu=True) @@ -56,6 +58,7 @@ class StackOpTest(test.TestCase): c1 = gen_data_flow_ops.stack_pop_v2(h, dtypes.float32) self.assertAllClose(a, self.evaluate(c1)) + @test_util.run_deprecated_v1 def testStackPushPopSwap(self): self._testStackPushPopSwap(use_gpu=False) self._testStackPushPopSwap(use_gpu=True) @@ -93,6 +96,7 @@ class StackOpTest(test.TestCase): c1, b1, [r, v], [r.get_shape(), tensor_shape.unknown_shape()]) self.assertAllClose(np.ones(2000) * 10.0, self.evaluate(ry)) + @test_util.run_deprecated_v1 def testStackWhileSwap(self): self._testStackWhileSwap(use_gpu=False) self._testStackWhileSwap(use_gpu=True) @@ -112,6 +116,7 @@ class StackOpTest(test.TestCase): r = c1 + c2 self.assertAllClose(9.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testMultiStack(self): self._testMultiStack(use_gpu=False) self._testMultiStack(use_gpu=True) @@ -135,6 +140,7 @@ class StackOpTest(test.TestCase): self.assertAllClose(out1, 4.0) self.assertAllClose(out2, 5.0) + @test_util.run_deprecated_v1 def testSameNameStacks(self): self._testSameNameStacks(use_gpu=False) self._testSameNameStacks(use_gpu=True) @@ -146,6 +152,7 @@ class StackOpTest(test.TestCase): c1 = gen_data_flow_ops.stack_close_v2(h) self.evaluate(c1) + @test_util.run_deprecated_v1 def testCloseStack(self): self._testCloseStack(use_gpu=False) self._testCloseStack(use_gpu=True) @@ -159,6 +166,7 @@ class StackOpTest(test.TestCase): c1 = gen_data_flow_ops.stack_close_v2(h) self.evaluate(c1) + @test_util.run_deprecated_v1 def testPushCloseStack(self): self._testPushCloseStack(use_gpu=False) self._testPushCloseStack(use_gpu=True) @@ -175,6 +183,7 @@ class StackOpRefTest(test.TestCase): c1 = gen_data_flow_ops.stack_pop(h, dtypes.float32) self.assertAllClose([[4.0, 5.0]], self.evaluate(c1)) + @test_util.run_deprecated_v1 def testStackPushPop(self): self._testStackPushPop(use_gpu=False) self._testStackPushPop(use_gpu=True) @@ -189,6 +198,7 @@ class StackOpRefTest(test.TestCase): c1 = gen_data_flow_ops.stack_pop(h, dtypes.float32) self.assertAllClose(a, self.evaluate(c1)) + @test_util.run_deprecated_v1 def testStackPushPopSwap(self): self._testStackPushPopSwap(use_gpu=False) self._testStackPushPopSwap(use_gpu=True) @@ -238,10 +248,12 @@ class StackOpRefTest(test.TestCase): c1, b1, [r, v], [r.get_shape(), tensor_shape.unknown_shape()]) self.assertAllClose(np.ones(2000) * 10.0, self.evaluate(ry)) + @test_util.run_deprecated_v1 def testStackWhileSwap(self): self._testStackWhileSwap(use_gpu=False) self._testStackWhileSwap(use_gpu=True) + @test_util.run_deprecated_v1 def testMultiStack(self): self._testMultiStack(use_gpu=False) self._testMultiStack(use_gpu=True) @@ -255,6 +267,7 @@ class StackOpRefTest(test.TestCase): _ = c1 + c2 self.assertNotEqual(h1.eval()[1], self.evaluate(h2)[1]) + @test_util.run_deprecated_v1 def testSameNameStacks(self): self._testSameNameStacks(use_gpu=False) self._testSameNameStacks(use_gpu=True) @@ -265,6 +278,7 @@ class StackOpRefTest(test.TestCase): c1 = gen_data_flow_ops.stack_close(h) self.evaluate(c1) + @test_util.run_deprecated_v1 def testCloseStack(self): self._testCloseStack(use_gpu=False) self._testCloseStack(use_gpu=True) @@ -277,6 +291,7 @@ class StackOpRefTest(test.TestCase): c1 = gen_data_flow_ops.stack_close(h) self.evaluate(c1) + @test_util.run_deprecated_v1 def testPushCloseStack(self): self._testPushCloseStack(use_gpu=False) self._testPushCloseStack(use_gpu=True) diff --git a/tensorflow/python/kernel_tests/stage_op_test.py b/tensorflow/python/kernel_tests/stage_op_test.py index b814843b86c..83e06ba48bd 100644 --- a/tensorflow/python/kernel_tests/stage_op_test.py +++ b/tensorflow/python/kernel_tests/stage_op_test.py @@ -18,6 +18,7 @@ from __future__ import print_function from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import math_ops @@ -28,6 +29,7 @@ TIMEOUT = 1 class StageTest(test.TestCase): + @test_util.run_deprecated_v1 def testSimple(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -47,6 +49,7 @@ class StageTest(test.TestCase): _, yval = sess.run([stage, y], feed_dict={x: i}) self.assertAllClose(4 * (i - 1) * (i - 1) * 128, yval, rtol=1e-4) + @test_util.run_deprecated_v1 def testMultiple(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -67,6 +70,7 @@ class StageTest(test.TestCase): self.assertAllClose( 4 * (i - 1) * (i - 1) * (i - 1) * 128, yval, rtol=1e-4) + @test_util.run_deprecated_v1 def testDictionary(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -110,6 +114,7 @@ class StageTest(test.TestCase): G.finalize() + @test_util.run_deprecated_v1 def testPeek(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -133,6 +138,7 @@ class StageTest(test.TestCase): for i in range(10): self.assertTrue(sess.run(peek, feed_dict={p: i}) == [i]) + @test_util.run_deprecated_v1 def testSizeAndClear(self): with ops.Graph().as_default() as G: with ops.device('/cpu:0'): @@ -158,6 +164,7 @@ class StageTest(test.TestCase): sess.run(clear) self.assertEqual(sess.run(size), 0) + @test_util.run_deprecated_v1 def testCapacity(self): capacity = 3 @@ -219,6 +226,7 @@ class StageTest(test.TestCase): # It should now be empty self.assertTrue(sess.run(size) == 0) + @test_util.run_deprecated_v1 def testMemoryLimit(self): memory_limit = 512 * 1024 # 512K chunk = 200 * 1024 # 256K diff --git a/tensorflow/python/kernel_tests/string_join_op_test.py b/tensorflow/python/kernel_tests/string_join_op_test.py index e4371ab5b93..2548e8695fe 100644 --- a/tensorflow/python/kernel_tests/string_join_op_test.py +++ b/tensorflow/python/kernel_tests/string_join_op_test.py @@ -17,12 +17,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops import string_ops from tensorflow.python.platform import test class StringJoinOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testStringJoin(self): input0 = ["a", "b"] input1 = "a" diff --git a/tensorflow/python/kernel_tests/string_length_op_test.py b/tensorflow/python/kernel_tests/string_length_op_test.py index 06bf28ebcee..bfa6ac2454a 100644 --- a/tensorflow/python/kernel_tests/string_length_op_test.py +++ b/tensorflow/python/kernel_tests/string_length_op_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -32,6 +33,7 @@ class StringLengthOpTest(test.TestCase): values = self.evaluate(lengths) self.assertAllEqual(values, [[[1, 2], [3, 4], [5, 6]]]) + @test_util.run_deprecated_v1 def testUnit(self): unicode_strings = [u"H\xc3llo", u"\U0001f604"] utf8_strings = [s.encode("utf-8") for s in unicode_strings] @@ -51,6 +53,7 @@ class StringLengthOpTest(test.TestCase): 'not in: "BYTE", "UTF8_CHAR"'): string_ops.string_length(utf8_strings, unit="XYZ") + @test_util.run_deprecated_v1 def testLegacyPositionalName(self): # Code that predates the 'unit' parameter may have used a positional # argument for the 'name' parameter. Check that we don't break such code. diff --git a/tensorflow/python/kernel_tests/string_split_op_test.py b/tensorflow/python/kernel_tests/string_split_op_test.py index 92e13db0f73..0c91deb5220 100644 --- a/tensorflow/python/kernel_tests/string_split_op_test.py +++ b/tensorflow/python/kernel_tests/string_split_op_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -39,6 +40,7 @@ class StringSplitOpTest(test.TestCase): self.assertAllEqual(values, [b"pigs", b"on", b"the", b"wing", b"animals"]) self.assertAllEqual(shape, [2, 4]) + @test_util.run_deprecated_v1 def testStringSplitEmptyDelimiter(self): strings = ["hello", "hola", b"\xF0\x9F\x98\x8E"] # Last string is U+1F60E @@ -81,6 +83,7 @@ class StringSplitOpTest(test.TestCase): self.assertAllEqual(values, [b"a", b"b", b"c", b"d", b"e", b"f", b"g"]) self.assertAllEqual(shape, [10, 1]) + @test_util.run_deprecated_v1 def testStringSplitWithDelimiter(self): strings = ["hello|world", "hello world"] @@ -103,6 +106,7 @@ class StringSplitOpTest(test.TestCase): self.assertAllEqual(values, [b"hello", b"world", b"hello", b"world"]) self.assertAllEqual(shape, [2, 2]) + @test_util.run_deprecated_v1 def testStringSplitWithDelimiterTensor(self): strings = ["hello|world", "hello world"] @@ -121,6 +125,7 @@ class StringSplitOpTest(test.TestCase): self.assertAllEqual(values, [b"hello", b"world", b"hello world"]) self.assertAllEqual(shape, [2, 2]) + @test_util.run_deprecated_v1 def testStringSplitWithDelimitersTensor(self): strings = ["hello.cruel,world", "hello cruel world"] diff --git a/tensorflow/python/kernel_tests/string_to_hash_bucket_op_test.py b/tensorflow/python/kernel_tests/string_to_hash_bucket_op_test.py index 2cc87008da0..25f573fc144 100644 --- a/tensorflow/python/kernel_tests/string_to_hash_bucket_op_test.py +++ b/tensorflow/python/kernel_tests/string_to_hash_bucket_op_test.py @@ -19,6 +19,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -26,6 +27,7 @@ from tensorflow.python.platform import test class StringToHashBucketOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testStringToOneHashBucketFast(self): with self.cached_session(): input_string = array_ops.placeholder(dtypes.string) @@ -34,6 +36,7 @@ class StringToHashBucketOpTest(test.TestCase): self.assertAllEqual([0, 0, 0], result) + @test_util.run_deprecated_v1 def testStringToHashBucketsFast(self): with self.cached_session(): input_string = array_ops.placeholder(dtypes.string) @@ -46,6 +49,7 @@ class StringToHashBucketOpTest(test.TestCase): # Fingerprint64('d') -> 4470636696479570465 -> mod 10 -> 5 self.assertAllEqual([9, 2, 2, 5], result) + @test_util.run_deprecated_v1 def testStringToOneHashBucketLegacyHash(self): with self.cached_session(): input_string = array_ops.placeholder(dtypes.string) @@ -54,6 +58,7 @@ class StringToHashBucketOpTest(test.TestCase): self.assertAllEqual([0, 0, 0], result) + @test_util.run_deprecated_v1 def testStringToHashBucketsLegacyHash(self): with self.cached_session(): input_string = array_ops.placeholder(dtypes.string) diff --git a/tensorflow/python/kernel_tests/string_to_number_op_test.py b/tensorflow/python/kernel_tests/string_to_number_op_test.py index 99ee25e1253..49ccfd1028f 100644 --- a/tensorflow/python/kernel_tests/string_to_number_op_test.py +++ b/tensorflow/python/kernel_tests/string_to_number_op_test.py @@ -19,6 +19,7 @@ from __future__ import division from __future__ import print_function from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import parsing_ops from tensorflow.python.platform import test @@ -45,6 +46,7 @@ class StringToNumberOpTest(test.TestCase): with self.assertRaisesOpError(outstr): output.eval(feed_dict={input_string: [instr]}) + @test_util.run_deprecated_v1 def testToFloat(self): self._test(dtypes.float32, [("0", 0), ("3", 3), ("-1", -1), @@ -58,6 +60,7 @@ class StringToNumberOpTest(test.TestCase): ("INF", float("INF"))], [("10foobar", _ERROR_MESSAGE + "10foobar")]) + @test_util.run_deprecated_v1 def testToDouble(self): self._test(dtypes.float64, [("0", 0), ("3", 3), ("-1", -1), @@ -71,6 +74,7 @@ class StringToNumberOpTest(test.TestCase): ("INF", float("INF"))], [("10foobar", _ERROR_MESSAGE + "10foobar")]) + @test_util.run_deprecated_v1 def testToInt32(self): self._test(dtypes.int32, [("0", 0), ("3", 3), ("-1", -1), @@ -84,6 +88,7 @@ class StringToNumberOpTest(test.TestCase): ("2.9", _ERROR_MESSAGE + "2.9"), ("10foobar", _ERROR_MESSAGE + "10foobar")]) + @test_util.run_deprecated_v1 def testToInt64(self): self._test(dtypes.int64, [("0", 0), ("3", 3), ("-1", -1), diff --git a/tensorflow/python/kernel_tests/substr_op_test.py b/tensorflow/python/kernel_tests/substr_op_test.py index bb2d4a79131..9302152e82b 100644 --- a/tensorflow/python/kernel_tests/substr_op_test.py +++ b/tensorflow/python/kernel_tests/substr_op_test.py @@ -22,6 +22,7 @@ from absl.testing import parameterized import numpy as np from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -319,6 +320,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, "UTF8_CHAR"), (np.int64, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testBadBroadcast(self, dtype, unit): test_string = [[b"ten", b"eleven", b"twelve"], [b"thirteen", b"fourteen", b"fifteen"], @@ -338,6 +340,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, -6, "UTF8_CHAR"), (np.int64, -6, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testOutOfRangeError_Scalar(self, dtype, pos, unit): # Scalar/Scalar test_string = { @@ -361,6 +364,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, -4, "UTF8_CHAR"), (np.int64, -4, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testOutOfRangeError_VectorScalar(self, dtype, pos, unit): # Vector/Scalar test_string = { @@ -381,6 +385,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, "UTF8_CHAR"), (np.int64, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testOutOfRangeError_MatrixMatrix(self, dtype, unit): # Matrix/Matrix test_string = { @@ -414,6 +419,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, "UTF8_CHAR"), (np.int64, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testOutOfRangeError_Broadcast(self, dtype, unit): # Broadcast test_string = { @@ -444,6 +450,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): (np.int32, "UTF8_CHAR"), (np.int64, "UTF8_CHAR"), ) + @test_util.run_deprecated_v1 def testMismatchPosLenShapes(self, dtype, unit): test_string = { "BYTE": [[b"ten", b"eleven", b"twelve"], @@ -471,6 +478,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): with self.assertRaises(ValueError): string_ops.substr(test_string, position, length) + @test_util.run_deprecated_v1 def testWrongDtype(self): with self.cached_session(): with self.assertRaises(TypeError): @@ -478,6 +486,7 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase): with self.assertRaises(TypeError): string_ops.substr(b"test", 3, 1.0) + @test_util.run_deprecated_v1 def testInvalidUnit(self): with self.cached_session(): with self.assertRaises(ValueError): diff --git a/tensorflow/python/kernel_tests/summary_v1_image_op_test.py b/tensorflow/python/kernel_tests/summary_v1_image_op_test.py index e1b24756f3f..56de2e933db 100644 --- a/tensorflow/python/kernel_tests/summary_v1_image_op_test.py +++ b/tensorflow/python/kernel_tests/summary_v1_image_op_test.py @@ -24,6 +24,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.core.framework import summary_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import image_ops import tensorflow.python.ops.nn_grad # pylint: disable=unused-import from tensorflow.python.platform import test @@ -49,6 +50,7 @@ class SummaryV1ImageOpTest(test.TestCase): }""" % ((i,) + shape[1:]) for i in xrange(3)) self.assertProtoEquals(expected, image_summ) + @test_util.run_deprecated_v1 def testImageSummary(self): for depth in (1, 3, 4): for positive in False, True: @@ -84,6 +86,7 @@ class SummaryV1ImageOpTest(test.TestCase): # Check the rest of the proto self._CheckProto(image_summ, shape) + @test_util.run_deprecated_v1 def testImageSummaryUint8(self): np.random.seed(7) for depth in (1, 3, 4): diff --git a/tensorflow/python/kernel_tests/summary_v1_ops_test.py b/tensorflow/python/kernel_tests/summary_v1_ops_test.py index 1206cb7013f..e070f5bf6f5 100644 --- a/tensorflow/python/kernel_tests/summary_v1_ops_test.py +++ b/tensorflow/python/kernel_tests/summary_v1_ops_test.py @@ -26,6 +26,7 @@ from __future__ import print_function from tensorflow.core.framework import summary_pb2 from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import logging_ops from tensorflow.python.platform import test from tensorflow.python.summary import summary @@ -60,6 +61,7 @@ class SummaryV1OpsTest(test.TestCase): value { tag: "c2" simple_value: 20.0 } """, self._AsSummary(value)) + @test_util.run_deprecated_v1 def testMergeSummary(self): with self.cached_session() as sess: const = constant_op.constant(10.0) diff --git a/tensorflow/python/kernel_tests/template_test.py b/tensorflow/python/kernel_tests/template_test.py index a187fa115ce..3b2a56bd1ff 100644 --- a/tensorflow/python/kernel_tests/template_test.py +++ b/tensorflow/python/kernel_tests/template_test.py @@ -72,6 +72,7 @@ def variable_scoped_function_with_local_variable(): class TemplateTest(test.TestCase): + @test_util.run_deprecated_v1 def test_end_to_end(self): """This test shows a very simple line model with test_loss. @@ -172,6 +173,7 @@ class TemplateTest(test.TestCase): self.assertEqual("s1/dummy:0", v1.name) self.assertEqual("s1_1/dummy:0", v3.name) + @test_util.run_deprecated_v1 def test_same_unique_name_raise_error(self): tmpl1 = template.make_template( "_", variable_scoped_function, unique_name_="s1") @@ -190,6 +192,7 @@ class TemplateTest(test.TestCase): template.make_template( "_", variable_scoped_function, unique_name_="s1") + @test_util.run_deprecated_v1 def test_unique_name_and_reuse(self): tmpl1 = template.make_template( "_", variable_scoped_function, unique_name_="s1") @@ -260,6 +263,7 @@ class TemplateTest(test.TestCase): self.assertEqual("s1/test/dummy:0", v1.name) self.assertEqual("s1_1/test/dummy:0", v3.name) + @test_util.run_deprecated_v1 def test_enforces_no_extra_trainable_variables(self): tmpl = template.make_template("s", function_with_create, trainable=True) @@ -675,6 +679,7 @@ class TemplateTest(test.TestCase): self.assertEqual(1, len(tb.variables)) # TODO(apassos) handle local variables in Eager + @test_util.run_deprecated_v1 def test_local_variables(self): # Make sure trainable_variables are created. with variable_scope.variable_scope("foo3"): diff --git a/tensorflow/python/kernel_tests/tensor_array_ops_test.py b/tensorflow/python/kernel_tests/tensor_array_ops_test.py index bb8645e2d54..76e90ffea39 100644 --- a/tensorflow/python/kernel_tests/tensor_array_ops_test.py +++ b/tensorflow/python/kernel_tests/tensor_array_ops_test.py @@ -165,6 +165,7 @@ class TensorArrayTest(test.TestCase): [106.0, 107.0], [8.0, 9.0]]), c0) @test_util.disable_control_flow_v2("b/118343594 (TensorArray.concat)") + @test_util.run_deprecated_v1 def testTensorArrayWriteConcat(self): self._testTensorArrayWriteConcat(dtypes.float32) self._testTensorArrayWriteConcat(dtypes.float64) @@ -188,6 +189,7 @@ class TensorArrayTest(test.TestCase): self.evaluate(ta.write(1, [[4.0, 5.0]]).concat())) @test_util.disable_control_flow_v2("b/118890905") + @test_util.run_deprecated_v1 def testTensorArrayReadOrPackNotAllValuesAvailableFillsZeros(self): self._testTensorArrayReadOrPackNotAllValuesAvailableFillsZeros() @@ -204,6 +206,7 @@ class TensorArrayTest(test.TestCase): self.evaluate(ta.write(1, [[4.0, 5.0]]).concat())) @test_util.disable_control_flow_v2("b/118890905") + @test_util.run_deprecated_v1 def testTensorArrayReadOrPackNotAllValuesAvailableInferShapeFillsZeros(self): self._testTensorArrayReadOrPackNotAllValuesAvailableInferShapeFillsZeros() @@ -303,6 +306,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(convert([[3.0, 301.0]]), d2) @test_util.disable_control_flow_v2("b/118343962 (TensorArray.split)") + @test_util.run_deprecated_v1 def testTensorArraySplitRead(self): self._testTensorArraySplitRead(dtypes.float32) self._testTensorArraySplitRead(dtypes.float64) @@ -313,6 +317,7 @@ class TensorArrayTest(test.TestCase): self._testTensorArraySplitRead(dtypes.string) @test_util.disable_control_flow_v2("v2 does not support TensorArray.grad.") + @test_util.run_deprecated_v1 def testSkipEagerTensorGradArrayWriteRead(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -346,6 +351,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([[2.0]], g_d1) self.assertAllEqual(-2.0, g_d2) + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradGrad(self): if not tensor_array_ops.ENABLE_TENSOR_ARRAY_V2: self.skipTest("Legacy TensorArray does not support double derivatives.") @@ -366,6 +372,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([2.0], session.run(g2)) @test_util.disable_control_flow_v2("v2 does not support TensorArray.grad.") + @test_util.run_deprecated_v1 def testSkipEagerTensorGradArrayDynamicWriteRead(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -408,6 +415,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(3, g_vs) @test_util.disable_control_flow_v2("v2 does not support TensorArray.grad.") + @test_util.run_deprecated_v1 def testSkipEagerTensorGradAccessTwiceReceiveSameObject(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -424,6 +432,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(t_g_ta_0, t_g_ta_1) self.assertAllEqual([[4.0, 5.0]], d_r1_0) + @test_util.run_deprecated_v1 def testTensorArrayWriteWrongIndexOrDataTypeFails(self): with self.session(use_gpu=True): ta = _make_ta(3, "foo", dtype=dtypes.float32) @@ -457,6 +466,7 @@ class TensorArrayTest(test.TestCase): with self.assertRaisesOpError(error_msg): self.evaluate(ta.write(3, 3.0).flow) + @test_util.run_deprecated_v1 def testTensorArrayReadWrongIndexOrDataTypeFails(self): with self.session(use_gpu=True): ta = _make_ta(3, "foo", dtype=dtypes.float32) @@ -491,6 +501,7 @@ class TensorArrayTest(test.TestCase): self.evaluate(ta.read(3)) @test_util.disable_control_flow_v2("v2 allows multiple writes.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayWriteMultipleFails(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -502,6 +513,7 @@ class TensorArrayTest(test.TestCase): self.evaluate(ta.write(2, 3.0).write(2, 3.0).flow) @test_util.disable_control_flow_v2("b/118343594 (TensorArray.concat)") + @test_util.run_deprecated_v1 def testTensorArrayConcatIncompatibleShapesFails(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -534,6 +546,7 @@ class TensorArrayTest(test.TestCase): self.evaluate(w3.concat()) @test_util.disable_control_flow_v2("b/118343962 (TensorArray.split)") + @test_util.run_deprecated_v1 def testTensorArraySplitIncompatibleShapesFails(self): with self.session(use_gpu=True): in_eager_mode = context.executing_eagerly() @@ -598,12 +611,14 @@ class TensorArrayTest(test.TestCase): wb1_grad.flow.eval() @test_util.disable_control_flow_v2("v2 does not support TensorArray.grad.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayWriteGradientAddMultipleAdds(self): for dtype in (dtypes.int32, dtypes.int64, dtypes.float32, dtypes.float64, dtypes.complex64, dtypes.complex128): self._testTensorArrayWriteGradientAddMultipleAdds(dtype) @test_util.disable_control_flow_v2("Low level legacy TA op test.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradWithShapeKnownElementShape(self): with self.session(use_gpu=True) as sess: ta = tensor_array_ops.TensorArray( @@ -634,6 +649,7 @@ class TensorArrayTest(test.TestCase): sess.run(read_value, feed_dict={value: fed_value})) @test_util.disable_control_flow_v2("Low level legacy TA op test.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradWithShapeUnknownElementShape(self): with self.session(use_gpu=True) as sess: ta = tensor_array_ops.TensorArray( @@ -720,6 +736,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(c([[3.0, 2.0]]), grad_vals[0]) self.assertAllEqual(c(-2.0), grad_vals[1]) + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradientWriteRead(self): for dtype in (np.float32, np.float64, np.complex64, np.complex128): self._testTensorArrayGradientWriteReadType(dtype) @@ -757,10 +774,12 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([4.0 + 40.0, 5.0 + 50.0], grad_vals[1]) @test_util.disable_control_flow_v2("b/118343594 (TensorArray.concat)") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradientWritePackConcatAndRead(self): self._testTensorArrayGradientWritePackConcatAndRead() @test_util.disable_control_flow_v2("v2 does not support clear_after_read.") + @test_util.run_deprecated_v1 def testTensorArrayReadTwice(self): with self.session(use_gpu=True): value = constant_op.constant([[1.0, -1.0], [10.0, -10.0]]) @@ -814,10 +833,12 @@ class TensorArrayTest(test.TestCase): self.assertEqual(len(grad_vals), 1) self.assertAllEqual([[2.0 - 1.5, 3.0 + 1.5], [4.0, 5.0]], grad_vals[0]) + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradientUnpackRead(self): self._testTensorArrayGradientUnpackRead() @test_util.disable_control_flow_v2("b/118343962 (TensorArray.split)") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradientSplitConcat(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -863,6 +884,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual(len(grad_vals), 1) self.assertAllEqual([[2.0, 3.0], [4.0, 5.0]], grad_vals[0]) + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradientDynamicUnpackRead(self): self._testTensorArrayGradientDynamicUnpackRead() @@ -1043,6 +1065,7 @@ class TensorArrayTest(test.TestCase): grad = gradients_impl.gradients(loop(x), [x])[0] self.assertAllClose(31.0, self.evaluate(grad)) + @test_util.run_deprecated_v1 def testSkipEagerSumOfTwoReadVariablesWithoutRepeatGrad(self): with self.session(use_gpu=True) as session: a = array_ops.identity( @@ -1078,6 +1101,7 @@ class TensorArrayTest(test.TestCase): def _grad_source_for_name(self, name): return tensor_array_grad._GetGradSource(constant_op.constant(0, name=name)) + @test_util.run_deprecated_v1 def testSkipEagerGetGradSource_Invalid(self): with self.assertRaises(ValueError): self._grad_source_for_name("") @@ -1086,6 +1110,7 @@ class TensorArrayTest(test.TestCase): with self.assertRaises(ValueError): self._grad_source_for_name("foo/bar") + @test_util.run_deprecated_v1 def testSkipEagerGetGradSource_NoEnclosingScope(self): self.assertEqual("gradients:0", self._grad_source_for_name("gradients")) self.assertEqual("gradients_0:0", self._grad_source_for_name("gradients_0")) @@ -1097,6 +1122,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual("gradients_0", self._grad_source_for_name("gradients_0/foo/bar")) + @test_util.run_deprecated_v1 def testSkipEagerGetGradSource_EnclosingScope(self): self.assertEqual("foo/gradients:0", self._grad_source_for_name("foo/gradients")) @@ -1111,11 +1137,13 @@ class TensorArrayTest(test.TestCase): self.assertEqual("foo/bar/gradients_0", self._grad_source_for_name("foo/bar/gradients_0/baz")) + @test_util.run_deprecated_v1 def testSkipEagerGetGradSource_NestedUsesInnermost(self): self.assertEqual( "foo/gradients/bar/gradients_0", self._grad_source_for_name("foo/gradients/bar/gradients_0/baz")) + @test_util.run_deprecated_v1 def testSkipEagerWriteShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1141,6 +1169,7 @@ class TensorArrayTest(test.TestCase): w0.write(0, c2) @test_util.disable_control_flow_v2("b/118343962 (TensorArray.split)") + @test_util.run_deprecated_v1 def testSkipEagerPartlyUnknownShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1212,10 +1241,12 @@ class TensorArrayTest(test.TestCase): w1.write(4, c2) @test_util.disable_control_flow_v2("b/117943489 (dynamic_size)") + @test_util.run_deprecated_v1 def testUnpackShape(self): self._testUnpackShape() @test_util.disable_control_flow_v2("b/118343962 (TensorArray.split)") + @test_util.run_deprecated_v1 def testSplitShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1246,6 +1277,7 @@ class TensorArrayTest(test.TestCase): tensor_shape.TensorShape( ta1.handle.op.get_attr("element_shape")).ndims, None) + @test_util.run_deprecated_v1 def testSkipEagerWriteUnknownShape(self): with self.session(use_gpu=True): ta = tensor_array_ops.TensorArray( @@ -1289,10 +1321,12 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(np.array([1.0, 1.0, 1.0]), self.evaluate(grad)[0]) @test_util.disable_control_flow_v2("b/117943489") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayUnpackDynamic(self): self._testTensorArrayUnpackDynamic() @test_util.disable_control_flow_v2("b/118343594 (TensorArray.concat)") + @test_util.run_deprecated_v1 def testSkipEagerTensorArraySplitDynamic(self): with self.session(use_gpu=True) as sess: ta = tensor_array_ops.TensorArray( @@ -1319,6 +1353,7 @@ class TensorArrayTest(test.TestCase): .ENABLE_TENSOR_ARRAY_V2 else v1_msg): ta.stack().eval() + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayEvalEmpty(self): self._testTensorArrayEvalEmpty() @@ -1339,10 +1374,12 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([0, 5], self.evaluate(concatenated).shape) @test_util.disable_control_flow_v2("b/117943489") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayEvalEmptyWithDefault(self): self._testTensorArrayEvalEmptyWithDefault() @test_util.disable_control_flow_v2("b/117943489") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayScatterReadAndGradients(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -1370,6 +1407,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual([[2.0, 3.0], [4.0, 5.0]], grad_vals[0]) @test_util.disable_control_flow_v2("b/117943286") + @test_util.run_deprecated_v1 def testTensorArrayWriteGatherAndGradients(self): with self.session(use_gpu=True) as session: ta = tensor_array_ops.TensorArray( @@ -1407,6 +1445,7 @@ class TensorArrayTest(test.TestCase): self.assertAllEqual(expected_grad, grad_vals[0]) @test_util.disable_control_flow_v2("colocate_with not supported in v2.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGetsDeviceFromFirstWrite(self): with ops.device("/job:worker/task:0/cpu:0"): # this initial device will be ignored. @@ -1456,6 +1495,7 @@ class TensorArrayTest(test.TestCase): [s for s in dev_stats[d] if "/TensorArray" in s.node_name]) @test_util.disable_control_flow_v2("colocate_with not supported in v2.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGetsDeviceFromFirstWriteInWhileLoop(self): with ops.device("/job:worker/task:0/cpu:0"): ta = tensor_array_ops.TensorArray(dtype=dtypes.float32, size=2) @@ -1486,6 +1526,7 @@ class TensorArrayTest(test.TestCase): [s for s in dev_stats[d] if "TensorArray" == s.node_name]) @test_util.disable_control_flow_v2("colocate_with not supported in v2.") + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayDisabledColocateWithFirstWriteCall(self): with ops.device("/job:worker/task:0/cpu:0"): ta = tensor_array_ops.TensorArray( @@ -1568,6 +1609,7 @@ class TensorArrayTest(test.TestCase): self.assertEqual(size0_v, 2) self.assertEqual(size1_v, 4) + @test_util.run_deprecated_v1 def testSkipEagerTensorArrayGradYsInCorrectScope(self): n_time = 1 n_dim = 1 diff --git a/tensorflow/python/kernel_tests/topk_op_test.py b/tensorflow/python/kernel_tests/topk_op_test.py index a72888c2567..5d46176bce8 100644 --- a/tensorflow/python/kernel_tests/topk_op_test.py +++ b/tensorflow/python/kernel_tests/topk_op_test.py @@ -27,6 +27,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import nn_ops @@ -181,6 +182,7 @@ class TopKTest(test.TestCase): k = constant_op.constant(3) self._validateTopK(inputs, k, [19, 18, 17], [11, 3, 7]) + @test_util.run_deprecated_v1 def testKNegative(self): inputs = [[0.1, 0.2], [0.3, 0.4]] with self.session(use_gpu=True): @@ -189,12 +191,14 @@ class TopKTest(test.TestCase): with self.assertRaisesOpError("Need k >= 0, got -7"): values.eval(feed_dict={k: -7}) + @test_util.run_deprecated_v1 def testKTooLarge(self): inputs = [[0.1, 0.2], [0.3, 0.4]] with self.assertRaisesRegexp(ValueError, r"must have last dimension >= k = 4"): nn_ops.top_k(inputs, 4) + @test_util.run_deprecated_v1 def testTopKGradients(self): with self.session(use_gpu=True) as sess: inputs = array_ops.placeholder(dtypes.float32, shape=[2, 5]) diff --git a/tensorflow/python/kernel_tests/trace_op_test.py b/tensorflow/python/kernel_tests/trace_op_test.py index f1abaefb66b..52640c02c22 100644 --- a/tensorflow/python/kernel_tests/trace_op_test.py +++ b/tensorflow/python/kernel_tests/trace_op_test.py @@ -19,6 +19,7 @@ from __future__ import print_function import numpy as np +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -34,6 +35,7 @@ class TraceTest(test.TestCase): tf_ans = math_ops.trace(x).eval() self.assertAllClose(tf_ans, np_ans) + @test_util.run_deprecated_v1 def testTrace(self): for dtype in [np.int32, np.float32, np.float64]: for shape in [[2, 2], [2, 3], [3, 2], [2, 3, 2], [2, 2, 2, 3]]: diff --git a/tensorflow/python/kernel_tests/unicode_decode_op_test.py b/tensorflow/python/kernel_tests/unicode_decode_op_test.py index c34145bff17..c165021eea3 100644 --- a/tensorflow/python/kernel_tests/unicode_decode_op_test.py +++ b/tensorflow/python/kernel_tests/unicode_decode_op_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import errors_impl as errors +from tensorflow.python.framework import test_util from tensorflow.python.ops import gen_string_ops from tensorflow.python.platform import test @@ -79,6 +80,7 @@ class UnicodeDecodeTest(test.TestCase): self.assertAllEqual(self.evaluate(row_splits).tolist(), [0, 4]) self.assertAllEqual(self.evaluate(starts).tolist(), [0, 3, 6, 9]) + @test_util.run_deprecated_v1 def testStrictError(self): text = constant_op.constant([b"\xFEED"]) _, error, _ = gen_string_ops.unicode_decode_with_offsets( @@ -97,6 +99,7 @@ class UnicodeDecodeTest(test.TestCase): with self.test_session(): self.assertAllEqual(self.evaluate(utf8_text).tolist(), [65533]) + @test_util.run_deprecated_v1 def testBadReplacementChar(self): text = constant_op.constant([b"\xFE"]) _, error, _ = gen_string_ops.unicode_decode_with_offsets( @@ -121,6 +124,7 @@ class UnicodeDecodeTest(test.TestCase): codepoint("o") ]) + @test_util.run_deprecated_v1 def testBadErrorPolicy(self): text = constant_op.constant(["hippopotamus"]) diff --git a/tensorflow/python/kernel_tests/unicode_script_op_test.py b/tensorflow/python/kernel_tests/unicode_script_op_test.py index 927e5459ed2..83cfeb20216 100644 --- a/tensorflow/python/kernel_tests/unicode_script_op_test.py +++ b/tensorflow/python/kernel_tests/unicode_script_op_test.py @@ -20,12 +20,14 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import string_ops from tensorflow.python.platform import test class UnicodeScriptOpTest(test.TestCase): + @test_util.run_deprecated_v1 def testValidScripts(self): inputs = [ ord("a"), @@ -45,6 +47,7 @@ class UnicodeScriptOpTest(test.TestCase): 0 # USCRIPT_COMMON (ZYYY) ]) + @test_util.run_deprecated_v1 def testInvalidScript(self): inputs = [-100, 0xffffff] with self.cached_session(): diff --git a/tensorflow/python/kernel_tests/unicode_transcode_op_test.py b/tensorflow/python/kernel_tests/unicode_transcode_op_test.py index 037ecd104b0..a3b4fd03474 100644 --- a/tensorflow/python/kernel_tests/unicode_transcode_op_test.py +++ b/tensorflow/python/kernel_tests/unicode_transcode_op_test.py @@ -22,6 +22,7 @@ from absl.testing import parameterized from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import string_ops from tensorflow.python.platform import test @@ -133,6 +134,7 @@ class UnicodeTranscodeOpTest(test.TestCase, parameterized.TestCase): values = self.evaluate(outputs) self.assertAllEqual(values, b"\x00 ") + @test_util.run_deprecated_v1 def test_transcode_bad_utf8_with_strict_errors(self): bad_string = b"\x00\xff" with self.cached_session() as sess: @@ -145,6 +147,7 @@ class UnicodeTranscodeOpTest(test.TestCase, parameterized.TestCase): "Invalid formatting on input string"): self.evaluate(outputs) + @test_util.run_deprecated_v1 def test_transcode_bad_utf8_start_with_strict_errors(self): bad_string = b"\xffabcd" with self.cached_session() as sess: @@ -317,12 +320,14 @@ class UnicodeTranscodeOpTest(test.TestCase, parameterized.TestCase): (b"\xfe\xff\x00<\xfe\xff\x00>", "UTF-16", b"<\xef\xbb\xbf>"), (b"\xff\xfe<\x00\xff\xfe>\x00", "UTF-16", b"<\xef\xbb\xbf>"), ) + @test_util.run_deprecated_v1 def test_bom_handling(self, string, input_encoding, expected): with self.test_session(): output = string_ops.unicode_transcode( string, input_encoding=input_encoding, output_encoding="UTF-8") self.assertAllEqual(output.eval(), expected) + @test_util.run_deprecated_v1 def test_invalid_encoding_causes_errors(self): strings = [[b"a", b"abc"], [b"ABC", b"DEF"]] @@ -349,6 +354,7 @@ class UnicodeTranscodeOpTest(test.TestCase, parameterized.TestCase): replace_control_characters=False) self.evaluate(outputs) + @test_util.run_deprecated_v1 def test_invalid_error_policy_causes_errors(self): strings = [[b"a", b"abc"], [b"ABC", b"DEF"]] @@ -378,6 +384,7 @@ class UnicodeTranscodeOpTest(test.TestCase, parameterized.TestCase): self.assertAllEqual([b"AbCdE", b"HiJkL"], transcoded) + @test_util.run_deprecated_v1 def test_cjk_encodings(self): strings_ja = [ b"\x5c\x5c", # Yen sign diff --git a/tensorflow/python/kernel_tests/unstack_op_test.py b/tensorflow/python/kernel_tests/unstack_op_test.py index d314e1eaf93..f5ba475e7ad 100644 --- a/tensorflow/python/kernel_tests/unstack_op_test.py +++ b/tensorflow/python/kernel_tests/unstack_op_test.py @@ -74,6 +74,7 @@ class UnstackOpTest(test.TestCase): cs = [self.evaluate(c) for c in cs] self.assertAllEqual(cs, data) + @test_util.run_deprecated_v1 def testGradientsAxis0(self): for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2): data = np.random.randn(*shape) @@ -86,6 +87,7 @@ class UnstackOpTest(test.TestCase): shapes[i]) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testGradientsAxis1(self): for shape in (2, 3), (3, 2), (4, 3, 2): data = np.random.randn(*shape) @@ -99,6 +101,7 @@ class UnstackOpTest(test.TestCase): out_shape) self.assertLess(err, 1e-6) + @test_util.run_deprecated_v1 def testInferNum(self): with self.cached_session(): for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2): @@ -107,16 +110,19 @@ class UnstackOpTest(test.TestCase): self.assertEqual(type(cs), list) self.assertEqual(len(cs), shape[0]) + @test_util.run_deprecated_v1 def testCannotInferNumFromUnknownShape(self): x = array_ops.placeholder(np.float32) with self.assertRaisesRegexp(ValueError, r'Cannot infer num from shape <unknown>'): array_ops.unstack(x) + @test_util.run_deprecated_v1 def testUnknownShapeOkWithNum(self): x = array_ops.placeholder(np.float32) array_ops.unstack(x, num=2) + @test_util.run_deprecated_v1 def testCannotInferNumFromNoneShape(self): x = array_ops.placeholder(np.float32, shape=(None,)) with self.assertRaisesRegexp(ValueError, diff --git a/tensorflow/python/kernel_tests/variable_ops_test.py b/tensorflow/python/kernel_tests/variable_ops_test.py index c63d7f89c73..0f3e2619925 100644 --- a/tensorflow/python/kernel_tests/variable_ops_test.py +++ b/tensorflow/python/kernel_tests/variable_ops_test.py @@ -60,15 +60,18 @@ class VariableOpTest(test.TestCase): # that Variable and Assign have GPU implementations for matching tf. self.assertAllEqual(x, self._initFetch(x, tftype, use_gpu=True)) + @test_util.run_deprecated_v1 def testBasic(self): self._testTypes(np.arange(0, 20).reshape([4, 5])) + @test_util.run_deprecated_v1 def testset_shape(self): p = state_ops.variable_op([1, 2], dtypes.float32) self.assertEqual([1, 2], p.get_shape()) p = state_ops.variable_op([1, 2], dtypes.float32, set_shape=False) self.assertEqual(tensor_shape.unknown_shape(), p.get_shape()) + @test_util.run_deprecated_v1 def testAssign(self): value = np.array([[42.0, 43.0]]) var = state_ops.variable_op(value.shape, dtypes.float32) @@ -76,6 +79,7 @@ class VariableOpTest(test.TestCase): assigned = state_ops.assign(var, value) self.assertShapeEqual(value, assigned) + @test_util.run_deprecated_v1 def testAssignNoValidateShape(self): value = np.array([[42.0, 43.0]]) var = state_ops.variable_op(value.shape, dtypes.float32) @@ -83,6 +87,7 @@ class VariableOpTest(test.TestCase): assigned = state_ops.assign(var, value, validate_shape=False) self.assertShapeEqual(value, assigned) + @test_util.run_deprecated_v1 def testAssignNoVarShape(self): value = np.array([[42.0, 43.0]]) var = state_ops.variable_op(value.shape, dtypes.float32, set_shape=False) @@ -90,6 +95,7 @@ class VariableOpTest(test.TestCase): assigned = state_ops.assign(var, value) self.assertShapeEqual(value, assigned) + @test_util.run_deprecated_v1 def testAssignNoVarShapeNoValidateShape(self): value = np.array([[42.0, 43.0]]) var = state_ops.variable_op(value.shape, dtypes.float32, set_shape=False) @@ -102,6 +108,7 @@ class VariableOpTest(test.TestCase): self.assertEqual(tensor_shape.unknown_shape(), tensor.get_shape()) return tensor + @test_util.run_deprecated_v1 def testAssignNoValueShape(self): value = self._NewShapelessTensor() shape = [1, 2] @@ -110,6 +117,7 @@ class VariableOpTest(test.TestCase): self.assertEqual(shape, var.get_shape()) self.assertEqual(shape, assigned.get_shape()) + @test_util.run_deprecated_v1 def testAssignNoValueShapeNoValidateShape(self): value = self._NewShapelessTensor() shape = [1, 2] @@ -118,6 +126,7 @@ class VariableOpTest(test.TestCase): assigned = state_ops.assign(var, value, validate_shape=False) self.assertEqual(tensor_shape.unknown_shape(), assigned.get_shape()) + @test_util.run_deprecated_v1 def testAssignNoShape(self): with self.cached_session(): value = self._NewShapelessTensor() @@ -126,6 +135,7 @@ class VariableOpTest(test.TestCase): self.assertEqual(tensor_shape.unknown_shape(), state_ops.assign(var, value).get_shape()) + @test_util.run_deprecated_v1 def testAssignNoShapeNoValidateShape(self): with self.cached_session(): value = self._NewShapelessTensor() @@ -136,6 +146,7 @@ class VariableOpTest(test.TestCase): state_ops.assign( var, value, validate_shape=False).get_shape()) + @test_util.run_deprecated_v1 def testAssignUpdate(self): var = state_ops.variable_op([1, 2], dtypes.float32) added = state_ops.assign_add(var, [[2.0, 3.0]]) @@ -143,6 +154,7 @@ class VariableOpTest(test.TestCase): subbed = state_ops.assign_sub(var, [[12.0, 13.0]]) self.assertEqual([1, 2], subbed.get_shape()) + @test_util.run_deprecated_v1 def testAssignUpdateNoVarShape(self): var = state_ops.variable_op([1, 2], dtypes.float32, set_shape=False) added = state_ops.assign_add(var, [[2.0, 3.0]]) @@ -150,6 +162,7 @@ class VariableOpTest(test.TestCase): subbed = state_ops.assign_sub(var, [[12.0, 13.0]]) self.assertEqual([1, 2], subbed.get_shape()) + @test_util.run_deprecated_v1 def testAssignUpdateNoValueShape(self): var = state_ops.variable_op([1, 2], dtypes.float32) added = state_ops.assign_add(var, self._NewShapelessTensor()) @@ -157,6 +170,7 @@ class VariableOpTest(test.TestCase): subbed = state_ops.assign_sub(var, self._NewShapelessTensor()) self.assertEqual([1, 2], subbed.get_shape()) + @test_util.run_deprecated_v1 def testAssignUpdateNoShape(self): var = state_ops.variable_op([1, 2], dtypes.float32, set_shape=False) added = state_ops.assign_add(var, self._NewShapelessTensor()) @@ -164,6 +178,7 @@ class VariableOpTest(test.TestCase): subbed = state_ops.assign_sub(var, self._NewShapelessTensor()) self.assertEqual(tensor_shape.unknown_shape(), subbed.get_shape()) + @test_util.run_deprecated_v1 def testTemporaryVariable(self): with test_util.use_gpu(): var = gen_state_ops.temporary_variable( @@ -173,6 +188,7 @@ class VariableOpTest(test.TestCase): final = gen_state_ops.destroy_temporary_variable(var, var_name="foo") self.assertAllClose([[10.0, 12.0]], self.evaluate(final)) + @test_util.run_deprecated_v1 def testDestroyNonexistentTemporaryVariable(self): with test_util.use_gpu(): var = gen_state_ops.temporary_variable([1, 2], dtypes.float32) @@ -180,6 +196,7 @@ class VariableOpTest(test.TestCase): with self.assertRaises(errors.NotFoundError): self.evaluate(final) + @test_util.run_deprecated_v1 def testDuplicateTemporaryVariable(self): with test_util.use_gpu(): var1 = gen_state_ops.temporary_variable( @@ -192,6 +209,7 @@ class VariableOpTest(test.TestCase): with self.assertRaises(errors.AlreadyExistsError): self.evaluate(final) + @test_util.run_deprecated_v1 def testDestroyTemporaryVariableTwice(self): with test_util.use_gpu(): var = gen_state_ops.temporary_variable([1, 2], dtypes.float32) @@ -201,6 +219,7 @@ class VariableOpTest(test.TestCase): with self.assertRaises(errors.NotFoundError): self.evaluate(final) + @test_util.run_deprecated_v1 def testTemporaryVariableNoLeak(self): with test_util.use_gpu(): var = gen_state_ops.temporary_variable( @@ -208,6 +227,7 @@ class VariableOpTest(test.TestCase): final = array_ops.identity(var) self.evaluate(final) + @test_util.run_deprecated_v1 def testTwoTemporaryVariablesNoLeaks(self): with test_util.use_gpu(): var1 = gen_state_ops.temporary_variable( @@ -217,6 +237,7 @@ class VariableOpTest(test.TestCase): final = var1 + var2 self.evaluate(final) + @test_util.run_deprecated_v1 def testAssignDependencyAcrossDevices(self): with test_util.use_gpu(): # The variable and an op to increment it are on the GPU. @@ -232,6 +253,7 @@ class VariableOpTest(test.TestCase): result = math_ops.multiply(var, var) self.assertAllClose([4.0], self.evaluate(result)) + @test_util.run_deprecated_v1 def testIsVariableInitialized(self): for use_gpu in [True, False]: with self.test_session(use_gpu=use_gpu): diff --git a/tensorflow/python/kernel_tests/variable_scope_test.py b/tensorflow/python/kernel_tests/variable_scope_test.py index 3720f736ac4..44d4bd5e30f 100644 --- a/tensorflow/python/kernel_tests/variable_scope_test.py +++ b/tensorflow/python/kernel_tests/variable_scope_test.py @@ -152,6 +152,7 @@ class VariableScopeTest(test.TestCase): # TypeError: Fetch argument <tf.Variable 'string:0' shape=() dtype=string> # has invalid type <class '...ResourceVariable'>, must be a string or Tensor. # (Can not convert a ResourceVariable into a Tensor or Operation.) + @test_util.run_deprecated_v1 def testStringDefaultInitializer(self): with self.cached_session(): v = variable_scope.get_variable("string", shape=[], dtype=dtypes.string) @@ -310,6 +311,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # InvalidArgumentError: /job:moo/replica:0/task:0/device:CPU:0 unknown device. + @test_util.run_deprecated_v1 def testVarScopeCachingDevice(self): with self.cached_session(): caching_device = "/job:moo" @@ -424,6 +426,7 @@ class VariableScopeTest(test.TestCase): # invalid type <class '...ops.resource_variable_ops.ResourceVariable'>, must # be a string or Tensor. (Can not convert a ResourceVariable into a Tensor or # Operation.) + @test_util.run_deprecated_v1 def testControlDeps(self): with self.cached_session() as sess: v0 = variable_scope.get_variable( @@ -450,6 +453,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # AssertionError: True is not false (last assertFalse) + @test_util.run_deprecated_v1 def testEnableResourceVariables(self): old = variable_scope._DEFAULT_USE_RESOURCE try: @@ -464,6 +468,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # TypeError: Fetch argument None has invalid type <type 'NoneType'> + @test_util.run_deprecated_v1 def testControlFlow(self): with self.cached_session() as sess: v0 = variable_scope.get_variable( @@ -1148,6 +1153,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testGetCollection(self): with self.cached_session(): _ = variable_scope.get_variable("testGetCollection_a", []) @@ -1204,6 +1210,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testGetTrainableVariablesWithGetVariable(self): with self.cached_session(): _ = variable_scope.get_variable("testGetTrainableVariables_a", []) @@ -1242,6 +1249,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testGetTrainableVariablesWithVariable(self): with self.cached_session(): _ = variable_scope.variable(1.0, name="testGetTrainableVariables_a") @@ -1283,6 +1291,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testGetGlobalVariables(self): with self.cached_session(): _ = variable_scope.get_variable("testGetGlobalVariables_a", []) @@ -1295,6 +1304,7 @@ class VariableScopeTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testGetLocalVariables(self): with self.cached_session(): _ = variable_scope.get_variable( @@ -1370,6 +1380,7 @@ class VariableScopeWithPartitioningTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testResultNameMatchesRequested(self): with variable_scope.variable_scope( "scope0", partitioner=axis0_into2_partitioner): @@ -1444,6 +1455,7 @@ class VariableScopeWithPartitioningTest(test.TestCase): # TODO(mihaimaruseac): Not converted to use wrap_function because of # obtaining different results in the eager case compared to the graph one + @test_util.run_deprecated_v1 def testScalarIgnoresPartitioner(self): with variable_scope.variable_scope( "scope0", partitioner=axis0_into2_partitioner): @@ -1583,6 +1595,7 @@ class VariableScopeWithCustomGetterTest(test.TestCase): # dtype=float32> cannot be interpreted as a Tensor. (Tensor # Tensor("custom_getter/add:0", shape=(1, 2, 3), dtype=float32) is not an # element of this graph.) + @test_util.run_deprecated_v1 def testGetterThatCreatesTwoVariablesAndSumsThem(self): def custom_getter(getter, name, *args, **kwargs): @@ -1610,6 +1623,7 @@ class VariableScopeWithCustomGetterTest(test.TestCase): # dtype=float32> cannot be interpreted as a Tensor. (Tensor # Tensor("sum_getter_2/add:0", shape=(1, 2, 3), dtype=float32) is not an # element of this graph.) + @test_util.run_deprecated_v1 def testNestedCustomGetters(self): def sum_getter(getter, name, *args, **kwargs): diff --git a/tensorflow/python/kernel_tests/variables_test.py b/tensorflow/python/kernel_tests/variables_test.py index 14ec46dcb22..08d885e8a87 100644 --- a/tensorflow/python/kernel_tests/variables_test.py +++ b/tensorflow/python/kernel_tests/variables_test.py @@ -28,6 +28,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_state_ops @@ -42,6 +43,7 @@ from tensorflow.python.util import compat class VariablesTestCase(test.TestCase): + @test_util.run_deprecated_v1 def testInitialization(self): with self.cached_session(): var0 = variables.VariableV1(0.0) @@ -69,6 +71,7 @@ class VariablesTestCase(test.TestCase): self.assertAllClose(0.0, self.evaluate(var0)) self.assertAllClose(1.1, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testInitializationOrder(self): with self.cached_session(): rnd = variables.Variable(random_ops.random_uniform([3, 6]), name="rnd") @@ -107,6 +110,7 @@ class VariablesTestCase(test.TestCase): for _ in variables.Variable([0.0, 1.0]): pass + @test_util.run_deprecated_v1 def testAssignments(self): with self.cached_session(): var = variables.Variable(0.0) @@ -125,6 +129,7 @@ class VariablesTestCase(test.TestCase): self.assertAllClose(4.0, self.evaluate(four)) self.assertAllClose(4.0, self.evaluate(var)) + @test_util.run_deprecated_v1 def testResourceAssignments(self): with self.session(use_gpu=True): var = resource_variable_ops.ResourceVariable(0.0) @@ -181,12 +186,15 @@ class VariablesTestCase(test.TestCase): self.evaluate(count_up_to) self.assertEqual(3, self.evaluate(var)) + @test_util.run_deprecated_v1 def testCountUpToInt32(self): self._countUpToTest(dtypes.int32) + @test_util.run_deprecated_v1 def testCountUpToInt64(self): self._countUpToTest(dtypes.int64) + @test_util.run_deprecated_v1 def testControlDepsNone(self): with self.cached_session(): c = constant_op.constant(1.0) @@ -200,6 +208,7 @@ class VariablesTestCase(test.TestCase): self.assertEqual([], var_x.value().op.control_inputs) self.assertEqual([], var_x._ref().op.control_inputs) # pylint: disable=protected-access + @test_util.run_deprecated_v1 def testControlFlow(self): with self.cached_session() as sess: v0 = variables.Variable(0, name="v0") @@ -236,6 +245,7 @@ class VariablesTestCase(test.TestCase): self.evaluate(v0.initializer) self.evaluate(add) + @test_util.run_deprecated_v1 def testControlFlowInitialization(self): """Expects an error if an initializer is in a control-flow scope.""" def cond(i, _): @@ -249,6 +259,7 @@ class VariablesTestCase(test.TestCase): with self.assertRaisesRegexp(ValueError, "inside a control-flow"): control_flow_ops.while_loop(cond, body, [0, 0]) + @test_util.run_deprecated_v1 def testUseVariableAsTensor(self): with self.cached_session(): var_x = variables.Variable(2.0) @@ -258,6 +269,7 @@ class VariablesTestCase(test.TestCase): self.assertAllClose(3.0, self.evaluate(var_y)) self.assertAllClose(5.0, math_ops.add(var_x, var_y).eval()) + @test_util.run_deprecated_v1 def testZeroSizeVarSameAsConst(self): with self.cached_session(): zero_size_var = variables.Variable(array_ops.zeros([0, 2])) @@ -270,6 +282,7 @@ class VariablesTestCase(test.TestCase): self.assertAllClose(const_mul.eval(), variable_output) self.assertAllClose([[0., 0.], [0., 0.]], variable_output) + @test_util.run_deprecated_v1 def testCachingDevice(self): with self.cached_session(): var = variables.Variable(2.0) @@ -280,6 +293,7 @@ class VariablesTestCase(test.TestCase): self.assertFalse(var_cached.device.startswith("/job:foo")) self.assertTrue(var_cached.value().device.startswith("/job:foo")) + @test_util.run_deprecated_v1 def testCollections(self): with self.cached_session(): var_x = variables.VariableV1(2.0) @@ -295,6 +309,7 @@ class VariablesTestCase(test.TestCase): variables.global_variables()) self.assertEqual([var_x, var_z, var_t], variables.trainable_variables()) + @test_util.run_deprecated_v1 def testCollectionsWithScope(self): with self.cached_session(): with ops.name_scope("scope_1"): @@ -316,6 +331,7 @@ class VariablesTestCase(test.TestCase): getattr(variables.Variable.__add__, attr), getattr(ops.Tensor.__add__, attr)) + @test_util.run_deprecated_v1 def testOperators(self): with self.cached_session(): var_f = variables.Variable([2.0]) @@ -389,12 +405,14 @@ class VariablesTestCase(test.TestCase): self.assertAllClose([[80.0]], self.evaluate(matmul)) self.assertAllClose([[20.0, 30.0], [40.0, 60.0]], self.evaluate(rmatmul)) + @test_util.run_deprecated_v1 def testSession(self): with self.cached_session() as sess: var = variables.Variable([1, 12]) variables.global_variables_initializer().run() self.assertAllClose([1, 12], self.evaluate(var)) + @test_util.run_deprecated_v1 def testColocation(self): with ops.device("/job:ps"): var = variables.VariableV1(0, name="v") @@ -403,6 +421,7 @@ class VariablesTestCase(test.TestCase): self.assertDeviceEqual("/job:ps", assign_op.device) self.assertEqual([b"loc:@v"], assign_op.op.colocation_groups()) + @test_util.run_deprecated_v1 def testInitializerFunction(self): value = [[-42], [133.7]] shape = [2, 1] @@ -440,6 +459,7 @@ class VariablesTestCase(test.TestCase): lambda: constant_op.constant(1.), constraint=constraint) + @test_util.run_deprecated_v1 def testNoRefDataRace(self): with self.cached_session(): a = variables.Variable([1, 2, 3], dtype=dtypes.float32) @@ -450,6 +470,7 @@ class VariablesTestCase(test.TestCase): self.assertAllEqual(b.eval(), [3, 4, 5]) self.assertAllEqual(c.eval(), [5, 6, 7]) + @test_util.run_deprecated_v1 def testInitializerFunctionDevicePlacement(self): with self.cached_session(): initializer = lambda: constant_op.constant(42.0) @@ -468,6 +489,7 @@ class VariablesTestCase(test.TestCase): for i in v2.initializer.inputs: self.assertEqual(expected_group_v2, i.op.colocation_groups()) + @test_util.run_deprecated_v1 def testVariableDefInitializedInstances(self): with ops.Graph().as_default(), self.cached_session() as sess: v_def = variables.Variable( @@ -511,6 +533,7 @@ class VariablesTestCase(test.TestCase): variables.Variable(variable_def=trainable_variable.to_proto()) .trainable) + @test_util.run_deprecated_v1 def testLoad(self): with self.cached_session(): var = variables.Variable(np.zeros((5, 5), np.float32)) @@ -519,6 +542,7 @@ class VariablesTestCase(test.TestCase): self.assertAllClose(np.ones((5, 5), np.float32), self.evaluate(var)) + @test_util.run_deprecated_v1 def testRepr(self): var = variables.VariableV1(np.zeros((5, 5), np.float32), name="noop") self.assertEqual( @@ -552,6 +576,7 @@ class IsInitializedTest(test.TestCase): variables.global_variables_initializer().run() self.assertEqual(0, self.evaluate(uninited).size) + @test_util.run_deprecated_v1 def testVariableList(self): with ops.Graph().as_default(), self.cached_session() as sess: v = variables.VariableV1([1, 2], name="v") @@ -589,6 +614,7 @@ class ObsoleteIsInitializedTest(test.TestCase): with ops.Graph().as_default(): self.assertEqual(None, variables.assert_variables_initialized()) + @test_util.run_deprecated_v1 def testVariables(self): with ops.Graph().as_default(), self.cached_session() as sess: v = variables.VariableV1([1, 2]) @@ -600,6 +626,7 @@ class ObsoleteIsInitializedTest(test.TestCase): variables.global_variables_initializer().run() self.evaluate(inited) + @test_util.run_deprecated_v1 def testVariableList(self): with ops.Graph().as_default(), self.cached_session() as sess: v = variables.VariableV1([1, 2]) diff --git a/tensorflow/python/kernel_tests/weights_broadcast_test.py b/tensorflow/python/kernel_tests/weights_broadcast_test.py index c476004b893..677d8f2f22f 100644 --- a/tensorflow/python/kernel_tests/weights_broadcast_test.py +++ b/tensorflow/python/kernel_tests/weights_broadcast_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import dtypes as dtypes_lib from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import weights_broadcast_ops from tensorflow.python.platform import test @@ -51,40 +52,48 @@ class AssertBroadcastableTest(test.TestCase): values_placeholder: values, }) + @test_util.run_deprecated_v1 def testScalar(self): self._test_valid(weights=5, values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def test1x1x1(self): self._test_valid( weights=np.asarray((5,)).reshape((1, 1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def test1x1xN(self): self._test_valid( weights=np.asarray((5, 7, 11, 3)).reshape((1, 1, 4)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def test1xNx1(self): self._test_valid( weights=np.asarray((5, 11)).reshape((1, 2, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def test1xNxN(self): self._test_valid( weights=np.asarray((5, 7, 11, 3, 2, 13, 7, 5)).reshape((1, 2, 4)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testNx1x1(self): self._test_valid( weights=np.asarray((5, 7, 11)).reshape((3, 1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testNx1xN(self): self._test_valid( weights=np.asarray(( 5, 7, 11, 3, 2, 12, 7, 5, 2, 17, 11, 3)).reshape((3, 1, 4)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testNxNxN(self): self._test_valid( weights=np.asarray(( @@ -107,29 +116,35 @@ class AssertBroadcastableTest(test.TestCase): values_placeholder: values, }) + @test_util.run_deprecated_v1 def testInvalid1(self): self._test_invalid(weights=np.asarray((5,)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalid1x1(self): self._test_invalid( weights=np.asarray((5,)).reshape((1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidPrefixMatch(self): self._test_invalid( weights=np.asarray((5, 7, 11, 3, 2, 12)).reshape((3, 2)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidSuffixMatch(self): self._test_invalid( weights=np.asarray((5, 7, 11, 3, 2, 12, 7, 5)).reshape((2, 4)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidOnesExtraDim(self): self._test_invalid( weights=np.asarray((5,)).reshape((1, 1, 1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidPrefixMatchExtraDim(self): self._test_invalid( weights=np.asarray(( @@ -137,6 +152,7 @@ class AssertBroadcastableTest(test.TestCase): 2, 17, 11, 3, 5, 7, 11, 3, 2, 12, 7, 5)).reshape((3, 2, 4, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidSuffixMatchExtraDim(self): self._test_invalid( weights=np.asarray(( @@ -164,18 +180,21 @@ class BroadcastWeightsTest(test.TestCase): values_placeholder: values, })) + @test_util.run_deprecated_v1 def testScalar(self): self._test_valid( weights=5, values=_test_values((3, 2, 4)), expected=5 * np.ones((3, 2, 4))) + @test_util.run_deprecated_v1 def test1x1x1(self): self._test_valid( weights=np.asarray((5,)).reshape((1, 1, 1)), values=_test_values((3, 2, 4)), expected=5 * np.ones((3, 2, 4))) + @test_util.run_deprecated_v1 def test1x1xN(self): weights = np.asarray((5, 7, 11, 3)).reshape((1, 1, 4)) self._test_valid( @@ -183,6 +202,7 @@ class BroadcastWeightsTest(test.TestCase): values=_test_values((3, 2, 4)), expected=np.tile(weights, reps=(3, 2, 1))) + @test_util.run_deprecated_v1 def test1xNx1(self): weights = np.asarray((5, 11)).reshape((1, 2, 1)) self._test_valid( @@ -190,6 +210,7 @@ class BroadcastWeightsTest(test.TestCase): values=_test_values((3, 2, 4)), expected=np.tile(weights, reps=(3, 1, 4))) + @test_util.run_deprecated_v1 def test1xNxN(self): weights = np.asarray((5, 7, 11, 3, 2, 13, 7, 5)).reshape((1, 2, 4)) self._test_valid( @@ -197,6 +218,7 @@ class BroadcastWeightsTest(test.TestCase): values=_test_values((3, 2, 4)), expected=np.tile(weights, reps=(3, 1, 1))) + @test_util.run_deprecated_v1 def testNx1x1(self): weights = np.asarray((5, 7, 11)).reshape((3, 1, 1)) self._test_valid( @@ -204,6 +226,7 @@ class BroadcastWeightsTest(test.TestCase): values=_test_values((3, 2, 4)), expected=np.tile(weights, reps=(1, 2, 4))) + @test_util.run_deprecated_v1 def testNx1xN(self): weights = np.asarray(( 5, 7, 11, 3, 2, 12, 7, 5, 2, 17, 11, 3)).reshape((3, 1, 4)) @@ -212,6 +235,7 @@ class BroadcastWeightsTest(test.TestCase): values=_test_values((3, 2, 4)), expected=np.tile(weights, reps=(1, 2, 1))) + @test_util.run_deprecated_v1 def testNxNxN(self): weights = np.asarray(( 5, 7, 11, 3, 2, 12, 7, 5, 2, 17, 11, 3, @@ -234,29 +258,35 @@ class BroadcastWeightsTest(test.TestCase): values_placeholder: values, }) + @test_util.run_deprecated_v1 def testInvalid1(self): self._test_invalid(weights=np.asarray((5,)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalid1x1(self): self._test_invalid( weights=np.asarray((5,)).reshape((1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidPrefixMatch(self): self._test_invalid( weights=np.asarray((5, 7, 11, 3, 2, 12)).reshape((3, 2)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidSuffixMatch(self): self._test_invalid( weights=np.asarray((5, 7, 11, 3, 2, 12, 7, 5)).reshape((2, 4)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidOnesExtraDim(self): self._test_invalid( weights=np.asarray((5,)).reshape((1, 1, 1, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidPrefixMatchExtraDim(self): self._test_invalid( weights=np.asarray(( @@ -264,6 +294,7 @@ class BroadcastWeightsTest(test.TestCase): 2, 17, 11, 3, 5, 7, 11, 3, 2, 12, 7, 5)).reshape((3, 2, 4, 1)), values=_test_values((3, 2, 4))) + @test_util.run_deprecated_v1 def testInvalidSuffixMatchExtraDim(self): self._test_invalid( weights=np.asarray(( diff --git a/tensorflow/python/kernel_tests/where_op_test.py b/tensorflow/python/kernel_tests/where_op_test.py index 9e074b23043..56c13904113 100644 --- a/tensorflow/python/kernel_tests/where_op_test.py +++ b/tensorflow/python/kernel_tests/where_op_test.py @@ -27,6 +27,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import resource_variable_ops @@ -54,6 +55,7 @@ class WhereOpTest(test.TestCase): with self.assertRaises(ValueError): array_ops.where([False, True], None, [1, 2]) + @test_util.run_deprecated_v1 def testBasicVec(self): x = np.asarray([True, False]) truth = np.asarray([[0]], dtype=np.int64) @@ -67,11 +69,13 @@ class WhereOpTest(test.TestCase): truth = np.asarray([[2], [4]], dtype=np.int64) self._testWhere(x, truth) + @test_util.run_deprecated_v1 def testRandomVec(self): x = np.random.rand(1000000) > 0.5 truth = np.vstack([np.where(x)[0].astype(np.int64)]).T self._testWhere(x, truth) + @test_util.run_deprecated_v1 def testBasicMat(self): x = np.asarray([[True, False], [True, False]]) @@ -80,6 +84,7 @@ class WhereOpTest(test.TestCase): self._testWhere(x, truth) + @test_util.run_deprecated_v1 def testBasic3Tensor(self): x = np.asarray([[[True, False], [True, False]], [[False, True], [False, True]], @@ -99,36 +104,47 @@ class WhereOpTest(test.TestCase): truth = np.vstack(truth).T # Convert to [num_true, indices]. self._testWhere(x, truth, expected_err_re) + @test_util.run_deprecated_v1 def testRandomBool(self): self._testRandom(np.bool) + @test_util.run_deprecated_v1 def testRandomInt32(self): self._testRandom(np.int32) + @test_util.run_deprecated_v1 def testRandomInt64(self): self._testRandom(np.int64) + @test_util.run_deprecated_v1 def testRandomFloat(self): self._testRandom(np.float32) + @test_util.run_deprecated_v1 def testRandomDouble(self): self._testRandom(np.float64) + @test_util.run_deprecated_v1 def testRandomComplex64(self): self._testRandom(np.complex64) + @test_util.run_deprecated_v1 def testRandomComplex128(self): self._testRandom(np.complex128) + @test_util.run_deprecated_v1 def testRandomUint8(self): self._testRandom(np.uint8) + @test_util.run_deprecated_v1 def testRandomInt8(self): self._testRandom(np.int8) + @test_util.run_deprecated_v1 def testRandomInt16(self): self._testRandom(np.int16) + @test_util.run_deprecated_v1 def testThreeArgument(self): x = np.array([[-2, 3, -1], [1, -3, -3]]) np_val = np.where(x > 0, x * x, -x) @@ -136,6 +152,7 @@ class WhereOpTest(test.TestCase): tf_val = array_ops.where(constant_op.constant(x) > 0, x * x, -x).eval() self.assertAllEqual(tf_val, np_val) + @test_util.run_deprecated_v1 def testBatchSelect(self): x = np.array([[-2, 3, -1] * 64, [1, -3, -3] * 64] * 8192) # [16384, 192] c_mat = np.array([[False] * 192, [True] * 192] * 8192) # [16384, 192] diff --git a/tensorflow/python/kernel_tests/while_v2_test.py b/tensorflow/python/kernel_tests/while_v2_test.py index e08699922af..09cbeb1a0d5 100644 --- a/tensorflow/python/kernel_tests/while_v2_test.py +++ b/tensorflow/python/kernel_tests/while_v2_test.py @@ -43,6 +43,7 @@ from tensorflow.python.platform import test class WhileV2Test(test.TestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testSingleLoopVar(self): x = constant_op.constant(2.) ret = while_loop_v2( @@ -64,6 +65,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(16., eval_result[0]) self.assertSequenceEqual(sess.run(grad), [32.]) + @test_util.run_deprecated_v1 def testMultipleLoopVarsBasic(self): x = constant_op.constant(5.) y = constant_op.constant(3.) @@ -84,6 +86,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertSequenceEqual(self.evaluate(ret), [45., 3.]) self.assertSequenceEqual(self.evaluate(grad), [9.]) + @test_util.run_deprecated_v1 def testMultipleLoopVars(self): x = constant_op.constant(5.) y = constant_op.constant(3.) @@ -114,6 +117,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertSequenceEqual(self.evaluate(grady_1), [6.]) self.assertSequenceEqual(self.evaluate(grady_2), [61.]) + @test_util.run_deprecated_v1 def testMultipleWhileLoops(self): x = constant_op.constant(2.) ret1 = while_loop_v2( @@ -128,6 +132,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertSequenceEqual(self.evaluate(grad), [32.]) self.assertSequenceEqual(self.evaluate(grad_grad), [48.]) + @test_util.run_deprecated_v1 def testDoubleDerivative(self): x = constant_op.constant(2.) ret = while_loop_v2( @@ -140,6 +145,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertSequenceEqual(self.evaluate(grad), [32.]) self.assertSequenceEqual(self.evaluate(grad_grad), [48.]) + @test_util.run_deprecated_v1 def testPruning(self): x = constant_op.constant(1) @@ -175,6 +181,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): g = GetOptimizedGraph() self.assertEqual(len([n for n in g.node if n.op == "Enter"]), 2) + @test_util.run_deprecated_v1 def testCaptureExternalTensorInCond(self): x = constant_op.constant(2.) y = constant_op.constant(1.) @@ -187,6 +194,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(self.evaluate(ret), 18.) self.assertSequenceEqual(self.evaluate(grad), [9.]) + @test_util.run_deprecated_v1 def testCaptureExternalTensorInBody(self): x = constant_op.constant(2.) y = constant_op.constant(3.) @@ -197,6 +205,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(self.evaluate(ret), 18.) self.assertSequenceEqual(self.evaluate(grad), [9.]) + @test_util.run_deprecated_v1 def testLoopWithTensorListPushBack(self): x = constant_op.constant(2.) @@ -219,6 +228,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(sess.run(ret[0]), 16.) self.assertSequenceEqual(self.evaluate(grad), [32.]) + @test_util.run_deprecated_v1 def testDuplicateAccumulator(self): x = constant_op.constant(2.) @@ -259,6 +269,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): ("PartiallyDefinedShape", [None, 2]), ("FullyDefinedShape", [1, 2]), ) + @test_util.run_deprecated_v1 def testAccumulatorElementShape(self, shape): def MatchShape(actual_tensor_shape): @@ -344,6 +355,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): while2_op.get_attr("body").name, r"foo_while_1_body_\d*") @test_util.enable_control_flow_v2 + @test_util.run_deprecated_v1 def testWhileAndTensorArray(self): with self.cached_session() as sess: param = constant_op.constant(2.0) @@ -354,6 +366,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): r = gradients_impl.gradients(r, param)[0] self.assertAllClose(21.0, self.evaluate(r)) + @test_util.run_deprecated_v1 def testNestedWhile(self): # Compute sum of geometric progression: n^0 + n^1 + ... + n^m # We compute the pow using a while loop. @@ -377,6 +390,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(self.evaluate(result), 364.) self.assertSequenceEqual(self.evaluate(grad), [547.]) + @test_util.run_deprecated_v1 def testIdentityNodeInBody(self): def Body(v): @@ -392,6 +406,7 @@ class WhileV2Test(test.TestCase, parameterized.TestCase): self.assertEqual(self.evaluate(ret), 16.) self.assertSequenceEqual(self.evaluate(grad), [32.]) + @test_util.run_deprecated_v1 def testNestedWhileAndTensorArray(self): n = constant_op.constant(3.0) diff --git a/tensorflow/python/kernel_tests/xent_op_test.py b/tensorflow/python/kernel_tests/xent_op_test.py index 77669f08cc1..f5d03c23701 100644 --- a/tensorflow/python/kernel_tests/xent_op_test.py +++ b/tensorflow/python/kernel_tests/xent_op_test.py @@ -27,6 +27,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker @@ -88,6 +89,7 @@ class XentTest(test.TestCase): self._testSingleClass(True) self._testSingleClass(False) + @test_util.run_deprecated_v1 def testRankTooLarge(self): for dtype in np.float16, np.float32: np_features = np.array([[[1., 1., 1., 1.]], [[1., 2., 3., @@ -152,12 +154,14 @@ class XentTest(test.TestCase): self.assertAllCloseAccordingToType(np_loss, tf_loss) self.assertAllCloseAccordingToType(np_backprop, tf_backprop) + @test_util.run_deprecated_v1 def testShapeMismatch(self): with self.cached_session(): with self.assertRaises(ValueError): gen_nn_ops.softmax_cross_entropy_with_logits( [[0., 1.], [2., 3.]], [[0., 1., 0.], [1., 0., 0.]]) + @test_util.run_deprecated_v1 def testNotMatrix(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -179,6 +183,7 @@ class XentTest(test.TestCase): np.array([[1., 1., 1., 1.], [1., 2., 3., 4.]]).astype(np.float64), np.array([[0., 0., 0., 1.], [0., .5, .5, 0.]]).astype(np.float64)) + @test_util.run_deprecated_v1 def testGradient(self): with self.cached_session() as sess: l = constant_op.constant( @@ -206,6 +211,7 @@ class XentTest(test.TestCase): print("cross entropy gradient err = ", err) self.assertLess(err, 5e-8) + @test_util.run_deprecated_v1 def testGradientLabelWithV2(self): with self.cached_session(): l = constant_op.constant( @@ -224,6 +230,7 @@ class XentTest(test.TestCase): self.assertLess(err, 5e-8) + @test_util.run_deprecated_v1 def testSecondGradient(self): with self.cached_session() as sess: l = constant_op.constant( diff --git a/tensorflow/python/kernel_tests/zero_division_test.py b/tensorflow/python/kernel_tests/zero_division_test.py index 7c82f9320a1..3dd9ec4ba94 100644 --- a/tensorflow/python/kernel_tests/zero_division_test.py +++ b/tensorflow/python/kernel_tests/zero_division_test.py @@ -27,6 +27,7 @@ from tensorflow.python.platform import test class ZeroDivisionTest(test.TestCase): + @test_util.run_deprecated_v1 def testZeros(self): with test_util.use_gpu(): for dtype in dtypes.uint8, dtypes.int16, dtypes.int32, dtypes.int64: diff --git a/tensorflow/python/layers/base_test.py b/tensorflow/python/layers/base_test.py index 45099677e0f..d0ec4f4425f 100644 --- a/tensorflow/python/layers/base_test.py +++ b/tensorflow/python/layers/base_test.py @@ -143,6 +143,7 @@ class BaseLayerTest(test.TestCase): synchronization=variable_scope.VariableSynchronization.ON_READ, trainable=True) + @test_util.run_deprecated_v1 def testReusePartitionedVaraiblesAndRegularizers(self): regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3 partitioner = partitioned_variables.fixed_size_partitioner(3) @@ -445,6 +446,7 @@ class BaseLayerTest(test.TestCase): self.assertTrue(isinstance(result, dict)) self.assertEqual(set(['label', 'logits']), set(result.keys())) + @test_util.run_deprecated_v1 def testActivityRegularizer(self): regularizer = math_ops.reduce_sum layer = base_layers.Layer(activity_regularizer=regularizer) @@ -533,6 +535,7 @@ class BaseLayerTest(test.TestCase): self.assertEqual(len(layer.trainable_variables), 1) self.assertEqual(layer.variables[0].graph, outer_graph) + @test_util.run_deprecated_v1 def testGetUpdateFor(self): class MyLayer(base_layers.Layer): @@ -577,6 +580,7 @@ class BaseLayerTest(test.TestCase): self.assertEqual(len(layer.get_updates_for([intermediate_inputs])), 1) self.assertEqual(len(layer.get_updates_for([outputs])), 0) + @test_util.run_deprecated_v1 def testGetLossesFor(self): class MyLayer(base_layers.Layer): diff --git a/tensorflow/python/layers/convolutional_test.py b/tensorflow/python/layers/convolutional_test.py index d3200fa5b57..a3e493edfea 100644 --- a/tensorflow/python/layers/convolutional_test.py +++ b/tensorflow/python/layers/convolutional_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.layers import convolutional as conv_layers from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops @@ -59,6 +60,7 @@ class ConvTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'kernel_size'): conv_layers.conv2d(images, 32, None) + @test_util.run_deprecated_v1 def testCreateConv2D(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -87,6 +89,7 @@ class ConvTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testCreateConv2DChannelsFirst(self): height, width = 7, 9 images = random_ops.random_uniform((5, 4, height, width)) @@ -97,6 +100,7 @@ class ConvTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testUnknownInputChannels(self): images = array_ops.placeholder(dtypes.float32, (5, 7, 9, None)) layer = conv_layers.Conv2D(32, [3, 3], activation=nn_ops.relu) @@ -140,6 +144,7 @@ class ConvTest(test.TestCase): self.assertListEqual(output.get_shape().as_list(), [5, height / 2, width, 32]) + @test_util.run_deprecated_v1 def testCreateConv1D(self): width = 7 data = random_ops.random_uniform((5, width, 4)) @@ -156,6 +161,7 @@ class ConvTest(test.TestCase): output = conv_layers.conv1d(data, 32, 3, activation=nn_ops.relu) self.assertListEqual(output.get_shape().as_list(), [5, width - 2, 32]) + @test_util.run_deprecated_v1 def testCreateConv1DChannelsFirst(self): width = 7 data = random_ops.random_uniform((5, 4, width)) @@ -165,6 +171,7 @@ class ConvTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testUnknownInputChannelsConv1D(self): data = array_ops.placeholder(dtypes.float32, (5, 4, None)) layer = conv_layers.Conv1D(32, 3, activation=nn_ops.relu) @@ -180,6 +187,7 @@ class ConvTest(test.TestCase): 'should be defined. Found `None`.'): _ = layer.apply(data) + @test_util.run_deprecated_v1 def testCreateConv3D(self): depth, height, width = 6, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 4)) @@ -191,6 +199,7 @@ class ConvTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 3, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testUnknownInputChannelsConv3D(self): volumes = array_ops.placeholder(dtypes.float32, (5, 6, 7, 9, None)) layer = conv_layers.Conv3D(32, [3, 3, 3], activation=nn_ops.relu) @@ -199,6 +208,7 @@ class ConvTest(test.TestCase): 'should be defined. Found `None`.'): _ = layer.apply(volumes) + @test_util.run_deprecated_v1 def testConv2DKernelRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -210,6 +220,7 @@ class ConvTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv2DBiasRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -221,6 +232,7 @@ class ConvTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv2DNoBias(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -247,6 +259,7 @@ class ConvTest(test.TestCase): output = layer.apply(images) self.assertListEqual(output.get_shape().as_list(), [5, height - 2, 3, 32]) + @test_util.run_deprecated_v1 def testFunctionalConv2DReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -255,6 +268,7 @@ class ConvTest(test.TestCase): conv_layers.conv2d(images, 32, [3, 3], name='conv1', reuse=True) self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv2DReuseFromScope(self): with variable_scope.variable_scope('scope'): height, width = 7, 9 @@ -265,6 +279,7 @@ class ConvTest(test.TestCase): conv_layers.conv2d(images, 32, [3, 3], name='conv1') self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv2DInitializerFromScope(self): with self.cached_session() as sess: with variable_scope.variable_scope( @@ -283,6 +298,7 @@ class ConvTest(test.TestCase): # Check that the bias still got initialized to zeros. self.assertAllClose(weights[1], np.zeros((32))) + @test_util.run_deprecated_v1 def testFunctionalConv2DNoReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -325,6 +341,7 @@ class ConvTest(test.TestCase): self.assertEqual(conv3d.kernel_constraint, k_constraint) self.assertEqual(conv3d.bias_constraint, b_constraint) + @test_util.run_deprecated_v1 def testConv3DChannelsFirst(self): # Test case for GitHub issue 15655 images = array_ops.placeholder( @@ -358,6 +375,7 @@ class SeparableConv1DTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'kernel_size'): conv_layers.separable_conv1d(data, 32, None) + @test_util.run_deprecated_v1 def testCreateSeparableConv1D(self): length = 9 data = random_ops.random_uniform((5, length, 4)) @@ -379,6 +397,7 @@ class SeparableConv1DTest(test.TestCase): self.assertEqual(layer.pointwise_kernel.get_shape().as_list(), [1, 8, 32]) self.assertEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testCreateSeparableConv1DChannelsFirst(self): length = 9 data = random_ops.random_uniform((5, 4, length)) @@ -404,6 +423,7 @@ class SeparableConv1DTest(test.TestCase): output = layer.apply(data) self.assertEqual(output.get_shape().as_list(), [5, length // 2, 32]) + @test_util.run_deprecated_v1 def testCreateSeparableConv1DWithStridesChannelsFirst(self): data_format = 'channels_first' length = 10 @@ -413,6 +433,7 @@ class SeparableConv1DTest(test.TestCase): output = layer.apply(data) self.assertEqual(output.get_shape().as_list(), [5, 32, length // 2]) + @test_util.run_deprecated_v1 def testFunctionalConv1DReuse(self): length = 10 data = random_ops.random_uniform((5, length, 3), seed=1) @@ -421,6 +442,7 @@ class SeparableConv1DTest(test.TestCase): conv_layers.separable_conv1d(data, 32, 3, name='sepconv1', reuse=True) self.assertEqual(len(variables.trainable_variables()), 3) + @test_util.run_deprecated_v1 def testFunctionalConv1DReuseFromScope(self): with variable_scope.variable_scope('scope'): length = 10 @@ -431,6 +453,7 @@ class SeparableConv1DTest(test.TestCase): conv_layers.separable_conv1d(data, 32, 3, name='sepconv1') self.assertEqual(len(variables.trainable_variables()), 3) + @test_util.run_deprecated_v1 def testFunctionalConv1DNoReuse(self): length = 10 data = random_ops.random_uniform((5, length, 3), seed=1) @@ -439,6 +462,7 @@ class SeparableConv1DTest(test.TestCase): conv_layers.separable_conv1d(data, 32, 3) self.assertEqual(len(variables.trainable_variables()), 6) + @test_util.run_deprecated_v1 def testSeparableConv1DDepthwiseRegularizer(self): length = 9 data = random_ops.random_uniform((5, length, 4)) @@ -450,6 +474,7 @@ class SeparableConv1DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv1DPointwiseRegularizer(self): length = 9 data = random_ops.random_uniform((5, length, 4)) @@ -461,6 +486,7 @@ class SeparableConv1DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv1DBiasRegularizer(self): length = 9 data = random_ops.random_uniform((5, length, 4)) @@ -472,6 +498,7 @@ class SeparableConv1DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv1DNoBias(self): length = 9 data = random_ops.random_uniform((5, length, 4)) @@ -522,6 +549,7 @@ class SeparableConv2DTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'kernel_size'): conv_layers.separable_conv2d(images, 32, None) + @test_util.run_deprecated_v1 def testCreateSeparableConv2D(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -562,6 +590,7 @@ class SeparableConv2DTest(test.TestCase): [1, 1, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [32]) + @test_util.run_deprecated_v1 def testCreateSeparableConv2DChannelsFirst(self): height, width = 7, 9 images = random_ops.random_uniform((5, 4, height, width)) @@ -584,6 +613,7 @@ class SeparableConv2DTest(test.TestCase): output = layer.apply(images) self.assertListEqual(output.get_shape().as_list(), [5, height, width, 64]) + @test_util.run_deprecated_v1 def testCreateSeparableConvWithStrides(self): height, width = 6, 8 # Test strides tuple @@ -607,6 +637,7 @@ class SeparableConv2DTest(test.TestCase): self.assertListEqual(output.get_shape().as_list(), [5, height / 2, width, 32]) + @test_util.run_deprecated_v1 def testCreateSeparableConvWithStridesChannelsFirst(self): data_format = 'channels_first' height, width = 6, 8 @@ -632,6 +663,7 @@ class SeparableConv2DTest(test.TestCase): self.assertListEqual(output.get_shape().as_list(), [5, 32, height / 2, width]) + @test_util.run_deprecated_v1 def testFunctionalConv2DReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -641,6 +673,7 @@ class SeparableConv2DTest(test.TestCase): images, 32, [3, 3], name='sepconv1', reuse=True) self.assertEqual(len(variables.trainable_variables()), 3) + @test_util.run_deprecated_v1 def testFunctionalConv2DReuseFromScope(self): with variable_scope.variable_scope('scope'): height, width = 7, 9 @@ -651,6 +684,7 @@ class SeparableConv2DTest(test.TestCase): conv_layers.separable_conv2d(images, 32, [3, 3], name='sepconv1') self.assertEqual(len(variables.trainable_variables()), 3) + @test_util.run_deprecated_v1 def testFunctionalConv2DInitializerFromScope(self): with self.cached_session() as sess: with variable_scope.variable_scope( @@ -671,6 +705,7 @@ class SeparableConv2DTest(test.TestCase): # Check that the bias still got initialized to zeros. self.assertAllClose(weights[2], np.zeros((32))) + @test_util.run_deprecated_v1 def testFunctionalConv2DNoReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -679,6 +714,7 @@ class SeparableConv2DTest(test.TestCase): conv_layers.separable_conv2d(images, 32, [3, 3]) self.assertEqual(len(variables.trainable_variables()), 6) + @test_util.run_deprecated_v1 def testSeparableConv2DDepthwiseRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -690,6 +726,7 @@ class SeparableConv2DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv2DPointwiseRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -701,6 +738,7 @@ class SeparableConv2DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv2DBiasRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -712,6 +750,7 @@ class SeparableConv2DTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testSeparableConv2DNoBias(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -768,6 +807,7 @@ class Conv2DTransposeTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'kernel_size'): conv_layers.conv2d_transpose(images, 32, None) + @test_util.run_deprecated_v1 def testCreateConv2DTranspose(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -839,6 +879,7 @@ class Conv2DTransposeTest(test.TestCase): self.assertListEqual(output.get_shape().as_list(), [5, height * 2, width, 32]) + @test_util.run_deprecated_v1 def testConv2DTransposeKernelRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -850,6 +891,7 @@ class Conv2DTransposeTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv2DTransposeBiasRegularizer(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -861,6 +903,7 @@ class Conv2DTransposeTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv2DTransposeNoBias(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 4)) @@ -873,6 +916,7 @@ class Conv2DTransposeTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 32, 4]) self.assertEqual(layer.bias, None) + @test_util.run_deprecated_v1 def testFunctionalConv2DTransposeReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -881,6 +925,7 @@ class Conv2DTransposeTest(test.TestCase): conv_layers.conv2d_transpose(images, 32, [3, 3], name='deconv1', reuse=True) self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv2DTransposeReuseFromScope(self): with variable_scope.variable_scope('scope'): height, width = 7, 9 @@ -891,6 +936,7 @@ class Conv2DTransposeTest(test.TestCase): conv_layers.conv2d_transpose(images, 32, [3, 3], name='deconv1') self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv2DTransposeInitializerFromScope(self): with self.cached_session() as sess: with variable_scope.variable_scope( @@ -909,6 +955,7 @@ class Conv2DTransposeTest(test.TestCase): # Check that the bias still got initialized to zeros. self.assertAllClose(weights[1], np.zeros((32))) + @test_util.run_deprecated_v1 def testFunctionalConv2DTransposeNoReuse(self): height, width = 7, 9 images = random_ops.random_uniform((5, height, width, 3), seed=1) @@ -955,6 +1002,7 @@ class Conv3DTransposeTest(test.TestCase): with self.assertRaisesRegexp(ValueError, 'kernel_size'): conv_layers.conv3d_transpose(volumes, 4, None) + @test_util.run_deprecated_v1 def testCreateConv3DTranspose(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32)) @@ -976,6 +1024,7 @@ class Conv3DTransposeTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 3, 4, 32]) self.assertListEqual(layer.bias.get_shape().as_list(), [4]) + @test_util.run_deprecated_v1 def testCreateConv3DTransposeChannelsFirst(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, 32, depth, height, width)) @@ -1019,6 +1068,7 @@ class Conv3DTransposeTest(test.TestCase): self.assertListEqual(output.get_shape().as_list(), [5, depth * 2, height, width, 4]) + @test_util.run_deprecated_v1 def testConv3DTransposeKernelRegularizer(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32)) @@ -1030,6 +1080,7 @@ class Conv3DTransposeTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv3DTransposeBiasRegularizer(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32)) @@ -1041,6 +1092,7 @@ class Conv3DTransposeTest(test.TestCase): self.evaluate([v.initializer for v in layer.variables]) self.assertListEqual(self.evaluate(layer.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testConv3DTransposeNoBias(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32)) @@ -1053,6 +1105,7 @@ class Conv3DTransposeTest(test.TestCase): self.assertListEqual(layer.kernel.get_shape().as_list(), [3, 3, 3, 4, 32]) self.assertEqual(layer.bias, None) + @test_util.run_deprecated_v1 def testFunctionalConv3DTransposeReuse(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1) @@ -1062,6 +1115,7 @@ class Conv3DTransposeTest(test.TestCase): volumes, 4, [3, 3, 3], name='deconv1', reuse=True) self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv3DTransposeReuseFromScope(self): with variable_scope.variable_scope('scope'): depth, height, width = 5, 7, 9 @@ -1072,6 +1126,7 @@ class Conv3DTransposeTest(test.TestCase): conv_layers.conv3d_transpose(volumes, 4, [3, 3, 3], name='deconv1') self.assertEqual(len(variables.trainable_variables()), 2) + @test_util.run_deprecated_v1 def testFunctionalConv3DTransposeInitializerFromScope(self): with self.cached_session() as sess: with variable_scope.variable_scope( @@ -1091,6 +1146,7 @@ class Conv3DTransposeTest(test.TestCase): # Check that the bias still got initialized to zeros. self.assertAllClose(weights[1], np.zeros((4))) + @test_util.run_deprecated_v1 def testFunctionalConv3DTransposeNoReuse(self): depth, height, width = 5, 7, 9 volumes = random_ops.random_uniform((5, depth, height, width, 32), seed=1) diff --git a/tensorflow/python/layers/core_test.py b/tensorflow/python/layers/core_test.py index a61639b2db8..cf6f0fbb700 100644 --- a/tensorflow/python/layers/core_test.py +++ b/tensorflow/python/layers/core_test.py @@ -59,6 +59,7 @@ class DenseTest(test.TestCase): dense.apply(random_ops.random_uniform((5, 2))) self.assertEqual(dense.name, 'dense_2') + @test_util.run_deprecated_v1 def testVariableInput(self): with self.cached_session(): v = variable_scope.get_variable( @@ -140,6 +141,7 @@ class DenseTest(test.TestCase): outputs = dense.apply(inputs) self.assertEqual(outputs.get_shape().as_list(), [1, 2, 4, 7]) + @test_util.run_deprecated_v1 def testCallOnPlaceHolder(self): inputs = array_ops.placeholder(dtype=dtypes.float32) dense = core_layers.Dense(4, name='my_dense') @@ -179,6 +181,7 @@ class DenseTest(test.TestCase): if not context.executing_eagerly(): self.assertEqual(outputs.op.name, 'dense2/BiasAdd') + @test_util.run_deprecated_v1 def testActivityRegularizer(self): regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3 dense = core_layers.Dense( @@ -189,6 +192,7 @@ class DenseTest(test.TestCase): self.assertEqual(len(loss_keys), 1) self.assertListEqual(dense.losses, loss_keys) + @test_util.run_deprecated_v1 def testKernelRegularizer(self): regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3 dense = core_layers.Dense( @@ -200,6 +204,7 @@ class DenseTest(test.TestCase): self.evaluate([v.initializer for v in dense.variables]) self.assertAllEqual(self.evaluate(dense.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testKernelRegularizerWithReuse(self): regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3 inputs = random_ops.random_uniform((5, 3), seed=1) @@ -212,6 +217,7 @@ class DenseTest(test.TestCase): self.assertEqual( len(ops.get_collection(ops.GraphKeys.REGULARIZATION_LOSSES)), 1) + @test_util.run_deprecated_v1 def testBiasRegularizer(self): regularizer = lambda x: math_ops.reduce_sum(x) * 1e-3 dense = core_layers.Dense(2, name='my_dense', bias_regularizer=regularizer) @@ -222,6 +228,7 @@ class DenseTest(test.TestCase): self.evaluate([v.initializer for v in dense.variables]) self.assertAllEqual(self.evaluate(dense.losses), self.evaluate(loss_keys)) + @test_util.run_deprecated_v1 def testFunctionalDense(self): with self.cached_session(): inputs = random_ops.random_uniform((5, 3), seed=1) @@ -231,6 +238,7 @@ class DenseTest(test.TestCase): len(ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES)), 2) self.assertEqual(outputs.op.name, 'my_dense/Relu') + @test_util.run_deprecated_v1 def testFunctionalDenseTwice(self): inputs = random_ops.random_uniform((5, 3), seed=1) core_layers.dense(inputs, 2) @@ -262,6 +270,7 @@ class DenseTest(test.TestCase): vars2 = variables.trainable_variables() self.assertEqual(vars1, vars2) + @test_util.run_deprecated_v1 def testFunctionalDenseInitializerFromScope(self): with variable_scope.variable_scope( 'scope', @@ -307,6 +316,7 @@ class DenseTest(test.TestCase): core_layers.dense(inputs, 2) self.assertEqual(called[0], 2) + @test_util.run_deprecated_v1 def testFunctionalDenseInScope(self): with self.cached_session(): with variable_scope.variable_scope('test'): @@ -393,6 +403,7 @@ class DropoutTest(test.TestCase): np_output = self.evaluate(dropped) self.assertAllClose(np.ones((5, 3)), np_output) + @test_util.run_deprecated_v1 def testDynamicLearningPhase(self): with self.cached_session() as sess: dp = core_layers.Dropout(0.5, seed=1) @@ -426,6 +437,7 @@ class DropoutTest(test.TestCase): self.assertAlmostEqual(0., np_output.min()) self.assertAllClose(np_output[:, 0, :], np_output[:, 1, :]) + @test_util.run_deprecated_v1 def testFunctionalDropout(self): with self.cached_session(): inputs = array_ops.ones((5, 5)) @@ -437,6 +449,7 @@ class DropoutTest(test.TestCase): np_output = self.evaluate(dropped) self.assertAllClose(np.ones((5, 5)), np_output) + @test_util.run_deprecated_v1 def testDynamicRate(self): with self.cached_session() as sess: rate = array_ops.placeholder(dtype='float32', name='rate') @@ -452,6 +465,7 @@ class DropoutTest(test.TestCase): class FlattenTest(test.TestCase): + @test_util.run_deprecated_v1 def testCreateFlatten(self): with self.cached_session() as sess: x = array_ops.placeholder(shape=(None, 2, 3), dtype='float32') @@ -476,6 +490,7 @@ class FlattenTest(test.TestCase): shape = core_layers.Flatten().compute_output_shape((None, 3, None)) self.assertEqual(shape.as_list(), [None, None]) + @test_util.run_deprecated_v1 def testDataFormat5d(self): np_input_channels_last = np.arange( 120, dtype='float32').reshape([1, 5, 4, 3, 2]) @@ -493,6 +508,7 @@ class FlattenTest(test.TestCase): self.assertAllEqual(np_output_cl, np_output_cf) + @test_util.run_deprecated_v1 def testDataFormat4d(self): np_input_channels_last = np.arange( 24, dtype='float32').reshape([1, 4, 3, 2]) @@ -510,16 +526,19 @@ class FlattenTest(test.TestCase): self.assertAllEqual(np_output_cl, np_output_cf) + @test_util.run_deprecated_v1 def testFunctionalFlatten(self): x = array_ops.placeholder(shape=(None, 2, 3), dtype='float32') y = core_layers.flatten(x, name='flatten') self.assertEqual(y.get_shape().as_list(), [None, 6]) + @test_util.run_deprecated_v1 def testFlattenValueError(self): x = array_ops.placeholder(shape=(None,), dtype='float32') with self.assertRaises(ValueError): core_layers.Flatten()(x) + @test_util.run_deprecated_v1 def testFlattenUnknownAxes(self): with self.cached_session() as sess: x = array_ops.placeholder(shape=(5, None, None), dtype='float32') diff --git a/tensorflow/python/layers/normalization_test.py b/tensorflow/python/layers/normalization_test.py index cc3badbde1d..07d8e40b759 100644 --- a/tensorflow/python/layers/normalization_test.py +++ b/tensorflow/python/layers/normalization_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.core.protobuf import saver_pb2 from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.layers import convolutional as conv_layers from tensorflow.python.layers import normalization as normalization_layers from tensorflow.python.ops import array_ops @@ -143,6 +144,7 @@ class BNTest(test.TestCase): return train_vars, loss_val + @test_util.run_deprecated_v1 def testHalfPrecision(self): ref_vars, ref_loss = self._trainEvalSequence( dtype=dtypes.float32, @@ -228,33 +230,43 @@ class BNTest(test.TestCase): ckpt_b_use_gpu, use_gpu_test_a, use_gpu_test_b, freeze_mode) + @test_util.run_deprecated_v1 def testCheckpointFusedCPUAndFusedGPU(self): self._testCheckpointCrossDevice(True, False, True, True) + @test_util.run_deprecated_v1 def testCheckpointFusedCPUAndFusedCPU(self): self._testCheckpointCrossDevice(True, False, True, False) + @test_util.run_deprecated_v1 def testCheckpointFusedGPUAndFusedGPU(self): self._testCheckpointCrossDevice(True, True, True, True) + @test_util.run_deprecated_v1 def testCheckpointNonFusedCPUAndNonFusedGPU(self): self._testCheckpointCrossDevice(False, False, False, True) + @test_util.run_deprecated_v1 def testCheckpointNonFusedCPUAndNonFusedCPU(self): self._testCheckpointCrossDevice(False, False, False, False) + @test_util.run_deprecated_v1 def testCheckpointNonFusedGPUAndNonFusedGPU(self): self._testCheckpointCrossDevice(False, True, False, True) + @test_util.run_deprecated_v1 def testCheckpointNonFusedGPUAndFusedGPU(self): self._testCheckpointCrossDevice(False, True, True, True) + @test_util.run_deprecated_v1 def testCheckpointNonFusedGPUAndFusedCPU(self): self._testCheckpointCrossDevice(False, True, True, False) + @test_util.run_deprecated_v1 def testCheckpointNonFusedCPUAndFusedCPU(self): self._testCheckpointCrossDevice(False, False, True, False) + @test_util.run_deprecated_v1 def testCreateBN(self): # Call layer. bn = normalization_layers.BatchNormalization(axis=1) @@ -281,6 +293,7 @@ class BNTest(test.TestCase): ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES), bn.trainable_variables) + @test_util.run_deprecated_v1 def testCreateFusedBNFloat16(self): # Call layer. bn = normalization_layers.BatchNormalization(axis=1, fused=True) @@ -310,6 +323,7 @@ class BNTest(test.TestCase): ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES), bn.trainable_variables) + @test_util.run_deprecated_v1 def test3DInputAxis1(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -353,6 +367,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def test3DInputAxis2(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -436,6 +451,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def test4DInputAxis2(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -477,6 +493,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def test4DInputAxis3(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -518,6 +535,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def test4DInputAxis3Fused(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -601,6 +619,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testNegativeAxis(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -643,6 +662,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testBooleanLearningPhase(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -683,6 +703,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testFunctionalNoReuse(self): inputs = variables.Variable( np.random.random((5, 4, 3, 6)), dtype=dtypes.float32) @@ -735,6 +756,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testFunctionalReuse(self): inputs1 = variables.Variable( np.random.random((5, 4, 3, 6)), dtype=dtypes.float32) @@ -799,6 +821,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=2) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testFunctionalReuseFromScope(self): inputs = variables.Variable( np.random.random((5, 4, 3, 6)), dtype=dtypes.float32) @@ -813,6 +836,7 @@ class BNTest(test.TestCase): inputs, axis=-1, momentum=0.9, epsilon=epsilon, training=training) self.assertEqual(len(variables.global_variables()), 5) + @test_util.run_deprecated_v1 def testNoCenter(self): bn = normalization_layers.BatchNormalization(axis=1, center=False) inputs = random_ops.random_uniform((5, 4, 3), seed=1) @@ -828,6 +852,7 @@ class BNTest(test.TestCase): self.assertEqual(len(bn.trainable_variables), 1) self.assertEqual(len(bn.non_trainable_variables), 2) + @test_util.run_deprecated_v1 def testNoScale(self): bn = normalization_layers.BatchNormalization(axis=1, scale=False) inputs = random_ops.random_uniform((5, 4, 3), seed=1) @@ -843,6 +868,7 @@ class BNTest(test.TestCase): self.assertEqual(len(bn.trainable_variables), 1) self.assertEqual(len(bn.non_trainable_variables), 2) + @test_util.run_deprecated_v1 def testRegularizers(self): reg = lambda x: 0.1 * math_ops.reduce_sum(x) bn = normalization_layers.BatchNormalization(axis=1, beta_regularizer=reg) @@ -868,6 +894,7 @@ class BNTest(test.TestCase): self.assertEqual(bn.gamma_constraint, g_constraint) self.assertEqual(bn.beta_constraint, b_constraint) + @test_util.run_deprecated_v1 def testRenorm(self): shape = (4, 3) xt = array_ops.placeholder(dtypes.float32, shape) @@ -926,6 +953,7 @@ class BNTest(test.TestCase): self.assertAllClose(y_train, yt_val_train, atol=1e-5) self.assertAllClose(y_test, yt_val_test, atol=1e-5) + @test_util.run_deprecated_v1 def testAdjustment(self): shape = (4, 3) xt = array_ops.placeholder(dtypes.float32, shape) @@ -970,6 +998,7 @@ class BNTest(test.TestCase): self.assertAllClose(y_train, yt_val_train, atol=1e-5) self.assertAllClose(y_test, yt_val_test, atol=1e-5) + @test_util.run_deprecated_v1 def testRenormWithAdjustment(self): shape = (4, 3) xt = array_ops.placeholder(dtypes.float32, shape) @@ -1040,6 +1069,7 @@ class BNTest(test.TestCase): normalization_layers.batch_normalization( inp, virtual_batch_size=-1) + @test_util.run_deprecated_v1 def testGhostBNVirtualBatchFull(self): shape = [6, 5, 4, 3] inp = random_ops.random_uniform(shape, seed=1) @@ -1065,6 +1095,7 @@ class BNTest(test.TestCase): inp, virtual_batch_size=3) self.assertListEqual(out.shape.as_list(), shape) + @test_util.run_deprecated_v1 def testGhostBNUnknownBatchSize(self): np_shape = [10, 5, 4] tf_shape = [None, 5, 4] @@ -1080,6 +1111,7 @@ class BNTest(test.TestCase): self.assertListEqual(list(y.shape), np_shape) + @test_util.run_deprecated_v1 def testGhostBN2Dims(self): shape = [6, 2] virtual_batch_size = 3 @@ -1133,6 +1165,7 @@ class BNTest(test.TestCase): self.assertAllClose(y_train, y_val_train, atol=1e-5) self.assertAllClose(y_test, y_val_test, atol=1e-5) + @test_util.run_deprecated_v1 def testGhostBN4DimsAxis3(self): shape = [6, 10, 10, 3] virtual_batch_size = 2 @@ -1186,6 +1219,7 @@ class BNTest(test.TestCase): self.assertAllClose(y_train, y_val_train, atol=1e-2) self.assertAllClose(y_test, y_val_test, atol=1e-2) + @test_util.run_deprecated_v1 def testGhostBN4DimsAxis1(self): shape = [6, 3, 10, 10] virtual_batch_size = 2 @@ -1256,6 +1290,7 @@ class BNTest(test.TestCase): normalization_layers.batch_normalization( inp, axis=[1, 2, 1]) # duplicate + @test_util.run_deprecated_v1 def test3DInputMultiAxis12(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -1297,6 +1332,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def test5DInputMultiAxis123(self): epsilon = 1e-3 bn = normalization_layers.BatchNormalization( @@ -1338,6 +1374,7 @@ class BNTest(test.TestCase): self.assertAlmostEqual(np.mean(normed_np_output), 0., places=1) self.assertAlmostEqual(np.std(normed_np_output), 1., places=1) + @test_util.run_deprecated_v1 def testGhostBN5DimsMultiAxis14(self): shape = [6, 3, 10, 10, 4] virtual_batch_size = 3 diff --git a/tensorflow/python/layers/pooling_test.py b/tensorflow/python/layers/pooling_test.py index 7533674e5a0..cf1fa1e6915 100644 --- a/tensorflow/python/layers/pooling_test.py +++ b/tensorflow/python/layers/pooling_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.layers import pooling as pooling_layers from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops @@ -64,6 +65,7 @@ class PoolingTest(test.TestCase): output = layer.apply(images) self.assertListEqual(output.get_shape().as_list(), [5, 3, 4, 4]) + @test_util.run_deprecated_v1 def testCreateMaxPooling2DChannelsFirst(self): height, width = 7, 9 images = random_ops.random_uniform((5, 2, height, width)) @@ -73,6 +75,7 @@ class PoolingTest(test.TestCase): output = layer.apply(images) self.assertListEqual(output.get_shape().as_list(), [5, 2, 6, 8]) + @test_util.run_deprecated_v1 def testCreateAveragePooling2DChannelsFirst(self): height, width = 5, 6 images = random_ops.random_uniform((3, 4, height, width)) @@ -83,6 +86,7 @@ class PoolingTest(test.TestCase): output = layer.apply(images) self.assertListEqual(output.get_shape().as_list(), [3, 4, 4, 5]) + @test_util.run_deprecated_v1 def testCreateAveragePooling2DChannelsFirstWithNoneBatch(self): height, width = 5, 6 images = array_ops.placeholder(dtype='float32', diff --git a/tensorflow/python/ops/bitwise_ops_test.py b/tensorflow/python/ops/bitwise_ops_test.py index 739278273b9..d154b6759bf 100644 --- a/tensorflow/python/ops/bitwise_ops_test.py +++ b/tensorflow/python/ops/bitwise_ops_test.py @@ -34,6 +34,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): def __init__(self, method_name="runTest"): super(BitwiseOpTest, self).__init__(method_name) + @test_util.run_deprecated_v1 def testBinaryOps(self): dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64, dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64] @@ -70,6 +71,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): gen_bitwise_ops.population_count(input_tensor)) self.assertAllEqual(truth, popcnt_result) + @test_util.run_deprecated_v1 def testInvertOp(self): dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64, dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64] @@ -94,6 +96,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): expected = [dtype.max - x for x in inputs] self.assertAllEqual(inverted, expected) + @test_util.run_deprecated_v1 def testShiftsWithPositiveLHS(self): dtype_list = [np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64] @@ -108,6 +111,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): self.assertAllEqual(left_shift_result, np.left_shift(lhs, rhs)) self.assertAllEqual(right_shift_result, np.right_shift(lhs, rhs)) + @test_util.run_deprecated_v1 def testShiftsWithNegativeLHS(self): dtype_list = [np.int8, np.int16, np.int32, np.int64] @@ -121,6 +125,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): self.assertAllEqual(left_shift_result, np.left_shift(lhs, rhs)) self.assertAllEqual(right_shift_result, np.right_shift(lhs, rhs)) + @test_util.run_deprecated_v1 def testImplementationDefinedShiftsDoNotCrash(self): dtype_list = [np.int8, np.int16, np.int32, np.int64] @@ -136,6 +141,7 @@ class BitwiseOpTest(test_util.TensorFlowTestCase): bitwise_ops.right_shift(lhs, rhs)]) + @test_util.run_deprecated_v1 def testShapeInference(self): dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64, dtypes.uint8, dtypes.uint16] diff --git a/tensorflow/python/ops/clip_ops_test.py b/tensorflow/python/ops/clip_ops_test.py index e9f7941b426..a59a0c22d40 100644 --- a/tensorflow/python/ops/clip_ops_test.py +++ b/tensorflow/python/ops/clip_ops_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import clip_ops from tensorflow.python.ops import numerics from tensorflow.python.platform import test @@ -57,6 +58,7 @@ class ClipOpsTest(test.TestCase): result, expected = self.evaluate([clipped, dense_clipped]) self.assertAllClose(result, expected) + @test_util.run_deprecated_v1 def testClipTensorByNorm(self): # Simple example self._testClipTensorByNorm([[-3.0, 0.0, 0.0], [4.0, 0.0, 0.0]], 4.0, diff --git a/tensorflow/python/ops/collective_ops_test.py b/tensorflow/python/ops/collective_ops_test.py index 9c772a93548..0fd9368d219 100644 --- a/tensorflow/python/ops/collective_ops_test.py +++ b/tensorflow/python/ops/collective_ops_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.core.protobuf import config_pb2 from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import collective_ops from tensorflow.python.platform import test @@ -49,16 +50,19 @@ class CollectiveOpTest(test.TestCase): self.assertAllClose(results[0], expected, rtol=1e-5, atol=1e-5) self.assertAllClose(results[1], expected, rtol=1e-5, atol=1e-5) + @test_util.run_deprecated_v1 def testCollectiveReduce(self): self._testCollectiveReduce([0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1], [0.3, 1.3, 2.3, 3.3, 4.3, 5.3, 6.3, 7.3], [0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2], True) + @test_util.run_deprecated_v1 def testCollectiveAutoGraphKey(self): self._testCollectiveReduce([0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1], [0.3, 1.3, 2.3, 3.3, 4.3, 5.3, 6.3, 7.3], [0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2], False) + @test_util.run_deprecated_v1 def testCollectiveReduceScalar(self): self._testCollectiveReduce(0.1, 0.3, 0.2, True) @@ -81,6 +85,7 @@ class CollectiveOpTest(test.TestCase): self.assertAllClose(results[0], t0, rtol=1e-5, atol=1e-5) self.assertAllClose(results[1], t0, rtol=1e-5, atol=1e-5) + @test_util.run_deprecated_v1 def testCollectiveBroadcast(self): self._testCollectiveBroadcast([0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1]) diff --git a/tensorflow/python/ops/gradient_checker_test.py b/tensorflow/python/ops/gradient_checker_test.py index 66c7b9a71b5..4d2b5efac7b 100644 --- a/tensorflow/python/ops/gradient_checker_test.py +++ b/tensorflow/python/ops/gradient_checker_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import math_ops @@ -46,6 +47,7 @@ def _nan_grad(unused_op, grad): class GradientCheckerTest(test.TestCase): + @test_util.run_deprecated_v1 def testAddSimple(self): np.random.seed(1) # Fix seed to avoid flakiness with self.session(use_gpu=False): @@ -60,6 +62,7 @@ class GradientCheckerTest(test.TestCase): tf_logging.info("x1 error = %f", error) assert error < 1e-4 + @test_util.run_deprecated_v1 def testAddSimpleGPU(self): np.random.seed(2) # Fix seed to avoid flakiness with self.session(use_gpu=True): @@ -74,6 +77,7 @@ class GradientCheckerTest(test.TestCase): tf_logging.info("x1 error = %f", error) assert error < 1e-4 + @test_util.run_deprecated_v1 def testAddCustomized(self): np.random.seed(3) # Fix seed to avoid flakiness with self.cached_session(): @@ -92,6 +96,7 @@ class GradientCheckerTest(test.TestCase): tf_logging.info("x2 error = %f", error) assert error < 1e-10 + @test_util.run_deprecated_v1 def testGather(self): np.random.seed(4) # Fix seed to avoid flakiness with self.cached_session(): @@ -109,6 +114,7 @@ class GradientCheckerTest(test.TestCase): tf_logging.info("gather error = %f", error) assert error < 1e-4 + @test_util.run_deprecated_v1 def testNestedGather(self): np.random.seed(5) # Fix seed to avoid flakiness with self.cached_session(): @@ -130,6 +136,7 @@ class GradientCheckerTest(test.TestCase): tf_logging.info("nested gather error = %f", error) assert error < 1e-4 + @test_util.run_deprecated_v1 def testComplexMul(self): with self.cached_session(): size = () @@ -144,6 +151,7 @@ class GradientCheckerTest(test.TestCase): self.assertLess( gradient_checker.compute_gradient_error(x, size, y, size), 2e-4) + @test_util.run_deprecated_v1 def testComplexConj(self): with self.cached_session(): size = () @@ -157,6 +165,7 @@ class GradientCheckerTest(test.TestCase): self.assertLess( gradient_checker.compute_gradient_error(x, size, y, size), 2e-5) + @test_util.run_deprecated_v1 def testEmptySucceeds(self): with self.cached_session(): x = array_ops.placeholder(dtypes.float32) @@ -279,18 +288,23 @@ class MiniMNISTTest(test.TestCase): tf_logging.info("Mini MNIST: %s gradient error = %g", tag, err) return err + @test_util.run_deprecated_v1 def testInputGradient(self): self.assertLess(self._BuildAndTestMiniMNIST(0, "input"), 1e-8) + @test_util.run_deprecated_v1 def testHiddenWeightGradient(self): self.assertLess(self._BuildAndTestMiniMNIST(1, "hidden_weight"), 1e-8) + @test_util.run_deprecated_v1 def testHiddenBiasGradient(self): self.assertLess(self._BuildAndTestMiniMNIST(2, "hidden_bias"), 1e-8) + @test_util.run_deprecated_v1 def testSoftmaxWeightGradient(self): self.assertLess(self._BuildAndTestMiniMNIST(3, "softmax_weight"), 1e-8) + @test_util.run_deprecated_v1 def testSoftmaxBiasGradient(self): self.assertLess(self._BuildAndTestMiniMNIST(4, "softmax_bias"), 1e-8) diff --git a/tensorflow/python/ops/histogram_ops_test.py b/tensorflow/python/ops/histogram_ops_test.py index cd1abbfc132..b48ef67196b 100644 --- a/tensorflow/python/ops/histogram_ops_test.py +++ b/tensorflow/python/ops/histogram_ops_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.framework import constant_op from tensorflow.python.ops import array_ops from tensorflow.python.ops import histogram_ops @@ -84,6 +85,7 @@ class HistogramFixedWidthTest(test.TestCase): def setUp(self): self.rng = np.random.RandomState(0) + @test_util.run_deprecated_v1 def test_with_invalid_value_range(self): values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15] with self.assertRaisesRegexp( @@ -92,6 +94,7 @@ class HistogramFixedWidthTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "Dimension must be 2 but is 3"): histogram_ops.histogram_fixed_width(values, [1.0, 2.0, 3.0]) + @test_util.run_deprecated_v1 def test_with_invalid_nbins(self): values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15] with self.assertRaisesRegexp( @@ -146,6 +149,7 @@ class HistogramFixedWidthTest(test.TestCase): self.assertEqual(dtypes.int32, hist.dtype) self.assertAllClose(expected_bin_counts, self.evaluate(hist)) + @test_util.run_deprecated_v1 def test_shape_inference(self): value_range = [0.0, 5.0] values = [[-1.0, 0.0, 1.5], [2.0, 5.0, 15]] diff --git a/tensorflow/python/ops/image_grad_test.py b/tensorflow/python/ops/image_grad_test.py index 0ea15b0d23f..c481266dd71 100644 --- a/tensorflow/python/ops/image_grad_test.py +++ b/tensorflow/python/ops/image_grad_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import image_ops @@ -47,6 +48,7 @@ class ResizeNearestNeighborOpTest(test.TestCase): resize_out = self.evaluate(resize_out) self.assertEqual(out_shape, list(resize_out.shape)) + @test_util.run_deprecated_v1 def testGradFromResizeToLargerInBothDims(self): in_shape = [1, 2, 3, 1] out_shape = [1, 4, 6, 1] @@ -62,6 +64,7 @@ class ResizeNearestNeighborOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradFromResizeToSmallerInBothDims(self): in_shape = [1, 4, 6, 1] out_shape = [1, 2, 3, 1] @@ -77,6 +80,7 @@ class ResizeNearestNeighborOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testCompareGpuVsCpu(self): in_shape = [1, 4, 6, 3] out_shape = [1, 8, 16, 3] @@ -116,6 +120,7 @@ class ResizeBilinearOpTest(test.TestCase): resize_out = self.evaluate(resize_out) self.assertEqual(out_shape, list(resize_out.shape)) + @test_util.run_deprecated_v1 def testGradFromResizeToLargerInBothDims(self): in_shape = [1, 2, 3, 1] out_shape = [1, 4, 6, 1] @@ -129,6 +134,7 @@ class ResizeBilinearOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradFromResizeToSmallerInBothDims(self): in_shape = [1, 4, 6, 1] out_shape = [1, 2, 3, 1] @@ -142,6 +148,7 @@ class ResizeBilinearOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testCompareGpuVsCpu(self): in_shape = [2, 4, 6, 3] out_shape = [2, 8, 16, 3] @@ -160,6 +167,7 @@ class ResizeBilinearOpTest(test.TestCase): self.assertAllClose(grad[False], grad[True], rtol=1e-4, atol=1e-4) + @test_util.run_deprecated_v1 def testTypes(self): in_shape = [1, 4, 6, 1] out_shape = [1, 2, 3, 1] @@ -199,6 +207,7 @@ class ResizeBicubicOpTest(test.TestCase): resize_out = self.evaluate(resize_out) self.assertEqual(out_shape, list(resize_out.shape)) + @test_util.run_deprecated_v1 def testGradFromResizeToLargerInBothDims(self): in_shape = [1, 2, 3, 1] out_shape = [1, 4, 6, 1] @@ -214,6 +223,7 @@ class ResizeBicubicOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradFromResizeToSmallerInBothDims(self): in_shape = [1, 4, 6, 1] out_shape = [1, 2, 3, 1] @@ -229,6 +239,7 @@ class ResizeBicubicOpTest(test.TestCase): input_tensor, in_shape, resize_out, out_shape, x_init_value=x) self.assertLess(err, 1e-3) + @test_util.run_deprecated_v1 def testGradOnUnsupportedType(self): in_shape = [1, 4, 6, 1] out_shape = [1, 2, 3, 1] @@ -306,6 +317,7 @@ class CropAndResizeOpTest(test.TestCase): samples.append(sample) return samples + @test_util.run_deprecated_v1 def testGradRandomBoxes(self): """Test that the gradient is correct for randomly generated boxes. diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 71a574e0a02..e7249333bd3 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -211,6 +211,7 @@ class GrayscaleToRGBTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, y_np) + @test_util.run_deprecated_v1 def testShapeInference(self): # Shape inference works and produces expected output where possible rgb_shape = [7, None, 19, 3] @@ -271,6 +272,7 @@ class AdjustGamma(test_util.TensorFlowTestCase): else: raise AssertionError("Exception not raised: %s" % err_msg) + @test_util.run_deprecated_v1 def test_adjust_gamma_less_zero_tensor(self): """White image should be returned for gamma equal to zero""" with self.cached_session(): @@ -308,6 +310,7 @@ class AdjustGamma(test_util.TensorFlowTestCase): self.assertAllClose(y_tf, y_np, 1e-6) + @test_util.run_deprecated_v1 def test_adjust_gamma_less_one(self): """Verifying the output with expected results for gamma correction with gamma equal to half""" @@ -329,6 +332,7 @@ class AdjustGamma(test_util.TensorFlowTestCase): self.assertAllClose(y_tf, y_np, 1e-6) + @test_util.run_deprecated_v1 def test_adjust_gamma_greater_one(self): """Verifying the output with expected results for gamma correction with gamma equal to two""" @@ -938,6 +942,7 @@ class AdjustSaturationTest(test_util.TensorFlowTestCase): y_v[i][2] = b return y_v.reshape(x_np.shape) + @test_util.run_deprecated_v1 def testAdjustRandomSaturation(self): x_shapes = [ [2, 2, 3], @@ -996,6 +1001,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, x_np) + @test_util.run_deprecated_v1 def testLeftRight(self): x_np = np.array([[1, 2, 3], [1, 2, 3]], dtype=np.uint8).reshape([2, 3, 1]) y_np = np.array([[3, 2, 1], [3, 2, 1]], dtype=np.uint8).reshape([2, 3, 1]) @@ -1021,6 +1027,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, y_np) + @test_util.run_deprecated_v1 def testRandomFlipLeftRight(self): x_np = np.array([[1, 2, 3], [1, 2, 3]], dtype=np.uint8).reshape([2, 3, 1]) y_np = np.array([[3, 2, 1], [3, 2, 1]], dtype=np.uint8).reshape([2, 3, 1]) @@ -1049,6 +1056,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): self.assertGreaterEqual(count_flipped, 20) self.assertGreaterEqual(count_unflipped, 20) + @test_util.run_deprecated_v1 def testRandomFlipLeftRightWithBatch(self): batch_size = 16 seed = 42 @@ -1113,6 +1121,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, x_np) + @test_util.run_deprecated_v1 def testUpDown(self): x_np = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.uint8).reshape([2, 3, 1]) y_np = np.array([[4, 5, 6], [1, 2, 3]], dtype=np.uint8).reshape([2, 3, 1]) @@ -1138,6 +1147,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, y_np) + @test_util.run_deprecated_v1 def testRandomFlipUpDown(self): x_np = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.uint8).reshape([2, 3, 1]) y_np = np.array([[4, 5, 6], [1, 2, 3]], dtype=np.uint8).reshape([2, 3, 1]) @@ -1166,6 +1176,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): self.assertGreaterEqual(count_flipped, 20) self.assertGreaterEqual(count_unflipped, 20) + @test_util.run_deprecated_v1 def testRandomFlipUpDownWithBatch(self): batch_size = 16 seed = 42 @@ -1230,6 +1241,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, x_np) + @test_util.run_deprecated_v1 def testTranspose(self): x_np = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.uint8).reshape([2, 3, 1]) y_np = np.array([[1, 4], [2, 5], [3, 6]], dtype=np.uint8).reshape([3, 2, 1]) @@ -1256,6 +1268,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_tf = self.evaluate(y) self.assertAllEqual(y_tf, y_np) + @test_util.run_deprecated_v1 def testPartialShapes(self): p_unknown_rank = array_ops.placeholder(dtypes.uint8) p_unknown_dims_3 = array_ops.placeholder( @@ -1314,6 +1327,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): rotated = image_ops.rot90(rotated) self.assertAllEqual(image, self.evaluate(rotated)) + @test_util.run_deprecated_v1 def testRot90NumpyEquivalence(self): image = np.arange(24, dtype=np.uint8).reshape([2, 4, 3]) with self.test_session(use_gpu=True): @@ -1323,6 +1337,7 @@ class FlipTransposeRotateTest(test_util.TensorFlowTestCase): y_np = np.rot90(image, k=k) self.assertAllEqual(y_np, y_tf.eval({k_placeholder: k})) + @test_util.run_deprecated_v1 def testRot90NumpyEquivalenceWithBatch(self): image = np.arange(48, dtype=np.uint8).reshape([2, 2, 4, 3]) with self.test_session(use_gpu=True): @@ -1411,6 +1426,7 @@ class AdjustContrastTest(test_util.TensorFlowTestCase): y_tf = self._adjustContrastTf(x_np, contrast_factor) self.assertAllClose(y_tf, y_np, rtol=1e-5, atol=1e-5) + @test_util.run_deprecated_v1 def testContrastFactorShape(self): x_shape = [1, 2, 2, 3] x_data = [0, 5, 13, 54, 135, 226, 37, 8, 234, 90, 255, 1] @@ -1474,6 +1490,7 @@ class PerImageWhiteningTest(test_util.TensorFlowTestCase): y /= stddev return y + @test_util.run_deprecated_v1 def testBasic(self): x_shape = [13, 9, 3] x_np = np.arange(0, np.prod(x_shape), dtype=np.int32).reshape(x_shape) @@ -1574,11 +1591,13 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): y = image_ops.crop_to_bounding_box(image, 0, 0, height, width) self.assertEqual(y.get_shape().as_list(), post_shape) + @test_util.run_deprecated_v1 def testNoOp(self): x_shape = [10, 10, 10] x = np.random.uniform(size=x_shape) self._assertReturns(x, x_shape, 0, 0, x, x_shape) + @test_util.run_deprecated_v1 def testCrop(self): x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x_shape = [3, 3, 1] @@ -1603,6 +1622,7 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): y = [1, 2, 4, 5, 7, 8] self._assertReturns(x, x_shape, offset_height, offset_width, y, y_shape) + @test_util.run_deprecated_v1 def testShapeInference(self): self._assertShapeInference([55, 66, 3], 55, 66, [55, 66, 3]) self._assertShapeInference([59, 69, 3], 55, 66, [55, 66, 3]) @@ -1616,6 +1636,7 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): self._assertShapeInference([None, None, None], 55, 66, [55, 66, None]) self._assertShapeInference(None, 55, 66, [55, 66, None]) + @test_util.run_deprecated_v1 def testNon3DInput(self): # Input image is not 3D x = [0] * 15 @@ -1627,6 +1648,7 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): target_width, "'image' must have either 3 or 4 dimensions.") + @test_util.run_deprecated_v1 def testZeroLengthInput(self): # Input image has 0-length dimension(s). # Each line is a test configuration: @@ -1658,6 +1680,7 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): "assertion failed:", use_tensor_inputs_options=[True]) + @test_util.run_deprecated_v1 def testBadParams(self): x_shape = [4, 4, 1] x = np.zeros(x_shape) @@ -1675,6 +1698,7 @@ class CropToBoundingBoxTest(test_util.TensorFlowTestCase): for params, err_msg in test_config: self._assertRaises(x, x_shape, *params, err_msg=err_msg) + @test_util.run_deprecated_v1 def testNameScope(self): image = array_ops.placeholder(dtypes.float32, shape=[55, 66, 3]) y = image_ops.crop_to_bounding_box(image, 0, 0, 55, 66) @@ -1691,6 +1715,7 @@ class CentralCropTest(test_util.TensorFlowTestCase): else: self.assertEqual(y.get_shape().as_list(), post_shape) + @test_util.run_deprecated_v1 def testNoOp(self): x_shapes = [[13, 9, 3], [5, 13, 9, 3]] for x_shape in x_shapes: @@ -1734,6 +1759,7 @@ class CentralCropTest(test_util.TensorFlowTestCase): self.assertAllEqual(y_tf, y_np) self.assertAllEqual(y_tf.shape, y_np.shape) + @test_util.run_deprecated_v1 def testCropping2(self): # Test case for 10315 x_shapes = [[240, 320, 3], [5, 240, 320, 3]] @@ -1750,6 +1776,7 @@ class CentralCropTest(test_util.TensorFlowTestCase): self.assertAllEqual(y_tf, y_np) self.assertAllEqual(y_tf.shape, y_np.shape) + @test_util.run_deprecated_v1 def testShapeInference(self): # Test no-op fraction=1.0, with 3-D tensors. self._assertShapeInference([50, 60, 3], 1.0, [50, 60, 3]) @@ -1810,6 +1837,7 @@ class CentralCropTest(test_util.TensorFlowTestCase): with self.assertRaises(ValueError): _ = image_ops.central_crop(x, 0.5) + @test_util.run_deprecated_v1 def testNameScope(self): x_shape = [13, 9, 3] x_np = np.ones(x_shape, dtype=np.float32) @@ -1902,12 +1930,14 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): with self.test_session(use_gpu=True): self.assertAllClose(y, self.evaluate(y_tf)) + @test_util.run_deprecated_v1 def testNoOp(self): x_shape = [10, 10, 10] x = np.random.uniform(size=x_shape) offset_height, offset_width = [0, 0] self._assertReturns(x, x_shape, offset_height, offset_width, x, x_shape) + @test_util.run_deprecated_v1 def testPadding(self): x = [1, 2, 3, 4, 5, 6, 7, 8, 9] x_shape = [3, 3, 1] @@ -1932,6 +1962,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): y_shape = [3, 4, 1] self._assertReturns(x, x_shape, offset_height, offset_width, y, y_shape) + @test_util.run_deprecated_v1 def testShapeInference(self): self._assertShapeInference([55, 66, 3], 55, 66, [55, 66, 3]) self._assertShapeInference([50, 60, 3], 55, 66, [55, 66, 3]) @@ -1945,6 +1976,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): self._assertShapeInference([None, None, None], 55, 66, [55, 66, None]) self._assertShapeInference(None, 55, 66, [55, 66, None]) + @test_util.run_deprecated_v1 def testNon3DInput(self): # Input image is not 3D x = [0] * 15 @@ -1956,6 +1988,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): target_width, "'image' must have either 3 or 4 dimensions.") + @test_util.run_deprecated_v1 def testZeroLengthInput(self): # Input image has 0-length dimension(s). # Each line is a test configuration: @@ -1988,6 +2021,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): "all dims of \\'image.shape\\' must be > 0", use_tensor_inputs_options=[True]) + @test_util.run_deprecated_v1 def testBadParams(self): x_shape = [3, 3, 1] x = np.zeros(x_shape) @@ -2002,6 +2036,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): for config_item in test_config: self._assertRaises(x, x_shape, *config_item) + @test_util.run_deprecated_v1 def testNameScope(self): image = array_ops.placeholder(dtypes.float32, shape=[55, 66, 3]) y = image_ops.pad_to_bounding_box(image, 0, 0, 55, 66) @@ -2109,6 +2144,7 @@ class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase): # TODO(wicke, shlens, dga): Restore this test so that it is no longer flaky. # self.assertGreaterEqual(min(fraction_object_covered), min_object_covered) + @test_util.run_deprecated_v1 def testWholeImageBoundingBox(self): height = 40 width = 50 @@ -2123,6 +2159,7 @@ class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase): aspect_ratio_range=(0.75, 1.33), area_range=(0.05, 1.0)) + @test_util.run_deprecated_v1 def testWithBoundingBox(self): height = 40 width = 50 @@ -2153,6 +2190,7 @@ class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase): aspect_ratio_range=(0.75, 1.33), area_range=(0.05, 1.0)) + @test_util.run_deprecated_v1 def testSampleDistortedBoundingBoxShape(self): with self.test_session(use_gpu=True): image_size = constant_op.constant( @@ -2248,6 +2286,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): else: return False + @test_util.run_deprecated_v1 def testNoOp(self): img_shape = [1, 6, 4, 1] single_shape = [6, 4, 1] @@ -2282,6 +2321,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): newshape = self.evaluate(yshape) self.assertAllEqual(single_shape, newshape) + @test_util.run_deprecated_v1 def testTensorArguments(self): img_shape = [1, 6, 4, 1] single_shape = [6, 4, 1] @@ -2343,6 +2383,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): _ = image_ops.resize_images(image, [6, None], image_ops.ResizeMethod.BILINEAR) + @test_util.run_deprecated_v1 def testReturnDtype(self): target_shapes = [[6, 4], [3, 2], [ array_ops.placeholder(dtypes.int32), @@ -2591,6 +2632,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): value[use_gpu] = self.evaluate(out_op) self.assertAllClose(value[True], value[False], rtol=1e-5, atol=1e-5) + @test_util.run_deprecated_v1 def testShapeInference(self): self._assertShapeInference([50, 60, 3], [55, 66], [55, 66, 3]) self._assertShapeInference([55, 66, 3], [55, 66], [55, 66, 3]) @@ -2611,6 +2653,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): self._assertShapeInference([59, 60, None], [55, 66], [55, 66, None]) self._assertShapeInference([None, None, None], [55, 66], [55, 66, None]) + @test_util.run_deprecated_v1 def testNameScope(self): img_shape = [1, 3, 2, 1] with self.test_session(use_gpu=True): @@ -2661,6 +2704,7 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): preserve_aspect_ratio, use_tensor_inputs) self.assertShapeEqual(y, ops.convert_to_tensor(y_tf)) + @test_util.run_deprecated_v1 def testPreserveAspectRatioMultipleImages(self): x_shape = [10, 100, 100, 10] x = np.random.uniform(size=x_shape) @@ -2668,36 +2712,42 @@ class ResizeImagesTest(test_util.TensorFlowTestCase): self._assertResizeCheckShape(x, x_shape, [250, 250], [10, 250, 250, 10], preserve_aspect_ratio=False) + @test_util.run_deprecated_v1 def testPreserveAspectRatioNoOp(self): x_shape = [10, 10, 10] x = np.random.uniform(size=x_shape) self._assertResizeEqual(x, x_shape, x, x_shape) + @test_util.run_deprecated_v1 def testPreserveAspectRatioSmaller(self): x_shape = [100, 100, 10] x = np.random.uniform(size=x_shape) self._assertResizeCheckShape(x, x_shape, [75, 50], [50, 50, 10]) + @test_util.run_deprecated_v1 def testPreserveAspectRatioSmallerMultipleImages(self): x_shape = [10, 100, 100, 10] x = np.random.uniform(size=x_shape) self._assertResizeCheckShape(x, x_shape, [75, 50], [10, 50, 50, 10]) + @test_util.run_deprecated_v1 def testPreserveAspectRatioLarger(self): x_shape = [100, 100, 10] x = np.random.uniform(size=x_shape) self._assertResizeCheckShape(x, x_shape, [150, 200], [150, 150, 10]) + @test_util.run_deprecated_v1 def testPreserveAspectRatioSameRatio(self): x_shape = [1920, 1080, 3] x = np.random.uniform(size=x_shape) self._assertResizeCheckShape(x, x_shape, [3840, 2160], [3840, 2160, 3]) + @test_util.run_deprecated_v1 def testPreserveAspectRatioSquare(self): x_shape = [299, 299, 3] x = np.random.uniform(size=x_shape) @@ -2767,12 +2817,14 @@ class ResizeImageWithPadTest(test_util.TensorFlowTestCase): y = image_ops.resize_image_with_pad(image, height, width) self.assertEqual(y.get_shape().as_list(), post_shape) + @test_util.run_deprecated_v1 def testNoOp(self): x_shape = [10, 10, 10] x = np.random.uniform(size=x_shape) self._assertReturns(x, x_shape, x, x_shape) + @test_util.run_deprecated_v1 def testPad(self): # Reduce vertical dimension x = [1, 2, 3, 4, 5, 6, 7, 8] @@ -2863,12 +2915,14 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): y = image_ops.resize_image_with_crop_or_pad(image, height, width) self.assertEqual(y.get_shape().as_list(), post_shape) + @test_util.run_deprecated_v1 def testNoOp(self): x_shape = [10, 10, 10] x = np.random.uniform(size=x_shape) self._assertReturns(x, x_shape, x, x_shape) + @test_util.run_deprecated_v1 def testPad(self): # Pad even along col. x = [1, 2, 3, 4, 5, 6, 7, 8] @@ -2906,6 +2960,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertReturns(x, x_shape, y, y_shape) + @test_util.run_deprecated_v1 def testCrop(self): # Crop even along col. x = [1, 2, 3, 4, 5, 6, 7, 8] @@ -2943,6 +2998,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertReturns(x, x_shape, y, y_shape) + @test_util.run_deprecated_v1 def testCropAndPad(self): # Pad along row but crop along col. x = [1, 2, 3, 4, 5, 6, 7, 8] @@ -2962,6 +3018,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertReturns(x, x_shape, y, y_shape) + @test_util.run_deprecated_v1 def testShapeInference(self): self._assertShapeInference([50, 60, 3], 55, 66, [55, 66, 3]) self._assertShapeInference([55, 66, 3], 55, 66, [55, 66, 3]) @@ -2983,6 +3040,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertShapeInference([None, None, None], 55, 66, [55, 66, None]) self._assertShapeInference(None, 55, 66, [55, 66, None]) + @test_util.run_deprecated_v1 def testNon3DInput(self): # Input image is not 3D x = [0] * 15 @@ -2996,6 +3054,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertRaises(x, x_shape, target_height, target_width, "'image' must have either 3 or 4 dimensions.") + @test_util.run_deprecated_v1 def testZeroLengthInput(self): # Input image has 0-length dimension(s). target_height, target_width = [1, 1] @@ -3021,6 +3080,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): "all dims of \\'image.shape\\' must be > 0", use_tensor_inputs_options=[True]) + @test_util.run_deprecated_v1 def testBadParams(self): x_shape = [4, 4, 1] x = np.zeros(x_shape) @@ -3035,6 +3095,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): self._assertRaises(x, x_shape, target_height, target_width, "target_width must be > 0") + @test_util.run_deprecated_v1 def testNameScope(self): image = array_ops.placeholder(dtypes.float32, shape=[50, 60, 3]) y = image_ops.resize_image_with_crop_or_pad(image, 55, 66) @@ -3118,6 +3179,7 @@ class JpegTest(test_util.TensorFlowTestCase): image1_crop, image2 = self.evaluate([image1_crop, image2]) self.assertAllEqual(image1_crop, image2) + @test_util.run_deprecated_v1 def testCropAndDecodeJpegWithInvalidCropWindow(self): with self.cached_session() as sess: # Encode it, then decode it, then encode it @@ -3194,6 +3256,7 @@ class JpegTest(test_util.TensorFlowTestCase): # The images should be the same. self.assertAllClose(image1, image2) + @test_util.run_deprecated_v1 def testShape(self): with self.test_session(use_gpu=True) as sess: jpeg = constant_op.constant("nonsense") @@ -3202,6 +3265,7 @@ class JpegTest(test_util.TensorFlowTestCase): self.assertEqual(image.get_shape().as_list(), [None, None, channels or None]) + @test_util.run_deprecated_v1 def testExtractJpegShape(self): # Read a real jpeg and verify shape. path = ("tensorflow/core/lib/jpeg/testdata/" @@ -3212,6 +3276,7 @@ class JpegTest(test_util.TensorFlowTestCase): [image_shape] = sess.run([image_ops.extract_jpeg_shape(jpeg)]) self.assertEqual(image_shape.tolist(), [256, 128, 3]) + @test_util.run_deprecated_v1 def testExtractJpegShapeforCmyk(self): # Read a cmyk jpeg image, and verify its shape. path = ("tensorflow/core/lib/jpeg/testdata/" @@ -3293,6 +3358,7 @@ class PngTest(test_util.TensorFlowTestCase): self.assertEqual(2, image0.shape[-1]) self.assertAllEqual(image0, image1) + @test_util.run_deprecated_v1 def testShape(self): with self.test_session(use_gpu=True): png = constant_op.constant("nonsense") @@ -3337,6 +3403,7 @@ class GifTest(test_util.TensorFlowTestCase): self._testValid("scan.gif") self._testValid("optimized.gif") + @test_util.run_deprecated_v1 def testShape(self): with self.test_session(use_gpu=True) as sess: gif = constant_op.constant("nonsense") @@ -3363,6 +3430,7 @@ class ConvertImageTest(test_util.TensorFlowTestCase): self.assertTrue(y_saturate.dtype == output_dtype) self.assertAllClose(y_saturate.eval(), y_np, atol=1e-5) + @test_util.run_deprecated_v1 def testNoConvert(self): # Make sure converting to the same data type creates only an identity op with self.test_session(use_gpu=True): @@ -3372,6 +3440,7 @@ class ConvertImageTest(test_util.TensorFlowTestCase): self.assertEquals(y.op.type, "Identity") self.assertEquals(y.op.inputs[0], image) + @test_util.run_deprecated_v1 def testConvertBetweenInteger(self): # Make sure converting to between integer types scales appropriately with self.test_session(use_gpu=True): @@ -3380,6 +3449,7 @@ class ConvertImageTest(test_util.TensorFlowTestCase): self._convert([0, 2**32], dtypes.int64, dtypes.int32, [0, 1]) self._convert([0, 1], dtypes.int32, dtypes.int64, [0, 2**32]) + @test_util.run_deprecated_v1 def testConvertBetweenFloat(self): # Make sure converting to between float types does nothing interesting with self.test_session(use_gpu=True): @@ -3388,6 +3458,7 @@ class ConvertImageTest(test_util.TensorFlowTestCase): self._convert([-1.0, 0, 1.0, 200000], dtypes.float64, dtypes.float32, [-1.0, 0, 1.0, 200000]) + @test_util.run_deprecated_v1 def testConvertBetweenIntegerAndFloat(self): # Make sure converting from and to a float type scales appropriately with self.test_session(use_gpu=True): @@ -3396,6 +3467,7 @@ class ConvertImageTest(test_util.TensorFlowTestCase): self._convert([0, 1.1 / 255.0, 1], dtypes.float32, dtypes.uint8, [0, 1, 255]) + @test_util.run_deprecated_v1 def testConvertBetweenInt16AndInt8(self): with self.test_session(use_gpu=True): # uint8, uint16 @@ -3587,6 +3659,7 @@ class TotalVariationTest(test_util.TensorFlowTestCase): class FormatTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testFormats(self): prefix = "tensorflow/core/lib" paths = ("png/testdata/lena_gray.png", "jpeg/testdata/jpeg_merge_test1.jpg", @@ -3619,6 +3692,7 @@ class FormatTest(test_util.TensorFlowTestCase): class NonMaxSuppressionTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testSelectFromThreeClusters(self): boxes_np = [[0, 0, 1, 1], [0, 0.1, 1, 1.1], [0, -0.1, 1, 0.9], [0, 10, 1, 11], [0, 10.1, 1, 11.1], [0, 100, 1, 101]] @@ -3634,6 +3708,7 @@ class NonMaxSuppressionTest(test_util.TensorFlowTestCase): boxes, scores, max_output_size, iou_threshold).eval() self.assertAllClose(selected_indices, [3, 0, 5]) + @test_util.run_deprecated_v1 def testInvalidShape(self): # The boxes should be 2D of shape [num_boxes, 4]. with self.assertRaisesRegexp(ValueError, @@ -3676,6 +3751,7 @@ class NonMaxSuppressionTest(test_util.TensorFlowTestCase): scores = constant_op.constant([0.9]) image_ops.non_max_suppression(boxes, scores, 3, [[0.5]]) + @test_util.run_deprecated_v1 def testDataTypes(self): # Test case for GitHub issue 20199. boxes_np = [[0, 0, 1, 1], [0, 0.1, 1, 1.1], [0, -0.1, 1, 0.9], @@ -3720,6 +3796,7 @@ class NonMaxSuppressionTest(test_util.TensorFlowTestCase): class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testSelectFromThreeClusters(self): boxes_np = [[0, 0, 1, 1], [0, 0.1, 1, 1.1], [0, -0.1, 1, 0.9], [0, 10, 1, 11], [0, 10.1, 1, 11.1], [0, 100, 1, 101]] @@ -3752,6 +3829,7 @@ class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase): self.assertAllClose(selected_indices.eval(), [3, 0, 5]) self.assertEqual(num_valid.eval(), 3) + @test_util.run_deprecated_v1 def testSelectFromContinuousOverLap(self): boxes_np = [[0, 0, 1, 1], [0, 0.2, 1, 1.2], [0, 0.4, 1, 1.4], [0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]] @@ -3779,6 +3857,7 @@ class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase): class NonMaxSuppressionWithOverlapsTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testSelectOneFromThree(self): overlaps_np = [ [1.0, 0.7, 0.2], @@ -3804,6 +3883,7 @@ class NonMaxSuppressionWithOverlapsTest(test_util.TensorFlowTestCase): class VerifyCompatibleImageShapesTest(test_util.TensorFlowTestCase): """Tests utility function used by ssim() and psnr().""" + @test_util.run_deprecated_v1 def testWrongDims(self): img = array_ops.placeholder(dtype=dtypes.float32) img_np = np.array((2, 2)) @@ -3813,6 +3893,7 @@ class VerifyCompatibleImageShapesTest(test_util.TensorFlowTestCase): with self.assertRaises(errors.InvalidArgumentError): sess.run(checks, {img: img_np}) + @test_util.run_deprecated_v1 def testShapeMismatch(self): img1 = array_ops.placeholder(dtype=dtypes.float32) img2 = array_ops.placeholder(dtype=dtypes.float32) @@ -3853,6 +3934,7 @@ class PSNRTest(test_util.TensorFlowTestCase): """Returns an image or image batch with given shape.""" return np.random.rand(*shape).astype(np.float32) * max_val + @test_util.run_deprecated_v1 def testPSNRSingleImage(self): image1 = self._RandomImage((8, 8, 1), 1) image2 = self._RandomImage((8, 8, 1), 1) @@ -3866,6 +3948,7 @@ class PSNRTest(test_util.TensorFlowTestCase): tf_psnr = image_ops.psnr(tf_image1, tf_image2, 1.0, "psnr").eval() self.assertAllClose(psnr, tf_psnr, atol=0.001) + @test_util.run_deprecated_v1 def testPSNRMultiImage(self): image1 = self._RandomImage((10, 8, 8, 1), 1) image2 = self._RandomImage((10, 8, 8, 1), 1) @@ -3879,6 +3962,7 @@ class PSNRTest(test_util.TensorFlowTestCase): tf_psnr = image_ops.psnr(tf_image1, tf_image2, 1, "psnr").eval() self.assertAllClose(psnr, tf_psnr, atol=0.001) + @test_util.run_deprecated_v1 def testGoldenPSNR(self): q20, q72, q95 = self._LoadTestImages() @@ -3903,6 +3987,7 @@ class PSNRTest(test_util.TensorFlowTestCase): self.assertAllClose(psnr2, tf_psnr2, atol=0.001) self.assertAllClose(psnr3, tf_psnr3, atol=0.001) + @test_util.run_deprecated_v1 def testInfinity(self): q20, _, _ = self._LoadTestImages() psnr = self._PSNR_NumPy(q20, q20, 1) @@ -3911,6 +3996,7 @@ class PSNRTest(test_util.TensorFlowTestCase): tf_psnr = image_ops.psnr(tf_q20, tf_q20, 1, "psnr").eval() self.assertAllClose(psnr, tf_psnr, atol=0.001) + @test_util.run_deprecated_v1 def testInt(self): img1 = self._RandomImage((10, 8, 8, 1), 255) img2 = self._RandomImage((10, 8, 8, 1), 255) @@ -3952,6 +4038,7 @@ class SSIMTest(test_util.TensorFlowTestCase): """Returns an image or image batch with given shape.""" return np.random.rand(*shape).astype(np.float32) * max_val + @test_util.run_deprecated_v1 def testAgainstMatlab(self): """Tests against values produced by Matlab.""" img = self._LoadTestImages() @@ -3989,6 +4076,7 @@ class SSIMTest(test_util.TensorFlowTestCase): with self.test_session(use_gpu=True): self.assertAllClose(expected, self.evaluate(ssim), atol=1e-4) + @test_util.run_deprecated_v1 def testNegative(self): """Tests against negative SSIM index.""" step = np.expand_dims(np.arange(0, 256, 16, dtype=np.uint8), axis=0) @@ -4003,6 +4091,7 @@ class SSIMTest(test_util.TensorFlowTestCase): with self.test_session(use_gpu=True): self.assertLess(ssim.eval(), 0) + @test_util.run_deprecated_v1 def testInt(self): img1 = self._RandomImage((1, 16, 16, 3), 255) img2 = self._RandomImage((1, 16, 16, 3), 255) @@ -4044,6 +4133,7 @@ class MultiscaleSSIMTest(test_util.TensorFlowTestCase): """Returns an image or image batch with given shape.""" return np.random.rand(*shape).astype(np.float32) * max_val + @test_util.run_deprecated_v1 def testAgainstMatlab(self): """Tests against MS-SSIM computed with Matlab implementation. @@ -4060,6 +4150,7 @@ class MultiscaleSSIMTest(test_util.TensorFlowTestCase): self.assertAllClose(expected, np.squeeze(scores), atol=1e-4) + @test_util.run_deprecated_v1 def testUnweightedIsDifferentiable(self): img = self._LoadTestImages() ph = [array_ops.placeholder(dtype=dtypes.float32) for _ in range(2)] @@ -4121,6 +4212,7 @@ class MultiscaleSSIMTest(test_util.TensorFlowTestCase): self.assertTrue(np.all(msssim >= 0.0)) self.assertTrue(np.all(msssim <= 1.0)) + @test_util.run_deprecated_v1 def testInt(self): img1 = self._RandomImage((1, 180, 240, 3), 255) img2 = self._RandomImage((1, 180, 240, 3), 255) diff --git a/tensorflow/python/ops/losses/util_test.py b/tensorflow/python/ops/losses/util_test.py index df2e60e2e45..22a8eaae266 100644 --- a/tensorflow/python/ops/losses/util_test.py +++ b/tensorflow/python/ops/losses/util_test.py @@ -20,12 +20,14 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops.losses import util from tensorflow.python.platform import test class LossesUtilTest(test.TestCase): + @test_util.run_deprecated_v1 def testGetRegularizationLoss(self): # Empty regularization collection should evaluate to 0.0. with self.cached_session(): diff --git a/tensorflow/python/ops/math_grad_test.py b/tensorflow/python/ops/math_grad_test.py index d1fe834fc78..88aa48271f3 100644 --- a/tensorflow/python/ops/math_grad_test.py +++ b/tensorflow/python/ops/math_grad_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients @@ -52,6 +53,7 @@ class SquaredDifferenceOpTest(test.TestCase): self.assertLess(left_err, 1e-10) self.assertLess(right_err, 1e-10) + @test_util.run_deprecated_v1 def testGrad(self): self._testGrad([1, 2, 3, 2], [3, 2]) self._testGrad([2, 4], [3, 2, 4]) @@ -83,6 +85,7 @@ class AbsOpTest(test.TestCase): value, shape, output, output.get_shape().as_list()) self.assertLess(error, max_error) + @test_util.run_deprecated_v1 def testComplexAbs(self): # Bias random test values away from zero to avoid numeric instabilities. self._testGrad( @@ -99,6 +102,7 @@ class AbsOpTest(test.TestCase): class MinOrMaxGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testMinGradient(self): inputs = constant_op.constant([1.0], dtype=dtypes.float32) outputs = math_ops.reduce_min(array_ops.concat([inputs, inputs], 0)) @@ -106,6 +110,7 @@ class MinOrMaxGradientTest(test.TestCase): error = gradient_checker.compute_gradient_error(inputs, [1], outputs, []) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testMaxGradient(self): inputs = constant_op.constant([1.0], dtype=dtypes.float32) outputs = math_ops.reduce_max(array_ops.concat([inputs, inputs], 0)) @@ -116,6 +121,7 @@ class MinOrMaxGradientTest(test.TestCase): class MaximumOrMinimumGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testMaximumGradient(self): inputs = constant_op.constant([1.0, 2.0, 3.0, 4.0], dtype=dtypes.float32) outputs = math_ops.maximum(inputs, 3.0) @@ -123,6 +129,7 @@ class MaximumOrMinimumGradientTest(test.TestCase): error = gradient_checker.compute_gradient_error(inputs, [4], outputs, [4]) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testMinimumGradient(self): inputs = constant_op.constant([1.0, 2.0, 3.0, 4.0], dtype=dtypes.float32) outputs = math_ops.minimum(inputs, 2.0) @@ -133,6 +140,7 @@ class MaximumOrMinimumGradientTest(test.TestCase): class ProdGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testProdGradient(self): inputs = constant_op.constant([[1., 2.], [3., 4.]], dtype=dtypes.float32) @@ -143,6 +151,7 @@ class ProdGradientTest(test.TestCase): outputs, outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testProdGradientForNegativeAxis(self): inputs = constant_op.constant([[1., 2.], [3., 4.]], dtype=dtypes.float32) @@ -153,6 +162,7 @@ class ProdGradientTest(test.TestCase): outputs, outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testProdGradientComplex(self): for dtype in dtypes.complex64, dtypes.complex128: inputs = constant_op.constant([[1 + 3j, 2 - 1j], [3j, 4]], @@ -164,6 +174,7 @@ class ProdGradientTest(test.TestCase): outputs, outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testProdGradientForNegativeAxisComplex(self): for dtype in dtypes.complex64, dtypes.complex128: inputs = constant_op.constant([[1 + 3j, 2 - 1j], [3j, 4]], @@ -178,6 +189,7 @@ class ProdGradientTest(test.TestCase): class SegmentMinOrMaxGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testSegmentMinGradient(self): data = constant_op.constant([1.0, 2.0, 3.0], dtype=dtypes.float32) segment_ids = constant_op.constant([0, 0, 1], dtype=dtypes.int64) @@ -187,6 +199,7 @@ class SegmentMinOrMaxGradientTest(test.TestCase): [2]) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testSegmentMaxGradient(self): data = constant_op.constant([1.0, 2.0, 3.0], dtype=dtypes.float32) segment_ids = constant_op.constant([0, 0, 1], dtype=dtypes.int64) @@ -196,6 +209,7 @@ class SegmentMinOrMaxGradientTest(test.TestCase): [2]) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testSegmentMinGradientWithTies(self): inputs = constant_op.constant([1.0], dtype=dtypes.float32) data = array_ops.concat([inputs, inputs], 0) @@ -206,6 +220,7 @@ class SegmentMinOrMaxGradientTest(test.TestCase): [1]) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testSegmentMaxGradientWithTies(self): inputs = constant_op.constant([1.0], dtype=dtypes.float32) data = array_ops.concat([inputs, inputs], 0) @@ -219,6 +234,7 @@ class SegmentMinOrMaxGradientTest(test.TestCase): class FloorModGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testFloorModGradient(self): # Making sure the input is not near the discontinuity point where # x/y == floor(x/y) @@ -233,6 +249,7 @@ class FloorModGradientTest(test.TestCase): class DivNoNanGradientTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasicGradient(self): inputs = constant_op.constant(np.arange(-3, 3), dtype=dtypes.float32) @@ -244,6 +261,7 @@ class DivNoNanGradientTest(test.TestCase): outputs.get_shape().as_list()) self.assertLess(error, 1e-4) + @test_util.run_deprecated_v1 def testGradientWithDenominatorIsZero(self): x = constant_op.constant(np.arange(-3, 3), dtype=dtypes.float32) @@ -263,6 +281,7 @@ class XlogyTest(test.TestCase): xlogy_ygrad = self.evaluate(gradients.gradients(math_ops.xlogy(x, y), y)[0]) return xlogy_xgrad, xlogy_ygrad + @test_util.run_deprecated_v1 def testNonZeroValuesGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0.1, dtype=dtype) @@ -273,6 +292,7 @@ class XlogyTest(test.TestCase): self.assertAllClose(xlogy_expected_xgrad, xlogy_xgrad) self.assertAllClose(xlogy_expected_ygrad, xlogy_ygrad) + @test_util.run_deprecated_v1 def testZeroXGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0., dtype=dtype) @@ -282,6 +302,7 @@ class XlogyTest(test.TestCase): self.assertAllClose(zero, xlogy_xgrad) self.assertAllClose(zero, xlogy_ygrad) + @test_util.run_deprecated_v1 def testZeroYGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0.1, dtype=dtype) @@ -290,6 +311,7 @@ class XlogyTest(test.TestCase): self.assertAllClose(-np.inf, xlogy_xgrad) self.assertAllClose(np.inf, xlogy_ygrad) + @test_util.run_deprecated_v1 def testZeroXYGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0., dtype=dtype) @@ -307,6 +329,7 @@ class XdivyTest(test.TestCase): xdivy_ygrad = self.evaluate(gradients.gradients(math_ops.xdivy(x, y), y)[0]) return xdivy_xgrad, xdivy_ygrad + @test_util.run_deprecated_v1 def testNonZeroValuesGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0.1, dtype=dtype) @@ -317,6 +340,7 @@ class XdivyTest(test.TestCase): self.assertAllClose(xdivy_expected_xgrad, xdivy_xgrad) self.assertAllClose(xdivy_expected_ygrad, xdivy_ygrad) + @test_util.run_deprecated_v1 def testZeroXGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0., dtype=dtype) @@ -326,6 +350,7 @@ class XdivyTest(test.TestCase): self.assertAllClose(zero, xdivy_xgrad) self.assertAllClose(zero, xdivy_ygrad) + @test_util.run_deprecated_v1 def testZeroYGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0.1, dtype=dtype) @@ -334,6 +359,7 @@ class XdivyTest(test.TestCase): self.assertAllClose(np.inf, xdivy_xgrad) self.assertAllClose(-np.inf, xdivy_ygrad) + @test_util.run_deprecated_v1 def testZeroXYGrad(self): for dtype in [dtypes.float16, dtypes.float32, dtypes.float64]: x = constant_op.constant(0., dtype=dtype) diff --git a/tensorflow/python/ops/math_ops_test.py b/tensorflow/python/ops/math_ops_test.py index cd45b6f1364..add1621a56b 100644 --- a/tensorflow/python/ops/math_ops_test.py +++ b/tensorflow/python/ops/math_ops_test.py @@ -92,6 +92,7 @@ class ReduceTest(test_util.TensorFlowTestCase): class LogSumExpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testReduceLogSumExp(self): for dtype in [np.float16, np.float32, np.double]: x_np = np.random.rand(5, 5).astype(dtype) @@ -120,6 +121,7 @@ class LogSumExpTest(test_util.TensorFlowTestCase): y_tf_np = self.evaluate(y_tf) self.assertAllClose(y_tf_np, y_np) + @test_util.run_deprecated_v1 def testKeepDims(self): for dtype in [np.float16, np.float32, np.double]: x_np = np.random.rand(5, 5).astype(dtype) @@ -129,6 +131,7 @@ class LogSumExpTest(test_util.TensorFlowTestCase): y_np = log(np.sum(exp(x_np), keepdims=True)) self.assertAllClose(y_tf_np, y_np) + @test_util.run_deprecated_v1 def testOverflow(self): x = [1000, 1001, 1002, 1003] for dtype in [np.float16, np.float32, np.double]: @@ -146,6 +149,7 @@ class LogSumExpTest(test_util.TensorFlowTestCase): y_np = log(np.sum(exp(x_np - max_np))) + max_np self.assertAllClose(y_tf_np, y_np) + @test_util.run_deprecated_v1 def testUnderflow(self): x = [-1000, -1001, -1002, -1003] for dtype in [np.float16, np.float32, np.double]: @@ -163,6 +167,7 @@ class LogSumExpTest(test_util.TensorFlowTestCase): y_np = log(np.sum(exp(x_np - max_np))) + max_np self.assertAllClose(y_tf_np, y_np) + @test_util.run_deprecated_v1 def testInfinity(self): with self.session(use_gpu=True): res = math_ops.reduce_logsumexp(-np.inf).eval() @@ -186,6 +191,7 @@ class RoundTest(test_util.TensorFlowTestCase): class ModTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testFloat(self): x = [0.5, 0.7, 0.3] for dtype in [np.float32, np.double]: @@ -256,6 +262,7 @@ class ApproximateEqualTest(test_util.TensorFlowTestCase): z_tf = self.evaluate(math_ops.approximate_equal(x, y, tolerance=0.0001)) self.assertAllEqual(z, z_tf) + @test_util.run_deprecated_v1 def testApproximateEqualShape(self): for dtype in [np.float32, np.double]: x = np.array([1, 2], dtype=dtype) @@ -309,6 +316,7 @@ class ScalarMulTest(test_util.TensorFlowTestCase): class AccumulateNTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testFloat(self): np.random.seed(12345) x = [np.random.random((1, 2, 3, 4, 5)) - 0.5 for _ in range(5)] @@ -317,6 +325,7 @@ class AccumulateNTest(test_util.TensorFlowTestCase): self.assertAllClose(sum(x), math_ops.accumulate_n(tf_x).eval()) self.assertAllClose(x[0] * 5, math_ops.accumulate_n([tf_x[0]] * 5).eval()) + @test_util.run_deprecated_v1 def testInt(self): np.random.seed(54321) x = [np.random.randint(-128, 128, (5, 4, 3, 2, 1)) for _ in range(6)] @@ -328,6 +337,7 @@ class AccumulateNTest(test_util.TensorFlowTestCase): class AddNTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testPartials(self): """Test that previously revealed a bug in buffer forwarding for AddN.""" partials = [] @@ -341,6 +351,7 @@ class AddNTest(test_util.TensorFlowTestCase): with self.session(use_gpu=True): self.assertAllEqual(res.eval(), 100) + @test_util.run_deprecated_v1 def testFloat(self): np.random.seed(12345) for num_inputs in range(1, 10): @@ -351,6 +362,7 @@ class AddNTest(test_util.TensorFlowTestCase): self.assertAllClose(x[0] * num_inputs, math_ops.add_n([tf_x[0]] * num_inputs).eval()) + @test_util.run_deprecated_v1 def testInt(self): np.random.seed(54321) for num_inputs in range(1, 10): @@ -364,6 +376,7 @@ class AddNTest(test_util.TensorFlowTestCase): self.assertAllEqual(x[0] * num_inputs, math_ops.add_n([tf_x[0]] * num_inputs).eval()) + @test_util.run_deprecated_v1 def testGrad(self): np.random.seed(42) for num_inputs in range(1, 10): @@ -392,6 +405,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): divs = np.arange(-3, 0, .25).reshape(1, 12) return nums, divs + @test_util.run_deprecated_v1 def testFloorModInt(self): nums, divs = self.intTestData() with self.cached_session(): @@ -401,6 +415,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): np_result = nums % divs self.assertAllEqual(tf_result, np_result) + @test_util.run_deprecated_v1 def testFloorModFloat(self): nums, divs = self.floatTestData() with self.cached_session(): @@ -412,6 +427,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): # % array_ops.constant(divs)).eval() # self.assertAllEqual(tf2_result, tf_result) + @test_util.run_deprecated_v1 def testTruncateModInt(self): nums, divs = self.intTestData() with self.cached_session(): @@ -419,6 +435,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): np_result = np.fmod(nums, divs) self.assertAllEqual(tf_result, np_result) + @test_util.run_deprecated_v1 def testTruncateModFloat(self): nums, divs = self.floatTestData() with self.cached_session(): @@ -426,6 +443,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): np_result = np.fmod(nums, divs) self.assertAllEqual(tf_result, np_result) + @test_util.run_deprecated_v1 def testDivideInt(self): nums, divs = self.intTestData() with self.cached_session(): @@ -437,12 +455,14 @@ class DivAndModTest(test_util.TensorFlowTestCase): # // array_ops.constant(divs)).eval() # self.assertAllEqual(tf2_result, tf_result) + @test_util.run_deprecated_v1 def testDivideName(self): with self.cached_session(): op = math_ops.divide( array_ops.constant(3), array_ops.constant(4), name="my_cool_divide") self.assertEqual(op.name, "my_cool_divide:0") + @test_util.run_deprecated_v1 def testRealDiv(self): nums, divs = self.floatTestData() with self.cached_session(): @@ -450,12 +470,14 @@ class DivAndModTest(test_util.TensorFlowTestCase): np_result = np.divide(nums, divs) self.assertAllEqual(tf_result, np_result) + @test_util.run_deprecated_v1 def testComplexDiv(self): foo = array_ops.constant([1. + 3.j]) with self.cached_session(): _ = math_ops.divide(foo, 1.).eval() _ = math_ops.div(foo, 2.).eval() + @test_util.run_deprecated_v1 def testFloorDivGrad(self): with self.cached_session(): a = variables.Variable(2.) @@ -471,6 +493,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): [None if x is None else self.evaluate(x) for x in c_grad], [None, None]) + @test_util.run_deprecated_v1 def testConsistent(self): nums, divs = self.intTestData() with self.cached_session(): @@ -497,6 +520,7 @@ class DivAndModTest(test_util.TensorFlowTestCase): class DivNoNanTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testBasic(self): for dtype in [np.float32, np.float64]: nums = np.arange(-10, 10, .25, dtype=dtype).reshape(80, 1) diff --git a/tensorflow/python/ops/nn_batchnorm_test.py b/tensorflow/python/ops/nn_batchnorm_test.py index 31b2790f2b8..e978f1d3260 100644 --- a/tensorflow/python/ops/nn_batchnorm_test.py +++ b/tensorflow/python/ops/nn_batchnorm_test.py @@ -71,6 +71,7 @@ class BatchNormalizationTest(test.TestCase): gamma if scale_after_normalization else None, epsilon) + @test_util.run_deprecated_v1 def testBatchNorm(self): x_shape = [3, 5, 4, 2] param_shape = [2] @@ -169,16 +170,20 @@ class BatchNormalizationTest(test.TestCase): shift_after_normalization, v, err_tolerance) + @test_util.run_deprecated_v1 def testBatchNormInputGradient(self): self._testBatchNormGradientInAllNeedConfigs(0, "x") + @test_util.run_deprecated_v1 def testBatchNormMeanGradient(self): self._testBatchNormGradientInAllNeedConfigs(1, "mean") + @test_util.run_deprecated_v1 def testBatchNormVarianceGradient(self): self._testBatchNormGradientInAllNeedConfigs( 2, "variance", err_tolerance=1e-03) + @test_util.run_deprecated_v1 def testBatchNormBetaGradient(self): # Since beta does not exist when scale_after_normalization=False, we only # test for scale_after_normalization=True. @@ -187,6 +192,7 @@ class BatchNormalizationTest(test.TestCase): self._testBatchNormGradient(3, "beta", scale_after_normalization, True, v) + @test_util.run_deprecated_v1 def testBatchNormGammaGradient(self): # If scale_after_normalization is False, backprop for gamma in v1 # will be 0. In version 2 of the API, if scale_after_normalization is False, @@ -199,6 +205,7 @@ class BatchNormalizationTest(test.TestCase): self._testBatchNormGradient(4, "gamma", True, shift_after_normalization, 2) + @test_util.run_deprecated_v1 def testBatchNormGradImpl(self): x_shape = [7, 5, 4, 6] param_shape = [6] @@ -245,6 +252,7 @@ class BatchNormalizationTest(test.TestCase): self.assertAllClose( all_grads[i + len(to_check)], all_grads[i], atol=0.000001) + @test_util.run_deprecated_v1 def testBatchNormKeepDims(self): """Test for tf.nn.moments(..., keep_dims=True / False). @@ -391,6 +399,7 @@ class SufficientStatisticsTest(test.TestCase): if shift: self.assertAllClose(np_s, tf_s, atol=0.000001) + @test_util.run_deprecated_v1 def testSuffStats(self): for has_shape in [True, False]: for keep_dims in [True, False]: @@ -511,6 +520,7 @@ class MomentsTest(test.TestCase): self.assertAllCloseAccordingToType(expected_mean, self.evaluate(mean)) self.assertAllCloseAccordingToType(expected_variance, self.evaluate(var)) + @test_util.run_deprecated_v1 def testBasic(self): for keep_dims in [False, True]: for dtype in [dtypes.float32, dtypes.float16]: @@ -519,6 +529,7 @@ class MomentsTest(test.TestCase): self.RunMomentTestWithDynamicShape( shape=[2, 3, 5, 4], axes=[0], keep_dims=keep_dims, dtype=dtype) + @test_util.run_deprecated_v1 def testGlobalNormalization(self): for keep_dims in [False, True]: for dtype in [dtypes.float32, dtypes.float16]: @@ -533,6 +544,7 @@ class MomentsTest(test.TestCase): keep_dims=keep_dims, dtype=dtype) + @test_util.run_deprecated_v1 def testAxes(self): for keep_dims in [False, True]: for dtype in [dtypes.float32, dtypes.float16]: @@ -573,9 +585,11 @@ class MomentsTest(test.TestCase): print("Moments %s gradient err vs input %d = %g" % (from_y, i, err)) self.assertLess(err, 1e-11) + @test_util.run_deprecated_v1 def testMeanGlobalGradient(self): self._testGlobalGradient(from_y="mean") + @test_util.run_deprecated_v1 def testVarGlobalGradient(self): self._testGlobalGradient(from_y="var") diff --git a/tensorflow/python/ops/nn_grad_test.py b/tensorflow/python/ops/nn_grad_test.py index 8065df4b165..95e05a977b8 100644 --- a/tensorflow/python/ops/nn_grad_test.py +++ b/tensorflow/python/ops/nn_grad_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import nn_grad # pylint: disable=unused-import @@ -31,6 +32,7 @@ from tensorflow.python.platform import test class Relu6OpTest(test.TestCase): + @test_util.run_deprecated_v1 def testRelu6GradGrad(self): inputs = constant_op.constant( [[-2, -1, 1, 3], [5, 7, 8, 9]], dtype=dtypes.float32) diff --git a/tensorflow/python/ops/nn_test.py b/tensorflow/python/ops/nn_test.py index f7c8a7a70ac..a7ed834c723 100644 --- a/tensorflow/python/ops/nn_test.py +++ b/tensorflow/python/ops/nn_test.py @@ -49,6 +49,7 @@ class ZeroFractionTest(test_lib.TestCase): nonzeros = np.count_nonzero(x.flatten()) return 1.0 - nonzeros / total_elements + @test_util.run_deprecated_v1 def testZeroFraction(self): x_shape = [5, 17] x_np = np.random.randint(0, 2, size=x_shape).astype(np.float32) @@ -62,21 +63,25 @@ class ZeroFractionTest(test_lib.TestCase): eps = 1e-8 self.assertAllClose(y_tf_np, y_np, eps) + @test_util.run_deprecated_v1 def testZeroFractionEmpty(self): x = np.zeros(0) y = self.evaluate(nn_impl.zero_fraction(x)) self.assertTrue(np.isnan(y)) + @test_util.run_deprecated_v1 def testZeroFraction2_27Zeros(self): sparsity = nn_impl.zero_fraction( array_ops.zeros([int(2**27 * 1.01)], dtype=dtypes.int8)) self.assertAllClose(1.0, self.evaluate(sparsity)) + @test_util.run_deprecated_v1 def testZeroFraction2_27Ones(self): sparsity = nn_impl.zero_fraction( array_ops.ones([int(2**27 * 1.01)], dtype=dtypes.int8)) self.assertAllClose(0.0, self.evaluate(sparsity)) + @test_util.run_deprecated_v1 def testUnknownSize(self): value = array_ops.placeholder(dtype=dtypes.float32) sparsity = nn_impl.zero_fraction(value) @@ -122,6 +127,7 @@ class SoftmaxTest(test_lib.TestCase, parameterized.TestCase): self.assertAllClose(y_pos_axis_tf, z_gt_axis_tf, eps) @parameterized.parameters(((5, 10),), ((2, 3, 4),)) + @test_util.run_deprecated_v1 def testGradient(self, x_shape): x_np = np.random.randn(*x_shape).astype(np.float64) with self.cached_session(): @@ -157,6 +163,7 @@ class LogPoissonLossTest(test_lib.TestCase): self.assertAllClose(y_tf_np, y_np, eps) self.assertAllClose(y_tf_np_stirling, y_np_stirling, eps) + @test_util.run_deprecated_v1 def testGradient(self): x_shape = [5, 10] x_np = np.random.randn(*x_shape).astype(np.float64) @@ -207,6 +214,7 @@ class LogSoftmaxTest(test_lib.TestCase, parameterized.TestCase): self.assertAllClose(y_pos_axis_tf, z_gt_axis_tf, eps) @parameterized.parameters(((5, 10),), ((2, 3, 4),)) + @test_util.run_deprecated_v1 def testGradient(self, x_shape): x_np = np.random.randn(*x_shape).astype(np.float64) with self.cached_session(): @@ -229,6 +237,7 @@ class L2LossTest(test_lib.TestCase): value = self.evaluate(l2loss) self.assertAllClose(7.0, value) + @test_util.run_deprecated_v1 def testGradient(self): x_shape = [20, 7, 3] np.random.seed(1) # Make it reproducible. @@ -276,6 +285,7 @@ class L2NormalizeTest(test_lib.TestCase): y_tf = nn_impl.l2_normalize_v2(x_tf, dim) self.assertAllClose(y_np, self.evaluate(y_tf)) + @test_util.run_deprecated_v1 def testL2NormalizeGradient(self): x_shape = [20, 7, 3] np.random.seed(1) @@ -361,6 +371,7 @@ class DropoutTest(test_lib.TestCase): sorted_value = np.unique(np.sort(value[i, :])) self.assertEqual(sorted_value.size, 1) + @test_util.run_deprecated_v1 def testDropoutPlaceholderKeepProb(self): # Runs dropout with 0-1 tensor 10 times, sum the number of ones and validate # that it is producing approximately the right number of ones over a large @@ -389,6 +400,7 @@ class DropoutTest(test_lib.TestCase): print(rel_error) self.assertTrue(rel_error < 0.15) + @test_util.run_deprecated_v1 def testShapedDropoutUnknownShape(self): x_dim = 40 y_dim = 30 @@ -422,6 +434,7 @@ class DropoutTest(test_lib.TestCase): print(rel_error) self.assertTrue(rel_error < 0.15) + @test_util.run_deprecated_v1 def testInvalidKeepProb(self): x_dim = 40 y_dim = 30 @@ -437,6 +450,7 @@ class DropoutTest(test_lib.TestCase): with self.assertRaises(ValueError): nn_ops.dropout(t, array_ops.placeholder(dtypes.float32, shape=[2])) + @test_util.run_deprecated_v1 def testShapedDropoutShapeError(self): # Runs shaped dropout and verifies an error is thrown on misshapen noise. x_dim = 40 @@ -457,6 +471,7 @@ class DropoutTest(test_lib.TestCase): _ = nn_ops.dropout(t, keep_prob, noise_shape=[x_dim, 1]) _ = nn_ops.dropout(t, keep_prob, noise_shape=[1, 1]) + @test_util.run_deprecated_v1 def testNoDropoutFast(self): x = array_ops.zeros((5,)) for p in 1, constant_op.constant(1.0): @@ -938,6 +953,7 @@ class ReluTest(test_lib.TestCase): z = self.evaluate(nn_ops.relu(constant_op.constant(x))) self.assertAllEqual(y, z) + @test_util.run_deprecated_v1 def testNaNs(self): # Test that relu(nan) = nan for various sizes. for i in range(18): @@ -966,6 +982,7 @@ class LeakyReluTest(test_lib.TestCase): self.assertLessEqual(outputs.max(), 1.0) self.assertAllClose(inputs, outputs) + @test_util.run_deprecated_v1 def testValues(self): for dtype in [np.int32, np.int64, np.float16, np.float32, np.float64]: np_values = np.array([-2, -1, 0, 1, 2], dtype=dtype) @@ -977,6 +994,7 @@ class LeakyReluTest(test_lib.TestCase): self.assertAllClose( outputs, [-0.4, -0.2, 0.0, 1.0, 2.0], rtol=tol, atol=tol) + @test_util.run_deprecated_v1 def testName(self): np_values = np.array([-2, -1, 0, 1, 2], dtype=np.float64) outputs_with_name_set = nn_ops.leaky_relu( @@ -990,6 +1008,7 @@ class LeakyReluTest(test_lib.TestCase): class SwishTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testValues(self): np_values = np.array( [np.linspace(-10.0, 0.0, 100), @@ -1004,6 +1023,7 @@ class SwishTest(test_lib.TestCase): self.assertAllClose(actual_outputs, expected_outputs) + @test_util.run_deprecated_v1 def testGradients(self): shape = [5, 3, 4] sigma = 5 diff --git a/tensorflow/python/ops/nn_xent_test.py b/tensorflow/python/ops/nn_xent_test.py index 7bf18c47fee..3e5c198fc6a 100644 --- a/tensorflow/python/ops/nn_xent_test.py +++ b/tensorflow/python/ops/nn_xent_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import nn_impl @@ -53,6 +54,7 @@ class SigmoidCrossEntropyWithLogitsTest(test.TestCase): losses = np.array(self._SigmoidCrossEntropyWithLogits(x, y)).reshape(*sizes) return logits, targets, losses + @test_util.run_deprecated_v1 def testConstructionNamed(self): with self.cached_session(): logits, targets, _ = self._Inputs() @@ -82,6 +84,7 @@ class SigmoidCrossEntropyWithLogitsTest(test.TestCase): tf_loss = self.evaluate(loss) self.assertAllClose(np_loss, tf_loss, atol=0.001) + @test_util.run_deprecated_v1 def testGradient(self): sizes = [4, 2] with self.cached_session(): @@ -92,6 +95,7 @@ class SigmoidCrossEntropyWithLogitsTest(test.TestCase): print("logistic loss gradient err = ", err) self.assertLess(err, 1e-7) + @test_util.run_deprecated_v1 def testGradientAtZero(self): with self.cached_session(): logits = constant_op.constant([0.0, 0.0], dtype=dtypes.float64) @@ -129,6 +133,7 @@ class WeightedCrossEntropyTest(test.TestCase): losses = np.array(self._WeightedCrossEntropy(x, y, q)).reshape(*sizes) return logits, targets, q, losses + @test_util.run_deprecated_v1 def testConstructionNamed(self): with self.cached_session(): logits, targets, pos_weight, _ = self._Inputs() @@ -157,6 +162,7 @@ class WeightedCrossEntropyTest(test.TestCase): tf_loss = self.evaluate(loss) self.assertAllClose(np_loss, tf_loss, atol=0.001) + @test_util.run_deprecated_v1 def testGradient(self): sizes = [4, 2] with self.cached_session(): diff --git a/tensorflow/python/ops/ragged/convert_to_tensor_or_ragged_tensor_op_test.py b/tensorflow/python/ops/ragged/convert_to_tensor_or_ragged_tensor_op_test.py index 243fa34c4b8..ef3464f2437 100644 --- a/tensorflow/python/ops/ragged/convert_to_tensor_or_ragged_tensor_op_test.py +++ b/tensorflow/python/ops/ragged/convert_to_tensor_or_ragged_tensor_op_test.py @@ -90,6 +90,7 @@ class RaggedConvertToTensorOrRaggedTensorTest(test_util.TensorFlowTestCase, preferred_dtype=dtypes.string, expected_dtype=dtypes.int32), ]) + @test_util.run_deprecated_v1 def testConvertRaggedTensorValue(self, value, dtype=None, @@ -145,6 +146,7 @@ class RaggedConvertToTensorOrRaggedTensorTest(test_util.TensorFlowTestCase, message=('Tensor conversion requested dtype string for ' 'Tensor with dtype int32')), ]) + @test_util.run_deprecated_v1 def testConvertTensorError(self, pylist, message, diff --git a/tensorflow/python/ops/ragged/ragged_batch_gather_op_test.py b/tensorflow/python/ops/ragged/ragged_batch_gather_op_test.py index 79a2ecd87ae..d9d840500cb 100644 --- a/tensorflow/python/ops/ragged/ragged_batch_gather_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_batch_gather_op_test.py @@ -135,6 +135,7 @@ class RaggedBatchGatherOpTest(test_util.TensorFlowTestCase, expected=ragged.constant_value( [[[[b'c', b'a'], [b'd', b'd']], [[b'f', b'e']]]], ragged_rank=2)), ]) + @test_util.run_deprecated_v1 def testRaggedBatchGather(self, descr, params, indices, expected): result = ragged.batch_gather(params, indices) self.assertEqual( @@ -144,6 +145,7 @@ class RaggedBatchGatherOpTest(test_util.TensorFlowTestCase, expected = expected.tolist() self.assertEqual(result.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testRaggedBatchGatherUnknownRankError(self): params = [['a', 'b'], ['c', 'd']] indices = array_ops.placeholder(dtypes.int32, shape=None) @@ -186,6 +188,7 @@ class RaggedBatchGatherOpTest(test_util.TensorFlowTestCase, indices=[[[0]]], message='batch shape from indices does not match params shape'), ]) + @test_util.run_deprecated_v1 def testRaggedBatchGatherStaticError(self, params, indices, diff --git a/tensorflow/python/ops/ragged/ragged_boolean_mask_op_test.py b/tensorflow/python/ops/ragged/ragged_boolean_mask_op_test.py index b3279c1e840..d939d9d6341 100644 --- a/tensorflow/python/ops/ragged/ragged_boolean_mask_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_boolean_mask_op_test.py @@ -298,6 +298,7 @@ class RaggedBooleanMaskOpTest(test_util.TensorFlowTestCase, keepdims=True, expected=ragged.constant_value([[[1], [4, 6]], [[7, 9], []]])), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testBooleanMask(self, descr, data, mask, keepdims, expected): actual = ragged.boolean_mask(data, mask, keepdims=keepdims) self.assertEqual( @@ -307,6 +308,7 @@ class RaggedBooleanMaskOpTest(test_util.TensorFlowTestCase, expected = expected.tolist() self.assertEqual(actual.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testErrors(self): self.assertRaisesRegexp(ValueError, r'mask\.shape\.ndims must be kown statically', diff --git a/tensorflow/python/ops/ragged/ragged_concat_op_test.py b/tensorflow/python/ops/ragged/ragged_concat_op_test.py index bddc5d8580f..3699f90f46b 100644 --- a/tensorflow/python/ops/ragged/ragged_concat_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_concat_op_test.py @@ -221,6 +221,7 @@ class RaggedConcatOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): axis=0, expected=[[b'a00', b'a01'], [], [b'a20', b'a21']]), ) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedConcat(self, descr, rt_inputs, @@ -266,6 +267,7 @@ class RaggedConcatOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): error=ValueError, message='Dimension 0 in both shapes must be equal'), ) + @test_util.run_deprecated_v1 def testStaticError(self, rt_inputs, axis, error, message, ragged_ranks=None): rt_inputs = self._rt_inputs_to_tensors(rt_inputs, ragged_ranks) self.assertRaisesRegexp(error, message, ragged.concat, rt_inputs, axis) @@ -278,6 +280,7 @@ class RaggedConcatOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): error=errors.InvalidArgumentError, message='Input tensors have incompatible shapes'), ]) + @test_util.run_deprecated_v1 def testRuntimeError(self, rt_inputs, axis, error, message, ragged_ranks=None): rt_inputs = [ @@ -287,6 +290,7 @@ class RaggedConcatOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.test_session(): self.assertRaisesRegexp(error, message, concatenated.eval) + @test_util.run_deprecated_v1 def testNegativeAxisWithUnknownRankError(self): rt_inputs = [ array_ops.placeholder(dtypes.int64), @@ -296,6 +300,7 @@ class RaggedConcatOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): ValueError, r'axis may only be negative if ndims is statically known.', ragged.concat, rt_inputs, -1) + @test_util.run_deprecated_v1 def testSingleTensorInput(self): """Tests ragged_concat with a single tensor input. diff --git a/tensorflow/python/ops/ragged/ragged_const_op_test.py b/tensorflow/python/ops/ragged/ragged_const_op_test.py index 9c3b2ac88af..2505b23912a 100644 --- a/tensorflow/python/ops/ragged/ragged_const_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_const_op_test.py @@ -133,6 +133,7 @@ class RaggedConstOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): dict(pylist=[[b'a', b'b'], [b'c'], [b'd', b'e', b'f']], dtype=dtypes.string), ) + @test_util.run_deprecated_v1 def testRaggedConst(self, pylist, dtype=None, @@ -258,6 +259,7 @@ class RaggedConstOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): exception=ValueError, message='inner values have inconsistent shape'), ) + @test_util.run_deprecated_v1 def testRaggedConstError(self, pylist, dtype=None, diff --git a/tensorflow/python/ops/ragged/ragged_elementwise_ops_test.py b/tensorflow/python/ops/ragged/ragged_elementwise_ops_test.py index 26e6b8b6d44..305a96df9cc 100644 --- a/tensorflow/python/ops/ragged/ragged_elementwise_ops_test.py +++ b/tensorflow/python/ops/ragged/ragged_elementwise_ops_test.py @@ -394,6 +394,7 @@ class RaggedElementwiseOpsTest(test_util.TensorFlowTestCase, result_flat_values = array_ops.reshape(result, [-1]) self.assertAllEqual(expected_flat_values, result_flat_values) + @test_util.run_deprecated_v1 def testUnknownRankError(self): x = ragged.constant([[1, 2], [3]]) y = ragged.from_row_splits( diff --git a/tensorflow/python/ops/ragged/ragged_expand_dims_op_test.py b/tensorflow/python/ops/ragged/ragged_expand_dims_op_test.py index 0c4fd458c23..3ff66973b6f 100644 --- a/tensorflow/python/ops/ragged/ragged_expand_dims_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_expand_dims_op_test.py @@ -105,6 +105,7 @@ class RaggedExpandDimsOpTest(test_util.TensorFlowTestCase, expected=EXAMPLE4D_EXPAND_AXIS[4], expected_shape=[3, None, None, 2, 1]), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedExpandDims(self, rt_input, axis, diff --git a/tensorflow/python/ops/ragged/ragged_from_sparse_op_test.py b/tensorflow/python/ops/ragged/ragged_from_sparse_op_test.py index 77418ff20db..3c0db9e8fb6 100644 --- a/tensorflow/python/ops/ragged/ragged_from_sparse_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_from_sparse_op_test.py @@ -29,6 +29,7 @@ from tensorflow.python.platform import googletest class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExample(self): st = sparse_tensor.SparseTensor( indices=[[0, 0], [0, 1], [0, 2], [1, 0], [3, 0]], @@ -39,6 +40,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(rt.eval().tolist(), [[1, 2, 3], [4], [], [5]]) + @test_util.run_deprecated_v1 def testEmpty(self): st = sparse_tensor.SparseTensor( indices=array_ops.zeros([0, 2], dtype=dtypes.int64), @@ -49,6 +51,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(rt.eval().tolist(), [[], [], [], []]) + @test_util.run_deprecated_v1 def testBadSparseTensorRank(self): st1 = sparse_tensor.SparseTensor(indices=[[0]], values=[0], dense_shape=[3]) st2 = sparse_tensor.SparseTensor( @@ -64,6 +67,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): self.assertRaisesRegexp(ValueError, r'rank\(st_input\) must be 2', ragged.from_sparse, st3) + @test_util.run_deprecated_v1 def testGoodPartialSparseTensorRank(self): st1 = sparse_tensor.SparseTensor( indices=[[0, 0]], @@ -78,6 +82,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): ragged.from_sparse(st1) ragged.from_sparse(st2) + @test_util.run_deprecated_v1 def testNonRaggedSparseTensor(self): # "index_suffix" means the value of the innermost dimension of the index # (i.e., indices[i][-1]). diff --git a/tensorflow/python/ops/ragged/ragged_from_tensor_op_test.py b/tensorflow/python/ops/ragged/ragged_from_tensor_op_test.py index 7c59cd0b77b..1d8a00cc18d 100644 --- a/tensorflow/python/ops/ragged/ragged_from_tensor_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_from_tensor_op_test.py @@ -31,6 +31,7 @@ from tensorflow.python.platform import googletest class RaggedFromTensorOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testDocStringExamples(self): # The examples from ragged.from_tensor.__doc__. dt = constant_op.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) @@ -262,6 +263,7 @@ class RaggedFromTensorOpTest(test_util.TensorFlowTestCase, [[[5, 6], [7]], [[0, 8], []]]] }, ) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedFromTensor(self, tensor, expected, @@ -278,6 +280,7 @@ class RaggedFromTensorOpTest(test_util.TensorFlowTestCase, with self.test_session(): self.assertEqual(rt.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testHighDimensions(self): # Use distinct prime numbers for all dimension shapes in this test, so # we can see any errors that are caused by mixing up dimension sizes. @@ -395,6 +398,7 @@ class RaggedFromTensorOpTest(test_util.TensorFlowTestCase, 'expected': [[], []] }, ) + @test_util.run_deprecated_v1 def testEmpty(self, dt_shape, expected, lengths=None, padding=None): dt = array_ops.zeros(dt_shape) rt = ragged.from_tensor(dt, lengths, padding) @@ -447,6 +451,7 @@ class RaggedFromTensorOpTest(test_util.TensorFlowTestCase, 'error': (ValueError, r'ragged_rank must be greater than 0; got -1') }, ) + @test_util.run_deprecated_v1 def testErrors(self, tensor, lengths=None, diff --git a/tensorflow/python/ops/ragged/ragged_gather_nd_op_test.py b/tensorflow/python/ops/ragged/ragged_gather_nd_op_test.py index c52db9e2a16..62c6819374a 100644 --- a/tensorflow/python/ops/ragged/ragged_gather_nd_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_gather_nd_op_test.py @@ -183,6 +183,7 @@ class RaggedGatherNdOpTest(test_util.TensorFlowTestCase, indices=[[0, 0, 1], [0, 0, 0], [0, 1, 0]], expected=[[b'c', b'd'], [b'a', b'b'], [b'e', b'f']]), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedGatherNd(self, descr, params, indices, expected): result = ragged.gather_nd(params, indices) self.assertEqual( @@ -192,6 +193,7 @@ class RaggedGatherNdOpTest(test_util.TensorFlowTestCase, expected = expected.tolist() self.assertEqual(self.evaluate(result).tolist(), expected) + @test_util.run_deprecated_v1 def testRaggedGatherNdUnknownRankError(self): params = ragged.constant([['a', 'b'], ['c', 'd']]) indices1 = array_ops.placeholder(dtypes.int32, shape=None) @@ -219,6 +221,7 @@ class RaggedGatherNdOpTest(test_util.TensorFlowTestCase, indices=ragged.constant([[0]]), message='The innermost dimension of indices may not be ragged'), ]) + @test_util.run_deprecated_v1 def testRaggedGatherNdStaticError(self, params, indices, diff --git a/tensorflow/python/ops/ragged/ragged_gather_op_test.py b/tensorflow/python/ops/ragged/ragged_gather_op_test.py index bb52d05c32e..76c90cdfeeb 100644 --- a/tensorflow/python/ops/ragged/ragged_gather_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_gather_op_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class RaggedTensorOpsTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExamples(self): params = constant_op.constant(['a', 'b', 'c', 'd', 'e']) indices = constant_op.constant([3, 1, 2, 1, 0]) @@ -46,6 +47,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): ragged.gather(ragged_params, ragged_indices).eval().tolist(), [[[b'e'], [b'd'], []], [[b'd']], [], [[b'a', b'b', b'c']]]) + @test_util.run_deprecated_v1 def testTensorParamsAndTensorIndices(self): params = ['a', 'b', 'c', 'd', 'e'] indices = [2, 0, 2, 1] @@ -55,6 +57,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): [b'c', b'a', b'c', b'b']) self.assertEqual(type(ragged.gather(params, indices)), ops.Tensor) + @test_util.run_deprecated_v1 def testRaggedParamsAndTensorIndices(self): params = ragged.constant([['a', 'b'], ['c', 'd', 'e'], ['f'], [], ['g']]) indices = [2, 0, 2, 1] @@ -63,6 +66,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): ragged.gather(params, indices).eval().tolist(), [[b'f'], [b'a', b'b'], [b'f'], [b'c', b'd', b'e']]) + @test_util.run_deprecated_v1 def testTensorParamsAndRaggedIndices(self): params = ['a', 'b', 'c', 'd', 'e'] indices = ragged.constant([[2, 1], [1, 2, 0], [3]]) @@ -71,6 +75,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): ragged.gather(params, indices).eval().tolist(), [[b'c', b'b'], [b'b', b'c', b'a'], [b'd']]) + @test_util.run_deprecated_v1 def testRaggedParamsAndRaggedIndices(self): params = ragged.constant([['a', 'b'], ['c', 'd', 'e'], ['f'], [], ['g']]) indices = ragged.constant([[2, 1], [1, 2, 0], [3]]) @@ -82,6 +87,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): [[]]] # [p[3] ]] ) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedParamsAndScalarIndices(self): params = ragged.constant([['a', 'b'], ['c', 'd', 'e'], ['f'], [], ['g']]) indices = 1 @@ -89,6 +95,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): self.assertEqual( ragged.gather(params, indices).eval().tolist(), [b'c', b'd', b'e']) + @test_util.run_deprecated_v1 def test3DRaggedParamsAnd2DTensorIndices(self): params = ragged.constant([[['a', 'b'], []], [['c', 'd'], ['e'], ['f']], [['g']]]) @@ -101,6 +108,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): [[[b'g']], [[b'g']]]] # [p2, p2]] ) # pyformat: disable + @test_util.run_deprecated_v1 def testTensorParamsAnd4DRaggedIndices(self): indices = ragged.constant( [[[[3, 4], [0, 6]], []], [[[2, 1], [1, 0]], [[2, 5]], [[2, 3]]], @@ -115,6 +123,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): [[[b'c', b'b'], [b'b', b'a']], [[b'c', b'f']], [[b'c', b'd']]], [[[b'b', b'a']]]]) # pyformat: disable + @test_util.run_deprecated_v1 def testOutOfBoundsError(self): tensor_params = ['a', 'b', 'c'] tensor_indices = [0, 1, 2] @@ -131,6 +140,7 @@ class RaggedTensorOpsTest(test_util.TensorFlowTestCase): r'indices\[1\] = 3 is not in \[0, 2\)', ragged.gather(ragged_params, ragged_indices).eval) + @test_util.run_deprecated_v1 def testUnknownIndicesRankError(self): params = ragged.constant([], ragged_rank=1) indices = constant_op.constant([0], dtype=dtypes.int64) diff --git a/tensorflow/python/ops/ragged/ragged_map_fn_op_test.py b/tensorflow/python/ops/ragged/ragged_map_fn_op_test.py index dac86310b9f..7a8603c949a 100644 --- a/tensorflow/python/ops/ragged/ragged_map_fn_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_map_fn_op_test.py @@ -140,6 +140,7 @@ class RaggedMapOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): ), ]) + @test_util.run_deprecated_v1 def testRaggedMap( self, fn, @@ -164,6 +165,7 @@ class RaggedMapOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): output_values = self.evaluate(output) self.assertAllEqual(expected_output, output_values.tolist()) + @test_util.run_deprecated_v1 def testRaggedMapOnStructure(self): batman = ragged.constant([[1, 2, 3], [4], [5, 6, 7]]) # [[10, 20, 30], [40], [50, 60, 70]] @@ -184,6 +186,7 @@ class RaggedMapOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertAllEqual(output.eval().tolist(), [66, 44, 198]) # Test mapping over a dict of RTs can produce a dict of RTs. + @test_util.run_deprecated_v1 def testRaggedMapOnStructure_RaggedOutputs(self): batman = ragged.constant([[1, 2, 3], [4], [5, 6, 7]]) # [[10, 20, 30], [40], [50, 60, 70]] @@ -215,6 +218,7 @@ class RaggedMapOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertAllEqual(output['robin'].eval().tolist(), [[11, 21, 31], [41], [51, 61, 71]]) + @test_util.run_deprecated_v1 def testZip(self): x = ragged.constant([[10, 20], [30, 40], [50, 60], [70], [80, 90, 100]], dtypes.int64) @@ -237,6 +241,7 @@ class RaggedMapOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): result, [[[0, 10], [0, 20]], [[1, 30], [1, 40]], [[2, 50], [2, 60]], [[3, 70]], [[4, 80], [4, 90], [4, 100]]]) + @test_util.run_deprecated_v1 def testBatchGather(self): tokens = ragged.constant([['hello', '.', 'there'], ['merhaba'], ['bonjour', '.', 'ca va', '?']]) diff --git a/tensorflow/python/ops/ragged/ragged_map_inner_values_op_test.py b/tensorflow/python/ops/ragged/ragged_map_inner_values_op_test.py index 798d7c3ce81..b5802cb82d9 100644 --- a/tensorflow/python/ops/ragged/ragged_map_inner_values_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_map_inner_values_op_test.py @@ -43,6 +43,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, with self.test_session(): self.assertEqual(result.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testDocStringExamples(self): """Test the examples in apply_op_to_ragged_values.__doc__.""" rt = ragged.constant([[1, 2, 3], [], [4, 5], [6]]) @@ -54,6 +55,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, self.assertEqual(v2.eval().tolist(), [[1, 4, 9], [], [16, 25], [36]]) self.assertEqual(v3.eval().tolist(), [[6, 7, 8], [], [9, 10], [11]]) + @test_util.run_deprecated_v1 def testOpWithSingleRaggedTensorArg(self): tensor = ragged.constant([[1, 2, 3], [], [4, 5]]) self.assertRaggedMapInnerValuesReturns( @@ -61,17 +63,20 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, args=(tensor,), expected=[[0, 0, 0], [], [0, 0]]) + @test_util.run_deprecated_v1 def testOpWithTwoRaggedTensorArgs(self): x = ragged.constant([[3, 1, 4], [], [1, 5]]) y = ragged.constant([[1, 2, 3], [], [4, 5]]) self.assertRaggedMapInnerValuesReturns( op=math_ops.multiply, args=(x, y), expected=[[3, 2, 12], [], [4, 25]]) + @test_util.run_deprecated_v1 def testOpWithRaggedTensorAndScalarArgs(self): y = ragged.constant([[1, 2, 3], [], [4, 5]]) self.assertRaggedMapInnerValuesReturns( op=math_ops.multiply, args=(5, y), expected=[[5, 10, 15], [], [20, 25]]) + @test_util.run_deprecated_v1 def testOpWithThreeRaggedTensorArgs(self): condition = ragged.constant( [[True, True, False], [], [True, False]]) # pyformat: disable @@ -82,6 +87,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, args=(condition, x, y), expected=[[b'a', b'b', b'C'], [], [b'd', b'E']]) + @test_util.run_deprecated_v1 def testOpWithRaggedTensorListArg(self): x = ragged.constant([[1, 2, 3], [], [4, 5]]) y = ragged.constant([[10, 20, 30], [], [40, 50]]) @@ -90,6 +96,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, args=([x, y, x],), expected=[[12, 24, 36], [], [48, 60]]) + @test_util.run_deprecated_v1 def testOpWithKeywordArgs(self): x = ragged.constant([[3, 1, 4], [], [1, 5]]) y = ragged.constant([[1, 2, 3], [], [4, 5]]) @@ -98,6 +105,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, kwargs=dict(x=x, y=y), expected=[[3, 2, 12], [], [4, 25]]) + @test_util.run_deprecated_v1 def testOpWithMixedPositionalAndKeywordArgs(self): x = ragged.constant([[3, 1, 4], [], [1, 5]]) y = ragged.constant([[1, 2, 3], [], [4, 5]]) @@ -107,6 +115,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, kwargs=dict(y=y), expected=[[3, 2, 12], [], [4, 25]]) + @test_util.run_deprecated_v1 def testNonElementWiseOp(self): x = ragged.constant( [[[3, 1, 4], [1, 5, 9], [2, 6, 5]], [], [[3, 5, 8], [9, 7, 9]]], @@ -119,6 +128,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, }, expected=[[8, 15, 13], [], [16, 25]]) + @test_util.run_deprecated_v1 def testOpWithRaggedRankGreaterThanOne(self): # ragged_rank=0 x0 = [3, 1, 4, 1, 5, 9, 2, 6, 5] @@ -163,6 +173,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, [[[54, 14], [48, 45]]] # row 3 ]) # pyformat: disable + @test_util.run_deprecated_v1 def testOpWithRaggedRankThree(self): x = ragged.constant([[[3, 1, 4]], [], [[], [1, 5]]]) y = ragged.constant([[[1, 2, 3]], [], [[], [4, 5]]]) @@ -171,6 +182,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, args=(x, y), expected=[[[3, 2, 12]], [], [[], [4, 25]]]) + @test_util.run_deprecated_v1 def testOpWithInnerValuesOnly(self): x = constant_op.constant([[1, 2], [3, 4], [5, 6]]) y = constant_op.constant(2) @@ -191,6 +203,7 @@ class RaggedMapInnerValuesOpTest(test_util.TensorFlowTestCase, r'Inputs must have identical ragged splits.*', ragged.map_inner_values, math_ops.add, x, y) + @test_util.run_deprecated_v1 def testRaggedTensorSplitsMismatchErrorAtRuntime(self): splits1 = array_ops.placeholder_with_default( constant_op.constant([0, 3, 3, 5], dtypes.int64), None) diff --git a/tensorflow/python/ops/ragged/ragged_operators_test.py b/tensorflow/python/ops/ragged/ragged_operators_test.py index a99d788ef79..7fe8159d822 100644 --- a/tensorflow/python/ops/ragged/ragged_operators_test.py +++ b/tensorflow/python/ops/ragged/ragged_operators_test.py @@ -27,6 +27,7 @@ class RaggedElementwiseOpsTest(test_util.TensorFlowTestCase): # @TODO(edloper): Test right-handed versions of operators once we add # broadcasting support for elementwise ops. + @test_util.run_deprecated_v1 def testOrderingOperators(self): x = ragged.constant([[1, 5], [3]]) y = ragged.constant([[4, 5], [1]]) @@ -40,6 +41,7 @@ class RaggedElementwiseOpsTest(test_util.TensorFlowTestCase): if a != b: print('%30s %s' % (b, a)) + @test_util.run_deprecated_v1 def testArithmeticOperators(self): x = ragged.constant([[1.0, -2.0], [8.0]]) y = ragged.constant([[4.0, 4.0], [2.0]]) @@ -75,6 +77,7 @@ class RaggedElementwiseOpsTest(test_util.TensorFlowTestCase): self.assertEqual((2.0 % y).eval().tolist(), [[2.0, 2.0], [0.0]]) self.assertEqual((x % 2.0).eval().tolist(), [[1.0, 0.0], [0.0]]) + @test_util.run_deprecated_v1 def testLogicalOperators(self): a = ragged.constant([[True, True], [False]]) b = ragged.constant([[True, False], [False]]) diff --git a/tensorflow/python/ops/ragged/ragged_range_op_test.py b/tensorflow/python/ops/ragged/ragged_range_op_test.py index 3c6a6fb75c8..644423ecb7f 100644 --- a/tensorflow/python/ops/ragged/ragged_range_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_range_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.platform import googletest class RaggedRangeOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExamples(self): """Examples from ragged_range.__doc__.""" with self.test_session(): @@ -38,6 +39,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): rt3 = ragged.range([0, 5, 8], [3, 3, 12], 2).eval().tolist() self.assertEqual(rt3, [[0, 2], [], [8, 10]]) + @test_util.run_deprecated_v1 def testBasicRanges(self): with self.test_session(): # Specify limits only. @@ -56,6 +58,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): [list(range(0, 4, 2)), list(range(3, 4, 3)), list(range(5, 15, 4))]) + @test_util.run_deprecated_v1 def testFloatRanges(self): with self.test_session(): expected = [[0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 2.8, 3.2, 3.6], [3.0], @@ -64,6 +67,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): [0.4, 1.5, 2.2]).eval().tolist() self.assertEqual(expected, [[round(v, 5) for v in row] for row in actual]) + @test_util.run_deprecated_v1 def testNegativeDeltas(self): with self.test_session(): self.assertEqual( @@ -77,6 +81,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): [list(range(0, 0, -1)), list(range(-3, 0, 1)), list(range(5, 0, -2))]) + @test_util.run_deprecated_v1 def testBroadcast(self): with self.test_session(): # Specify starts and limits, broadcast deltas. @@ -89,6 +94,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): self.assertEqual( ragged.range(0, 5, 1).eval().tolist(), [list(range(0, 5, 1))]) + @test_util.run_deprecated_v1 def testEmptyRanges(self): rt1 = ragged.range([0, 5, 3], [0, 3, 5]) rt2 = ragged.range([0, 5, 5], [0, 3, 5], -1) @@ -96,6 +102,7 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): self.assertEqual(rt1.eval().tolist(), [[], [], [3, 4]]) self.assertEqual(rt2.eval().tolist(), [[], [5, 4], []]) + @test_util.run_deprecated_v1 def testShapeFnErrors(self): with self.test_session(): self.assertRaisesRegexp(ValueError, r'Shape must be at most rank 1.*', @@ -107,12 +114,14 @@ class RaggedRangeOpTest(test_util.TensorFlowTestCase): self.assertRaisesRegexp(ValueError, r'Dimensions must be equal.*', ragged.range, [0], [1, 2]) + @test_util.run_deprecated_v1 def testKernelErrors(self): with self.test_session(): self.assertRaisesRegexp(errors.InvalidArgumentError, r'Requires delta != 0', ragged.range(0, 0, 0).eval) + @test_util.run_deprecated_v1 def testShape(self): self.assertEqual(ragged.range(0, 0, 0).shape.as_list(), [1, None]) self.assertEqual(ragged.range([1, 2, 3]).shape.as_list(), [3, None]) diff --git a/tensorflow/python/ops/ragged/ragged_reduce_op_test.py b/tensorflow/python/ops/ragged/ragged_reduce_op_test.py index 93176c738df..9f51d59ba3c 100644 --- a/tensorflow/python/ops/ragged/ragged_reduce_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_reduce_op_test.py @@ -300,6 +300,7 @@ class RaggedReduceOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): axis=2, expected=[[mean(1, 2), mean(3, 4, 5)], [mean(6, 7), 8], [9]]), ) + @test_util.run_deprecated_v1 def testReduce(self, ragged_reduce_op, rt_input, axis, expected): rt_input = ragged.constant(rt_input) reduced = ragged_reduce_op(rt_input, axis) @@ -311,6 +312,7 @@ class RaggedReduceOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertTrue( ((actual == expected) | (np.isnan(actual) & np.isnan(expected))).all()) + @test_util.run_deprecated_v1 def testMeanNan(self): rt_as_list = [[0, 1, 2, 3], [4], [], [5, 6], [7], [8, 9]] expected = ( @@ -321,6 +323,7 @@ class RaggedReduceOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.test_session(): self.assertEqualWithNan(reduced.eval(), expected) + @test_util.run_deprecated_v1 def testMeanWithTensorInputs(self): tensor = [[1.0, 2.0, 3.0], [10.0, 20.0, 30.0]] expected = [2.0, 20.0] @@ -328,6 +331,7 @@ class RaggedReduceOpsTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.test_session(): self.assertAllEqual(reduced.eval(), expected) + @test_util.run_deprecated_v1 def testErrors(self): rt_input = ragged.constant([[1, 2, 3], [4, 5]]) axis = array_ops.placeholder_with_default(constant_op.constant([0]), None) diff --git a/tensorflow/python/ops/ragged/ragged_row_lengths_op_test.py b/tensorflow/python/ops/ragged/ragged_row_lengths_op_test.py index 4d5a0a5d11c..4a705be4848 100644 --- a/tensorflow/python/ops/ragged/ragged_row_lengths_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_row_lengths_op_test.py @@ -143,6 +143,7 @@ class RaggedRowLengthsOp(test_util.TensorFlowTestCase, parameterized.TestCase): expected=[[2, 3, 0], [4, 1]], expected_ragged_rank=1), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testRowLengths(self, rt_input, expected, diff --git a/tensorflow/python/ops/ragged/ragged_row_splits_to_segment_ids_op_test.py b/tensorflow/python/ops/ragged/ragged_row_splits_to_segment_ids_op_test.py index f246bf35524..7f5f4e91bde 100644 --- a/tensorflow/python/ops/ragged/ragged_row_splits_to_segment_ids_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_row_splits_to_segment_ids_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.platform import googletest class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExample(self): splits = [0, 3, 3, 5, 6, 9] expected = [0, 0, 0, 2, 2, 3, 4, 4, 4] @@ -33,12 +34,14 @@ class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(segment_ids.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testEmptySplits(self): # Note: the splits for an empty ragged tensor contains a single zero. segment_ids = ragged.row_splits_to_segment_ids([0]) with self.test_session(): self.assertEqual(segment_ids.eval().tolist(), []) + @test_util.run_deprecated_v1 def testErrors(self): self.assertRaisesRegexp(ValueError, r'Invalid row_splits: \[\]', ragged.row_splits_to_segment_ids, []) diff --git a/tensorflow/python/ops/ragged/ragged_segment_ids_to_row_splits_op_test.py b/tensorflow/python/ops/ragged/ragged_segment_ids_to_row_splits_op_test.py index fa7adf66b0b..7e52f2d844b 100644 --- a/tensorflow/python/ops/ragged/ragged_segment_ids_to_row_splits_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_segment_ids_to_row_splits_op_test.py @@ -26,6 +26,7 @@ from tensorflow.python.platform import googletest class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExample(self): segment_ids = [0, 0, 0, 2, 2, 3, 4, 4, 4] expected = [0, 3, 3, 5, 6, 9] @@ -33,6 +34,7 @@ class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(splits.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testEmptySegmentIds(self): # Note: the splits for an empty ragged tensor contains a single zero. segment_ids = ragged.segment_ids_to_row_splits([]) @@ -49,6 +51,7 @@ class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): self.assertRaisesRegexp(ValueError, r'Shape \(1, 1\) must have rank 1', ragged.segment_ids_to_row_splits, [[0]]) + @test_util.run_deprecated_v1 def testNumSegments(self): segment_ids = [0, 0, 0, 2, 2, 3, 4, 4, 4] num_segments = 7 @@ -57,6 +60,7 @@ class RaggedSplitsToSegmentIdsOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(splits.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testUnsortedSegmentIds(self): # Segment ids are not required to be sorted. segment_ids = [0, 4, 3, 2, 4, 4, 2, 0, 0] diff --git a/tensorflow/python/ops/ragged/ragged_segment_op_test.py b/tensorflow/python/ops/ragged/ragged_segment_op_test.py index 40a101b4dad..9e4877ae3e6 100644 --- a/tensorflow/python/ops/ragged/ragged_segment_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_segment_op_test.py @@ -110,6 +110,7 @@ class RaggedSegmentOpsTest(test_util.TensorFlowTestCase, (ragged.segment_mean, mean, [5, 4, 3, 2, 1, 0]), (ragged.segment_mean, mean, [0, 0, 0, 10, 10, 10]), ) + @test_util.run_deprecated_v1 def testRaggedSegment_Int(self, segment_op, combiner, segment_ids): rt_as_list = [[0, 1, 2, 3], [4], [], [5, 6], [7], [8, 9]] rt = ragged.constant(rt_as_list) @@ -146,6 +147,7 @@ class RaggedSegmentOpsTest(test_util.TensorFlowTestCase, (ragged.segment_sqrt_n, sqrt_n, [5, 4, 3, 2, 1, 0]), (ragged.segment_sqrt_n, sqrt_n, [0, 0, 0, 10, 10, 10]), ) + @test_util.run_deprecated_v1 def testRaggedSegment_Float(self, segment_op, combiner, segment_ids): rt_as_list = [[0., 1., 2., 3.], [4.], [], [5., 6.], [7.], [8., 9.]] rt = ragged.constant(rt_as_list) @@ -157,6 +159,7 @@ class RaggedSegmentOpsTest(test_util.TensorFlowTestCase, self.assertNestedListAmostEqual( self.evaluate(segmented).tolist(), expected, places=5) + @test_util.run_deprecated_v1 def testRaggedRankTwo(self): rt = ragged.constant([ [[111, 112, 113, 114], [121],], # row 0 @@ -179,6 +182,7 @@ class RaggedSegmentOpsTest(test_util.TensorFlowTestCase, []] # pyformat: disable self.assertEqual(self.evaluate(segmented2).tolist(), expected2) + @test_util.run_deprecated_v1 def testRaggedSegmentIds(self): rt = ragged.constant([ [[111, 112, 113, 114], [121],], # row 0 @@ -201,6 +205,7 @@ class RaggedSegmentOpsTest(test_util.TensorFlowTestCase, 'but segment_ids is ragged and data is not.', ragged.segment_sum, dt, segment_ids, 3) + @test_util.run_deprecated_v1 def testShapeMismatchError2(self): rt = ragged.constant([ [[111, 112, 113, 114], [121]], # row 0 diff --git a/tensorflow/python/ops/ragged/ragged_stack_op_test.py b/tensorflow/python/ops/ragged/ragged_stack_op_test.py index d474a749f04..43434716942 100644 --- a/tensorflow/python/ops/ragged/ragged_stack_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_stack_op_test.py @@ -265,6 +265,7 @@ class RaggedStackOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): axis=0, expected=[[[b'a00', b'a01'], [], [b'a20', b'a21']]]), ) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedStack(self, descr, rt_inputs, @@ -313,6 +314,7 @@ class RaggedStackOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): def testError(self, rt_inputs, axis, error, message): self.assertRaisesRegexp(error, message, ragged.stack, rt_inputs, axis) + @test_util.run_deprecated_v1 def testSingleTensorInput(self): """Tests ragged_stack with a single tensor input. diff --git a/tensorflow/python/ops/ragged/ragged_tensor_test.py b/tensorflow/python/ops/ragged/ragged_tensor_test.py index fa681c07bb7..608fbd6e5b7 100644 --- a/tensorflow/python/ops/ragged/ragged_tensor_test.py +++ b/tensorflow/python/ops/ragged/ragged_tensor_test.py @@ -114,6 +114,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # RaggedTensor class docstring examples #============================================================================= + @test_util.run_deprecated_v1 def testClassDocStringExamples(self): # From section: "Component Tensors" rt = ragged.from_row_splits( @@ -199,6 +200,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # RaggedTensor Constructor (private) #============================================================================= + @test_util.run_deprecated_v1 def testRaggedTensorConstruction(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_splits = constant_op.constant([0, 2, 2, 5, 6, 7], dtypes.int64) @@ -243,6 +245,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # RaggedTensor Factory Ops #============================================================================= + @test_util.run_deprecated_v1 def testFromValueRowIdsWithDerivedNRows(self): # nrows is known at graph creation time. values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) @@ -265,6 +268,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromValueRowIdsWithDerivedNRowsDynamic(self): # nrows is not known at graph creation time. values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) @@ -288,6 +292,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromValueRowIdsWithExplicitNRows(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) value_rowids = constant_op.constant([0, 0, 2, 2, 2, 3, 4], dtypes.int64) @@ -309,6 +314,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g'], [], []]) + @test_util.run_deprecated_v1 def testFromValueRowIdsWithExplicitNRowsEqualToDefault(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) value_rowids = constant_op.constant([0, 0, 2, 2, 2, 3, 4], dtypes.int64) @@ -332,6 +338,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromValueRowIdsWithEmptyValues(self): rt = ragged.from_value_rowids([], []) rt_nrows = ragged.nrows(rt) @@ -343,6 +350,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertEqual(self.evaluate(rt_nrows).tolist(), 0) self.assertEqual(self.evaluate(rt).tolist(), []) + @test_util.run_deprecated_v1 def testFromRowSplits(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_splits = constant_op.constant([0, 2, 2, 5, 6, 7], dtypes.int64) @@ -368,6 +376,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.assertRaisesRegexp(ValueError, err_msg): ragged.from_row_splits([], []) + @test_util.run_deprecated_v1 def testFromRowStarts(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_starts = constant_op.constant([0, 2, 2, 5, 6], dtypes.int64) @@ -388,6 +397,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromRowLimits(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_limits = constant_op.constant([2, 2, 5, 6, 7], dtypes.int64) @@ -408,6 +418,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromRowLengths(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_lengths = constant_op.constant([2, 0, 3, 1, 1], dtypes.int64) @@ -429,6 +440,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[b'a', b'b'], [], [b'c', b'd', b'e'], [b'f'], [b'g']]) + @test_util.run_deprecated_v1 def testFromNestedValueRowIdsWithDerivedNRows(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) nested_value_rowids = [ @@ -453,6 +465,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.evaluate(rt).tolist(), [[[b'a', b'b'], []], [[b'c', b'd', b'e']], [], [[b'f'], [b'g']]]) + @test_util.run_deprecated_v1 def testFromNestedValueRowIdsWithExplicitNRows(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) nested_value_rowids = [ @@ -509,6 +522,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): ragged.from_nested_value_rowids([1, 2, 3], [[0, 1, 2], [0, 1, 2]], constant_op.constant([3, 3])) + @test_util.run_deprecated_v1 def testFromNestedRowSplits(self): inner_values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) nested_row_splits = [ @@ -576,6 +590,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): value_rowids=value_rowids, nrows=array_ops.expand_dims(nrows, 0)) + @test_util.run_deprecated_v1 def testGraphMismatch(self): with ops.Graph().as_default(): values = constant_op.constant([1, 2, 3]) @@ -588,6 +603,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # Ragged Value & Row-Partitioning Tensor Accessors #============================================================================= + @test_util.run_deprecated_v1 def testRaggedTensorAccessors_2d(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) row_splits = constant_op.constant([0, 2, 2, 5, 6, 7], dtypes.int64) @@ -622,6 +638,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): [self.evaluate(s).tolist() for s in rt.nested_row_splits], [[0, 2, 2, 5, 6, 7]]) + @test_util.run_deprecated_v1 def testRaggedTensorAccessors_3d_with_ragged_rank_1(self): values = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]] row_splits = constant_op.constant([0, 2, 2, 5, 6, 7], dtypes.int64) @@ -657,6 +674,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): [self.evaluate(s).tolist() for s in rt.nested_row_splits], [[0, 2, 2, 5, 6, 7]]) + @test_util.run_deprecated_v1 def testRaggedTensorAccessors_3d_with_ragged_rank_2(self): values = constant_op.constant(['a', 'b', 'c', 'd', 'e', 'f', 'g']) nested_row_splits = [ @@ -709,6 +727,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # RaggedTensor.shape #============================================================================= + @test_util.run_deprecated_v1 def testShape(self): """Tests for RaggedTensor.shape.""" rt1 = ragged.from_row_splits(b'a b c d e f g'.split(), [0, 2, 5, 6, 6, 7]) @@ -842,6 +861,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[:, -2:], [row[-2:] for row in EXAMPLE_RAGGED_TENSOR_2D]), # TODO(edloper): Add tests for strided slices, once support is added. ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemWithRaggedRank1(self, slice_spec, expected): """Test that rt.__getitem__(slice_spec) == expected.""" # Ragged tensor @@ -883,6 +903,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[..., 0, 0, 0], IndexError, 'Too many indices for RaggedTensor'), ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemErrorsWithRaggedRank1(self, slice_spec, expected, message): """Test that rt.__getitem__(slice_spec) == expected.""" @@ -961,6 +982,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # TODO(edloper): Add tests slicing inner ragged dimensions, one support # is added. ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemWithRaggedRank2(self, slice_spec, expected): """Test that rt.__getitem__(slice_spec) == expected.""" rt = ragged.from_nested_row_splits( @@ -982,6 +1004,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[5], ValueError, '.*out of bounds.*'), (SLICE_BUILDER[0, 5], ValueError, '.*out of bounds.*'), ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemErrorsWithRaggedRank2(self, slice_spec, expected, message): """Test that rt.__getitem__(slice_spec) == expected.""" @@ -996,6 +1019,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[2:], []), (SLICE_BUILDER[:-3], []), ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemWithEmptyTensor(self, slice_spec, expected): """Test that rt.__getitem__(slice_spec) == expected.""" rt = ragged.from_row_splits([], [0]) @@ -1005,6 +1029,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[0], ValueError, '.*out of bounds.*'), (SLICE_BUILDER[-1], ValueError, '.*out of bounds.*'), ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemErrorsWithEmptyTensor(self, slice_spec, expected, message): """Test that rt.__getitem__(slice_spec) == expected.""" @@ -1020,6 +1045,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): (SLICE_BUILDER[0, 1], EXAMPLE_RAGGED_TENSOR_2D[0][1]), (SLICE_BUILDER[-3, 0], EXAMPLE_RAGGED_TENSOR_2D[-3][0]), ) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemWithPlaceholderShapes(self, slice_spec, expected): """Test that rt.__getitem__(slice_spec) == expected.""" # Intentionally use an unknown shape for `splits`, to force the code path @@ -1034,6 +1060,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): @parameterized.parameters( (SLICE_BUILDER[..., 2], ValueError, 'Ellipsis not supported for unknown shape RaggedTensors'),) + @test_util.run_deprecated_v1 def testRaggedTensorGetItemErrorsWithPlaceholderShapes( self, slice_spec, expected, message): """Test that rt.__getitem__(slice_spec) == expected.""" @@ -1042,6 +1069,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): rt = ragged.from_row_splits(values, [0, 1]) self._TestGetItemException(rt, slice_spec, expected, message) + @test_util.run_deprecated_v1 def testGetItemNewAxis(self): # rt: [[[['a', 'b'], ['c', 'd']], [], [['e', 'f']]], []] splits1 = [0, 3, 3] @@ -1089,6 +1117,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): #============================================================================= # RaggedTensor.__str__ #============================================================================= + @test_util.run_deprecated_v1 def testRaggedTensorStr(self): rt1 = ragged.from_row_splits(b'a b c d e f g'.split(), [0, 2, 5, 6, 6, 7]) expected1 = ('RaggedTensor(values=Tensor("RaggedFromRowSplits/values:0", ' @@ -1126,6 +1155,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): # RaggedTensor.with_values() and RaggedTensor.with_inner_values(). #============================================================================= + @test_util.run_deprecated_v1 def testWithValues(self): rt1 = ragged.constant([[1, 2], [3, 4, 5], [6], [], [7]]) rt2 = ragged.constant([[[1, 2], [3, 4, 5]], [[6]], [], [[], [7]]]) @@ -1147,6 +1177,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): #============================================================================= # Session.run #============================================================================= + @test_util.run_deprecated_v1 def testSessionRun(self): rt1 = ragged.constant([[1, 2, 3], [4]]) rt2 = ragged.constant([[[], [1, 2]], [[3]]]) @@ -1156,6 +1187,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertEqual(result['rt1'].tolist(), [[1, 2, 3], [4]]) self.assertEqual(result['rt2'].tolist(), [[[], [1, 2]], [[3]]]) + @test_util.run_deprecated_v1 def testSessionRunFeed(self): rt1 = ragged.from_row_splits( array_ops.placeholder(dtypes.int32), @@ -1176,6 +1208,7 @@ class RaggedTensorTest(test_util.TensorFlowTestCase, parameterized.TestCase): self.assertEqual(result['rt1'].tolist(), [[1, 2, 3], [4]]) self.assertEqual(result['rt2'].tolist(), [[[], [1, 2]], [[3]]]) + @test_util.run_deprecated_v1 def testSessionPartialRunFeed(self): # Placeholder inputs. a = ragged.from_row_splits( diff --git a/tensorflow/python/ops/ragged/ragged_tile_op_test.py b/tensorflow/python/ops/ragged/ragged_tile_op_test.py index 672d2121147..f335b15dd15 100644 --- a/tensorflow/python/ops/ragged/ragged_tile_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_tile_op_test.py @@ -181,6 +181,7 @@ class RaggedTileOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): [[[5], [6]]]]), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedTile(self, descr, rt_input, @@ -209,6 +210,7 @@ class RaggedTileOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): with self.test_session(): self.assertEqual(tiled.eval().tolist(), expected) + @test_util.run_deprecated_v1 def testRaggedTileWithTensorInput(self): # When the input is a `Tensor`, ragged_tile just delegates to tf.tile. dt = constant_op.constant([[1, 2], [3, 4]]) diff --git a/tensorflow/python/ops/ragged/ragged_to_sparse_op_test.py b/tensorflow/python/ops/ragged/ragged_to_sparse_op_test.py index cb8e82c00d1..69b31ad0e97 100644 --- a/tensorflow/python/ops/ragged/ragged_to_sparse_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_to_sparse_op_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): + @test_util.run_deprecated_v1 def testDocStringExample(self): rt = ragged.constant([[1, 2, 3], [4], [], [5, 6]]) st = ragged.to_sparse(rt) @@ -40,6 +41,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): with self.test_session(): self.assertEqual(' '.join(repr(st.eval()).split()), expected) + @test_util.run_deprecated_v1 def test2DRaggedTensorWithOneRaggedDimension(self): rt = ragged.constant([['a', 'b'], ['c', 'd', 'e'], ['f'], [], ['g']]) with self.test_session(): @@ -49,6 +51,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): self.assertAllEqual(st.values, b'a b c d e f g'.split()) self.assertAllEqual(st.dense_shape, [5, 3]) + @test_util.run_deprecated_v1 def test3DRaggedTensorWithOneRaggedDimension(self): rt = ragged.constant([[[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]], [[11, 12]], [], [[13, 14]]], @@ -63,6 +66,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) self.assertAllEqual(st.dense_shape, [5, 3, 2]) + @test_util.run_deprecated_v1 def test4DRaggedTensorWithOneRaggedDimension(self): rt = ragged.constant( [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [], [[[9, 10], [11, 12]]]], @@ -88,6 +92,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): ]) self.assertAllEqual(st.dense_shape, [3, 2, 2, 2]) + @test_util.run_deprecated_v1 def test4DRaggedTensorWithTwoRaggedDimensions(self): rt = ragged.constant([[[[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]]], [[[11, 12]], [], [[13, 14]]], []], @@ -135,6 +140,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): self.assertEqual(st.values.shape.as_list(), [7]) self.assertEqual(st.dense_shape.shape.as_list(), [3]) + @test_util.run_deprecated_v1 def testKernelErrors(self): # An empty vector, defined using a placeholder to ensure that we can't # determine that it's invalid at graph-construction time. @@ -173,6 +179,7 @@ class RaggedTensorToSparseOpTest(test_util.TensorFlowTestCase): self.assertRaisesRegexp(errors.InvalidArgumentError, empty_splits_error, ragged.to_sparse(bad_rt5).eval) + @test_util.run_deprecated_v1 def testGradient(self): # rt1.shape == rt2.shape == [2, (D2), (D3), 2]. rt1 = ragged.constant([[[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0]]]], diff --git a/tensorflow/python/ops/ragged/ragged_to_tensor_op_test.py b/tensorflow/python/ops/ragged/ragged_to_tensor_op_test.py index 688676e46c6..77499b9cb3c 100644 --- a/tensorflow/python/ops/ragged/ragged_to_tensor_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_to_tensor_op_test.py @@ -30,6 +30,7 @@ from tensorflow.python.platform import googletest class RaggedTensorToTensorOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): + @test_util.run_deprecated_v1 def testDocStringExamples(self): """Example from ragged_to_tensor.__doc__.""" rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) @@ -97,6 +98,7 @@ class RaggedTensorToTensorOpTest(test_util.TensorFlowTestCase, 'expected': [[[[1], [2]], [[9], [9]], [[3], [9]]]], }, ) + @test_util.run_deprecated_v1 def testRaggedTensorToTensor(self, rt_input, expected, @@ -132,6 +134,7 @@ class RaggedTensorToTensorOpTest(test_util.TensorFlowTestCase, 'error': (TypeError, "Expected int32, got 'a' of type 'str' instead"), }, ) + @test_util.run_deprecated_v1 def testError(self, rt_input, default, error, ragged_rank=None): rt = ragged.constant(rt_input, ragged_rank=ragged_rank) with self.assertRaisesRegexp(error[0], error[1]): diff --git a/tensorflow/python/ops/ragged/ragged_where_op_test.py b/tensorflow/python/ops/ragged/ragged_where_op_test.py index 03672e4521b..de83a549771 100644 --- a/tensorflow/python/ops/ragged/ragged_where_op_test.py +++ b/tensorflow/python/ops/ragged/ragged_where_op_test.py @@ -165,6 +165,7 @@ class RaggedWhereOpTest(test_util.TensorFlowTestCase, parameterized.TestCase): y=ragged.constant_value([[[['a']]], [[['b']]]]), expected=ragged.constant_value([[[[], [b'A']]], [[[b'b']]]])), ]) # pyformat: disable + @test_util.run_deprecated_v1 def testRaggedWhere(self, condition, expected, x=None, y=None): result = ragged.where(condition, x, y) self.assertEqual( diff --git a/tensorflow/python/ops/sort_ops_test.py b/tensorflow/python/ops/sort_ops_test.py index 8a92f492664..17ce604cbf1 100644 --- a/tensorflow/python/ops/sort_ops_test.py +++ b/tensorflow/python/ops/sort_ops_test.py @@ -25,6 +25,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import sort_ops @@ -33,9 +34,11 @@ from tensorflow.python.platform import test class SortTest(test.TestCase): + @test_util.run_deprecated_v1 def testRandom_lowDimensionality(self): self._testRandom_lowDimensionality(negative_axis=False) + @test_util.run_deprecated_v1 def testRandom_lowDimensionality_negative(self): self._testRandom_lowDimensionality(negative_axis=True) @@ -53,6 +56,7 @@ class SortTest(test.TestCase): np.sort(arr, axis=sort_axis), sort_ops.sort(constant_op.constant(arr), axis=sort_axis).eval()) + @test_util.run_deprecated_v1 def testRandom_highDimensionality(self): np.random.seed(100) for _ in range(20): @@ -65,6 +69,7 @@ class SortTest(test.TestCase): np.sort(arr, axis=sort_axis), sort_ops.sort(constant_op.constant(arr), axis=sort_axis).eval()) + @test_util.run_deprecated_v1 def testScalar(self): # Create an empty scalar where the static shape is unknown. zeros_length_1 = array_ops.zeros( @@ -77,11 +82,13 @@ class SortTest(test.TestCase): with self.assertRaises(errors.InvalidArgumentError): sort.eval() + @test_util.run_deprecated_v1 def testNegativeOutOfBounds_staticShape(self): arr = constant_op.constant([3, 4, 5]) with self.assertRaises(ValueError): sort_ops.sort(arr, axis=-4) + @test_util.run_deprecated_v1 def testDescending(self): arr = np.random.random((10, 5, 5)) with self.cached_session(): @@ -90,6 +97,7 @@ class SortTest(test.TestCase): sort_ops.sort( constant_op.constant(arr), axis=0, direction='DESCENDING').eval()) + @test_util.run_deprecated_v1 def testSort_staticallyKnownRank_constantTransposition(self): # The transposition array should be a constant if the rank of "values" is # statically known. @@ -107,6 +115,7 @@ class SortTest(test.TestCase): tensor_util.constant_value(transposition), [0, 4, 2, 3, 1]) + @test_util.run_deprecated_v1 def testArgsort_1d(self): arr = np.random.random(42) with self.cached_session(): @@ -114,6 +123,7 @@ class SortTest(test.TestCase): np.sort(arr), array_ops.gather(arr, sort_ops.argsort(arr)).eval()) + @test_util.run_deprecated_v1 def testArgsort(self): arr = np.random.random((5, 6, 7, 8)) for axis in range(4): diff --git a/tensorflow/python/ops/special_math_ops_test.py b/tensorflow/python/ops/special_math_ops_test.py index 7438cdb3f11..94aaebed951 100644 --- a/tensorflow/python/ops/special_math_ops_test.py +++ b/tensorflow/python/ops/special_math_ops_test.py @@ -46,6 +46,7 @@ class LBetaTest(test.TestCase): 0.5, self.evaluate(math_ops.exp(special_math_ops.lbeta(x_one_half)))) self.assertEqual([], special_math_ops.lbeta(x_one).get_shape()) + @test_util.run_deprecated_v1 def test_one_dimensional_arg_dynamic(self): # Should evaluate to 1 and 1/2. x_one = [1, 1.] @@ -57,6 +58,7 @@ class LBetaTest(test.TestCase): self.assertAllClose(0.5, beta_ph.eval(feed_dict={ph: x_one_half})) + @test_util.run_deprecated_v1 def test_four_dimensional_arg_with_partial_shape_dynamic(self): x_ = np.ones((3, 2, 3, 4)) # Gamma(1) = 0! = 1 @@ -81,6 +83,7 @@ class LBetaTest(test.TestCase): self.evaluate(math_ops.exp(special_math_ops.lbeta(x_one_half)))) self.assertEqual((2,), special_math_ops.lbeta(x_one_half).get_shape()) + @test_util.run_deprecated_v1 def test_two_dimensional_arg_dynamic(self): # Should evaluate to 1/2. x_one_half = [[2, 1.], [2, 1.]] @@ -288,6 +291,7 @@ class EinsumTest(test.TestCase): for case in self.long_cases: self.run_test(case) + @test_util.run_deprecated_v1 def test_invalid(self): for axes in self.invalid_cases: inputs = [ @@ -297,6 +301,7 @@ class EinsumTest(test.TestCase): with self.assertRaises(ValueError): _ = special_math_ops.einsum(axes, *inputs) + @test_util.run_deprecated_v1 def test_invalid_keyword_arguments(self): m0 = array_ops.placeholder(dtypes.int32, shape=(1, None)) m1 = array_ops.placeholder(dtypes.int32, shape=(None, 1)) @@ -311,11 +316,13 @@ class EinsumTest(test.TestCase): invalid1='value1', invalid2='value2') + @test_util.run_deprecated_v1 def test_repeated_axis_single_input(self): x = array_ops.placeholder(dtypes.float32, shape=[2, 2]) with self.assertRaises(ValueError): _ = special_math_ops.einsum('ii->', x) + @test_util.run_deprecated_v1 def test_dim_mismatch(self): for axes, input_shapes in self.dim_mismatch_cases: inputs = [ diff --git a/tensorflow/python/profiler/internal/run_metadata_test.py b/tensorflow/python/profiler/internal/run_metadata_test.py index 216cc3dd54b..a8859f845b3 100644 --- a/tensorflow/python/profiler/internal/run_metadata_test.py +++ b/tensorflow/python/profiler/internal/run_metadata_test.py @@ -26,6 +26,7 @@ from tensorflow.core.protobuf import config_pb2 from tensorflow.core.protobuf import rewriter_config_pb2 from tensorflow.python.client import session from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variables @@ -154,6 +155,7 @@ class RunMetadataTest(test.TestCase): # deallocates the memory after matmul started. self.assertGreater(random_allocs[1].alloc_micros, mm.all_start_micros) + @test_util.run_deprecated_v1 def testCPU(self): ops.reset_default_graph() with ops.device('/cpu:0'): @@ -167,6 +169,7 @@ class RunMetadataTest(test.TestCase): ret = _extract_node(run_meta, 'MatMul:MatMul') self.assertEqual(len(ret), 0) + @test_util.run_deprecated_v1 def testLoopCPU(self): ops.reset_default_graph() with ops.device('/cpu:0'): diff --git a/tensorflow/python/profiler/pprof_profiler_test.py b/tensorflow/python/profiler/pprof_profiler_test.py index 11a3487360c..120a0d0eaa6 100644 --- a/tensorflow/python/profiler/pprof_profiler_test.py +++ b/tensorflow/python/profiler/pprof_profiler_test.py @@ -24,6 +24,7 @@ from proto import profile_pb2 from tensorflow.core.framework import step_stats_pb2 from tensorflow.core.protobuf import config_pb2 from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -135,6 +136,7 @@ comment: 9 profile.ParseFromString(profile_contents) self.assertEquals(expected_proto, str(profile)) + @test_util.run_deprecated_v1 def testProfileWithWhileLoop(self): options = config_pb2.RunOptions() options.trace_level = config_pb2.RunOptions.FULL_TRACE diff --git a/tensorflow/python/profiler/profile_context_test.py b/tensorflow/python/profiler/profile_context_test.py index 680cd71d1fc..885f08ca4b9 100644 --- a/tensorflow/python/profiler/profile_context_test.py +++ b/tensorflow/python/profiler/profile_context_test.py @@ -21,6 +21,7 @@ import os from tensorflow.python.client import session from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import gfile from tensorflow.python.platform import test @@ -35,6 +36,7 @@ builder = option_builder.ProfileOptionBuilder class ProfilerContextTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasics(self): ops.reset_default_graph() outfile = os.path.join(test.get_temp_dir(), "dump") @@ -69,6 +71,7 @@ class ProfilerContextTest(test.TestCase): with gfile.Open(outfile, "r") as f: self.assertEqual(profile_str, f.read()) + @test_util.run_deprecated_v1 def testAutoTracingInDeubMode(self): ops.reset_default_graph() x = lib.BuildFullModel() @@ -90,6 +93,7 @@ class ProfilerContextTest(test.TestCase): for f in gfile.ListDirectory(test.get_temp_dir()): self.assertFalse("run_meta" in f) + @test_util.run_deprecated_v1 def testDisabled(self): ops.reset_default_graph() x = lib.BuildFullModel() diff --git a/tensorflow/python/profiler/profiler_test.py b/tensorflow/python/profiler/profiler_test.py index eacb7d21e6a..e4f7361e5d7 100644 --- a/tensorflow/python/profiler/profiler_test.py +++ b/tensorflow/python/profiler/profiler_test.py @@ -21,6 +21,7 @@ import os from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import gfile from tensorflow.python.platform import test @@ -35,6 +36,7 @@ builder = option_builder.ProfileOptionBuilder class ProfilerTest(test.TestCase): + @test_util.run_deprecated_v1 def testProfileBasic(self): ops.reset_default_graph() outfile = os.path.join(test.get_temp_dir(), 'dump') @@ -171,6 +173,7 @@ class ProfilerTest(test.TestCase): checker = advice_pb.checkers['ExpensiveOperationChecker'] self.assertGreater(len(checker.reports), 0) + @test_util.run_deprecated_v1 def testMultipleProfilePerStep(self): ops.reset_default_graph() opts = (builder(builder.trainable_variables_parameter()) diff --git a/tensorflow/python/saved_model/loader_test.py b/tensorflow/python/saved_model/loader_test.py index 3378bf08cd9..3b7f0b250e7 100644 --- a/tensorflow/python/saved_model/loader_test.py +++ b/tensorflow/python/saved_model/loader_test.py @@ -26,6 +26,7 @@ from absl.testing import parameterized from tensorflow.python.client import session from tensorflow.python.framework import errors from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import state_ops from tensorflow.python.ops import variables @@ -93,6 +94,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): super(SavedModelLoaderTest, self).tearDown() shutil.rmtree(test.get_temp_dir(), ignore_errors=True) + @test_util.run_deprecated_v1 def test_load_function(self, builder_cls): self.export_simple_graph(builder_cls) loader = loader_impl.SavedModelLoader(SIMPLE_ADD_SAVED_MODEL) @@ -108,6 +110,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): self.assertEqual(5, sess.graph.get_tensor_by_name("x:0").eval()) self.assertEqual(7, sess.graph.get_tensor_by_name("y:0").eval()) + @test_util.run_deprecated_v1 def test_load_graph(self, builder_cls): self.export_simple_graph(builder_cls) loader = loader_impl.SavedModelLoader(SIMPLE_ADD_SAVED_MODEL) @@ -127,6 +130,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): with self.assertRaises(errors.FailedPreconditionError): self.evaluate(y) + @test_util.run_deprecated_v1 def test_load_with_import_scope(self, builder_cls): self.export_graph_with_main_op(builder_cls) loader = loader_impl.SavedModelLoader(SAVED_MODEL_WITH_MAIN_OP) @@ -157,6 +161,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): self.assertEqual(5, sess.graph.get_tensor_by_name("baa/x:0").eval()) self.assertEqual(7, sess.graph.get_tensor_by_name("baa/y:0").eval()) + @test_util.run_deprecated_v1 def test_restore_variables(self, builder_cls): self.export_graph_with_main_op(builder_cls) loader = loader_impl.SavedModelLoader(SAVED_MODEL_WITH_MAIN_OP) @@ -174,6 +179,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): loader.restore_variables(sess, tf_saver.Saver()) self.assertEqual(55, self.evaluate(z)) + @test_util.run_deprecated_v1 def test_run_init_op(self, builder_cls): self.export_graph_with_main_op(builder_cls) loader = loader_impl.SavedModelLoader(SAVED_MODEL_WITH_MAIN_OP) @@ -206,6 +212,7 @@ class SavedModelLoaderTest(test.TestCase, parameterized.TestCase): with self.assertRaises(RuntimeError): loader.get_meta_graph_def_from_tags(["not_a_graph"]) + @test_util.run_deprecated_v1 def test_load_saved_model_with_no_variables(self, builder_cls): """Test that SavedModel runs saver when there appear to be no variables. diff --git a/tensorflow/python/saved_model/save_test.py b/tensorflow/python/saved_model/save_test.py index 8fb28039a44..ef0a92fddd9 100644 --- a/tensorflow/python/saved_model/save_test.py +++ b/tensorflow/python/saved_model/save_test.py @@ -282,6 +282,7 @@ class SaveTest(test.TestCase): {"out": model(array_ops.ones([1, 4]))}, self._import_and_infer(save_dir, {"x": [[1., 1., 1., 1.]]})) + @test_util.run_deprecated_v1 def test_export_functional_keras_model_after_fit(self): x = input_layer.Input((1,)) y = core.Dense(1, name="y")(x) diff --git a/tensorflow/python/saved_model/saved_model_test.py b/tensorflow/python/saved_model/saved_model_test.py index efcd21cce3a..0f18fb1a016 100644 --- a/tensorflow/python/saved_model/saved_model_test.py +++ b/tensorflow/python/saved_model/saved_model_test.py @@ -199,6 +199,7 @@ class SavedModelTest(SavedModelTestBase): constants.SAVED_MODEL_FILENAME_PBTXT): loader.load(sess, ["foo"], export_dir) + @test_util.run_deprecated_v1 def testVerifySessionGraphUsage(self): export_dir = self._get_export_dir("test_verify_session_graph_usage") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -219,6 +220,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual( 42, ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)[0].eval()) + @test_util.run_deprecated_v1 def testSequence(self): export_dir = self._get_export_dir("test_sequence") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -236,6 +238,7 @@ class SavedModelTest(SavedModelTestBase): self.assertRaises(AssertionError, builder.add_meta_graph_and_variables, sess, ["baz"]) + @test_util.run_deprecated_v1 def testTags(self): export_dir = self._get_export_dir("test_tags") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -325,6 +328,7 @@ class SavedModelTest(SavedModelTestBase): self.assertRaises(RuntimeError, loader.load, sess, ["foo", "baz"], export_dir) + @test_util.run_deprecated_v1 def testVariables(self): export_dir = self._get_export_dir("test_variables") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -377,6 +381,7 @@ class SavedModelTest(SavedModelTestBase): self.assertRaises(errors.NotFoundError, loader.load, sess, ["baz"], export_dir) + @test_util.run_deprecated_v1 def testGraphWithoutVariables(self): export_dir = self._get_export_dir("test_graph_has_variables") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -412,6 +417,7 @@ class SavedModelTest(SavedModelTestBase): c = a * b self.assertEqual(30.0, self.evaluate(c)) + @test_util.run_deprecated_v1 def testNoOverwrite(self): export_dir = self._get_export_dir("test_no_overwrite") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -436,6 +442,7 @@ class SavedModelTest(SavedModelTestBase): self.assertRaises(AssertionError, saved_model_builder._SavedModelBuilder, export_dir) + @test_util.run_deprecated_v1 def testSaveAsText(self): export_dir = self._get_export_dir("test_astext") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -467,6 +474,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual( 42, ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)[0].eval()) + @test_util.run_deprecated_v1 def testCollections(self): export_dir = self._get_export_dir("test_collections") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -517,6 +525,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual(len(ops.get_collection("foo_vars")), 0) + @test_util.run_deprecated_v1 def testSignatureDefs(self): export_dir = self._get_export_dir("test_signature_defs") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -604,6 +613,7 @@ class SavedModelTest(SavedModelTestBase): self._validate_sig_def_keys(builder, valid_tensor_info, constants.TRAIN_OP_SIGNATURE_KEY) + @test_util.run_deprecated_v1 def testSignatureDefValidationSucceedsWithName(self): tensor_with_name = meta_graph_pb2.TensorInfo() tensor_with_name.name = "foo" @@ -617,6 +627,7 @@ class SavedModelTest(SavedModelTestBase): builder = saved_model_builder._SavedModelBuilder(export_dir) self._validate_outputs_tensor_info_accept(builder, tensor_with_name) + @test_util.run_deprecated_v1 def testSignatureDefValidationSucceedsWithCoo(self): tensor_with_coo = meta_graph_pb2.TensorInfo() # TODO(soergel) test validation of each of the fields of coo_sparse @@ -631,6 +642,7 @@ class SavedModelTest(SavedModelTestBase): builder = saved_model_builder._SavedModelBuilder(export_dir) self._validate_outputs_tensor_info_accept(builder, tensor_with_coo) + @test_util.run_deprecated_v1 def testAssets(self): export_dir = self._get_export_dir("test_assets") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -662,6 +674,7 @@ class SavedModelTest(SavedModelTestBase): compat.as_bytes("ignored.txt")) self.assertFalse(file_io.file_exists(ignored_asset_path)) + @test_util.run_deprecated_v1 def testAssetsNameCollisionDiffFile(self): export_dir = self._get_export_dir("test_assets_name_collision_diff_file") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -693,6 +706,7 @@ class SavedModelTest(SavedModelTestBase): "asset_file_tensor_1:0", asset_id=1) + @test_util.run_deprecated_v1 def testAssetsNameCollisionSameFilepath(self): export_dir = self._get_export_dir("test_assets_name_collision_same_path") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -730,6 +744,7 @@ class SavedModelTest(SavedModelTestBase): compat.as_bytes("hello42.txt_1")) self.assertFalse(file_io.file_exists(ignored_asset_path)) + @test_util.run_deprecated_v1 def testAssetsNameCollisionSameFile(self): export_dir = self._get_export_dir("test_assets_name_collision_same_file") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -767,6 +782,7 @@ class SavedModelTest(SavedModelTestBase): compat.as_bytes("hello42.txt_1")) self.assertFalse(file_io.file_exists(ignored_asset_path)) + @test_util.run_deprecated_v1 def testAssetsNameCollisionManyFiles(self): export_dir = self._get_export_dir("test_assets_name_collision_many_files") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -838,6 +854,7 @@ class SavedModelTest(SavedModelTestBase): # the main_op, following a restore. self.assertEqual(3, ops.get_collection("v")[2].eval()) + @test_util.run_deprecated_v1 def testTrainOp(self): export_dir = self._get_export_dir("test_train_op") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -865,6 +882,7 @@ class SavedModelTest(SavedModelTestBase): self.assertIsInstance( loader_impl.get_train_op(meta_graph_def), ops.Tensor) + @test_util.run_deprecated_v1 def testTrainOpGroup(self): export_dir = self._get_export_dir("test_train_op_group") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -892,6 +910,7 @@ class SavedModelTest(SavedModelTestBase): self.assertIsInstance( loader_impl.get_train_op(meta_graph_def), ops.Operation) + @test_util.run_deprecated_v1 def testTrainOpAfterVariables(self): export_dir = self._get_export_dir("test_train_op_after_variables") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -922,6 +941,7 @@ class SavedModelTest(SavedModelTestBase): loader.load(sess, ["pre_foo"], export_dir) self.assertFalse(ops.get_collection(constants.TRAIN_OP_KEY)) + @test_util.run_deprecated_v1 def testMultipleAssets(self): export_dir = self._get_export_dir("test_multiple_assets") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -962,6 +982,7 @@ class SavedModelTest(SavedModelTestBase): self._validate_assets(export_dir, bar_graph.asset_file_def, "bar.txt", "content_bar", "asset_file_tensor:0") + @test_util.run_deprecated_v1 def testDuplicateAssets(self): export_dir = self._get_export_dir("test_duplicate_assets") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1008,6 +1029,7 @@ class SavedModelTest(SavedModelTestBase): self._validate_assets(export_dir, bar_graph.asset_file_def, "foo.txt", "content_foo", "asset_file_tensor:0") + @test_util.run_deprecated_v1 def testOp(self): export_dir = self._get_export_dir("test_op") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1080,6 +1102,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual(b"k1", v1.keys().eval()) self.assertEqual(3.0, v1.values().eval()) + @test_util.run_deprecated_v1 def testCustomSaver(self): export_dir = self._get_export_dir("test_custom_saver") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1102,6 +1125,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual( saved_graph.saver_def.restore_op_name, "my_saver/restore_all") + @test_util.run_deprecated_v1 def testNoCustomSaver(self): export_dir = self._get_export_dir("test_no_custom_saver") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1124,6 +1148,7 @@ class SavedModelTest(SavedModelTestBase): self.assertEqual( saved_graph.saver_def.restore_op_name, "save/restore_all") + @test_util.run_deprecated_v1 def testMultipleCustomSavers(self): export_dir = self._get_export_dir("test_multiple_custom_savers") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1154,6 +1179,7 @@ class SavedModelTest(SavedModelTestBase): _validate_custom_saver("tag_1", "save_1/restore_all") _validate_custom_saver("tag_2", "save_2/restore_all") + @test_util.run_deprecated_v1 def testImportScope(self): export_dir = self._get_export_dir("test_scoped_assets") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1205,6 +1231,7 @@ class SavedModelTest(SavedModelTestBase): ops.get_default_graph().get_tensor_by_name( "scope_name/constant_tensor_name:0").eval()) + @test_util.run_deprecated_v1 def testClearDevices(self): export_dir = self._get_export_dir("test_clear_devices") builder = saved_model_builder._SavedModelBuilder(export_dir) @@ -1323,6 +1350,7 @@ class SavedModelV1Test(SavedModelTestBase): self.assertEqual(expected_asset_file_name, asset.filename) self.assertEqual(expected_asset_tensor_name, asset.tensor_info.name) + @test_util.run_deprecated_v1 def testWritingAssetsToCollection(self): export_dir = self._get_export_dir("test_writing_assets_to_collection") builder = saved_model_builder.SavedModelBuilder(export_dir) @@ -1355,12 +1383,14 @@ class SavedModelV1Test(SavedModelTestBase): compat.as_bytes("ignored.txt")) self.assertFalse(file_io.file_exists(ignored_asset_path)) + @test_util.run_deprecated_v1 def testLegacyInitOpWithNonEmptyCollection(self): export_dir = self._get_export_dir( "test_legacy_init_op_with_non_empty_collection") self._testInitOpsWithNonEmptyCollection(export_dir, constants.LEGACY_INIT_OP_KEY) + @test_util.run_deprecated_v1 def testMainOpWithNonEmptyCollection(self): export_dir = self._get_export_dir("test_main_op_with_non_empty_collection") self._testInitOpsWithNonEmptyCollection(export_dir, constants.MAIN_OP_KEY) @@ -1464,6 +1494,7 @@ class SavedModelV1Test(SavedModelTestBase): self.assertIn("T", node_def.attr) self.assertIn("Tout", node_def.attr) + @test_util.run_deprecated_v1 def testLegacyInitOp(self): export_dir = self._get_export_dir("test_legacy_init_op") builder = saved_model_builder.SavedModelBuilder(export_dir) diff --git a/tensorflow/python/saved_model/signature_def_utils_test.py b/tensorflow/python/saved_model/signature_def_utils_test.py index cc0fd8ce056..53c452359f1 100644 --- a/tensorflow/python/saved_model/signature_def_utils_test.py +++ b/tensorflow/python/saved_model/signature_def_utils_test.py @@ -22,6 +22,7 @@ from tensorflow.core.framework import types_pb2 from tensorflow.core.protobuf import meta_graph_pb2 from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test @@ -59,6 +60,7 @@ def _make_signature(inputs, outputs, name=None): class SignatureDefUtilsTest(test.TestCase): + @test_util.run_deprecated_v1 def testBuildSignatureDef(self): x = array_ops.placeholder(dtypes.float32, 1, name="x") x_tensor_info = utils.build_tensor_info(x) @@ -89,6 +91,7 @@ class SignatureDefUtilsTest(test.TestCase): self.assertEqual(types_pb2.DT_FLOAT, y_tensor_info_actual.dtype) self.assertEqual(0, len(y_tensor_info_actual.tensor_shape.dim)) + @test_util.run_deprecated_v1 def testRegressionSignatureDef(self): input1 = constant_op.constant("a", name="input-1") output1 = constant_op.constant(2.2, name="output-1") @@ -114,6 +117,7 @@ class SignatureDefUtilsTest(test.TestCase): self.assertEqual(types_pb2.DT_FLOAT, y_tensor_info_actual.dtype) self.assertEqual(0, len(y_tensor_info_actual.tensor_shape.dim)) + @test_util.run_deprecated_v1 def testClassificationSignatureDef(self): input1 = constant_op.constant("a", name="input-1") output1 = constant_op.constant("b", name="output-1") @@ -145,6 +149,7 @@ class SignatureDefUtilsTest(test.TestCase): self.assertEqual(types_pb2.DT_FLOAT, scores_tensor_info_actual.dtype) self.assertEqual(0, len(scores_tensor_info_actual.tensor_shape.dim)) + @test_util.run_deprecated_v1 def testPredictionSignatureDef(self): input1 = constant_op.constant("a", name="input-1") input2 = constant_op.constant("b", name="input-2") @@ -181,11 +186,13 @@ class SignatureDefUtilsTest(test.TestCase): self.assertEqual(types_pb2.DT_STRING, output2_tensor_info_actual.dtype) self.assertEqual(0, len(output2_tensor_info_actual.tensor_shape.dim)) + @test_util.run_deprecated_v1 def testTrainSignatureDef(self): self._testSupervisedSignatureDef( signature_def_utils_impl.supervised_train_signature_def, signature_constants.SUPERVISED_TRAIN_METHOD_NAME) + @test_util.run_deprecated_v1 def testEvalSignatureDef(self): self._testSupervisedSignatureDef( signature_def_utils_impl.supervised_eval_signature_def, @@ -239,11 +246,13 @@ class SignatureDefUtilsTest(test.TestCase): self.assertEqual( types_pb2.DT_FLOAT, signature_def.outputs["metrics/value"].dtype) + @test_util.run_deprecated_v1 def testTrainSignatureDefMissingInputs(self): self._testSupervisedSignatureDefMissingInputs( signature_def_utils_impl.supervised_train_signature_def, signature_constants.SUPERVISED_TRAIN_METHOD_NAME) + @test_util.run_deprecated_v1 def testEvalSignatureDefMissingInputs(self): self._testSupervisedSignatureDefMissingInputs( signature_def_utils_impl.supervised_eval_signature_def, diff --git a/tensorflow/python/saved_model/simple_save_test.py b/tensorflow/python/saved_model/simple_save_test.py index 0d0665072ac..21c2e9df2fa 100644 --- a/tensorflow/python/saved_model/simple_save_test.py +++ b/tensorflow/python/saved_model/simple_save_test.py @@ -21,6 +21,7 @@ from __future__ import print_function import os from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.saved_model import loader @@ -53,6 +54,7 @@ class SimpleSaveTest(test.TestCase): self.assertEqual(actual_tensor_info.tensor_shape.dim[i].size, expected_tensor.shape[i]) + @test_util.run_deprecated_v1 def testSimpleSave(self): """Test simple_save that uses the default parameters.""" export_dir = os.path.join(test.get_temp_dir(), diff --git a/tensorflow/python/summary/summary_test.py b/tensorflow/python/summary/summary_test.py index cacc28cc596..64f0f315c58 100644 --- a/tensorflow/python/summary/summary_test.py +++ b/tensorflow/python/summary/summary_test.py @@ -30,6 +30,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -38,6 +39,7 @@ from tensorflow.python.summary import summary as summary_lib class SummaryTest(test.TestCase): + @test_util.run_deprecated_v1 def testScalarSummary(self): with self.cached_session() as s: i = constant_op.constant(3) @@ -51,6 +53,7 @@ class SummaryTest(test.TestCase): self.assertEqual(values[0].tag, 'outer/inner') self.assertEqual(values[0].simple_value, 3.0) + @test_util.run_deprecated_v1 def testScalarSummaryWithFamily(self): with self.cached_session() as s: i = constant_op.constant(7) @@ -74,6 +77,7 @@ class SummaryTest(test.TestCase): self.assertEqual(values[0].tag, 'family/outer/family/inner_1') self.assertEqual(values[0].simple_value, 7.0) + @test_util.run_deprecated_v1 def testSummarizingVariable(self): with self.cached_session() as s: c = constant_op.constant(42.0) @@ -89,6 +93,7 @@ class SummaryTest(test.TestCase): self.assertEqual(value.tag, 'summary') self.assertEqual(value.simple_value, 42.0) + @test_util.run_deprecated_v1 def testImageSummary(self): with self.cached_session() as s: i = array_ops.ones((5, 4, 4, 3)) @@ -103,6 +108,7 @@ class SummaryTest(test.TestCase): expected = sorted('outer/inner/image/{}'.format(i) for i in xrange(3)) self.assertEqual(tags, expected) + @test_util.run_deprecated_v1 def testImageSummaryWithFamily(self): with self.cached_session() as s: i = array_ops.ones((5, 2, 3, 1)) @@ -119,6 +125,7 @@ class SummaryTest(test.TestCase): for i in xrange(3)) self.assertEqual(tags, expected) + @test_util.run_deprecated_v1 def testHistogramSummary(self): with self.cached_session() as s: i = array_ops.ones((5, 4, 4, 3)) @@ -130,6 +137,7 @@ class SummaryTest(test.TestCase): self.assertEqual(len(summary.value), 1) self.assertEqual(summary.value[0].tag, 'outer/inner') + @test_util.run_deprecated_v1 def testHistogramSummaryWithFamily(self): with self.cached_session() as s: i = array_ops.ones((5, 4, 4, 3)) @@ -148,6 +156,7 @@ class SummaryTest(test.TestCase): const = constant_op.constant(10, dtype=dtype) summary_lib.histogram('h', const) + @test_util.run_deprecated_v1 def testAudioSummary(self): with self.cached_session() as s: i = array_ops.ones((5, 3, 4)) @@ -162,6 +171,7 @@ class SummaryTest(test.TestCase): expected = sorted('outer/inner/audio/{}'.format(i) for i in xrange(3)) self.assertEqual(tags, expected) + @test_util.run_deprecated_v1 def testAudioSummaryWithFamily(self): with self.cached_session() as s: i = array_ops.ones((5, 3, 4)) @@ -178,6 +188,7 @@ class SummaryTest(test.TestCase): for i in xrange(3)) self.assertEqual(tags, expected) + @test_util.run_deprecated_v1 def testTextSummary(self): with self.cached_session(): with self.assertRaises(ValueError): @@ -193,6 +204,7 @@ class SummaryTest(test.TestCase): summ = summary_lib.text('foo', array_ops.constant('one')) self.assertEqual(summ.op.type, 'TensorSummaryV2') + @test_util.run_deprecated_v1 def testSummaryNameConversion(self): c = constant_op.constant(3) s = summary_lib.scalar('name with spaces', c) @@ -204,6 +216,7 @@ class SummaryTest(test.TestCase): s3 = summary_lib.scalar('/name/with/leading/slash', c) self.assertEqual(s3.op.name, 'name/with/leading/slash') + @test_util.run_deprecated_v1 def testSummaryWithFamilyMetaGraphExport(self): with ops.name_scope('outer'): i = constant_op.constant(11) diff --git a/tensorflow/python/summary/writer/writer_test.py b/tensorflow/python/summary/writer/writer_test.py index 20b62e5016a..d702ddc0a27 100644 --- a/tensorflow/python/summary/writer/writer_test.py +++ b/tensorflow/python/summary/writer/writer_test.py @@ -35,6 +35,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import summary_ops_v2 from tensorflow.python.platform import gfile from tensorflow.python.platform import test @@ -100,6 +101,7 @@ class FileWriterTestCase(test.TestCase): # We should be done. self.assertRaises(StopIteration, lambda: next(rr)) + @test_util.run_deprecated_v1 def testAddingSummaryGraphAndRunMetadata(self): test_dir = self._CleanTestDir("basics") sw = self._FileWriter(test_dir) @@ -173,6 +175,7 @@ class FileWriterTestCase(test.TestCase): # We should be done. self.assertRaises(StopIteration, lambda: next(rr)) + @test_util.run_deprecated_v1 def testGraphAsNamed(self): test_dir = self._CleanTestDir("basics_named_graph") with ops.Graph().as_default() as g: @@ -181,6 +184,7 @@ class FileWriterTestCase(test.TestCase): sw.close() self._assertEventsWithGraph(test_dir, g, True) + @test_util.run_deprecated_v1 def testGraphAsPositional(self): test_dir = self._CleanTestDir("basics_positional_graph") with ops.Graph().as_default() as g: @@ -189,6 +193,7 @@ class FileWriterTestCase(test.TestCase): sw.close() self._assertEventsWithGraph(test_dir, g, True) + @test_util.run_deprecated_v1 def testGraphDefAsNamed(self): test_dir = self._CleanTestDir("basics_named_graph_def") with ops.Graph().as_default() as g: @@ -198,6 +203,7 @@ class FileWriterTestCase(test.TestCase): sw.close() self._assertEventsWithGraph(test_dir, g, False) + @test_util.run_deprecated_v1 def testGraphDefAsPositional(self): test_dir = self._CleanTestDir("basics_positional_graph_def") with ops.Graph().as_default() as g: @@ -207,6 +213,7 @@ class FileWriterTestCase(test.TestCase): sw.close() self._assertEventsWithGraph(test_dir, g, False) + @test_util.run_deprecated_v1 def testGraphAndGraphDef(self): with self.assertRaises(ValueError): test_dir = self._CleanTestDir("basics_graph_and_graph_def") @@ -216,12 +223,14 @@ class FileWriterTestCase(test.TestCase): sw = self._FileWriter(test_dir, graph=g, graph_def=gd) sw.close() + @test_util.run_deprecated_v1 def testNeitherGraphNorGraphDef(self): with self.assertRaises(TypeError): test_dir = self._CleanTestDir("basics_string_instead_of_graph") sw = self._FileWriter(test_dir, "string instead of graph object") sw.close() + @test_util.run_deprecated_v1 def testCloseAndReopen(self): test_dir = self._CleanTestDir("close_and_reopen") sw = self._FileWriter(test_dir) @@ -265,6 +274,7 @@ class FileWriterTestCase(test.TestCase): # We should be done. self.assertRaises(StopIteration, lambda: next(rr)) + @test_util.run_deprecated_v1 def testNonBlockingClose(self): test_dir = self._CleanTestDir("non_blocking_close") sw = self._FileWriter(test_dir) @@ -274,6 +284,7 @@ class FileWriterTestCase(test.TestCase): sw.close() self._assertRecent(time_before_close) + @test_util.run_deprecated_v1 def testUseAfterClose(self): test_dir = self._CleanTestDir("use_after_close") sw = self._FileWriter(test_dir) @@ -289,6 +300,7 @@ class FileWriterTestCase(test.TestCase): for w in triggered: self.assertEqual(w.category, UserWarning) + @test_util.run_deprecated_v1 def testWithStatement(self): test_dir = self._CleanTestDir("with_statement") with self._FileWriter(test_dir) as sw: @@ -299,6 +311,7 @@ class FileWriterTestCase(test.TestCase): # Checks that values returned from session Run() calls are added correctly to # summaries. These are numpy types so we need to check they fit in the # protocol buffers correctly. + @test_util.run_deprecated_v1 def testAddingSummariesFromSessionRunCalls(self): test_dir = self._CleanTestDir("global_step") sw = self._FileWriter(test_dir) @@ -345,6 +358,7 @@ class FileWriterTestCase(test.TestCase): # We should be done. self.assertRaises(StopIteration, lambda: next(rr)) + @test_util.run_deprecated_v1 def testPluginMetadataStrippedFromSubsequentEvents(self): test_dir = self._CleanTestDir("basics") sw = self._FileWriter(test_dir) @@ -404,6 +418,7 @@ class FileWriterTestCase(test.TestCase): # We should be done. self.assertRaises(StopIteration, lambda: next(rr)) + @test_util.run_deprecated_v1 def testFileWriterWithSuffix(self): test_dir = self._CleanTestDir("test_suffix") sw = self._FileWriter(test_dir, filename_suffix="_test_suffix") diff --git a/tensorflow/python/tools/freeze_graph_test.py b/tensorflow/python/tools/freeze_graph_test.py index 5dc14a6961e..efdf7dd2cf1 100644 --- a/tensorflow/python/tools/freeze_graph_test.py +++ b/tensorflow/python/tools/freeze_graph_test.py @@ -161,9 +161,11 @@ class FreezeGraphTest(test_util.TensorFlowTestCase): },) builder.save(as_text=True) + @test_util.run_deprecated_v1 def testFreezeGraphV1(self): self._testFreezeGraph(saver_pb2.SaverDef.V1) + @test_util.run_deprecated_v1 def testFreezeGraphV2(self): self._testFreezeGraph(saver_pb2.SaverDef.V2) diff --git a/tensorflow/python/tools/optimize_for_inference_test.py b/tensorflow/python/tools/optimize_for_inference_test.py index 10bfb0dc706..310776ff1b0 100644 --- a/tensorflow/python/tools/optimize_for_inference_test.py +++ b/tensorflow/python/tools/optimize_for_inference_test.py @@ -128,6 +128,7 @@ class OptimizeForInferenceTest(test.TestCase): graph_def, [], [add_name], dtypes.float32.as_datatype_enum) self.assertProtoEquals(expected_output, output) + @test_util.run_deprecated_v1 def testFoldBatchNorms(self): with self.cached_session() as sess: inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] @@ -171,6 +172,7 @@ class OptimizeForInferenceTest(test.TestCase): for node in optimized_graph_def.node: self.assertNotEqual("BatchNormWithGlobalNormalization", node.op) + @test_util.run_deprecated_v1 def testFoldFusedBatchNorms(self): for data_format, use_gpu in [("NHWC", False), ("NCHW", True)]: with self.cached_session(use_gpu=use_gpu) as sess: @@ -222,6 +224,7 @@ class OptimizeForInferenceTest(test.TestCase): for node in optimized_graph_def.node: self.assertNotEqual("FusedBatchNorm", node.op) + @test_util.run_deprecated_v1 def testFuseResizePadAndConv(self): with self.cached_session() as sess: inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] @@ -253,6 +256,7 @@ class OptimizeForInferenceTest(test.TestCase): self.assertNotEqual("MirrorPad", node.op) self.assertNotEqual("ResizeBilinear", node.op) + @test_util.run_deprecated_v1 def testFuseResizeAndConv(self): with self.cached_session() as sess: inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] @@ -282,6 +286,7 @@ class OptimizeForInferenceTest(test.TestCase): self.assertNotEqual("MirrorPad", node.op) + @test_util.run_deprecated_v1 def testFusePadAndConv(self): with self.cached_session() as sess: inputs = [1, 4, 2, 5, 3, 6, -1, -4, -2, -5, -3, -6] diff --git a/tensorflow/python/training/adadelta_test.py b/tensorflow/python/training/adadelta_test.py index 7cbaf1039f9..0e5af5a9222 100644 --- a/tensorflow/python/training/adadelta_test.py +++ b/tensorflow/python/training/adadelta_test.py @@ -166,6 +166,7 @@ class AdadeltaOptimizerTest(test.TestCase): with context.eager_mode(): self.doTestBasic(use_resource=True, use_callable_params=True) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/training/adagrad_da_test.py b/tensorflow/python/training/adagrad_da_test.py index c7c47206a9c..aacfe6faf4e 100644 --- a/tensorflow/python/training/adagrad_da_test.py +++ b/tensorflow/python/training/adagrad_da_test.py @@ -22,6 +22,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -73,12 +74,15 @@ class AdagradDAOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.094821, -0.189358]), v1_val) + @test_util.run_deprecated_v1 def testAdagradDAWithoutRegularizationBasic1(self): self.doTestAdagradDAwithoutRegularizationBasic1() + @test_util.run_deprecated_v1 def testResourceAdagradDAWithoutRegularizationBasic1(self): self.doTestAdagradDAwithoutRegularizationBasic1(use_resource=True) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -100,6 +104,7 @@ class AdagradDAOptimizerTest(test.TestCase): self.evaluate(var0), rtol=0.01) + @test_util.run_deprecated_v1 def testAdagradDAwithoutRegularizationBasic2(self): for dtype in [dtypes.float64, dtypes.float32]: with self.cached_session() as sess: @@ -132,6 +137,7 @@ class AdagradDAOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.094821, -0.189358]), v1_val) + @test_util.run_deprecated_v1 def testAdagradDAWithL1(self): for dtype in [dtypes.float64, dtypes.float32]: with self.cached_session() as sess: @@ -164,6 +170,7 @@ class AdagradDAOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.085339, -0.17989]), v1_val) + @test_util.run_deprecated_v1 def testAdagradDAWithL1_L2(self): for dtype in [dtypes.float64, dtypes.float32]: with self.cached_session() as sess: diff --git a/tensorflow/python/training/adagrad_test.py b/tensorflow/python/training/adagrad_test.py index 962e65c41f5..da26fcdb7f6 100644 --- a/tensorflow/python/training/adagrad_test.py +++ b/tensorflow/python/training/adagrad_test.py @@ -96,6 +96,7 @@ class AdagradOptimizerTest(test.TestCase): def testBasicLocked(self): self.doTestBasic(use_locking=True) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -116,6 +117,7 @@ class AdagradOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -142,6 +144,7 @@ class AdagradOptimizerTest(test.TestCase): np.array([2.715679168701172, 3.715679168701172]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseBasic(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -173,6 +176,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([[3.0], [3.715679168701172]]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseRepeatedIndices(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -203,6 +207,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllClose(aggregated_update_var.eval(), self.evaluate(repeated_index_update_var)) + @test_util.run_deprecated_v1 def testSparseRepeatedIndicesResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -227,6 +232,7 @@ class AdagradOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( self.evaluate(var_repeated), self.evaluate(var_aggregated)) + @test_util.run_deprecated_v1 def testSparseStability(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -263,6 +269,7 @@ class AdagradOptimizerTest(test.TestCase): -0.01029443 ]]), self.evaluate(var0)) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -299,6 +306,7 @@ class AdagradOptimizerTest(test.TestCase): np.array([2.715679168701172, 3.715679168701172]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testDynamicShapeVariable_Ok(self): with self.cached_session(): v = variable_scope.get_variable("v", initializer=constant_op.constant(1.), @@ -307,6 +315,7 @@ class AdagradOptimizerTest(test.TestCase): # Creating optimizer should cause no exception. adagrad.AdagradOptimizer(3.0, initial_accumulator_value=0.1) + @test_util.run_deprecated_v1 def testDynamicShapeVariableWithCallableInit(self): var0 = variable_scope.get_variable("var0", initializer=constant_op.constant(1.), diff --git a/tensorflow/python/training/adam_test.py b/tensorflow/python/training/adam_test.py index 87dad0a8a65..b0bae275773 100644 --- a/tensorflow/python/training/adam_test.py +++ b/tensorflow/python/training/adam_test.py @@ -102,12 +102,15 @@ class AdamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparse(self): self.doTestSparse(use_resource=False) + @test_util.run_deprecated_v1 def testResourceSparse(self): self.doTestSparse(use_resource=True) + @test_util.run_deprecated_v1 def testSparseDevicePlacement(self): for index_dtype in [dtypes.int32, dtypes.int64]: with self.cached_session(force_gpu=test.is_gpu_available()): @@ -121,6 +124,7 @@ class AdamOptimizerTest(test.TestCase): variables.global_variables_initializer().run() minimize_op.run() + @test_util.run_deprecated_v1 def testSparseRepeatedIndices(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -236,6 +240,7 @@ class AdamOptimizerTest(test.TestCase): with context.eager_mode(): self.doTestBasic(use_resource=True, use_callable_params=True) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -274,6 +279,7 @@ class AdamOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/training/basic_loops_test.py b/tensorflow/python/training/basic_loops_test.py index 5f5718e64a6..511a8334d56 100644 --- a/tensorflow/python/training/basic_loops_test.py +++ b/tensorflow/python/training/basic_loops_test.py @@ -23,6 +23,7 @@ import shutil from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.training import basic_loops from tensorflow.python.training import supervisor @@ -37,6 +38,7 @@ def _test_dir(test_name): class BasicTrainLoopTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasicTrainLoop(self): logdir = _test_dir("basic_train_loop") sv = supervisor.Supervisor(logdir=logdir) @@ -55,6 +57,7 @@ class BasicTrainLoopTest(test.TestCase): sv, train_fn, args=(sv, "y"), kwargs={"a": "A"}) self.assertEqual(3, num_calls[0]) + @test_util.run_deprecated_v1 def testBasicTrainLoopExceptionAborts(self): logdir = _test_dir("basic_train_loop_exception_aborts") sv = supervisor.Supervisor(logdir=logdir) @@ -71,6 +74,7 @@ class BasicTrainLoopTest(test.TestCase): with self.assertRaisesRegexp(RuntimeError, "Failed"): basic_loops.basic_train_loop(sv, train_fn) + @test_util.run_deprecated_v1 def testBasicTrainLoopRetryOnAborted(self): logdir = _test_dir("basic_train_loop_exception_aborts") sv = supervisor.Supervisor(logdir=logdir) diff --git a/tensorflow/python/training/basic_session_run_hooks_test.py b/tensorflow/python/training/basic_session_run_hooks_test.py index 03810b57e37..8e54a14f47c 100644 --- a/tensorflow/python/training/basic_session_run_hooks_test.py +++ b/tensorflow/python/training/basic_session_run_hooks_test.py @@ -34,6 +34,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import state_ops @@ -91,10 +92,12 @@ class MockCheckpointSaverListener( class SecondOrStepTimerTest(test.TestCase): + @test_util.run_deprecated_v1 def test_raise_in_both_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.SecondOrStepTimer(every_secs=2.0, every_steps=10) + @test_util.run_deprecated_v1 def test_raise_in_none_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.SecondOrStepTimer() @@ -413,11 +416,13 @@ class CheckpointSaverHookTest(test.TestCase): basic_session_run_hooks.CheckpointSaverHook( self.model_dir, saver=self.scaffold.saver, scaffold=self.scaffold) + @test_util.run_deprecated_v1 def test_raise_in_both_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.CheckpointSaverHook( self.model_dir, save_secs=10, save_steps=20) + @test_util.run_deprecated_v1 def test_raise_in_none_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.CheckpointSaverHook(self.model_dir) @@ -1143,11 +1148,13 @@ class SummarySaverHookTest(test.TestCase): basic_session_run_hooks.SummarySaverHook( scaffold=monitored_session.Scaffold(), summary_op=self.summary_op) + @test_util.run_deprecated_v1 def test_raise_in_both_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.SummarySaverHook( save_secs=10, save_steps=20, summary_writer=self.summary_writer) + @test_util.run_deprecated_v1 def test_raise_in_none_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.SummarySaverHook( @@ -1478,10 +1485,12 @@ class ProfilerHookTest(test.TestCase): def _count_timeline_files(self): return len(gfile.Glob(self.filepattern)) + @test_util.run_deprecated_v1 def test_raise_in_both_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.ProfilerHook(save_secs=10, save_steps=20) + @test_util.run_deprecated_v1 def test_raise_in_none_secs_and_steps(self): with self.assertRaises(ValueError): basic_session_run_hooks.ProfilerHook(save_secs=None, save_steps=None) diff --git a/tensorflow/python/training/checkpoint_management_test.py b/tensorflow/python/training/checkpoint_management_test.py index b61ed17531a..8606ec4a206 100644 --- a/tensorflow/python/training/checkpoint_management_test.py +++ b/tensorflow/python/training/checkpoint_management_test.py @@ -62,6 +62,7 @@ class LatestCheckpointWithRelativePaths(test.TestCase): finally: shutil.rmtree(tempdir) + @test_util.run_deprecated_v1 def testNameCollision(self): # Make sure we have a clean directory to work in. with self.tempDir() as tempdir: @@ -99,6 +100,7 @@ class LatestCheckpointWithRelativePaths(test.TestCase): self.assertIsNotNone( checkpoint_management.latest_checkpoint(traindir)) + @test_util.run_deprecated_v1 def testRelativePath(self): # Make sure we have a clean directory to work in. with self.tempDir() as tempdir: @@ -270,6 +272,7 @@ class SaverUtilsTest(test.TestCase): def tearDown(self): gfile.DeleteRecursively(self._base_dir) + @test_util.run_deprecated_v1 def testCheckpointExists(self): for sharded in (False, True): for version in (saver_pb2.SaverDef.V2, saver_pb2.SaverDef.V1): @@ -288,6 +291,7 @@ class SaverUtilsTest(test.TestCase): ckpt_prefix = checkpoint_management.latest_checkpoint(self._base_dir) self.assertTrue(checkpoint_management.checkpoint_exists(ckpt_prefix)) + @test_util.run_deprecated_v1 def testGetCheckpointMtimes(self): prefixes = [] for version in (saver_pb2.SaverDef.V2, saver_pb2.SaverDef.V1): @@ -302,6 +306,7 @@ class SaverUtilsTest(test.TestCase): self.assertEqual(2, len(mtimes)) self.assertTrue(mtimes[1] >= mtimes[0]) + @test_util.run_deprecated_v1 def testRemoveCheckpoint(self): for sharded in (False, True): for version in (saver_pb2.SaverDef.V2, saver_pb2.SaverDef.V1): diff --git a/tensorflow/python/training/device_setter_test.py b/tensorflow/python/training/device_setter_test.py index 85b75502ab0..3cff87b326f 100644 --- a/tensorflow/python/training/device_setter_test.py +++ b/tensorflow/python/training/device_setter_test.py @@ -19,6 +19,7 @@ from __future__ import division from __future__ import print_function from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import resource_variable_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -33,6 +34,7 @@ class DeviceSetterTest(test.TestCase): "worker": ["worker0:2222", "worker1:2222", "worker2:2222"] }) + @test_util.run_deprecated_v1 def testCPUOverride(self): with ops.device( device_setter.replica_device_setter(cluster=self._cluster_spec)): @@ -47,12 +49,14 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps/task:1", w.initializer.device) self.assertDeviceEqual("/job:worker/cpu:0", a.device) + @test_util.run_deprecated_v1 def testResource(self): with ops.device( device_setter.replica_device_setter(cluster=self._cluster_spec)): v = resource_variable_ops.ResourceVariable([1, 2]) self.assertDeviceEqual("/job:ps/task:0", v.device) + @test_util.run_deprecated_v1 def testPS2TasksWithClusterSpecClass(self): with ops.device( device_setter.replica_device_setter(cluster=self._cluster_spec)): @@ -65,6 +69,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps/task:1", w.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksPinVariableToJob(self): with ops.device( device_setter.replica_device_setter(cluster=self._cluster_spec)): @@ -82,6 +87,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps/task:1", x.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksUseCpuForPS(self): with ops.device( device_setter.replica_device_setter(ps_tasks=1, ps_device="/cpu:0")): @@ -95,6 +101,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:moon/cpu:0", w.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksNoMerging(self): with ops.device( device_setter.replica_device_setter( @@ -109,6 +116,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps", w.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksWithClusterSpecDict(self): with ops.device( device_setter.replica_device_setter(cluster=self._cluster_spec.as_dict( @@ -122,6 +130,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps/task:1", w.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksWithClusterDef(self): with ops.device( device_setter.replica_device_setter( @@ -135,6 +144,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:ps/task:1", w.initializer.device) self.assertDeviceEqual("/job:worker", a.device) + @test_util.run_deprecated_v1 def testPS2TasksWithDevice(self): cluster_spec = server_lib.ClusterSpec({ "sun": ["sun0:2222", "sun1:2222", "sun2:2222"], @@ -155,6 +165,7 @@ class DeviceSetterTest(test.TestCase): self.assertDeviceEqual("/job:moon/task:1", w.initializer.device) self.assertDeviceEqual("/job:sun", a.device) + @test_util.run_deprecated_v1 def testPS2TasksWithCPUConstraint(self): cluster_spec = server_lib.ClusterSpec({ "sun": ["sun0:2222", "sun1:2222", "sun2:2222"], diff --git a/tensorflow/python/training/ftrl_test.py b/tensorflow/python/training/ftrl_test.py index 70b5db31f80..39b299c64a3 100644 --- a/tensorflow/python/training/ftrl_test.py +++ b/tensorflow/python/training/ftrl_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -68,12 +69,15 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.28432083, -0.56694895]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithoutRegularization(self): self.doTestFtrlwithoutRegularization(use_resource=False) + @test_util.run_deprecated_v1 def testResourceFtrlWithoutRegularization(self): self.doTestFtrlwithoutRegularization(use_resource=True) + @test_util.run_deprecated_v1 def testFtrlwithoutRegularization2(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -103,6 +107,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.28232238, -0.56096673]), v1_val) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -121,6 +126,7 @@ class FtrlOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testFtrlWithL1(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -150,6 +156,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.93460727, -1.86147261]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session() as sess: @@ -180,6 +187,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.02406147, -0.04830509]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2_L2Shrinkage(self): """Test the new FTRL op with support for l2 shrinkage. @@ -217,6 +225,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType( np.array([-0.14378493, -0.13229476]), v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL1_L2_L2ShrinkageSparse(self): """Tests the new FTRL op with support for l2 shrinkage on sparse grads.""" for dtype in [dtypes.half, dtypes.float32]: @@ -251,6 +260,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([[-0.22578995], [2.]], v0_val) self.assertAllCloseAccordingToType([[4.], [-0.13229476]], v1_val) + @test_util.run_deprecated_v1 def testFtrlWithL2ShrinkageDoesNotChangeLrSchedule(self): """Verifies that l2 shrinkage in FTRL does not change lr schedule.""" for dtype in [dtypes.half, dtypes.float32]: @@ -335,6 +345,7 @@ class FtrlOptimizerTest(test.TestCase): # with Adagrad. # So, basing on these two properties, we test if our implementation of # FTRL-Proximal performs same updates as Adagrad or GradientDescent. + @test_util.run_deprecated_v1 def testEquivAdagradwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -355,6 +366,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivSparseAdagradwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -378,6 +390,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivSparseGradientDescentwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): @@ -401,6 +414,7 @@ class FtrlOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(val0, val2) self.assertAllCloseAccordingToType(val1, val3) + @test_util.run_deprecated_v1 def testEquivGradientDescentwithoutRegularization(self): for dtype in [dtypes.half, dtypes.float32]: with self.cached_session(): diff --git a/tensorflow/python/training/gradient_descent_test.py b/tensorflow/python/training/gradient_descent_test.py index 2028e7b4b09..5a6c5cfa747 100644 --- a/tensorflow/python/training/gradient_descent_test.py +++ b/tensorflow/python/training/gradient_descent_test.py @@ -24,6 +24,7 @@ from tensorflow.python.eager import function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -35,6 +36,7 @@ from tensorflow.python.training import gradient_descent class GradientDescentOptimizerTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -58,6 +60,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.evaluate(var1)) self.assertEqual(0, len(optimizer.variables())) + @test_util.run_deprecated_v1 def testBasicResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -83,6 +86,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([3.0 - 3.0 * 0.01, 4.0 - 3.0 * 0.01], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testBasicCallableParams(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -109,6 +113,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([3.0 - 3.0 * 0.01, 4.0 - 3.0 * 0.01], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -135,6 +140,7 @@ class GradientDescentOptimizerTest(test.TestCase): [[1.0 - np_grad * 4.0, 2.0 - np_grad * 5.0]], self.evaluate(var0)) self.assertAllCloseAccordingToType([3.0 - np_grad], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -162,6 +168,7 @@ class GradientDescentOptimizerTest(test.TestCase): [[1.0 - np_grad * 4.0, 2.0 - np_grad * 5.0]], self.evaluate(var0)) self.assertAllCloseAccordingToType([3.0 - np_grad], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testTensorLearningRate(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -184,6 +191,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType([3.0 - 3.0 * 0.01, 4.0 - 3.0 * 0.01], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testGradWrtRef(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -195,6 +203,7 @@ class GradientDescentOptimizerTest(test.TestCase): for grad, _ in grads_and_vars: self.assertAllCloseAccordingToType([1.0], self.evaluate(grad)) + @test_util.run_deprecated_v1 def testWithGlobalStep(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -218,6 +227,7 @@ class GradientDescentOptimizerTest(test.TestCase): self.evaluate(var1)) self.assertAllCloseAccordingToType(1, self.evaluate(global_step)) + @test_util.run_deprecated_v1 def testSparseBasic(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/training/input_test.py b/tensorflow/python/training/input_test.py index 327f0871383..a3d268a0174 100644 --- a/tensorflow/python/training/input_test.py +++ b/tensorflow/python/training/input_test.py @@ -28,6 +28,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import sparse_tensor +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables @@ -41,6 +42,7 @@ from tensorflow.python.util import compat class MatchFilenamesOnceTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def test(self): temp_dir = self.get_temp_dir() filenames = [os.path.join(temp_dir, n) for n in os.listdir(temp_dir)] @@ -68,6 +70,7 @@ class MatchFilenamesOnceTest(test_lib.TestCase): class LimitEpochsTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testNoLimit(self): with self.cached_session(): seven = constant_op.constant(7) @@ -76,6 +79,7 @@ class LimitEpochsTest(test_lib.TestCase): for _ in range(100): self.assertEqual(7, self.evaluate(seven_forever)) + @test_util.run_deprecated_v1 def testLimit(self): with self.cached_session(): love_me = constant_op.constant("Love Me") @@ -90,6 +94,7 @@ class LimitEpochsTest(test_lib.TestCase): class InputProducerTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testNoShuffle(self): with self.cached_session(): input_tensor = [[1, 2, 3, 4], @@ -114,6 +119,7 @@ class InputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testNoShapeInference(self): with self.cached_session(): # Disable shape inference for the input. @@ -139,6 +145,7 @@ class InputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testShapeError(self): input_tensor = array_ops.placeholder(dtypes.float32, None) with self.assertRaisesRegexp(ValueError, "fully defined shape"): @@ -147,6 +154,7 @@ class InputProducerTest(test_lib.TestCase): class StringInputProducerTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testNoShuffle(self): with self.cached_session(): strings = [b"to", b"be", b"or", b"not", b"to", b"be"] @@ -169,6 +177,7 @@ class StringInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testShuffle(self): with self.cached_session(): strings = [b"a", b"b", b"c"] @@ -214,6 +223,7 @@ class StringInputProducerTest(test_lib.TestCase): with self.assertRaises(ValueError): _ = inp.string_input_producer([]) + @test_util.run_deprecated_v1 def testNullString(self): # Runtime check for empty string list. This is slightly oblique: # The queue runner should die with an assertion error on the null @@ -233,6 +243,7 @@ class StringInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): strings = [b"to", b"be", b"or", b"not", b"to", b"be"] @@ -241,6 +252,7 @@ class StringInputProducerTest(test_lib.TestCase): self.assertProtoEquals("s: 'SHARED_NAME_XYZ'", queue.queue_ref.op.node_def.attr["shared_name"]) + @test_util.run_deprecated_v1 def testConstructionRace(self): with self.cached_session() as sess: strings = [b"to", b"be", b"or", b"not", b"to", b"be"] @@ -263,6 +275,7 @@ class StringInputProducerTest(test_lib.TestCase): class RangeInputProducerTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testNoShuffle(self): with self.cached_session(): num_epochs = 3 @@ -285,6 +298,7 @@ class RangeInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testShuffle(self): with self.cached_session(): num_epochs = 200 @@ -324,6 +338,7 @@ class RangeInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): range_size = 5 @@ -335,6 +350,7 @@ class RangeInputProducerTest(test_lib.TestCase): class SliceInputProducerTest(test_lib.TestCase): + @test_util.run_deprecated_v1 def testNoShuffle(self): with self.cached_session() as sess: num_epochs = 3 @@ -359,6 +375,7 @@ class SliceInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testShuffle(self): with self.cached_session() as sess: num_epochs = 1200 @@ -403,6 +420,7 @@ class SliceInputProducerTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): source_strings = ["A", "B", "D", "G"] @@ -495,12 +513,15 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testOneThread(self): self._testOneThreadHelper(use_dict=False) + @test_util.run_deprecated_v1 def testOneThreadDict(self): self._testOneThreadHelper(use_dict=True) + @test_util.run_deprecated_v1 def testUint32DataTypes(self): values = constant_op.constant([0, 1, 2, 3, 4, 5], dtype=dtypes.uint32) batched = inp.batch([values], batch_size=2) @@ -512,6 +533,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testUint64DataTypes(self): values = constant_op.constant([0, 1, 2, 3, 4, 5], dtype=dtypes.uint64) batched = inp.batch([values], batch_size=2) @@ -523,6 +545,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testOneThreadDynamicPad(self): with self.cached_session() as sess: batch_size = 10 @@ -553,6 +576,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testOneThreadEnqueueMany(self): with self.cached_session() as sess: batch_size = 10 @@ -588,6 +612,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testManyThreads(self): with self.cached_session() as sess: batch_size = 10 @@ -628,6 +653,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testOneThreadSmallerBatch(self): with self.cached_session() as sess: batch_size = 10 @@ -685,6 +711,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testManyThreadsSmallerBatch(self): with self.cached_session() as sess: batch_size = 10 @@ -740,6 +767,7 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): batch_size = 10 @@ -757,12 +785,14 @@ class BatchTest(test_lib.TestCase): "s: 'SHARED_NAME_XYZ'", batched[0].op.inputs[0].op.node_def.attr["shared_name"]) + @test_util.run_deprecated_v1 def testCannotInferRankError(self): with self.cached_session(): x = array_ops.placeholder(dtype=dtypes.int64) with self.assertRaisesRegexp(ValueError, "Cannot infer Tensor's rank"): inp.batch([x], batch_size=2) + @test_util.run_deprecated_v1 def testBatchedSparseTensorInferredShape(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -770,6 +800,7 @@ class BatchTest(test_lib.TestCase): batched = inp.batch([sparse], batch_size=2) self.assertAllEqual((2,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testBatchedSparseTensorInferredShapeEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -777,6 +808,7 @@ class BatchTest(test_lib.TestCase): batched = inp.batch([sparse], batch_size=2, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testBatchedSparseTensorInferredShapeUnknownRank(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -786,6 +818,7 @@ class BatchTest(test_lib.TestCase): batched = inp.batch([sparse], batch_size=2) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testBatchedSparseTensorInferredShapeUnknownRankEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -795,6 +828,7 @@ class BatchTest(test_lib.TestCase): batched = inp.batch([sparse], batch_size=2, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testSingleElementDict(self): x = inp.batch({"c": [12, 12]}, batch_size=8) self.assertAllEqual((8, 2), x["c"].get_shape().as_list()) @@ -838,24 +872,31 @@ class BatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSingleThreadKeepInput(self): self._testKeepInputHelper(1, False) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(1, True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInput(self): self._testKeepInputHelper(5, False) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(5, True) + @test_util.run_deprecated_v1 def testMaybeEnqueuePerExample(self): self._testKeepInputHelper(1, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testMultipleThreadMaybeEnqueuePerExample(self): self._testKeepInputHelper(5, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testInvalidKeepInputVector(self): # Can't have vector `keep_input` with `enqueue_many=False`. with self.assertRaisesRegexp(ValueError, "`keep_input` cannot be a vector"): @@ -877,6 +918,7 @@ class BatchTest(test_lib.TestCase): batch_size=1, enqueue_many=True) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShape(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -884,6 +926,7 @@ class BatchTest(test_lib.TestCase): batched = inp.maybe_batch([sparse], keep_input=True, batch_size=2) self.assertAllEqual((2,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -892,6 +935,7 @@ class BatchTest(test_lib.TestCase): [sparse], keep_input=True, batch_size=2, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueManyPerExample(self): sparse = sparse_tensor.SparseTensor( indices=[[0], [0]], values=[1.0, 2.0], dense_shape=[2]) @@ -900,6 +944,7 @@ class BatchTest(test_lib.TestCase): [sparse], keep_input=[True, False], batch_size=2, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRank(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -909,6 +954,7 @@ class BatchTest(test_lib.TestCase): batched = inp.maybe_batch([sparse], keep_input=True, batch_size=2) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -919,6 +965,7 @@ class BatchTest(test_lib.TestCase): [sparse], keep_input=True, batch_size=2, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankPerExample(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -929,6 +976,7 @@ class BatchTest(test_lib.TestCase): [sparse], keep_input=[True, False], batch_size=2, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchCorrectValues(self): sparse_t = sparse_tensor.SparseTensor( indices=[[0, 1], [0, 2], [1, 0], [1, 3]], @@ -1055,12 +1103,15 @@ class BatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testTwoThreads(self): self._testTwoThreadsHelper(use_dict=False) + @test_util.run_deprecated_v1 def testTwoThreadsDict(self): self._testTwoThreadsHelper(use_dict=True) + @test_util.run_deprecated_v1 def testMismatchedDictKeys(self): with self.assertRaisesRegexp(ValueError, "must have the same keys"): inp.batch_join( @@ -1075,6 +1126,7 @@ class BatchJoinTest(test_lib.TestCase): }], batch_size=8) + @test_util.run_deprecated_v1 def testTwoThreadsDynamicPad(self): with self.cached_session() as sess: # Two threads, the first generates (0..69, ["a"] * 1..70). @@ -1152,6 +1204,7 @@ class BatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testTwoThreadsSmallerBatch(self): with self.cached_session() as sess: extra_elements = 2 @@ -1253,6 +1306,7 @@ class BatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testTwoThreadsDynamicPadSmallerBatch(self): with self.cached_session() as sess: extra_elements = 2 @@ -1351,6 +1405,7 @@ class BatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): batch_size = 10 @@ -1373,12 +1428,14 @@ class BatchJoinTest(test_lib.TestCase): "s: 'SHARED_NAME_XYZ'", batched[0].op.inputs[0].op.node_def.attr["shared_name"]) + @test_util.run_deprecated_v1 def testCannotInferRankError(self): with self.cached_session(): x = array_ops.placeholder(dtype=dtypes.int64) with self.assertRaisesRegexp(ValueError, "Cannot infer Tensor's rank"): inp.batch_join([[x]], batch_size=2) + @test_util.run_deprecated_v1 def testSingleElementDict(self): x = inp.batch_join([{"c": [12, 12]}], batch_size=8) self.assertAllEqual((8, 2), x["c"].get_shape().as_list()) @@ -1425,24 +1482,31 @@ class BatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSingleThreadKeepInput(self): self._testKeepInputHelper(1, False) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(1, True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInput(self): self._testKeepInputHelper(5, False) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(5, True) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputPerExample(self): self._testKeepInputHelper(1, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputPerExample(self): self._testKeepInputHelper(5, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testInvalidKeepInputVector(self): # Can't have vector `keep_input` with `enqueue_many=False`. with self.assertRaisesRegexp(ValueError, "`keep_input` cannot be a vector"): @@ -1464,6 +1528,7 @@ class BatchJoinTest(test_lib.TestCase): batch_size=1, enqueue_many=True) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShape(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -1471,6 +1536,7 @@ class BatchJoinTest(test_lib.TestCase): batched = inp.maybe_batch_join([[sparse]], keep_input=True, batch_size=2) self.assertAllEqual((2,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -1479,6 +1545,7 @@ class BatchJoinTest(test_lib.TestCase): [[sparse]], keep_input=True, batch_size=2, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueManyPerExample(self): sparse = sparse_tensor.SparseTensor( indices=[[0], [0]], values=[1.0, 2.0], dense_shape=[2]) @@ -1487,6 +1554,7 @@ class BatchJoinTest(test_lib.TestCase): [[sparse]], keep_input=[True, False], batch_size=2, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRank(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -1496,6 +1564,7 @@ class BatchJoinTest(test_lib.TestCase): batched = inp.maybe_batch_join([[sparse]], keep_input=True, batch_size=2) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -1506,6 +1575,7 @@ class BatchJoinTest(test_lib.TestCase): [[sparse]], keep_input=True, batch_size=2, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankPerExample(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -1516,6 +1586,7 @@ class BatchJoinTest(test_lib.TestCase): [[sparse]], keep_input=[True, False], batch_size=2, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchCorrectValues(self): sparse = sparse_tensor.SparseTensor( indices=[[0, 1], [0, 2], [1, 0], [1, 3]], @@ -1601,12 +1672,15 @@ class ShuffleBatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testOneThread(self): self._testOneThreadHelper(use_dict=False) + @test_util.run_deprecated_v1 def testOneThreadDict(self): self._testOneThreadHelper(use_dict=True) + @test_util.run_deprecated_v1 def testOneThreadSmallerBatch(self): with self.cached_session() as sess: batch_size = 10 @@ -1663,6 +1737,7 @@ class ShuffleBatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testManyThreads(self): with self.cached_session() as sess: batch_size = 10 @@ -1710,6 +1785,7 @@ class ShuffleBatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testManyThreadsSmallerBatch(self): with self.cached_session() as sess: batch_size = 10 @@ -1768,6 +1844,7 @@ class ShuffleBatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): batch_size = 10 @@ -1828,24 +1905,31 @@ class ShuffleBatchTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSingleThreadKeepInput(self): self._testKeepInputHelper(1, False) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(1, True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInput(self): self._testKeepInputHelper(5, False) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(5, True) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputPerExample(self): self._testKeepInputHelper(1, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputPerExample(self): self._testKeepInputHelper(5, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testInvalidKeepInputVector(self): # Can't have vector `keep_input` with `enqueue_many=False`. with self.assertRaisesRegexp(ValueError, "`keep_input` cannot be a vector"): @@ -1864,6 +1948,7 @@ class ShuffleBatchTest(test_lib.TestCase): keep_input=array_ops.placeholder(dtypes.bool), enqueue_many=True) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShape(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -1871,6 +1956,7 @@ class ShuffleBatchTest(test_lib.TestCase): batched = inp.maybe_shuffle_batch([sparse], 2, 10, 1, True) self.assertAllEqual((2,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -1879,6 +1965,7 @@ class ShuffleBatchTest(test_lib.TestCase): [sparse], 2, 10, 1, True, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueManyPerExample(self): sparse = sparse_tensor.SparseTensor( indices=[[0], [0]], values=[1.0, 2.0], dense_shape=[2]) @@ -1887,6 +1974,7 @@ class ShuffleBatchTest(test_lib.TestCase): [sparse], 2, 10, 1, [True, False], enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRank(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -1896,6 +1984,7 @@ class ShuffleBatchTest(test_lib.TestCase): batched = inp.maybe_shuffle_batch([sparse], 2, 10, 1, True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -1906,6 +1995,7 @@ class ShuffleBatchTest(test_lib.TestCase): [sparse], 2, 10, 1, True, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankPerExample(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -2024,12 +2114,15 @@ class ShuffleBatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testTwoThreads(self): self._testTwoThreadsHelper(use_dict=False) + @test_util.run_deprecated_v1 def testTwoThreadsDict(self): self._testTwoThreadsHelper(use_dict=True) + @test_util.run_deprecated_v1 def testTwoThreadsSmallerBatch(self): with self.cached_session() as sess: # Two threads, the first generates (0..26, "a"). @@ -2133,6 +2226,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testMismatchedDictKeys(self): with self.assertRaisesRegexp(ValueError, "must have the same keys"): inp.shuffle_batch_join( @@ -2150,6 +2244,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): min_after_dequeue=16, seed=223607) + @test_util.run_deprecated_v1 def testSharedName(self): with self.cached_session(): batch_size = 10 @@ -2214,24 +2309,31 @@ class ShuffleBatchJoinTest(test_lib.TestCase): for thread in threads: thread.join() + @test_util.run_deprecated_v1 def testSingleThreadKeepInput(self): self._testKeepInputHelper(1, False) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(1, True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInput(self): self._testKeepInputHelper(5, False) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputEnqueueMany(self): self._testKeepInputHelper(5, True) + @test_util.run_deprecated_v1 def testSingleThreadKeepInputPerExample(self): self._testKeepInputHelper(1, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testMultipleThreadKeepInputPerExample(self): self._testKeepInputHelper(5, True, keep_input_vector=True) + @test_util.run_deprecated_v1 def testInvalidKeepInputVector(self): # Can't have vector `keep_input` with `enqueue_many=False`. with self.assertRaisesRegexp(ValueError, "`keep_input` cannot be a vector"): @@ -2253,6 +2355,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): keep_input=array_ops.placeholder(dtypes.bool), enqueue_many=True) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShape(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -2260,6 +2363,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): batched = inp.maybe_shuffle_batch_join([[sparse]], 2, 10, 1, True) self.assertAllEqual((2,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=[[0]], values=[1.0], dense_shape=[1]) @@ -2268,6 +2372,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): [[sparse]], 2, 10, 1, True, enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeEnqueueManyPerExample(self): sparse = sparse_tensor.SparseTensor( indices=[[0], [0]], values=[1.0, 2.0], dense_shape=[2]) @@ -2276,6 +2381,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): [[sparse]], 2, 10, 1, [True, False], enqueue_many=True) self.assertAllEqual((1,), batched.dense_shape.get_shape().as_list()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRank(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -2285,6 +2391,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): batched = inp.maybe_shuffle_batch_join([[sparse]], 2, 10, 1, True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankEnqueueMany(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), @@ -2295,6 +2402,7 @@ class ShuffleBatchJoinTest(test_lib.TestCase): [[sparse]], 2, 10, 1, True, enqueue_many=True) self.assertIs(None, batched.dense_shape.get_shape().num_elements()) + @test_util.run_deprecated_v1 def testMaybeBatchedSparseTensorInferredShapeUnknownRankPerExample(self): sparse = sparse_tensor.SparseTensor( indices=array_ops.placeholder(dtypes.int64), diff --git a/tensorflow/python/training/learning_rate_decay_test.py b/tensorflow/python/training/learning_rate_decay_test.py index 9c31c0924f5..9de5bc8168f 100644 --- a/tensorflow/python/training/learning_rate_decay_test.py +++ b/tensorflow/python/training/learning_rate_decay_test.py @@ -61,6 +61,7 @@ class LRDecayTest(test_util.TensorFlowTestCase): self.evaluate(step.assign(100)) self.assertAllClose(self.evaluate(decayed_lr), expected, 1e-6) + @test_util.run_deprecated_v1 def testVariables(self): step = variables.VariableV1(1) assign_1 = step.assign(1) @@ -100,6 +101,7 @@ class LRDecayTest(test_util.TensorFlowTestCase): self.assertAllClose(self.evaluate(decayed_lr), 0.001, 1e-6) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testPiecewiseConstantEdgeCases(self): x_int = resource_variable_ops.ResourceVariable( 0, dtype=variables.dtypes.int32) diff --git a/tensorflow/python/training/learning_rate_decay_v2_test.py b/tensorflow/python/training/learning_rate_decay_v2_test.py index 354ddb25be5..cb96773e299 100644 --- a/tensorflow/python/training/learning_rate_decay_v2_test.py +++ b/tensorflow/python/training/learning_rate_decay_v2_test.py @@ -61,6 +61,7 @@ class LRDecayTestV2(test_util.TensorFlowTestCase): self.evaluate(step.assign(100)) self.assertAllClose(self.evaluate(decayed_lr()), expected, 1e-6) + @test_util.run_deprecated_v1 def testVariables(self): step = variables.Variable(1) assign_1 = step.assign(1) diff --git a/tensorflow/python/training/momentum_test.py b/tensorflow/python/training/momentum_test.py index b6cac6addfb..ba155fa6c64 100644 --- a/tensorflow/python/training/momentum_test.py +++ b/tensorflow/python/training/momentum_test.py @@ -160,6 +160,7 @@ class MomentumOptimizerTest(test.TestCase): self.assertStartsWith(optimizer_variables[1].name, "var3") self.assertEquals(2, len(optimizer_variables)) + @test_util.run_deprecated_v1 def testNesterovMomentum(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -186,6 +187,7 @@ class MomentumOptimizerTest(test.TestCase): self.assertAllClose(var0_np, self.evaluate(var0)) self.assertAllClose(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testSparseNesterovMomentum(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -280,6 +282,7 @@ class MomentumOptimizerTest(test.TestCase): self.evaluate(sgd_op) self.assertAllCloseAccordingToType([[1, 1], [0, 0]], self.evaluate(var0)) + @test_util.run_deprecated_v1 def testTensorLearningRateAndMomentum(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -440,6 +443,7 @@ class MomentumOptimizerTest(test.TestCase): # pylint: enable=line-too-long return db_grad, db_out + @test_util.run_deprecated_v1 def testLikeDistBeliefMom01(self): with self.cached_session(): db_grad, db_out = self._dbParamsMom01() @@ -453,6 +457,7 @@ class MomentumOptimizerTest(test.TestCase): mom_update.run(feed_dict={grads0: db_grad[i]}) self.assertAllClose(np.array(db_out[i]), self.evaluate(var0)) + @test_util.run_deprecated_v1 def testSparse(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -534,6 +539,7 @@ class MomentumOptimizerTest(test.TestCase): ]), self.evaluate(var1)[2]) + @test_util.run_deprecated_v1 def testSharing(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): diff --git a/tensorflow/python/training/monitored_session_test.py b/tensorflow/python/training/monitored_session_test.py index 2ceb387ec34..9dbcfa52b7c 100644 --- a/tensorflow/python/training/monitored_session_test.py +++ b/tensorflow/python/training/monitored_session_test.py @@ -37,6 +37,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import resource_variable_ops @@ -504,6 +505,7 @@ class StopAtNSession(monitored_session._WrappedSession): class WrappedSessionTest(test.TestCase): """_WrappedSession tests.""" + @test_util.run_deprecated_v1 def test_properties(self): with self.cached_session() as sess: constant_op.constant(0.0) @@ -511,6 +513,7 @@ class WrappedSessionTest(test.TestCase): self.assertEquals(sess.graph, wrapped_sess.graph) self.assertEquals(sess.sess_str, wrapped_sess.sess_str) + @test_util.run_deprecated_v1 def test_should_stop_on_close(self): with self.cached_session() as sess: wrapped_sess = monitored_session._WrappedSession(sess) @@ -518,6 +521,7 @@ class WrappedSessionTest(test.TestCase): wrapped_sess.close() self.assertTrue(wrapped_sess.should_stop()) + @test_util.run_deprecated_v1 def test_should_stop_uses_check_stop(self): with self.cached_session() as sess: wrapped_sess = StopAtNSession(sess, 3) @@ -526,6 +530,7 @@ class WrappedSessionTest(test.TestCase): self.assertFalse(wrapped_sess.should_stop()) self.assertTrue(wrapped_sess.should_stop()) + @test_util.run_deprecated_v1 def test_should_stop_delegates_to_wrapped_session(self): with self.cached_session() as sess: wrapped_sess0 = StopAtNSession(sess, 4) @@ -544,6 +549,7 @@ class WrappedSessionTest(test.TestCase): wrapped_sess.close() self.assertTrue(wrapped_sess.should_stop()) + @test_util.run_deprecated_v1 def test_run(self): with self.cached_session() as sess: c = constant_op.constant(0) @@ -561,6 +567,7 @@ def busy_wait_for_coord_stop(coord): class CoordinatedSessionTest(test.TestCase): """_CoordinatedSession tests.""" + @test_util.run_deprecated_v1 def test_properties(self): with self.cached_session() as sess: constant_op.constant(0.0) @@ -569,6 +576,7 @@ class CoordinatedSessionTest(test.TestCase): self.assertEquals(sess.graph, coord_sess.graph) self.assertEquals(sess.sess_str, coord_sess.sess_str) + @test_util.run_deprecated_v1 def test_run(self): with self.cached_session() as sess: c = constant_op.constant(0) @@ -577,6 +585,7 @@ class CoordinatedSessionTest(test.TestCase): coord_sess = monitored_session._CoordinatedSession(sess, coord) self.assertEqual(42, coord_sess.run(v, feed_dict={c: 42})) + @test_util.run_deprecated_v1 def test_should_stop_on_close(self): with self.cached_session() as sess: coord = coordinator.Coordinator() @@ -585,6 +594,7 @@ class CoordinatedSessionTest(test.TestCase): coord_sess.close() self.assertTrue(coord_sess.should_stop()) + @test_util.run_deprecated_v1 def test_should_stop_on_coord_stop(self): with self.cached_session() as sess: coord = coordinator.Coordinator() @@ -593,6 +603,7 @@ class CoordinatedSessionTest(test.TestCase): coord.request_stop() self.assertTrue(coord_sess.should_stop()) + @test_util.run_deprecated_v1 def test_dont_request_stop_on_exception_in_main_thread(self): with self.cached_session() as sess: c = constant_op.constant(0) @@ -607,6 +618,7 @@ class CoordinatedSessionTest(test.TestCase): self.assertFalse(coord.should_stop()) self.assertFalse(coord_sess.should_stop()) + @test_util.run_deprecated_v1 def test_stop_threads_on_close_after_exception(self): with self.cached_session() as sess: c = constant_op.constant(0) @@ -654,6 +666,7 @@ class CoordinatedSessionTest(test.TestCase): self.assertTrue(coord.should_stop()) self.assertTrue(coord_sess.should_stop()) + @test_util.run_deprecated_v1 def test_propagates_exception_trace(self): assertion = control_flow_ops.Assert(False, ['This should fail.']) with self.cached_session() as sess: @@ -801,6 +814,7 @@ class RecoverableSessionTest(test.TestCase): def create_session(self): return self._sess + @test_util.run_deprecated_v1 def test_properties(self): with self.cached_session() as sess: constant_op.constant(0.0) @@ -809,6 +823,7 @@ class RecoverableSessionTest(test.TestCase): self.assertEquals(sess.graph, recoverable_sess.graph) self.assertEquals(sess.sess_str, recoverable_sess.sess_str) + @test_util.run_deprecated_v1 def test_run(self): with self.cached_session() as sess: c = constant_op.constant(0) @@ -817,6 +832,7 @@ class RecoverableSessionTest(test.TestCase): self._SessionReturner(sess)) self.assertEqual(51, recoverable_sess.run(v, feed_dict={c: 51})) + @test_util.run_deprecated_v1 def test_recovery(self): with self.cached_session() as sess: @@ -863,6 +879,7 @@ class RecoverableSessionTest(test.TestCase): with self.assertRaisesRegexp(IndexError, 'pop from empty list'): recoverable_sess.run(v, feed_dict={c: -12}) + @test_util.run_deprecated_v1 def test_recovery_from_coordinator_exception(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -888,6 +905,7 @@ class RecoverableSessionTest(test.TestCase): self.assertFalse(session.should_stop()) self.assertEqual(2, session_creator.number_of_sessions_created) + @test_util.run_deprecated_v1 def test_recovery_from_non_preemption_in_coordinator(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -917,6 +935,7 @@ class RecoverableSessionTest(test.TestCase): with self.assertRaises(errors_impl.UnknownError): session.close() + @test_util.run_deprecated_v1 def test_recovery_from_session_getting_stuck(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -941,6 +960,7 @@ class RecoverableSessionTest(test.TestCase): self.assertFalse(session.should_stop()) self.assertEqual(2, session_creator.number_of_sessions_created) + @test_util.run_deprecated_v1 def test_step_fn_recovery_from_coordinator_exception_when_run_hooks(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -971,6 +991,7 @@ class RecoverableSessionTest(test.TestCase): self.assertFalse(session.should_stop()) self.assertEqual(2, session_creator.number_of_sessions_created) + @test_util.run_deprecated_v1 def test_recovery_from_non_preemption_in_coordinator_when_run_hooks(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -1005,6 +1026,7 @@ class RecoverableSessionTest(test.TestCase): with self.assertRaises(errors_impl.UnknownError): session.close() + @test_util.run_deprecated_v1 def test_recovery_from_session_getting_stuck_when_run_hooks(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -1049,6 +1071,7 @@ class RecoverableSessionTest(test.TestCase): # exception. return session + @test_util.run_deprecated_v1 def test_step_fn_recovery_from_coordinator_exception_with_raw_session(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -1081,6 +1104,7 @@ class RecoverableSessionTest(test.TestCase): self.assertFalse(session.should_stop()) self.assertEqual(2, session_creator.number_of_sessions_created) + @test_util.run_deprecated_v1 def test_recovery_from_non_preemption_in_coordinator_with_raw_session(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -1118,6 +1142,7 @@ class RecoverableSessionTest(test.TestCase): with self.assertRaises(errors_impl.UnknownError): session.close() + @test_util.run_deprecated_v1 def test_recovery_from_session_getting_stuck_with_raw_session(self): with self.cached_session() as test_session: session_creator = CountingSessionCreator(test_session) @@ -1443,6 +1468,7 @@ class MonitoredSessionTest(test.TestCase): # This set of tests, verifies the supervised session behavior when exceptions # are raised next to the innermost session run() call. + @test_util.run_deprecated_v1 def test_recovery(self): logdir = _test_dir(self.get_temp_dir(), 'test_recovery') with ops.Graph().as_default(): @@ -1795,6 +1821,7 @@ class MonitoredSessionTest(test.TestCase): isinstance(hook.run_metadata_list[0], config_pb2.RunMetadata)) self.assertGreater(len(hook.run_metadata_list[0].partition_graphs), 0) + @test_util.run_deprecated_v1 def test_with_statement_and_close(self): # Test case for https://github.com/tensorflow/tensorflow/issues/12224 # where close() inside the with should have a better error message. diff --git a/tensorflow/python/training/moving_averages_test.py b/tensorflow/python/training/moving_averages_test.py index 6ce5de6663d..b15f7377f07 100644 --- a/tensorflow/python/training/moving_averages_test.py +++ b/tensorflow/python/training/moving_averages_test.py @@ -35,6 +35,7 @@ from tensorflow.python.training import saver as saver_lib class MovingAveragesTest(test.TestCase): + @test_util.run_deprecated_v1 def testAssignMovingAverageWithoutZeroDebias(self): with self.cached_session(): var = variables.Variable([10.0, 11.0]) @@ -49,6 +50,7 @@ class MovingAveragesTest(test.TestCase): [10.0 * 0.25 + 1.0 * (1.0 - 0.25), 11.0 * 0.25 + 2.0 * (1.0 - 0.25)], self.evaluate(var)) + @test_util.run_deprecated_v1 def testAssignMovingAverage(self): with self.cached_session(): var = variables.Variable([0.0, 0.0]) @@ -62,6 +64,7 @@ class MovingAveragesTest(test.TestCase): [1.0 * (1.0 - 0.25) / (1 - 0.25), 2.0 * (1.0 - 0.25) / (1 - 0.25)], self.evaluate(var)) + @test_util.run_deprecated_v1 def testAssignMovingAverageNewNamingMultipleCalls(self): with variable_scope.variable_scope("scope1") as vs1: with variable_scope.variable_scope("scope2"): @@ -76,6 +79,7 @@ class MovingAveragesTest(test.TestCase): actual_names = [v.name for v in vs1.global_variables()] self.assertSetEqual(set(expected_names), set(actual_names)) + @test_util.run_deprecated_v1 def testAssignMovingAverageNewNamingMultipleCallsWithReuse(self): with variable_scope.variable_scope("scope1") as vs1: var = variable_scope.get_variable("Var", shape=[]) @@ -86,6 +90,7 @@ class MovingAveragesTest(test.TestCase): moving_averages.assign_moving_average(var, 0.0, 0.99) moving_averages.assign_moving_average(var, 0.0, 0.99) + @test_util.run_deprecated_v1 def testWeightedMovingAverage(self): with self.cached_session() as sess: decay = 0.5 @@ -111,6 +116,7 @@ class MovingAveragesTest(test.TestCase): denominator_2 = denominator_1 * decay + weight_2 * (1.0 - decay) self.assertAllClose(numerator_2 / denominator_2, wma_array) + @test_util.run_deprecated_v1 def testWeightedMovingAverageBfloat16(self): bfloat16 = pywrap_tensorflow.TF_bfloat16_type() with self.cached_session() as sess: @@ -213,32 +219,38 @@ class ExponentialMovingAverageTest(test.TestCase): (10.0 + 30.0) * (1 - dk)) / _Scale(dk, 2), dim) self.assertAllClose(expected, self.evaluate(avg2)) + @test_util.run_deprecated_v1 def testAverageVariablesNoNumUpdates_Scalar(self): with self.cached_session(): ema = moving_averages.ExponentialMovingAverage(0.25) self._CheckDecay(ema, actual_decay=0.25, dim=1) + @test_util.run_deprecated_v1 def testAverageVariablesNoNumUpdates_Scalar_Debias(self): with self.cached_session(): ema = moving_averages.ExponentialMovingAverage(0.25, zero_debias=True) self._CheckDecay(ema, actual_decay=0.25, dim=1) + @test_util.run_deprecated_v1 def testAverageVariablesNoNumUpdates_Vector(self): with self.cached_session(): ema = moving_averages.ExponentialMovingAverage(0.25) self._CheckDecay(ema, actual_decay=0.25, dim=5) + @test_util.run_deprecated_v1 def testAverageVariablesNoNumUpdates_Vector_Debias(self): with self.cached_session(): ema = moving_averages.ExponentialMovingAverage(0.25, zero_debias=True) self._CheckDecay(ema, actual_decay=0.25, dim=5) + @test_util.run_deprecated_v1 def testAverageVariablesNumUpdates_Scalar(self): with self.cached_session(): # With num_updates 1, the decay applied is 0.1818 ema = moving_averages.ExponentialMovingAverage(0.25, num_updates=1) self._CheckDecay(ema, actual_decay=0.181818, dim=1) + @test_util.run_deprecated_v1 def testAverageVariablesNumUpdates_Scalar_Debias(self): with self.cached_session(): # With num_updates 1, the decay applied is 0.1818 @@ -246,12 +258,14 @@ class ExponentialMovingAverageTest(test.TestCase): 0.25, num_updates=1, zero_debias=True) self._CheckDecay(ema, actual_decay=0.181818, dim=1) + @test_util.run_deprecated_v1 def testAverageVariablesNumUpdates_Vector(self): with self.cached_session(): # With num_updates 1, the decay applied is 0.1818 ema = moving_averages.ExponentialMovingAverage(0.25, num_updates=1) self._CheckDecay(ema, actual_decay=0.181818, dim=5) + @test_util.run_deprecated_v1 def testAverageVariablesNumUpdates_Vector_Debias(self): with self.cached_session(): # With num_updates 1, the decay applied is 0.1818 @@ -259,6 +273,7 @@ class ExponentialMovingAverageTest(test.TestCase): 0.25, num_updates=1, zero_debias=True) self._CheckDecay(ema, actual_decay=0.181818, dim=5) + @test_util.run_deprecated_v1 def testAverageVariablesWithControlDeps(self): with self.cached_session() as sess: v0 = variables.Variable(0, name="v0") @@ -284,6 +299,7 @@ class ExponentialMovingAverageTest(test.TestCase): self.assertEqual([17.5], self.evaluate(v1_avg)) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testBasicEager(self): v0 = variables.Variable(1.0) v1 = variables.Variable(2.0) @@ -339,9 +355,11 @@ class ExponentialMovingAverageTest(test.TestCase): self.assertEqual(ema.average(v1).op.name, ema.average_name(v1)) self.assertEqual(ema.average(tensor2).op.name, ema.average_name(tensor2)) + @test_util.run_deprecated_v1 def testAverageVariablesNames(self): self.averageVariablesNamesHelper(zero_debias=True) + @test_util.run_deprecated_v1 def testAverageVariablesNamesNoDebias(self): self.averageVariablesNamesHelper(zero_debias=False) @@ -387,12 +405,15 @@ class ExponentialMovingAverageTest(test.TestCase): self.assertEqual( ema.average(tensor2).op.name, ema.average_name(tensor2)) + @test_util.run_deprecated_v1 def testAverageVariablesNamesRespectScope(self): self.averageVariablesNamesRespectScopeHelper(zero_debias=True) + @test_util.run_deprecated_v1 def testAverageVariablesNamesRespectScopeNoDebias(self): self.averageVariablesNamesRespectScopeHelper(zero_debias=False) + @test_util.run_deprecated_v1 def testSubsetAverageVariablesNames(self): with self.cached_session(): v0 = variables.Variable(10.0, name="v0") @@ -421,6 +442,7 @@ class ExponentialMovingAverageTest(test.TestCase): self.assertEqual(ema.average(v1).op.name, ema.average_name(v1)) self.assertEqual(ema.average(tensor2).op.name, ema.average_name(tensor2)) + @test_util.run_deprecated_v1 def testAverageVariablesDeviceAssignment(self): with ops.device("/job:dev_v0"): v0 = variables.Variable(10.0, name="v0") @@ -451,6 +473,7 @@ class ExponentialMovingAverageTest(test.TestCase): _ = saver_lib.import_meta_graph(meta_graph) return graph_copy + @test_util.run_deprecated_v1 def testImportedGraphVariablesToRestore(self): g = ops.Graph() with g.as_default(): diff --git a/tensorflow/python/training/optimizer_test.py b/tensorflow/python/training/optimizer_test.py index 5ed0a302859..e175b5a7998 100644 --- a/tensorflow/python/training/optimizer_test.py +++ b/tensorflow/python/training/optimizer_test.py @@ -62,6 +62,7 @@ class OptimizerTest(test.TestCase): self.assertAllClose([-14., -13.], self.evaluate(var0)) self.assertAllClose([-6., -5.], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testAggregationMethod(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -87,6 +88,7 @@ class OptimizerTest(test.TestCase): self.assertAllClose([-14., -13.], self.evaluate(var0)) self.assertAllClose([-6., -5.], self.evaluate(var1)) + @test_util.run_deprecated_v1 def testPrecomputedGradient(self): for dtype in [dtypes.half, dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -230,6 +232,7 @@ class OptimizerTest(test.TestCase): with self.assertRaises(NotImplementedError): sgd_op.apply_gradients(grads_and_vars) + @test_util.run_deprecated_v1 def testTrainOp(self): with self.cached_session(): var0 = variables.Variable([1.0, 2.0]) @@ -241,6 +244,7 @@ class OptimizerTest(test.TestCase): opt_op = sgd_op.minimize(cost, global_step, [var0, var1]) self.assertTrue(opt_op in ops.get_collection(ops.GraphKeys.TRAIN_OP)) + @test_util.run_deprecated_v1 def testConstraint(self): constraint_01 = lambda x: clip_ops.clip_by_value(x, -0.1, 0.) constraint_0 = lambda x: clip_ops.clip_by_value(x, 0., 1.) diff --git a/tensorflow/python/training/proximal_adagrad_test.py b/tensorflow/python/training/proximal_adagrad_test.py index 9d46a6682d9..ce214ac418a 100644 --- a/tensorflow/python/training/proximal_adagrad_test.py +++ b/tensorflow/python/training/proximal_adagrad_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -64,12 +65,15 @@ class ProximalAdagradOptimizerTest(test.TestCase): self.assertStartsWith(opt_vars[1].name, var1._shared_name) self.assertEqual(2, len(opt_vars)) + @test_util.run_deprecated_v1 def testProximalAdagradwithoutRegularization(self): self.doTestProximalAdagradwithoutRegularization(use_resource=False) + @test_util.run_deprecated_v1 def testResourceProximalAdagradwithoutRegularization(self): self.doTestProximalAdagradwithoutRegularization(use_resource=True) + @test_util.run_deprecated_v1 def testProximalAdagradwithoutRegularization2(self): with self.cached_session() as sess: var0 = variables.Variable([1.0, 2.0]) @@ -96,6 +100,7 @@ class ProximalAdagradOptimizerTest(test.TestCase): self.assertAllClose(np.array([-1.60261, -2.296985]), v0_val) self.assertAllClose(np.array([3.715679, 2.433051]), v1_val) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -114,6 +119,7 @@ class ProximalAdagradOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testProximalAdagradWithL1(self): with self.cached_session() as sess: var0 = variables.Variable([1.0, 2.0]) @@ -140,6 +146,7 @@ class ProximalAdagradOptimizerTest(test.TestCase): self.assertAllClose(np.array([-6.663634, -9.190331]), v0_val) self.assertAllClose(np.array([2.959304, 1.029232]), v1_val) + @test_util.run_deprecated_v1 def testProximalAdagradWithL1_L2(self): with self.cached_session() as sess: var0 = variables.Variable([1.0, 2.0]) @@ -206,6 +213,7 @@ class ProximalAdagradOptimizerTest(test.TestCase): v0_val, v1_val = self.evaluate([var0, var1]) return v0_val, v1_val + @test_util.run_deprecated_v1 def testEquivAdagradwithoutRegularization(self): with self.cached_session(): val0, val1 = self.applyOptimizer( @@ -223,6 +231,7 @@ class ProximalAdagradOptimizerTest(test.TestCase): self.assertAllClose(val0, val2) self.assertAllClose(val1, val3) + @test_util.run_deprecated_v1 def testEquivSparseAdagradwithoutRegularization(self): with self.cached_session(): val0, val1 = self.applyOptimizer( diff --git a/tensorflow/python/training/proximal_gradient_descent_test.py b/tensorflow/python/training/proximal_gradient_descent_test.py index 8797b308ebd..25b206605dc 100644 --- a/tensorflow/python/training/proximal_gradient_descent_test.py +++ b/tensorflow/python/training/proximal_gradient_descent_test.py @@ -23,6 +23,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import resource_variable_ops @@ -62,12 +63,15 @@ class ProximalGradientDescentOptimizerTest(test.TestCase): self.assertAllClose(np.array([-0.9, -1.8]), v0_val) self.assertAllClose(np.array([-0.09, -0.18]), v1_val) + @test_util.run_deprecated_v1 def testProximalGradientDescentwithoutRegularization(self): self.doTestProximalGradientDescentwithoutRegularization(use_resource=False) + @test_util.run_deprecated_v1 def testResourceProximalGradientDescentwithoutRegularization(self): self.doTestProximalGradientDescentwithoutRegularization(use_resource=True) + @test_util.run_deprecated_v1 def testProximalGradientDescentwithoutRegularization2(self): with self.cached_session() as sess: var0 = variables.Variable([1.0, 2.0]) @@ -92,6 +96,7 @@ class ProximalGradientDescentOptimizerTest(test.TestCase): self.assertAllClose(np.array([0.1, 0.2]), v0_val) self.assertAllClose(np.array([3.91, 2.82]), v1_val) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -111,6 +116,7 @@ class ProximalGradientDescentOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testProximalGradientDescentWithL1_L2(self): with self.cached_session() as sess: var0 = variables.Variable([1.0, 2.0]) @@ -174,6 +180,7 @@ class ProximalGradientDescentOptimizerTest(test.TestCase): v0_val, v1_val = self.evaluate([var0, var1]) return v0_val, v1_val + @test_util.run_deprecated_v1 def testEquivSparseGradientDescentwithoutRegularization(self): with self.cached_session(): val0, val1 = self.applyOptimizer( @@ -190,6 +197,7 @@ class ProximalGradientDescentOptimizerTest(test.TestCase): self.assertAllClose(val0, val2) self.assertAllClose(val1, val3) + @test_util.run_deprecated_v1 def testEquivGradientDescentwithoutRegularization(self): with self.cached_session(): val0, val1 = self.applyOptimizer( diff --git a/tensorflow/python/training/quantize_training_test.py b/tensorflow/python/training/quantize_training_test.py index 07fd488563e..62e783f2000 100644 --- a/tensorflow/python/training/quantize_training_test.py +++ b/tensorflow/python/training/quantize_training_test.py @@ -25,6 +25,7 @@ from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import importer from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -52,6 +53,7 @@ class PywrapQuantizeTrainingTest(test.TestCase): # Test that save/restoring works for EMA variables generated in the # quantized training rewrite. + @test_util.run_deprecated_v1 def testQuantizedSaveRestore(self): save_path = os.path.join(self.get_temp_dir(), 'quantized_save_restore') diff --git a/tensorflow/python/training/queue_runner_test.py b/tensorflow/python/training/queue_runner_test.py index 65c2c13d8bb..4113cecf55d 100644 --- a/tensorflow/python/training/queue_runner_test.py +++ b/tensorflow/python/training/queue_runner_test.py @@ -26,6 +26,7 @@ from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import data_flow_ops from tensorflow.python.ops import variables @@ -40,6 +41,7 @@ _MockOp = collections.namedtuple("MockOp", ["name"]) class QueueRunnerTest(test.TestCase): + @test_util.run_deprecated_v1 def testBasic(self): with self.cached_session() as sess: # CountUpTo will raise OUT_OF_RANGE when it reaches the count. @@ -60,6 +62,7 @@ class QueueRunnerTest(test.TestCase): # The variable should be 3. self.assertEqual(3, self.evaluate(var)) + @test_util.run_deprecated_v1 def testTwoOps(self): with self.cached_session() as sess: # CountUpTo will raise OUT_OF_RANGE when it reaches the count. @@ -83,6 +86,7 @@ class QueueRunnerTest(test.TestCase): self.assertEqual(3, self.evaluate(var0)) self.assertEqual(30, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testExceptionsCaptured(self): with self.cached_session() as sess: queue = data_flow_ops.FIFOQueue(10, dtypes.float32) @@ -99,6 +103,7 @@ class QueueRunnerTest(test.TestCase): self.assertTrue("Operation not in the graph" in str(exceptions[0])) self.assertTrue("Operation not in the graph" in str(exceptions[1])) + @test_util.run_deprecated_v1 def testRealDequeueEnqueue(self): with self.cached_session() as sess: q0 = data_flow_ops.FIFOQueue(3, dtypes.float32) @@ -127,6 +132,7 @@ class QueueRunnerTest(test.TestCase): with self.assertRaisesRegexp(errors_impl.OutOfRangeError, "is closed"): self.evaluate(dequeue1) + @test_util.run_deprecated_v1 def testRespectCoordShouldStop(self): with self.cached_session() as sess: # CountUpTo will raise OUT_OF_RANGE when it reaches the count. @@ -151,6 +157,7 @@ class QueueRunnerTest(test.TestCase): # The variable should be 0. self.assertEqual(0, self.evaluate(var)) + @test_util.run_deprecated_v1 def testRequestStopOnException(self): with self.cached_session() as sess: queue = data_flow_ops.FIFOQueue(10, dtypes.float32) @@ -163,6 +170,7 @@ class QueueRunnerTest(test.TestCase): with self.assertRaisesRegexp(ValueError, "Operation not in the graph"): coord.join() + @test_util.run_deprecated_v1 def testGracePeriod(self): with self.cached_session() as sess: # The enqueue will quickly block. @@ -180,6 +188,7 @@ class QueueRunnerTest(test.TestCase): # the queue to be closed and the enqueue to terminate. coord.join(stop_grace_period_secs=1.0) + @test_util.run_deprecated_v1 def testMultipleSessions(self): with self.cached_session() as sess: with session.Session() as other_sess: @@ -195,6 +204,7 @@ class QueueRunnerTest(test.TestCase): other_threads = qr.create_threads(other_sess, coord=coord) self.assertEqual(len(threads), len(other_threads)) + @test_util.run_deprecated_v1 def testIgnoreMultiStarts(self): with self.cached_session() as sess: # CountUpTo will raise OUT_OF_RANGE when it reaches the count. @@ -211,6 +221,7 @@ class QueueRunnerTest(test.TestCase): new_threads = qr.create_threads(sess, coord=coord) self.assertEqual([], new_threads) + @test_util.run_deprecated_v1 def testThreads(self): with self.cached_session() as sess: # CountUpTo will raise OUT_OF_RANGE when it reaches the count. @@ -238,6 +249,7 @@ class QueueRunnerTest(test.TestCase): self.assertEqual(1, len(exceptions)) self.assertTrue("Operation not in the graph" in str(exceptions[0])) + @test_util.run_deprecated_v1 def testName(self): with ops.name_scope("scope"): queue = data_flow_ops.FIFOQueue(10, dtypes.float32, name="queue") @@ -247,6 +259,7 @@ class QueueRunnerTest(test.TestCase): self.assertEqual( 1, len(ops.get_collection(ops.GraphKeys.QUEUE_RUNNERS, "scope"))) + @test_util.run_deprecated_v1 def testStartQueueRunners(self): # CountUpTo will raise OUT_OF_RANGE when it reaches the count. zero64 = constant_op.constant(0, dtype=dtypes.int64) @@ -265,6 +278,7 @@ class QueueRunnerTest(test.TestCase): # The variable should be 3. self.assertEqual(3, self.evaluate(var)) + @test_util.run_deprecated_v1 def testStartQueueRunnersRaisesIfNotASession(self): zero64 = constant_op.constant(0, dtype=dtypes.int64) var = variables.VariableV1(zero64) @@ -278,6 +292,7 @@ class QueueRunnerTest(test.TestCase): with self.assertRaisesRegexp(TypeError, "tf.Session"): queue_runner_impl.start_queue_runners("NotASession") + @test_util.run_deprecated_v1 def testStartQueueRunnersIgnoresMonitoredSession(self): zero64 = constant_op.constant(0, dtype=dtypes.int64) var = variables.VariableV1(zero64) @@ -292,6 +307,7 @@ class QueueRunnerTest(test.TestCase): monitored_session.MonitoredSession()) self.assertFalse(threads) + @test_util.run_deprecated_v1 def testStartQueueRunnersNonDefaultGraph(self): # CountUpTo will raise OUT_OF_RANGE when it reaches the count. graph = ops.Graph() diff --git a/tensorflow/python/training/rmsprop_test.py b/tensorflow/python/training/rmsprop_test.py index a9b8954e39d..8f029d5310e 100644 --- a/tensorflow/python/training/rmsprop_test.py +++ b/tensorflow/python/training/rmsprop_test.py @@ -89,6 +89,7 @@ class RMSPropOptimizerTest(test.TestCase): var_t[gindex] = var[gindex] - mom_t[gindex] return var_t, mg_t, rms_t, mom_t + @test_util.run_deprecated_v1 def testDense(self): # TODO(yori): Use ParameterizedTest when available for (dtype, learning_rate, decay, momentum, @@ -164,6 +165,7 @@ class RMSPropOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariable(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -187,6 +189,7 @@ class RMSPropOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testMinimizeSparseResourceVariableCentered(self): for dtype in [dtypes.float32, dtypes.float64]: with self.cached_session(): @@ -210,6 +213,7 @@ class RMSPropOptimizerTest(test.TestCase): self.evaluate(var0), atol=0.01) + @test_util.run_deprecated_v1 def testSparse(self): # TODO(yori): Use ParameterizedTest when available for (dtype, learning_rate, decay, @@ -286,6 +290,7 @@ class RMSPropOptimizerTest(test.TestCase): self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0)) self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1)) + @test_util.run_deprecated_v1 def testWithoutMomentum(self): for dtype in [dtypes.half, dtypes.float32]: with test_util.use_gpu(): @@ -354,6 +359,7 @@ class RMSPropOptimizerTest(test.TestCase): (0.01 * 2.0 / math.sqrt(0.90001 * 0.9 + 1e-5 + 1.0)) ]), self.evaluate(var1)) + @test_util.run_deprecated_v1 def testWithMomentum(self): for dtype in [dtypes.half, dtypes.float32]: with test_util.use_gpu(): diff --git a/tensorflow/python/training/saver_test.py b/tensorflow/python/training/saver_test.py index 6b2177b0bb7..40b7c0d5a7f 100644 --- a/tensorflow/python/training/saver_test.py +++ b/tensorflow/python/training/saver_test.py @@ -170,6 +170,7 @@ class SaverTest(test.TestCase): def testResourceBasic(self): self.basicSaveRestore(resource_variable_ops.ResourceVariable) + @test_util.run_deprecated_v1 def testResourceColocation(self): partitioner = partitioned_variables.fixed_size_partitioner(num_shards=2) with ops_lib.device("/job:ps/device:GPU:0"): @@ -300,6 +301,7 @@ class SaverTest(test.TestCase): not op.name.startswith("saver2/save/"))] self.assertEqual(ops_in_saver2_scope_but_not_save_scope, []) + @test_util.run_deprecated_v1 def testSaveCopyRestoreWithSaveRelativePaths(self): """Save, copy checkpoint dir and restore from copied dir. @@ -369,6 +371,7 @@ class SaverTest(test.TestCase): self.assertEqual(b"k1", v2.keys().eval()) self.assertEqual(30.0, v2.values().eval()) + @test_util.run_deprecated_v1 def testFilenameTensor(self): v0 = variables.VariableV1(0, name="v0") filename = b"somerandomfilename" @@ -387,6 +390,7 @@ class SaverTest(test.TestCase): ValueError, "The passed save_path is not a valid checkpoint:"): save.restore(sess, "invalid path") + @test_util.run_deprecated_v1 def testInt64(self): save_path = os.path.join(self.get_temp_dir(), "int64") @@ -462,6 +466,7 @@ class SaverTest(test.TestCase): # Verify non-duplicate names work. saver_module.Saver({"v0": v0, "v2": v2.saveable}) + @test_util.run_deprecated_v1 def testBasicsWithListOfVariables(self): save_path = os.path.join(self.get_temp_dir(), "basics_with_list") @@ -557,6 +562,7 @@ class SaverTest(test.TestCase): # The cached readers should know to re-read the file. self._SaveAndLoad("var1", 1.1, 2.2, save_path) + @test_util.run_deprecated_v1 def testAllowEmpty(self): save_path = os.path.join(self.get_temp_dir(), "allow_empty") with self.cached_session() as sess: @@ -661,6 +667,7 @@ class SaverTest(test.TestCase): self.assertAllClose(1.0, one.eval()) self.assertAllClose([2.0, 2.0, 2.0], twos.eval()) + @test_util.run_deprecated_v1 def testReshape(self): save_path = os.path.join(self.get_temp_dir(), "variables_reshape") with session.Session("", graph=ops_lib.Graph()) as sess: @@ -719,6 +726,7 @@ class SaverTest(test.TestCase): def testSaveWithGlobalStepWithPadding(self): self.testSaveWithGlobalStep(pad_step_number=True) + @test_util.run_deprecated_v1 def testSaveToNonexistingPath(self): file_io.write_string_to_file( os.path.join(self.get_temp_dir(), "actually_a_file"), "") @@ -761,6 +769,7 @@ class SaverTest(test.TestCase): error_msg_template = "Parent directory of {} doesn't exist, can't save." self.assertEqual(error_msg_template.format(save_path), str(exc)) + @test_util.run_deprecated_v1 def testSaveToURI(self): # ParseURI functions don't work on Windows yet. # TODO(jhseu): Remove this check when it works. @@ -982,6 +991,7 @@ class SaveRestoreShardedTest(test.TestCase): checkpoint_management.latest_checkpoint(self.get_temp_dir()), os.path.join(self.get_temp_dir(), "sharded_basics")) + @test_util.run_deprecated_v1 def testSaverDef(self): with self.cached_session(): v0 = variables.VariableV1(123, name="v0") @@ -1087,9 +1097,11 @@ class SaveRestoreShardedTest(test.TestCase): num_shards=3)) self.assertAllEqual(saved_full, restored_full) + @test_util.run_deprecated_v1 def testPartitionedVariable(self): self._testPartitionedVariables(use_resource=False) + @test_util.run_deprecated_v1 def testPartitionedResourceVariable(self): self._testPartitionedVariables(use_resource=True) @@ -1184,6 +1196,7 @@ class MaxToKeepTest(test.TestCase): # Deleted by the first helper. self.assertFalse(checkpoint_management.checkpoint_exists(s3)) + @test_util.run_deprecated_v1 def testNonSharded(self): save_dir = self._get_test_dir("max_to_keep_non_sharded") @@ -1421,6 +1434,7 @@ class MaxToKeepTest(test.TestCase): self.assertTrue( gfile.Exists(checkpoint_management.meta_graph_filename(s3))) + @test_util.run_deprecated_v1 def testNoMaxToKeep(self): save_dir = self._get_test_dir("no_max_to_keep") save_dir2 = self._get_test_dir("max_to_keep_0") @@ -1449,6 +1463,7 @@ class MaxToKeepTest(test.TestCase): self.assertEqual([], save2.last_checkpoints) self.assertTrue(checkpoint_management.checkpoint_exists(s2)) + @test_util.run_deprecated_v1 def testNoMetaGraph(self): save_dir = self._get_test_dir("no_meta_graph") @@ -1472,6 +1487,7 @@ class KeepCheckpointEveryNHoursTest(test.TestCase): @test_util.run_in_graph_and_eager_modes @test.mock.patch.object(saver_module, "time") + @test_util.run_deprecated_v1 def testNonSharded(self, mock_time): save_dir = self._get_test_dir("keep_checkpoint_every_n_hours") @@ -1591,6 +1607,7 @@ class SaveRestoreWithVariableNameMap(test.TestCase): self.assertEqual(20.0, self.evaluate(v1)) @test_util.run_in_graph_and_eager_modes + @test_util.run_deprecated_v1 def testNonReshapeResourceVariable(self): self._testNonReshape(resource_variable_ops.ResourceVariable) @@ -1605,6 +1622,7 @@ class MetaGraphTest(test.TestCase): gfile.MakeDirs(test_dir) return test_dir + @test_util.run_deprecated_v1 def testAddCollectionDef(self): test_dir = self._get_test_dir("good_collection") filename = os.path.join(test_dir, "metafile") @@ -1754,11 +1772,13 @@ class MetaGraphTest(test.TestCase): v1 = sess.graph.get_tensor_by_name("v1:0") self.assertEqual(11.0, v1.eval()) + @test_util.run_deprecated_v1 def testMultiSaverCollection(self): test_dir = self._get_test_dir("saver_collection") self._testMultiSaverCollectionSave(test_dir) self._testMultiSaverCollectionRestore(test_dir) + @test_util.run_deprecated_v1 def testClearExtraneousSavers(self): test_dir = self._get_test_dir("clear_extraneous_savers") filename = os.path.join(test_dir, "metafile") @@ -1813,6 +1833,7 @@ class MetaGraphTest(test.TestCase): self.assertEqual(33, len(meta_graph_def0.graph_def.node)) self.assertEqual(21, len(meta_graph_def1.graph_def.node)) + @test_util.run_deprecated_v1 def testBinaryAndTextFormat(self): test_dir = self._get_test_dir("binary_and_text") filename = os.path.join(test_dir, "metafile") @@ -1845,6 +1866,7 @@ class MetaGraphTest(test.TestCase): lambda e: "does not exist"): saver_module.import_meta_graph(filename) + @test_util.run_deprecated_v1 def testSliceVariable(self): test_dir = self._get_test_dir("slice_saver") filename = os.path.join(test_dir, "metafile") @@ -1985,6 +2007,7 @@ class MetaGraphTest(test.TestCase): train_op = ops_lib.get_collection("train_op")[0] self.evaluate(train_op) + @test_util.run_deprecated_v1 def testGraphExtension(self): test_dir = self._get_test_dir("graph_extension") self._testGraphExtensionSave(test_dir) @@ -2070,6 +2093,7 @@ class MetaGraphTest(test.TestCase): return i + 1, x + r self._testWhileLoopAndGradientSerDes(body) + @test_util.run_deprecated_v1 def testNestedControlFlowSerDes(self): # Test while loop in a cond in a while loop. # pylint: disable=g-long-lambda @@ -2098,6 +2122,7 @@ class MetaGraphTest(test.TestCase): lambda: math_ops.multiply(x, -1.0)))) # pylint: enable=g-long-lambda + @test_util.run_deprecated_v1 def testStrippedOpListDef(self): with self.cached_session(): # Creates a graph. @@ -2135,6 +2160,7 @@ class MetaGraphTest(test.TestCase): self.assertEqual(o.summary, "") self.assertEqual(o.description, "") + @test_util.run_deprecated_v1 def testStripDefaultValuedAttrs(self): """Verifies that default valued attrs are stripped, unless disabled.""" @@ -2171,6 +2197,7 @@ class MetaGraphTest(test.TestCase): self.assertIn("T", node_def.attr) self.assertIn("Tout", node_def.attr) + @test_util.run_deprecated_v1 def testImportIntoNamescope(self): # Test that we can import a meta graph into a namescope. test_dir = self._get_test_dir("import_into_namescope") @@ -2241,6 +2268,7 @@ class MetaGraphTest(test.TestCase): filename + ".meta", graph=graph_2, import_scope="my_scope") self.assertIsInstance(new_saver_3, saver_module.Saver) + @test_util.run_deprecated_v1 def testImportIntoImplicitNamescope(self): # Test that we can import a meta graph into an implicit namescope. test_dir = self._get_test_dir("import_into_namescope") @@ -2363,6 +2391,7 @@ class CheckpointReaderTest(test.TestCase): _WRITE_VERSION = saver_pb2.SaverDef.V1 + @test_util.run_deprecated_v1 def testDebugString(self): # Builds a graph. v0 = variables.VariableV1( @@ -2594,6 +2623,7 @@ class ScopedGraphTest(test.TestCase): # Verifies that we can save the subgraph under "hidden1" and restore it # into "new_hidden1" in the new graph. + @test_util.run_deprecated_v1 def testScopedSaveAndRestore(self): test_dir = self._get_test_dir("scoped_export_import") ckpt_filename = "ckpt" @@ -2603,6 +2633,7 @@ class ScopedGraphTest(test.TestCase): # Verifies that we can copy the subgraph under "hidden1" and copy it # to different name scope in the same graph or different graph. + @test_util.run_deprecated_v1 def testCopyScopedGraph(self): test_dir = self._get_test_dir("scoped_copy") saver0_ckpt = os.path.join(test_dir, "saver0.ckpt") @@ -2659,6 +2690,7 @@ class ScopedGraphTest(test.TestCase): saver3.restore(sess, saver0_ckpt) self.assertAllClose(expected, sess.run("new_hidden1/relu:0")) + @test_util.run_deprecated_v1 def testExportGraphDefWithScope(self): test_dir = self._get_test_dir("export_graph_def") saver0_ckpt = os.path.join(test_dir, "saver0.ckpt") @@ -2695,6 +2727,7 @@ class ScopedGraphTest(test.TestCase): saver3.restore(sess, saver0_ckpt) self.assertAllClose(expected, sess.run("new_hidden1/relu:0")) + @test_util.run_deprecated_v1 def testSerializeSaverWithScope(self): test_dir = self._get_test_dir("export_graph_def") saver1_ckpt = os.path.join(test_dir, "saver1.ckpt") @@ -2955,6 +2988,7 @@ class CheckpointableCompatibilityTests(test.TestCase): # exception" block in Python 3. self.assertNotIn("NewCheckpointReader", cs.exception.message) + @test_util.run_deprecated_v1 def testGraphChangedForRestoreErrorRaised(self): checkpoint_directory = self.get_temp_dir() checkpoint_prefix = os.path.join(checkpoint_directory, "ckpt") @@ -2976,6 +3010,7 @@ class CheckpointableCompatibilityTests(test.TestCase): "a mismatch between the current graph and the graph"): a_saver.restore(sess=sess, save_path=save_path) + @test_util.run_deprecated_v1 def testLoadFromObjectBasedGraph(self): checkpoint_directory = self.get_temp_dir() checkpoint_prefix = os.path.join(checkpoint_directory, "ckpt") diff --git a/tensorflow/python/training/server_lib_multiple_containers_test.py b/tensorflow/python/training/server_lib_multiple_containers_test.py index f599e9b55b9..fb6118942bd 100644 --- a/tensorflow/python/training/server_lib_multiple_containers_test.py +++ b/tensorflow/python/training/server_lib_multiple_containers_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.client import session from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.training import server_lib @@ -33,6 +34,7 @@ class MultipleContainersTest(test.TestCase): # TODO(b/34465411): Starting multiple servers with different configurations # in the same test is flaky. Move this test case back into # "server_lib_test.py" when this is no longer the case. + @test_util.run_deprecated_v1 def testMultipleContainers(self): with ops.container("test0"): v0 = variables.Variable(1.0, name="v0") diff --git a/tensorflow/python/training/server_lib_same_variables_clear_container_test.py b/tensorflow/python/training/server_lib_same_variables_clear_container_test.py index 3a5eb712c6f..e0ab21bbd97 100644 --- a/tensorflow/python/training/server_lib_same_variables_clear_container_test.py +++ b/tensorflow/python/training/server_lib_same_variables_clear_container_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.client import session from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.training import server_lib @@ -32,6 +33,7 @@ class SameVariablesClearContainerTest(test.TestCase): # TODO(b/34465411): Starting multiple servers with different configurations # in the same test is flaky. Move this test case back into # "server_lib_test.py" when this is no longer the case. + @test_util.run_deprecated_v1 def testSameVariablesClearContainer(self): # Starts two servers with different names so they map to different # resource "containers". diff --git a/tensorflow/python/training/server_lib_same_variables_clear_test.py b/tensorflow/python/training/server_lib_same_variables_clear_test.py index 4682f1ab84d..7b147af6c55 100644 --- a/tensorflow/python/training/server_lib_same_variables_clear_test.py +++ b/tensorflow/python/training/server_lib_same_variables_clear_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.client import session from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -32,6 +33,7 @@ class SameVariablesClearTest(test.TestCase): # TODO(b/34465411): Starting multiple servers with different configurations # in the same test is flaky. Move this test case back into # "server_lib_test.py" when this is no longer the case. + @test_util.run_deprecated_v1 def testSameVariablesClear(self): server = server_lib.Server.create_local_server() diff --git a/tensorflow/python/training/server_lib_same_variables_no_clear_test.py b/tensorflow/python/training/server_lib_same_variables_no_clear_test.py index 5aa7f45c2b3..1b2d588f444 100644 --- a/tensorflow/python/training/server_lib_same_variables_no_clear_test.py +++ b/tensorflow/python/training/server_lib_same_variables_no_clear_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.client import session from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import math_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test @@ -33,6 +34,7 @@ class SameVariablesNoClearTest(test.TestCase): # TODO(b/34465411): Starting multiple servers with different configurations # in the same test is flaky. Move this test case back into # "server_lib_test.py" when this is no longer the case. + @test_util.run_deprecated_v1 def testSameVariablesNoClear(self): server = server_lib.Server.create_local_server() diff --git a/tensorflow/python/training/server_lib_sparse_job_test.py b/tensorflow/python/training/server_lib_sparse_job_test.py index 8c2745b51aa..93b06e62160 100644 --- a/tensorflow/python/training/server_lib_sparse_job_test.py +++ b/tensorflow/python/training/server_lib_sparse_job_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.training import server_lib @@ -30,6 +31,7 @@ class SparseJobTest(test.TestCase): # TODO(b/34465411): Starting multiple servers with different configurations # in the same test is flaky. Move this test case back into # "server_lib_test.py" when this is no longer the case. + @test_util.run_deprecated_v1 def testSparseJob(self): server = server_lib.Server({"local": {37: "localhost:0"}}) with ops.device("/job:local/task:37"): diff --git a/tensorflow/python/training/session_manager_test.py b/tensorflow/python/training/session_manager_test.py index 2b5c3b01def..4294ffa8512 100644 --- a/tensorflow/python/training/session_manager_test.py +++ b/tensorflow/python/training/session_manager_test.py @@ -25,6 +25,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import variables @@ -68,6 +69,7 @@ class SessionManagerTest(test.TestCase): "", init_fn=lambda sess: sess.run(v.initializer)) self.assertAllClose([125], sess.run(v)) + @test_util.run_deprecated_v1 def testPrepareSessionFails(self): checkpoint_dir = os.path.join(self.get_temp_dir(), "prepare_session") checkpoint_dir2 = os.path.join(self.get_temp_dir(), "prepare_session2") @@ -152,6 +154,7 @@ class SessionManagerTest(test.TestCase): sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) + @test_util.run_deprecated_v1 def testRecoverSession(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), "recover_session") @@ -206,6 +209,7 @@ class SessionManagerTest(test.TestCase): variables.global_variables()), local_init_op=None) + @test_util.run_deprecated_v1 def testRecoverSessionWithReadyForLocalInitOp(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), @@ -259,6 +263,7 @@ class SessionManagerTest(test.TestCase): self.assertEquals(1, sess.run(v)) self.assertEquals(1, sess.run(w)) + @test_util.run_deprecated_v1 def testRecoverSessionWithReadyForLocalInitOpFailsToReadyLocal(self): # We use ready_for_local_init_op=tf.report_uninitialized_variables(), # which causes recover_session to not run local_init_op, and to return @@ -315,6 +320,7 @@ class SessionManagerTest(test.TestCase): sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(v)) + @test_util.run_deprecated_v1 def testRecoverSessionNoChkptStillRunsLocalInitOp(self): # This test checks for backwards compatibility. # In particular, we continue to ensure that recover_session will execute @@ -343,6 +349,7 @@ class SessionManagerTest(test.TestCase): sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(w)) + @test_util.run_deprecated_v1 def testRecoverSessionFailsStillRunsLocalInitOp(self): # Create a checkpoint. checkpoint_dir = os.path.join( @@ -386,6 +393,7 @@ class SessionManagerTest(test.TestCase): sess.graph.get_tensor_by_name("w:0")).eval(session=sess)) self.assertEquals(1, sess.run(w)) + @test_util.run_deprecated_v1 def testWaitForSessionLocalInit(self): server = server_lib.Server.create_local_server() with ops.Graph().as_default() as graph: @@ -437,6 +445,7 @@ class SessionManagerTest(test.TestCase): # because of overly restrictive ready_for_local_init_op sm.wait_for_session("", max_wait_secs=3) + @test_util.run_deprecated_v1 def testWaitForSessionInsufficientReadyForLocalInitCheck(self): with ops.Graph().as_default() as graph: v = variables.VariableV1(1, name="v") @@ -454,6 +463,7 @@ class SessionManagerTest(test.TestCase): "Session was not ready after waiting.*"): sm.wait_for_session("", max_wait_secs=3) + @test_util.run_deprecated_v1 def testPrepareSessionWithReadyForLocalInitOp(self): with ops.Graph().as_default(): v = variables.VariableV1(1, name="v") @@ -493,6 +503,7 @@ class SessionManagerTest(test.TestCase): self.assertEquals(1, sess.run(w)) self.assertEquals(3, sess.run(x)) + @test_util.run_deprecated_v1 def testPrepareSessionWithPartialInitOp(self): with ops.Graph().as_default(): v = variables.VariableV1(1, name="v") @@ -559,6 +570,7 @@ class SessionManagerTest(test.TestCase): self.assertEquals(1, sess.run(w_res)) self.assertEquals(3, sess.run(x_res)) + @test_util.run_deprecated_v1 def testPrepareSessionWithCyclicInitializer(self): # Regression test. Previously Variable._build_initializer_expr would enter # into an infinite recursion when the variable's initial_value involved @@ -632,6 +644,7 @@ class SessionManagerTest(test.TestCase): "Init operations did not make model ready for local_init"): sm2.prepare_session("", init_op=None) + @test_util.run_deprecated_v1 def testPrepareSessionWithInsufficientReadyForLocalInitCheck(self): with ops.Graph().as_default(): v = variables.VariableV1(1, name="v") @@ -684,6 +697,7 @@ class ObsoleteSessionManagerTest(test.TestCase): "", init_fn=lambda sess: sess.run(v.initializer)) self.assertAllClose([125], sess.run(v)) + @test_util.run_deprecated_v1 def testPrepareSessionFails(self): checkpoint_dir = os.path.join(self.get_temp_dir(), "prepare_session") checkpoint_dir2 = os.path.join(self.get_temp_dir(), "prepare_session2") @@ -745,6 +759,7 @@ class ObsoleteSessionManagerTest(test.TestCase): variables.is_variable_initialized( sess.graph.get_tensor_by_name("v:0")).eval(session=sess)) + @test_util.run_deprecated_v1 def testRecoverSession(self): # Create a checkpoint. checkpoint_dir = os.path.join(self.get_temp_dir(), "recover_session") diff --git a/tensorflow/python/training/slot_creator_test.py b/tensorflow/python/training/slot_creator_test.py index 382c15bb55c..1f26aaa434e 100644 --- a/tensorflow/python/training/slot_creator_test.py +++ b/tensorflow/python/training/slot_creator_test.py @@ -21,6 +21,7 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variable_scope @@ -31,6 +32,7 @@ from tensorflow.python.training import slot_creator class SlotCreatorTest(test.TestCase): + @test_util.run_deprecated_v1 def testCreateSlotFromVariable(self): with self.cached_session(): v = variables.Variable([1.0, 2.5], name="var") @@ -43,6 +45,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float32, slot.dtype.base_dtype) self.assertAllEqual([1.0, 2.5], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateSlotFromTensor(self): with self.cached_session(): v = constant_op.constant([1.0, 2.5], name="const") @@ -55,6 +58,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float32, slot.dtype.base_dtype) self.assertAllEqual([2.0, 5.0], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateZerosSlotFromVariable(self): with self.cached_session(): v = variables.Variable([1.0, 2.5], name="var") @@ -69,6 +73,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float64, slot.dtype.base_dtype) self.assertAllEqual([0.0, 0.0], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateZerosSlotFromDynamicShapedVariable(self): with self.cached_session(): dyn_shape = constant_op.constant([2], dtype=dtypes.int32) @@ -90,6 +95,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float64, slot.dtype.base_dtype) self.assertAllEqual([0.0, 0.0], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateZerosSlotFromTensor(self): with self.cached_session(): v = constant_op.constant([1.0, 2.5], name="const") @@ -103,6 +109,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float32, slot.dtype.base_dtype) self.assertAllEqual([0.0, 0.0], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateZerosSlotFromDynamicShapedTensor(self): with self.cached_session(): v = random_ops.random_uniform([2], dtype=dtypes.float64) @@ -118,6 +125,7 @@ class SlotCreatorTest(test.TestCase): self.assertEqual(dtypes.float64, slot.dtype.base_dtype) self.assertAllEqual([0.0, 0.0], self.evaluate(slot)) + @test_util.run_deprecated_v1 def testCreateSlotFromVariableRespectsScope(self): # See discussion on #2740. with self.cached_session(): diff --git a/tensorflow/python/training/supervisor_test.py b/tensorflow/python/training/supervisor_test.py index 9dc88d78ccc..f6505acc9ac 100644 --- a/tensorflow/python/training/supervisor_test.py +++ b/tensorflow/python/training/supervisor_test.py @@ -35,6 +35,7 @@ from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import io_ops from tensorflow.python.ops import parsing_ops @@ -420,6 +421,7 @@ class SupervisorTest(test.TestCase): with self.assertRaisesRegexp(RuntimeError, "requires a summary writer"): sv.summary_computed(sess, sess.run(summ)) + @test_util.run_deprecated_v1 def testLogdirButExplicitlyNoSummaryWriter(self): logdir = self._test_dir("explicit_no_summary_writer") with ops.Graph().as_default(): @@ -505,6 +507,7 @@ class SupervisorTest(test.TestCase): sv = supervisor.Supervisor(logdir="", session_manager=sm) sv.prepare_or_wait_for_session("") + @test_util.run_deprecated_v1 def testInitOp(self): logdir = self._test_dir("default_init_op") with ops.Graph().as_default(): @@ -514,6 +517,7 @@ class SupervisorTest(test.TestCase): self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) sv.stop() + @test_util.run_deprecated_v1 def testInitFn(self): logdir = self._test_dir("default_init_op") with ops.Graph().as_default(): @@ -527,6 +531,7 @@ class SupervisorTest(test.TestCase): self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) sv.stop() + @test_util.run_deprecated_v1 def testInitOpWithFeedDict(self): logdir = self._test_dir("feed_dict_init_op") with ops.Graph().as_default(): @@ -540,6 +545,7 @@ class SupervisorTest(test.TestCase): self.assertAllClose([1.0, 2.0, 3.0], sess.run(v)) sv.stop() + @test_util.run_deprecated_v1 def testReadyForLocalInitOp(self): server = server_lib.Server.create_local_server() logdir = self._test_dir("default_ready_for_local_init_op") @@ -582,6 +588,7 @@ class SupervisorTest(test.TestCase): sv0.stop() sv1.stop() + @test_util.run_deprecated_v1 def testReadyForLocalInitOpRestoreFromCheckpoint(self): server = server_lib.Server.create_local_server() logdir = self._test_dir("ready_for_local_init_op_restore") @@ -713,6 +720,7 @@ class SupervisorTest(test.TestCase): "Variables not initialized: w"): sv.prepare_or_wait_for_session(server.target) + @test_util.run_deprecated_v1 def testSetupFail(self): logdir = self._test_dir("setup_fail") with ops.Graph().as_default(): @@ -723,6 +731,7 @@ class SupervisorTest(test.TestCase): variables.VariableV1([1.0, 2.0, 3.0], name="v") supervisor.Supervisor(logdir=logdir, is_chief=False) + @test_util.run_deprecated_v1 def testDefaultGlobalStep(self): logdir = self._test_dir("default_global_step") with ops.Graph().as_default(): @@ -732,6 +741,7 @@ class SupervisorTest(test.TestCase): self.assertEquals(287, sess.run(sv.global_step)) sv.stop() + @test_util.run_deprecated_v1 def testRestoreFromMetaGraph(self): logdir = self._test_dir("restore_from_meta_graph") with ops.Graph().as_default(): @@ -753,6 +763,7 @@ class SupervisorTest(test.TestCase): # This test is based on the fact that the standard services start # right away and get to run once before sv.stop() returns. # We still sleep a bit to make the test robust. + @test_util.run_deprecated_v1 def testStandardServicesWithoutGlobalStep(self): logdir = self._test_dir("standard_services_without_global_step") # Create a checkpoint. @@ -803,6 +814,7 @@ class SupervisorTest(test.TestCase): # Same as testStandardServicesNoGlobalStep but with a global step. # We should get a summary about the step time. + @test_util.run_deprecated_v1 def testStandardServicesWithGlobalStep(self): logdir = self._test_dir("standard_services_with_global_step") # Create a checkpoint. diff --git a/tensorflow/python/training/training_ops_test.py b/tensorflow/python/training/training_ops_test.py index 929dd74ac64..51f49ca0818 100644 --- a/tensorflow/python/training/training_ops_test.py +++ b/tensorflow/python/training/training_ops_test.py @@ -24,6 +24,7 @@ import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes +from tensorflow.python.framework import test_util from tensorflow.python.framework.test_util import TensorFlowTestCase # Import resource_variable_ops for the variables-to-tensor implicit conversion. from tensorflow.python.ops import resource_variable_ops # pylint: disable=unused-import @@ -59,6 +60,7 @@ class TrainingOpsTest(TensorFlowTestCase): self.assertShapeEqual(out, apply_sgd) self.assertAllCloseAccordingToType(x - alpha * delta, out) + @test_util.run_deprecated_v1 def testApplyGradientDescent(self): for (dtype, use_gpu) in itertools.product( [np.float16, np.float32, np.float64], [False, True]): @@ -127,6 +129,7 @@ class TrainingOpsTest(TensorFlowTestCase): self.assertAllClose(linear_update, self.evaluate(linear)) self.assertAllClose(expected_out, out) + @test_util.run_deprecated_v1 def testApplyAdagrad(self): for (dtype, use_gpu) in itertools.product( [np.float16, np.float32, np.float64], [False, True]): @@ -136,6 +139,7 @@ class TrainingOpsTest(TensorFlowTestCase): grad = np.arange(100).astype(dtype) self._testTypesForAdagrad(x, y, lr, grad, use_gpu) + @test_util.run_deprecated_v1 def testApplyFtrl(self): for dtype in [np.float16, np.float32, np.float64]: x = np.arange(100).astype(dtype) @@ -207,6 +211,7 @@ class TrainingOpsTest(TensorFlowTestCase): self.assertAllCloseAccordingToType(y[index] + grad[i] * grad[i], self.evaluate(accum)[index]) + @test_util.run_deprecated_v1 def testSparseApplyAdagrad(self): for (dtype, index_type) in itertools.product( [np.float16, np.float32, np.float64], [np.int32, np.int64]): @@ -220,6 +225,7 @@ class TrainingOpsTest(TensorFlowTestCase): indices = np.array([0, 2]).astype(index_type) self._testTypesForSparseAdagrad(x, y, lr, grad, indices) + @test_util.run_deprecated_v1 def testSparseApplyAdagradDim1(self): for (dtype, index_type) in itertools.product( [np.float16, np.float32, np.float64], [np.int32, np.int64]): @@ -233,6 +239,7 @@ class TrainingOpsTest(TensorFlowTestCase): indices = np.array([0, 2]).astype(index_type) self._testTypesForSparseAdagrad(x, y, lr, grad, indices) + @test_util.run_deprecated_v1 def testSparseApplyFtrlDim1(self): for (dtype, index_type) in itertools.product( [np.float16, np.float32, np.float64], [np.int32, np.int64]): @@ -248,6 +255,7 @@ class TrainingOpsTest(TensorFlowTestCase): indices = np.array([0, 2]).astype(index_type) self._testTypesForSparseFtrl(x, y, z, lr, grad, indices) + @test_util.run_deprecated_v1 def testApplyAdam(self): for dtype, use_gpu in itertools.product( [np.float16, np.float32, np.float64], [False, True]): diff --git a/tensorflow/python/training/training_util_test.py b/tensorflow/python/training/training_util_test.py index ba64e785ac6..3317008fce0 100644 --- a/tensorflow/python/training/training_util_test.py +++ b/tensorflow/python/training/training_util_test.py @@ -20,6 +20,7 @@ from __future__ import print_function from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops +from tensorflow.python.framework import test_util from tensorflow.python.ops import variables from tensorflow.python.platform import test from tensorflow.python.training import monitored_session @@ -46,6 +47,7 @@ class GlobalStepTest(test.TestCase): self.assertRaisesRegexp(TypeError, 'does not have integer type', training_util.get_global_step, g) + @test_util.run_deprecated_v1 def test_invalid_shape(self): with ops.Graph().as_default() as g: self.assertIsNone(training_util.get_global_step()) @@ -70,6 +72,7 @@ class GlobalStepTest(test.TestCase): training_util.create_global_step, g) self._assert_global_step(training_util.create_global_step(ops.Graph())) + @test_util.run_deprecated_v1 def test_get_global_step(self): with ops.Graph().as_default() as g: self.assertIsNone(training_util.get_global_step()) diff --git a/tensorflow/python/util/deprecation_test.py b/tensorflow/python/util/deprecation_test.py index 34cbca52a1b..035c416d793 100644 --- a/tensorflow/python/util/deprecation_test.py +++ b/tensorflow/python/util/deprecation_test.py @@ -19,6 +19,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.platform import tf_logging as logging from tensorflow.python.util import deprecation @@ -174,6 +175,7 @@ class DeprecationTest(test.TestCase): set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -214,6 +216,7 @@ class DeprecationTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_one_line_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -239,6 +242,7 @@ class DeprecationTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_no_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -488,6 +492,7 @@ class DeprecatedArgsTest(test.TestCase): deprecation.deprecated_args(date, instructions, "missing")(_fn) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -535,6 +540,7 @@ class DeprecatedArgsTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_one_line_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -565,6 +571,7 @@ class DeprecatedArgsTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_no_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -595,6 +602,7 @@ class DeprecatedArgsTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_varargs(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -615,6 +623,7 @@ class DeprecatedArgsTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_kwargs(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -635,6 +644,7 @@ class DeprecatedArgsTest(test.TestCase): self._assert_subset(set(["after " + date, instructions]), set(args[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_positional_and_named(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -660,6 +670,7 @@ class DeprecatedArgsTest(test.TestCase): set(args2[1:])) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_positional_and_named_with_ok_vals(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -692,6 +703,7 @@ class DeprecatedArgsTest(test.TestCase): self.assertEqual(0, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_deprecated_args_once(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -708,6 +720,7 @@ class DeprecatedArgsTest(test.TestCase): self.assertEqual(1, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_deprecated_multiple_args_once_each(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -752,6 +765,7 @@ class DeprecatedArgValuesTest(test.TestCase): deprecation.deprecated_arg_values(date, instructions) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -804,6 +818,7 @@ class DeprecatedArgValuesTest(test.TestCase): self.assertEqual(2, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_with_one_line_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." @@ -839,6 +854,7 @@ class DeprecatedArgValuesTest(test.TestCase): self.assertEqual(2, mock_warning.call_count) @test.mock.patch.object(logging, "warning", autospec=True) + @test_util.run_deprecated_v1 def test_static_fn_no_doc(self, mock_warning): date = "2016-07-04" instructions = "This is how you update..." diff --git a/tensorflow/python/util/nest_test.py b/tensorflow/python/util/nest_test.py index 997a3c5c36f..d0d0c5f7935 100644 --- a/tensorflow/python/util/nest_test.py +++ b/tensorflow/python/util/nest_test.py @@ -482,6 +482,7 @@ class NestTest(parameterized.TestCase, test.TestCase): self.assertEqual(nt.a[1][::-1], rev_nt.a[1]) self.assertEqual(nt.b[::-1], rev_nt.b) + @test_util.run_deprecated_v1 def testMapStructureOverPlaceholders(self): inp_a = (array_ops.placeholder(dtypes.float32, shape=[3, 4]), array_ops.placeholder(dtypes.float32, shape=[3, 7])) diff --git a/tensorflow/python/util/tf_should_use_test.py b/tensorflow/python/util/tf_should_use_test.py index cde67c4e4f5..65d848cf2a5 100644 --- a/tensorflow/python/util/tf_should_use_test.py +++ b/tensorflow/python/util/tf_should_use_test.py @@ -24,6 +24,7 @@ import gc import sys from tensorflow.python.framework import constant_op +from tensorflow.python.framework import test_util from tensorflow.python.platform import test from tensorflow.python.platform import tf_logging from tensorflow.python.util import tf_should_use @@ -39,6 +40,7 @@ def reroute_error(): class TfShouldUseTest(test.TestCase): + @test_util.run_deprecated_v1 def testAddShouldUseWarningWhenNotUsed(self): c = constant_op.constant(0, name='blah0') def in_this_function(): @@ -52,6 +54,7 @@ class TfShouldUseTest(test.TestCase): self.assertIn('in_this_function', msg) self.assertFalse(gc.garbage) + @test_util.run_deprecated_v1 def testAddShouldUseFatalWhenNotUsed(self): c = constant_op.constant(0, name='blah0') def in_this_function(): @@ -74,6 +77,7 @@ class TfShouldUseTest(test.TestCase): error.assert_not_called() fatal.assert_not_called() + @test_util.run_deprecated_v1 def testAddShouldUseWarningWhenUsedWithAdd(self): def add(h): _ = h + 1 @@ -81,6 +85,7 @@ class TfShouldUseTest(test.TestCase): gc.collect() self.assertFalse(gc.garbage) + @test_util.run_deprecated_v1 def testAddShouldUseWarningWhenUsedWithGetName(self): def get_name(h): _ = h.name @@ -88,6 +93,7 @@ class TfShouldUseTest(test.TestCase): gc.collect() self.assertFalse(gc.garbage) + @test_util.run_deprecated_v1 def testShouldUseResult(self): @tf_should_use.should_use_result def return_const(value): @@ -101,6 +107,7 @@ class TfShouldUseTest(test.TestCase): gc.collect() self.assertFalse(gc.garbage) + @test_util.run_deprecated_v1 def testShouldUseResultWhenNotReallyUsed(self): @tf_should_use.should_use_result def return_const(value): diff --git a/tensorflow/tools/api/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py index cba6246feff..e7f23a11740 100644 --- a/tensorflow/tools/api/tests/api_compatibility_test.py +++ b/tensorflow/tools/api/tests/api_compatibility_test.py @@ -39,6 +39,7 @@ from google.protobuf import message from google.protobuf import text_format from tensorflow.python.lib.io import file_io +from tensorflow.python.framework import test_util from tensorflow.python.platform import resource_loader from tensorflow.python.platform import test from tensorflow.python.platform import tf_logging as logging @@ -310,6 +311,7 @@ class ApiCompatibilityTest(test.TestCase): update_goldens=FLAGS.update_goldens, api_version=api_version) + @test_util.run_deprecated_v1 def testAPIBackwardsCompatibility(self): api_version = 1 golden_file_pattern = os.path.join( @@ -328,6 +330,7 @@ class ApiCompatibilityTest(test.TestCase): 'tensorflow.python.util.lazy_loader.LazyLoader' in str(type(tf.contrib))) + @test_util.run_deprecated_v1 def testAPIBackwardsCompatibilityV1(self): api_version = 1 golden_file_pattern = os.path.join(