Commit 60059c6c authored by Aaron Watry's avatar Aaron Watry
Browse files

CL: refactor genclbuiltins.py to allow TSS functions with different arg types



Before, if you had a function that had 2-3 args, it was assumed that all
arguments were of the same base type.

Now, that assumption is removed and we used the argument type defined in the
test profile.

This will be useful in the next commit, where ldexp(floatN,int) is introduced.

This patch updates all multi-argument kernel generators to take an array of
input types, instead of assuming that all inputs are of the same base type as
the first argument.
Signed-off-by: Aaron Watry's avatarAaron Watry <awatry@gmail.com>
Reviewed-by: default avatarTom Stellard <thomas.stellard@amd.com>
parent 89f313c5
......@@ -139,44 +139,44 @@ def gen_kernel_1_arg(f, fnName, inType, outType):
gen_kernel(f, fnName, [inType], outType, [vecSize], '')
# 2 argument kernel with input types that match
def gen_kernel_2_arg_same_type(f, fnName, inType, outType):
# 2 argument kernel with input types that match their vector size
def gen_kernel_2_arg_same_size(f, fnName, inTypes, outType):
for vecSize in ALL_WIDTHS:
gen_kernel(f, fnName, [inType, inType], outType, [vecSize, vecSize],
gen_kernel(f, fnName, inTypes, outType, [vecSize, vecSize],
'')
# 2 argument kernel with 1 vector and one scalar input argument
def gen_kernel_2_arg_mixed_size(f, fnName, inType, outType):
def gen_kernel_2_arg_mixed_size(f, fnName, inTypes, outType):
for vecSize in VEC_WIDTHS:
gen_kernel(f, fnName, [inType, inType], outType, [vecSize, 1], 'tss_')
gen_kernel(f, fnName, inTypes, outType, [vecSize, 1], 'tss_')
# 2 argument kernel with 1 vector and one scalar input argument with multiple
# input data types
def gen_kernel_2_arg_mixed_sign(f, fnName, inType1, inType2, outType):
def gen_kernel_2_arg_mixed_sign(f, fnName, inTypes, outType):
for vecSize in ALL_WIDTHS:
gen_kernel(f, fnName, [inType1, inType2], outType, [vecSize, vecSize],
gen_kernel(f, fnName, inTypes, outType, [vecSize, vecSize],
'')
# 3-argument built-in functions
def gen_kernel_3_arg_same_type(f, fnName, inType, outType):
def gen_kernel_3_arg_same_type(f, fnName, inTypes, outType):
for vecSize in ALL_WIDTHS:
gen_kernel(f, fnName, [inType, inType, inType], outType,
gen_kernel(f, fnName, inTypes, outType,
[vecSize, vecSize, vecSize], ''
)
def gen_kernel_3_arg_mixed_size_tss(f, fnName, inType, outType):
def gen_kernel_3_arg_mixed_size_tss(f, fnName, inTypes, outType):
for vecSize in VEC_WIDTHS:
gen_kernel(f, fnName, [inType, inType, inType], outType,
gen_kernel(f, fnName, inTypes, outType,
[vecSize, 1, 1], 'tss_')
def gen_kernel_3_arg_mixed_size_tts(f, fnName, inType, outType):
def gen_kernel_3_arg_mixed_size_tts(f, fnName, inTypes, outType):
for vecSize in VEC_WIDTHS:
gen_kernel(f, fnName, [inType, inType, inType], outType,
gen_kernel(f, fnName, inTypes, outType,
[vecSize, vecSize, 1], 'tts_')
......@@ -189,21 +189,27 @@ def generate_kernels(f, dataType, fnName, fnDef):
return
if (len(argTypes) == 3 and not fnName is 'upsample'):
gen_kernel_2_arg_same_type(f, fnName, argTypes[1], argTypes[0])
gen_kernel_2_arg_same_size(f, fnName,
[argTypes[1], argTypes[2]], argTypes[0])
if (fnDef['function_type'] is 'tss'):
gen_kernel_2_arg_mixed_size(f, fnName, argTypes[1], argTypes[0])
gen_kernel_2_arg_mixed_size(f, fnName,
[argTypes[1], argTypes[2]], argTypes[0])
return
if (len(argTypes) == 4):
gen_kernel_3_arg_same_type(f, fnName, argTypes[1], argTypes[0])
gen_kernel_3_arg_same_type(f, fnName,
[argTypes[1], argTypes[2], argTypes[3]], argTypes[0])
if (fnDef['function_type'] is 'tss'):
gen_kernel_3_arg_mixed_size_tss(f, fnName, argTypes[1], argTypes[0])
gen_kernel_3_arg_mixed_size_tss(f, fnName,
[argTypes[1], argTypes[2], argTypes[3]], argTypes[0])
if (fnDef['function_type'] is 'tts'):
gen_kernel_3_arg_mixed_size_tts(f, fnName, argTypes[1], argTypes[0])
gen_kernel_3_arg_mixed_size_tts(f, fnName,
[argTypes[1], argTypes[2], argTypes[3]], argTypes[0])
return
if (fnName is 'upsample'):
gen_kernel_2_arg_mixed_sign(f, fnName, argTypes[1], argTypes[2],
gen_kernel_2_arg_mixed_sign(f, fnName,
[argTypes[1], argTypes[2]],
argTypes[0])
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment