ReduceOpUT继承了OpUT,包含了OpUT的能力。
ReduceOpUT主要供Reduce类型的算子进行测试用例的定义,例如ReduceSum, ReduceMean等算子。ReduceOpUT为这类算子提供了更加便利的接口,例如,创建算子编译用例时,对于一些简单场景无需输入format等信息。
@check_op_params(REQUIRED_INPUT, REQUIRED_INPUT, REQUIRED_OUTPUT, KERNEL_NAME) def add(input_x, input_y, output_z, kernel_name="add"):
ReduceOpUT.add_reduce_case(self, soc, input_info, axes, keep_dim=False, expect=op_status.SUCCESS, case_name=None)
示例:
ut_case.add_reduce_case("Ascend910", ["float16", (32, 32), "ND"], [0,], False)
以上用例与调用如下add_case接口的用例实现功能相同:
ut_case.add_case(support_soc="Ascend910", case={
"params": [{
"shape": (32, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}, {
"shape": (32,),
"ori_shape": (32,),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}, [0,], False]
})
ReduceOpUT.add_reduce_case_simple(self, soc, dtypes, shape, axes, keep_dim=False, expect=op_status.SUCCESS, case_name=None)
此接口较add_reduce_case接口,相当于将输入的所有format配置为“ND”。
示例:
ut_case.add_reduce_case_simple("Ascend910", ["float16", "float32"], [32, 32], [1,], True)
以上用例与调用如下add_case接口的用例实现功能相同:
ut_case.add_case(support_soc="Ascend910", case={
"params": [{
"shape": (32, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}, {
"shape": (32, 1),
"ori_shape": (32, 1),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}, [1,], True]
})
ut_case.add_case(support_soc="Ascend910", case={
"params": [{
"shape": (32, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float32"
}, {
"shape": (32, 1),
"ori_shape": (32, 1),
"format": "ND",
"ori_format": "ND",
"dtype": "float32"
}, [1,], True]
})