Test Case Definition File

  • The following describes the Less operator's test case definition file (Less_case.json).
    [
        {
            "case_name": "Test_Less_001",       // Test case name
            "op": "Less",                       // Operator type
            "input_desc": [                     // Input description
                {                               // The first input
                    "format": ["ND"],            
                    "type": ["int32","float"],
                    "shape": [12,32],
                    "data_distribute": [       // Distribution mode selected for test data generation
                        "uniform"
                    ],
                    "value_range": [      // Value range of the input
                        [
                            1.0,
                            384.0
                        ]
                    ]
                },
                {                                // The second input
                    "format": ["ND"],
                    "type": ["int32","float"],
                    "shape": [12,32],
                    "data_distribute": [
                        "uniform"
                    ],
                    "value_range": [
                        [
                            1.0,
                            384.0
                        ]
                    ]
                }
            ],
            "output_desc": [                    // Output description
                {
                    "format": ["ND"],
                    "type": ["bool","bool"],
                    "shape": [12,32]
                }
            ]
        },
        {
            "case_name": "Test_Less_002",
            "op": "Less",
            "input_desc": [
                {                               
                 ...
                },
                {                   
                 ... 
                }
            ],
            "output_desc": [
                {
                  ...
                }
            ]
        }
    ]
  • If the operator has attributes, the test case definition file is as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    [
        {
            "case_name":"Test_Conv2D_001",        // Test case name
            "op": "Conv2D",                      // Operator type, which is unique
            "input_desc": [            // Input description
                {                     // The first input
                    "format": [      // User-defined input format
                        "ND",
                        "NCHW"
                    ],
                    "type": [         // Input data types
                        "float",
                        "float16"
                    ],
                    "shape": [8,512,7,7],     // User-defined shape of the input tensor
                    "data_distribute": [            // Distribution mode selected for test data generation
                        "uniform"                 
                    ],
                    "value_range": [      // Value range of the input
                        [
                            0.1,
                            200000.0
                        ]
                    ]
                },
                {                     // The second input
                    "format": [
                        "ND",
                        "NCHW"
                    ],
                    "type": [
                        "float",
                        "float16"
                    ],
                    "shape": [512,512,3,3],
                    "data_distribute": [
                        "uniform"
                    ],
                    "value_range": [
                        [
                            0.1,
                            200000.0
                        ]
                    ]
                }
            ],  
            "output_desc": [                       // (Required) The same as the input tensor description
                {
                    "format": [
                        "ND",
                        "NCHW"
                    ],
                    "type": [
                        "float",
                        "float16"
                    ],
                    "shape": [8,512,7,7]
                }
            ],
            "attr": [                           // Operator attributes
                {
                    "name": "strides",          // Attribute name
                    "type": "list_int",         // Attribute data type
                   "value": [1,1,1,1]           // Attribute value, which matches the configured type
                },
               {
                    "name": "pads",
                    "type": "list_int",
                    "value": [1,1,1,1]
                },
                {
                    "name": "dilations",
                    "type": "list_int",
                    "value": [1,1,1,1]
                }
    
            ]
        }
    ]
    
  • If you need to specify an input, for example, to specify the axes parameter of the ReduceSum operator, the test case definition file is as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    [
        {
    	"case_name": "Test_ReduceSum_001",
            "op": "ReduceSum",
            "input_desc": [
                {
                    "format": ["ND"],
                    "type": ["int32"],         // To specify the value to be tested, only one data type can be specified per test case.
                    "shape": [3,6,3,4],
                    "data_distribute": [
                        "uniform"
                    ],
                    "value_range": [
                        [
                            -384,
                            384
                        ]
                    ]
                },
    	    {
    		"format": ["ND"],
                    "type": ["int32"],
                    "shape": [2],
                    "data_distribute": [
                        "uniform"
                    ],
                    "value_range": [
                        [
                            -3,
                            1
                        ]
                    ],
    		"value":[0,2]            // Configure a specific value, which must match that of shape.
                }
    	],
    	"output_desc": [
                {
                    "format": ["ND"],
                    "type": ["int32"],
                    "shape": [6,4]
                }
            ],
    	"attr":[
    	    {
    		"name":"keep_dims",
    		"type":"bool",
    		"value":false
    	    }
    	]
        }
    ]
    
  • If type of an operator is set to data_type, the test case definition file is as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    [
        {
    	"case_name": "Test_ArgMin_001",
            "op": "ArgMin",
            "input_desc": [
                {
                ...
                },
    	    {
                ...
                }
    	],
    	"output_desc": [
                {
                ...
                }
            ],
    	"attr":[
    	    {
    		"name":"dtype",
    		"type":"data_type",
    		"value":"int64"
    	    }
    	]
        }
    ]
    
  • The following is an example operator that allows an uncertain number of inputs (dynamic multi-input operator).
    Take the AddN operator as an example. If value of the N attribute is 3, there must be three inputs (that is, x0, x1, and x2 in the example), each of which has its own description.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    [
        {
            "op": "AddN",
            "input_desc": [
                {
    		"name":"x0",
                    "format": "NCHW",
                    "shape": [1,3,166,166],
                    "type": "float32"
                },
                {
    		"name":"x1",
                    "format": "NCHW",
                    "shape": [1,3,166,166],
                    "type": "int32"
                },
                {
    		"name":"x2",
                    "format": "NCHW",
                    "shape": [1,3,166,166],
                    "type": "float32"
                }
            ],
            "output_desc": [
                {
                    "format": "NCHW",
                    "shape": [1,3,166,166],
                    "type": "float32"
                }
            ],
            "attr": [
                {
                    "name": "N",
                    "type": "int",
                    "value": 3
                }
            ]
        }
    ]
    
  • If an input of the operator is a constant, the test case definition file is as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    [
        {
            "case_name":"Test_OpType_001", 
            "op": "OpType", 
            "input_desc": [            
                {                     
                    "format": ["ND"],
                    "type": ["int32"],
                    "shape": [1], 
                    "is_const":true,           // The input is a constant.
                    "data_distribute": [            
                        "uniform"                 
                    ],
                    "value":[11],              // Constant value
                    "value_range": [           // Pass constant values to min_value and max_value.
                        [
                            11,
                            11
                        ]
                    ]
                },
                {                     
                      ...
                }
            ],  
            "output_desc": [                     
                {
                    ...
                }
            ]
        }
    ]
    
  • If the data types of the operator inputs and outputs are complex numbers, the test case definition file is as follows:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    [
       {
            "case_name": "Test_ReduceSum_001",
            "op": "ReduceSum",
            "input_desc": [
                {
                    "format": ["ND"],
                    "type": [
                        "complex64",    // The input is of the complex type.
                        "complex128"    // The input is of the complex type.
                            ],
                    "shape": [3,6],
                    "data_distribute": [
                        "uniform"
                    ],
                    "value_range": [ // Value range of the real part
                        [
                            1,
                            10
                        ]
                    ]
                },
             {
                 "format": ["ND"],
                 "type": [
                         "int32",
                         "int64"],
                 "shape": [1],
                 "data_distribute": [
                        "uniform"
                    ],
                 "value_range": [
                        [
                            1,
                            1
                        ]
                    ]
                }
            ],
             "output_desc": [
                {
                    "format": ["ND"],
                    "type": [
                        "complex64",    // The input is of the complex type.
                        "complex128"    // The input is of the complex type.
                            ],
                    "shape": [3]
                }
            ],
            "attr":[
              {
                   "name":"keep_dims",
                   "type":"bool",
                   "value":false
              }
           ]
        }
    ]