diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2018-01-31 20:41:02 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2018-01-31 20:41:02 +0100 |
commit | ef5008f5e46c4fe6d3728beff1d3277d02aae099 (patch) | |
tree | 3b01fe2150bd394dbf3a8b411d30de63145243f6 /scripts | |
parent | 37c5e8f58c8c6a1f8888938baa67691f8ecddaf4 (diff) |
Created the API and stubs for the HAD (hadamard-product) routines
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/generator/generator.py | 2 | ||||
-rw-r--r-- | scripts/generator/generator/routine.py | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/scripts/generator/generator.py b/scripts/generator/generator.py index b77b861e..847bd896 100755 --- a/scripts/generator/generator.py +++ b/scripts/generator/generator.py @@ -83,6 +83,7 @@ xn = "n * x_inc" xm = "m * x_inc" yn = "n * y_inc" ym = "m * y_inc" +zn = "n * z_inc" an = "n * a_ld" apn = "((n*(n+1)) / 2)" cn = "n * c_ld" @@ -169,6 +170,7 @@ ROUTINES = [ ], [ # Level X: extra routines (not part of BLAS) # Special routines: + Routine(True, True, 0, False, "x", "had", T, [S,D,C,Z,H], ["n"], [], ["x","y"], ["z"], [xn,yn,zn], ["alpha","beta"], "", "Element-wise vector product (Hadamard)", "Performs the Hadamard element-wise product _z = alpha * x * y + beta * z_, in which _x_, _y_, and _z_z are vectors and _alpha_ and _beta_ are scalar constants.", []), Routine(True, True, 0, False, "x", "omatcopy", T, [S,D,C,Z,H], ["m","n"], ["layout","a_transpose"], ["a"], ["b"], [amn,bnma], ["alpha"], "", "Scaling and out-place transpose/copy (non-BLAS function)", "Performs scaling and out-of-place transposition/copying of matrices according to _B = alpha*op(A)_, in which _A_ is an input matrix (_m_ rows by _n_ columns), _B_ an output matrix, and _alpha_ a scalar value. The operation _op_ can be a normal matrix copy, a transposition or a conjugate transposition.", [ald_m, bld_n]), Routine(True, True, 0, False, "x", "im2col", T, [S,D,C,Z,H], im2col_constants, [], ["im"], ["col"], [im,col], [""], "", "Im2col function (non-BLAS function)", "Performs the im2col algorithm, in which _im_ is the input matrix and _col_ is the output matrix.", []), # Batched routines: diff --git a/scripts/generator/generator/routine.py b/scripts/generator/generator/routine.py index f7c2a701..052709ee 100644 --- a/scripts/generator/generator/routine.py +++ b/scripts/generator/generator/routine.py @@ -129,12 +129,12 @@ class Routine: @staticmethod def postfix(name): """Retrieves the postfix for a buffer""" - return "inc" if (name in ["x", "y"]) else "ld" + return "inc" if (name in ["x", "y", "z"]) else "ld" @staticmethod def buffers_vector(): """Distinguish between vectors and matrices""" - return ["x", "y"] + return ["x", "y", "z"] @staticmethod def buffers_matrix(): @@ -219,13 +219,13 @@ class Routine: def buffers_first(self): """Determines which buffers go first (between alpha and beta) and which ones go after""" - if self.level == "2b": + if self.level == "2b" or self.name == "had": return ["x", "y"] return ["ap", "a", "b", "x", "im"] def buffers_second(self): - if self.level == "2b": - return ["ap", "a", "b", "c"] + if self.level == "2b" or self.name == "had": + return ["z", "ap", "a", "b", "c"] return ["y", "c", "col"] def buffer(self, name): @@ -330,7 +330,7 @@ class Routine: a = [name + "_buffer()"] b = [name + "_offset"] c = [] - if name in ["x", "y"]: + if name in ["x", "y", "z"]: c = ["static_cast<int>(" + name + "_" + self.postfix(name) + ")"] elif name in ["a", "b", "c"]: c = [name + "_" + self.postfix(name)] @@ -349,7 +349,7 @@ class Routine: else: a = ["&" + name + "_buffer[" + name + "_offset]"] c = [] - if name in ["x", "y", "a", "b", "c"]: + if name in ["x", "y", "z", "a", "b", "c"]: c = ["static_cast<int>(" + name + "_" + self.postfix(name) + ")"] return [", ".join(a + c)] return [] @@ -370,7 +370,7 @@ class Routine: else: a = ["&" + name + "_buffer[" + name + "_offset]"] c = [] - if name in ["x", "y"]: + if name in ["x", "y", "z"]: c = ["static_cast<int>(" + name + "_" + self.postfix(name) + ")"] elif name in ["a", "b", "c"]: c = [name + "_" + self.postfix(name)] |