Caffe2 - Python API
A deep learning, cross platform ML framework
Classes | Public Member Functions | Public Attributes | List of all members
test_jit.TestScript Class Reference
Inheritance diagram for test_jit.TestScript:
test_jit.JitTestCase common_utils.TestCase expecttest.TestCase

Classes

class  DerivedStateModule
 
class  StarTestReturnThree
 
class  StarTestSumAndReturnThree
 
class  StarTestSumStarred
 

Public Member Functions

def capture_stdout (self)
 
def checkScriptRaisesRegex (self, script, inputs, exception, regex, optimize=True, outputs=None, capture_output=False)
 
def test_training_param (self)
 
def test_jitter_bug (self)
 
def test_parser_kwargonly (self)
 
def test_annoying_doubles (self)
 
def test_type_annotate (self)
 
def test_robust_op_resolution (self)
 
def test_tuple_io (self)
 
def test_tuple_create_return (self)
 
def test_list_io (self)
 
def get_sum_list_fn (self)
 
def test_sum_list_diff_elms (self)
 
def test_sum_list_empty (self)
 
def test_sum_list_one (self)
 
def test_sum_list_literal (self)
 
def test_sum_list_wrong_type (self)
 
def test_bool_list_io (self)
 
def test_nested_list (self)
 
def test_nested_list_construct (self)
 
def test_tensor_shape (self)
 
def test_tensor_grad (self)
 
def test_tensor_dtype (self)
 
def test_tensor_device (self)
 
def test_tensor_to_device (self)
 
def test_tensor_to_cpu (self)
 
def test_tensor_to_cuda (self)
 
def test_generic_list_errors (self)
 
def test_script_cu (self)
 
def test_string_cu (self)
 
def test_string_ops (self)
 
def test_string_new_line (self)
 
def test_string_single_escape (self)
 
def test_script_annotation (self)
 
def test_inf (self)
 
def test_add (self)
 
def test_mul (self)
 
def test_matmul_py3 (self)
 
def test_pow (self)
 
def test_triple (self)
 
def test_slice (self)
 
def test_gather (self)
 
def test_random (self)
 
def test_scriptmodule_releases_tensors_cuda (self)
 
def test_index (self)
 
def test_tensor_item (self)
 
def test_method_on_number (self)
 
def test_scalar_to_num_conversions (self)
 
def test_tuple_to_opt_list (self)
 
def test_advancedindex (self)
 
def test_keyword (self)
 
def test_constant_pooling_none (self)
 
def test_literal (self)
 
def test_expand (self)
 
def test_sum (self)
 
def test_cat (self)
 
def test_cat_lifts (self)
 
def test_list_literal (self)
 
def test_list_gather (self)
 
def test_tensor_len (self)
 
def test_list_len (self)
 
def test_list_ops (self)
 
def test_list_slice (self)
 
def test_mutable_list_append (self)
 
def test_mutable_list_append_2 (self)
 
def test_mutable_list_append_if (self)
 
def test_mutable_list_append_if_else (self)
 
def test_mutable_list_append_loop (self)
 
def test_mutable_list_append_loop_if (self)
 
def test_mutable_list_nested_loop (self)
 
def test_mutable_list_function_inline (self)
 
def test_mutable_list_reverse_empty (self)
 
def test_mutable_list_reverse (self)
 
def test_mutable_tensor_list_reverse (self)
 
def test_mutable_list_pop_empty (self)
 
def test_mutable_list_pop (self)
 
def test_mutable_list_pop2 (self)
 
def test_mutable_list_pop_at (self)
 
def test_mutable_list_pop_at2 (self)
 
def test_mutable_list_pop_at_negative (self)
 
def test_mutable_list_pop_at_negative2 (self)
 
def test_mutable_list_pop_slice (self)
 
def test_mutable_list_clear_empty (self)
 
def test_mutable_list_clear (self)
 
def test_mutable_list_insert (self)
 
def test_mutable_list_insert_negative (self)
 
def test_mutable_list_insert_neg_out_of_bounds (self)
 
