feat: toy tutorial chapter 1.
This commit is contained in:
13
examples/transpose.hello
Normal file
13
examples/transpose.hello
Normal file
@@ -0,0 +1,13 @@
|
||||
def main() {
|
||||
# Define a variable `a` with shape <2, 3>, initialized with the literal value.
|
||||
# The shape is inferred from the supplied literal.
|
||||
var a = [[1, 2, 3], [4, 5, 6]];
|
||||
|
||||
# b is identical to a, the literal tensor is implicitly reshaped: defining new
|
||||
# variables is the way to reshape tensors (element count must match).
|
||||
var b<2, 3> = [1, 2, 3, 4, 5, 6];
|
||||
|
||||
# transpose() and print() are the only builtin, the following will transpose
|
||||
# a and b and perform an element-wise multiplication before printing the result.
|
||||
print(transpose(a) * transpose(b));
|
||||
}
|
Reference in New Issue
Block a user