20 lines
701 B
Plaintext
20 lines
701 B
Plaintext
# User defined generic function that operates on unknown shaped arguments.
|
|
def multiply_transpose(a, b) {
|
|
return transpose(a) * transpose(b);
|
|
}
|
|
|
|
def main() {
|
|
# Define a variable `a` with shape <2, 3>, initialized with the literal value.
|
|
var a = [[1, 2, 3], [4, 5, 6]];
|
|
var b<2, 3> = [1, 2, 3, 4, 5, 6];
|
|
|
|
# This call will specialize `multiply_transpose` with <2, 3> for both
|
|
# arguments and deduce a return type of <3, 2> in initialization of `c`.
|
|
var c = multiply_transpose(a, b);
|
|
|
|
# A second call to `multiply_transpose` with <2, 3> for both arguments will
|
|
# reuse the previously specialized and inferred version and return <3, 2>.
|
|
var d = multiply_transpose(b, a);
|
|
|
|
print(d);
|
|
} |