def test_mutable_list_insert_out_of_bounds (self)
 
def test_mutable_list_remove_not_existing (self)
 
def test_mutable_list_remove (self)
 
def test_list_index_not_existing (self)
 
def test_list_index (self)
 
def test_tensor_list_index (self)
 
def test_tensor_list_index_not_existing (self)
 
def test_list_count (self)
 
def test_list_count_not_existing (self)
 
def test_tensor_list_count (self)
 
def test_tensor_list_count_not_existing (self)
 
def test_mutable_list_remove_tensor (self)
 
def test_mutable_list_remove2 (self)
 
def test_extend_list_mutable (self)
 
def test_extend_list_immutable (self)
 
def test_copy_list_mutable (self)
 
def test_copy_list_immutable (self)
 
def test_func_call (self)
 
def test_resize_input_ops (self)
 
def test_view_shape_prop (self)
 
def test_view_listconstruct_shape_prop (self)
 
def test_integral_shape_inference (self)
 
def test_fuser_multiple_blocks (self)
 
def test_dropout_script (self)
 
def test_cast (self)
 
def test_python_frontend (self)
 
def test_python_frontend_py2 (self)
 
def test_python_frontend_py3 (self)
 
def test_string_print (self)
 
def test_while (self)
 
def test_fibb (self)
 
def test_if (self)
 
def test_if_for_in_range (self)
 
def test_if_noelse (self)
 
def test_if_is_none_dispatch (self)
 
def test_explicit_bool_cast (self)
 
def test_while_nonexistent_value (self)
 
def test_while_nonexistent_cond_value (self)
 
def test_optional_refinement (self)
 
def test_while_write_outer_then_read (self)
 
def test_while_nest_if (self)
 
def test_math_ops (self)
 
def test_if_nest_while (self)
 
def test_script_for_in_range (self)
 
def test_script_for_in_range_dynamic (self)
 
def test_script_for_in_range_ast (self)
 
def test_script_for_in_range_if_ast (self)
 
def test_script_optional_none (self)
 
def test_script_clamp_none (self)
 
def test_script_bool_constant (self)
 
def test_ternary (self)
 
def test_print (self)
 
def test_format (self)
 
def test_logical_short_circuit (self)
 
def test_type_cast (self)
 
def test_multiple_assignment (self)
 
def test_literals (self)
 
def test_return (self)
 
def test_error (self)
 
def test_binop_unsupported_error (self)
 
def test_bitwise_ops (self)
 
def test_number_math (self)
 
def test_number_div (self)
 
def test_floor_div (self)
 
def test_number_augassign (self)
 
def test_number_neg (self)
 
def test_tensor_number_math (self)
 
def test_torch_tensor_bad_input (self)
 
def test_torch_tensor_empty_list (self)
 
def test_torch_tensor (self)
 
def test_tensor_to (self)
 
def test_tensor_number_math_cuda (self)
 
def test_not (self)
 
def test_is_isnot (self)
 
def test_isinstance (self)
 
def test_python_call (self)
 
def test_python_call_failure (self)
 
def test_python_call_annotation (self)
 
def test_python_call_annoytation_failure (self)
 
def test_desugar_module (self)
 
def test_script_docstring (self)
 
def test_script_method_docstring (self)
 
def test_rnn_cell_quantized (self)
 
def test_script_module (self)
 
def test_filecheck (self)
 
def test_script_module_call_noscript (self)
 
def test_script_module_nochange_submodule (self)
 
def test_script_inline_trace_multiple_args (self)
 
def test_script_module_const (self)
 
def test_script_module_fail_const (self)
 
def test_script_module_valid_consts (self)
 
def test_script_module_param_buffer_mutation (self)
 
def test_script_module_for (self)
 
def test_script_module_for2 (self)
 
def test_script_module_const_submodule_fail (self)
 
def test_pack_unpack_state (self)
 
def test_pack_unpack_nested (self)
 
def test_script_module_not_tuple (self)
 
def test_script_module_list_sequential_error (self)
 
def test_script_sequential_for (self)
 
