ElementwiseOpUT继承了OpUT,包含了OpUT的能力。
ElementwiseOpUT主要供单输入单输出的Elementwise类型的算子进行测试用例的定义,例如Abs, Square等算子。
ElementwiseOpUT为这类算子提供了更加便利的接口,例如,创建算子编译用例时,对于一些简单场景无需输入format等信息。
ElementwiseOpUT(op_type, op_module_name=None, op_func_name=None)
@check_op_params(REQUIRED_INPUT, REQUIRED_INPUT, REQUIRED_OUTPUT, KERNEL_NAME) def add(input_x, input_y, output_z, kernel_name="add"):
ElementwiseOpUT.add_elewise_case(self, soc, param_info, expect=op_status.SUCCESS, case_name=None)
示例:
ut_case.add_elewise_case("Ascend910", ["float16", (32, 32), "ND"])
以上用例与调用如下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, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}]
})
ElementwiseOpUT.add_elewise_case_simple(self, soc, dtypes, shape, expect=op_status.SUCCESS, case_name=None)
此接口较add_elewise_case接口,相当于将输入的所有format配置为“ND”。
示例:
ut_case.add_elewise_case_simple("Ascend910", ["float16", "float32"], [32, 32])
以上用例与调用如下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, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float16"
}]
})
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, 32),
"ori_shape": (32, 32),
"format": "ND",
"ori_format": "ND",
"dtype": "float32"
}]
})