def test_script_sequential_multi_output_fail (self)
 
def test_constant_insert_fail_lint (self)
 
def test_script_sequential_in_mod_list (self)
 
def test_script_nested_mod_list (self)
 
def test_constant_as_attr (self)
 
def test_script_star_expr (self)
 
def test_script_star_expr_string (self)
 
def test_script_star_assign (self)
 
def test_script_module_star_assign2 (self)
 
def test_script_module_star_assign2_inplace (self)
 
def test_script_module_star_assign_fail_pythonop (self)
 
def test_script_module_star_assign_fail_builtin (self)
 
def test_pack_padded_pad_packed_trace (self)
 
def test_script_outputs (self)
 
def test_script_get_device_cuda (self)
 
def test_script_chunk (self)
 
def test_rnn_trace_override (self)
 
def test_python_call_non_tensor (self)
 
def test_python_call_non_tensor_wrong (self)
 
def test_tuples (self)
 
def test_if_tuple_sizes (self)
 
def test_if_different_type (self)
 
def test_if_list_cat (self)
 
def test_if_supertype (self)
 
def test_list_unify (self)
 
def test_type_annotations_repeated_list (self)
 
def test_ntuple_builtins (self)
 
def test_embedding_renorm_grad_error (self)
 
def test_type_annotations (self)
 
def test_type_annotations_varargs (self)
 
def test_type_annotation_py3 (self)
 
def test_type_annotation_module (self)
 
def test_script_define_order (self)
 
def test_script_define_order_recursive_fail (self)
 
def test_script_kwargs_fn_call (self)
 
def test_trace_of_script (self)
 
def test_if_define (self)
 
def test_script_module_export_submodule (self)
 
def test_script_module_trace_resnet18 (self)
 
def test_script_module_script_resnet (self)
 
def test_script_module_export_tensor_type (self)
 
def test_script_module_export_tensor_cuda (self)
 
def test_script_module_export_blocks (self)
 
def test_script_module_export_shared_storage (self)
 
def test_onnx_export_script_module (self)
 
def test_trace_nested_datatypes (self)
 
def test_onnx_export_func_with_warnings (self)
 
def test_onnx_export_script_python_fail (self)
 
def test_onnx_export_script_inline_trace (self)
 
def test_onnx_export_script_inline_script (self)
 
def test_onnx_export_script_module_loop (self)
 
def test_onnx_export_script_truediv (self)
 
def test_onnx_raw_export_script_truediv (self)
 
def test_onnx_export_script_non_alpha_add_sub (self)
 
def test_onnx_export_script_module_if (self)
 
def test_onnx_export_script_inline_params (self)
 
def test_trace_with_size (self)
 
def test_tracing_slicing (self)
 
def test_tracing_indexing (self)
 
def test_index_select_shape_prop (self)
 
def test_onnx_export_speculate (self)
 
def test_onnx_export_shape_reshape (self)
 
def test_shape_analysis_loop (self)
 
def test_intlist_args (self)
 
def test_wrong_implicit_expand (self)
 
def test_builtin_args_fails (self)
 
def test_builtin_args (self)
 
def test_parser_type_annotations (self)
 
def test_parser_type_annotations_comment (self)
 
def test_parser_type_annotations_unknown_type (self)
 
def test_parser_type_annotations_subscript_non_ident (self)
 
def test_parser_type_annotations_subscript_tensor (self)
 
def test_parser_type_annotations_incompatible_expression (self)
 
def test_gather_dynamic_index (self)
 
def test_slice_dynamic_index (self)
 
def test_addmm_grad (self)
 
def test_zeros (self)
 
def test_vararg_zeros (self)
 
def test_rand (self)
 
def test_erase_number_types (self)
 
def test_mm_batching (self)
 
def test_loop_unrolling (self)
 
def test_loop_unrolling_const (self)
 
def test_loop_unrolling_nested (self)
 
def test_loop_unroll_unused_counter (self)
 
def test_loop_unroll_negative (self)
 
def test_where (self)
 
def test_where_method (self)
 
def test_reassign_module_lhs (self)
 
def test_reassign_module_rhs (self)
 
def test_unknown_builtin (self)
 
def test_return_tuple (self)
 
def test_method_no_self (self)
 
def test_return_stmt_not_at_end (self)
 
def test_for_range_no_arg (self)
 
def test_list_iterables (self)
 
def test_for_tuple_unpack (self)
 
def test_single_starred_lhs (self)
 
def test_singleton_tuple_unpack (self)
 
def test_multi_reduction (self)
 
def test_invalid_call_arguments (self)
 
def test_invalid_lhs_assignment (self)
 
def test_multi_starred_expr_lhs (self)
 
def test_pack_tuple_into_non_var (self)
 
def test_print_kwargs (self)
 
def test_builtin_use_as_value (self)
 
def test_wrong_use_as_tuple (self)
 
def test_wrong_attr_lookup (self)
 
def test_wrong_use_as_callable (self)
 
def test_python_val_doesnt_have_attr (self)
 
def test_wrong_module_attr_lookup (self)
 
def test_wrong_method_call_inputs (self)
 
def test_single_starred_expr_for_loop (self)
 
def test_duplicate (self)
 
def test_call_ge (self)
 
def test_wrong_return_type (self)
 
def test_call_python_fn_from_tracing_fn (self)
 
def test_call_python_mod_from_tracing_fn (self)
 
def test_call_traced_fn_from_tracing_fn (self)
 
def test_call_traced_mod_from_tracing_fn (self)
 
def test_call_script_fn_from_tracing_fn (self)
 
def test_call_script_mod_from_tracing_fn (self)
 
def test_call_python_fn_from_traced_module (self)
 
def test_call_python_mod_from_traced_module (self)
 
def test_call_traced_fn_from_traced_module (self)
 
def test_trace_hierarchy (self)
 
def test_trace_parameter (self)
 
def test_call_traced_module_from_traced_module (self)
 
def test_call_script_fn_from_traced_module (self)
 
def test_call_script_module_from_traced_module (self)
 
def test_call_python_fn_from_script_fn (self)
 
def test_call_python_mod_from_script_fn (self)
 
def test_call_traced_fn_from_script_fn (self)
 
def test_call_traced_mod_from_script_fn (self)
 
def test_call_script_fn_from_script_fn (self)
 
def test_call_script_mod_from_script_fn (self)
 
def test_call_python_fn_from_script_module (self)
 
def test_call_python_mod_from_script_module (self)
 
def test_call_tracing_fn_from_script_module (self)
 
def test_call_tracing_mod_from_script_module (self)
 
def test_call_script_fn_from_script_module (self)
 
def test_call_script_mod_from_script_module (self)
 
def test_module_with_params_called_fails (self)
 
def test_index_put_trace_with_view (self)
 
def test_index_put_trace_without_view (self)
 
def test_tuple_indexing (self)
 
def test_namedtuple_attr (self)
 
def test_tuple_slicing (self)
 
def test_unwrap_optional_builtin (self)
 
def test_indexing_error (self)
 
def test_annotated_script_fn (self)
 
def test_annotated_script_method (self)
 
def test_annotated_script_fn_return_mismatch (self)
 
def test_annotated_script_fn_arg_mismatch (self)
 
def test_script_non_tensor_args_outputs (self)
 
def test_inline_and_run_annotated_script_fn (self)
 
def test_file_format_serialization (self)
 
def type_input_return_pairs (self)
 
def format_code (self, code, pair)
 
def test_annot_string_py3_fn (self)
 
def test_annot_string_py3_method (self)
 
def test_annot_string_mypy_fn (self)
 
def test_annot_string_mypy_method (self)
 
def test_annot_ast_py3_fn (self)
 
def test_annot_ast_py3_method (self)
 
def test_annot_ast_mypy_fn (self)
 
def test_annot_ast_mypy_method (self)
 
def test_method_casts_script (self)
 
def test_listconstruct_erasure (self)
 
def test_trace_checker_arange_as_constant (self)
 
def test_trace_checker_dot_data (self)
 
def test_trace_checker_control_flow (self)
 
def test_trace_checker_memoization (self)
 
def test_int8_quantization_module (self)
 
def checkTracerWarning (self, args, kwargs)
 
def test_trace_checker_slice_lhs (self)
 
def test_trace_checker_inplace_on_view (self)
 
def test_lhs_index_fails (self)
 
def test_lhs_index_trivial (self)
 
def test_inplace_warn (self)
 
def test_trace_checker_dropout_train (self)
 
def test_trace_checker_dropout_notrain (self)
 
def test_export_dynamic_slice (self)
 
def test_string_frontend_elif (self)
 
def test_pyop_exception_message (self)
 
def test_builtin_error_messsage (self)
 
def test_exceptions (self)
 
def test_assertions (self)
 
def test_weak_script_function (self)
 
def test_python_op_exception (self)
 
def test_trace_contiguous (self)
 
def test_trace_contiguous_short_circuit (self)
 
def test_weak_module (self)
 
def test_weak_module_parameters_and_buffers (self)
 
def test_weak_module_nested (self)
 
def test_weak_module_submodule (self)
 
def test_weak_module_copying (self)
 
def test_backend_cudnn_enabled (self)
 
def test_inplace_add (self)
 
def test_add_out (self)
 
def test_augmented_assign (self)
 
def test_pass (self)
 
def test_optional_conversion (self)
 
def test_lhs_indexing (self)
 
def test_lhs_advanced_indexing_assignment (self)
 
def test_lhs_advanced_indexing_augmented_assignment (self)
 
def test_lhs_indexing_list (self)
 
def test_inplace_copy_script (self)
 
def test_lhs_indexing_increment (self)
 
def test_lhs_indexing_increment_list (self)
 
def test_lhs_indexing_increment_list_prim (self)
 
def test_lhs_indexing_multi (self)
 
def test_bool_dispatch (self)
 
def test_infer_size (self)
 
def test_mutable_dce (self)
 
def test_mutable_dce_block (self)
 
def test_mutable_dce_graph_input (self)
 
def test_mutable_dce_list (self)
 
def test_mutable_dce_loop (self)
 
def test_mutable_dce_wildcards (self)
 
def test_cpp_function_tensor_str (self)
 
def test_non_final_return (self)
 
def test_overloading (self)
 
def test_select_after_chunk (self)
 
def test_nn_LSTM (self)
 
def test_list_python_op (self)
 
def test_ignore_decorator (self)
 
def test_view_write (self)
 
def test_dict_view (self)
 
def test_dict_ops (self)
 
def test_dict (self)
 
def test_dict_mutability (self)
 
def test_dict_membership (self)
 
def dict_to_python (self)
 
def test_module_attrs (self)
 
def test_tensor_import_export (self)
 
def test_attribute_serialization (self)
 
def test_attribute_unpickling (self)
 
def test_submodule_attribute_serialization (self)
 
def test_optional_tuple (self)
 
def test_split (self)
 
- Public Member Functions inherited from test_jit.JitTestCase
def setUp (self)
 
def tearDown (self)
 
def disableModuleHook (self)
 
def emitModuleHook (self, module)
 
def getExportImportCopy (self, m, also_test_file=True, map_location=None)
 
def getExportImportCopyWithPacking (self, m, also_test_file=True, map_location=None)
 
def assertGraphContains (self, graph, kind)
 
def assertGraphContainsExactly (self, graph, kind, num_kind_nodes, consider_subgraphs=False)
 
def assertExpectedONNXGraph (self, trace, args, kwargs)
 
def assertExpectedGraph (self, trace, args, kwargs)
 
def run_pass (self, name, trace)
 
def checkScript (self, script, inputs, optimize=True, outputs=None, name='func', capture_output=False, frames_up=1, check_expected=False)
 
def checkTrace (self, func, reference_tensors, input_tensors=None, optimize=True, drop=None, allow_unused=False, verbose=False, inputs_require_grads=True, check_tolerance=1e-5, export_import=True, _force_outplace=False)
 
def createScriptModuleFromGraph (self, trace)
 
def assertExportImport (self, trace, inputs)
 
def assertExportImportModule (self, m, inputs)
 
def runAndSaveRNG (self, func, inputs, kwargs=None)
 
- Public Member Functions inherited from common_utils.TestCase
def __init__ (self, method_name='runTest')
 
def assertLeaksNoCudaTensors (self, name=None)
 
def wrap_with_cuda_memory_check (self, method)
 
def setUp (self)
 
def assertTensorsSlowEqual (self, x, y, prec=None, message='')
 
def genSparseTensor (self, size, sparse_dim, nnz, is_uncoalesced, device='cpu')
 
def safeToDense (self, t)
 
def safeCoalesce (self, t)
 
def assertEqual (self, x, y, prec=None, message='', allow_inf=False)
 
def assertAlmostEqual (self, x, y, places=None, msg=None, delta=None, allow_inf=None)
 
def assertNotEqual (self, x, y, prec=None, message='')
 
def assertObjectIn (self, obj, iterable)
 
def assertExpectedRaises (self, exc_type, callable, args, kwargs)
 
def assertWarns (self, callable, msg='')
 
def assertWarnsRegex (self, callable, regex, msg='')
 
def assertExpected (self, s, subname=None)
 
- Public Member Functions inherited from expecttest.TestCase
def assertExpectedInline (self, actual, expect, skip=0)
 

Public Attributes

 cell
 
 weight
 
 a
 
 sub
 
 sub2
 
 bias
 
 value
 
 m
 
 b
 
 i
 
 c
 
 d
 
 e
 
 f
 
 g
 
 h
 
 mods
 
 tensor_constant
 
 ssm
 
 submod
 
 someseq
 
 dim
 
 rnn
 
 conv1
 
 bn1
 
 relu
 
 conv2
 
 bn2
 
 downsample
 
 stride
 
 inplanes
 
 maxpool
 
 layer1
 
 layer2
 
 layer3
 
 layer4
 
 avgpool
 
 fc
 
 param
 
 param1
 
 param2
 
 param3
 
 param4
 
 mod
 
 unused
 
 asm
 
 traced
 
 module
 
 param_foo
 
 pm
 
 tm
 
 linear1
 
 conv
 
 number
 
 weak
 
 strong
 
 in_features
 
 out_features
 
 fc1
 
 fc2
 
 constant
 
 weak_submodule
 
 strong_submodule
 
 weak2
 
 submodule
 
 x
 
 some_state
 
 table
 
 float
 
 int
 
 tuple
 
 list
 
 tensor
 
 int_list
 
 id
 
 data
 
 s1
 
 s2
 

Additional Inherited Members

- Static Public Attributes inherited from common_utils.TestCase
int precision = 1
 
 maxDiff = None
 
 assertRegex = unittest.TestCase.assertRegexpMatches
 
 assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
 
- Static Public Attributes inherited from expecttest.TestCase
bool longMessage = True
 

Detailed Description

Definition at line 2973 of file test_jit.py.

Member Function Documentation

def test_jit.TestScript.checkScriptRaisesRegex (   self,
  script,
  inputs,
  exception,
  regex,
  optimize = True,
  outputs = None,
  capture_output = False 
)
Checks that a given function will throw the correct exception,
when executed with normal python, the string frontend, and the AST frontend

Definition at line 3015 of file test_jit.py.

def test_jit.TestScript.test_addmm_grad (   self)
This test checks several things:
    1. An expand node was inserted before the addmm operating on the
       bias term.
    2. The fused form of addmm appears in the ultimate graph that's
       executed.
    3. A sum op was emitted for accumulating gradients along the 0th
       (expanded) dimension of the bias term.
    4. The correct symbolic representation for the backward pass of the
       mm operator was emitted (x.t() -> mm)

    TODO: we should actually check these conditions once we have a way
    to dump the GraphExecutor state. Namely the processed forward graph
    and the backward graph.

Definition at line 8093 of file test_jit.py.


The documentation for this class was generated from the following file: