1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Number of rows of the first matrix
= 2
# Number of columns of the first matrix (and number of rows of the second matrix)
= 3
# Number of columns of the second matrix
= 4
# Scalar type of matrix elements
=
# Create a context
=
# Create a graph in a given context that will be used for matrix multiplication
=
# Create types of input matrices.
# Matrices can be represented as arrays with two 2-dimensional shapes.
# First, create the array type of a first matrix with shape `[n, m]`, which corresponds to a (n x m)-matrix.
=
# Second, create the array type of a second matrix with shape `[m, k]`, which corresponds to a (m x k)-matrix.
=
# For each input matrix, add input nodes to the empty graph g created above.
# Input nodes require the types of input matrices generated in previous lines.
=
=
# Matrix multiplication is a built-in function of CipherCore, so it can be computed by a single computational node.
= @
# Before computation, every graph should be finalized, which means that it should have a designated output node.
# This can be done by calling `g.set_output_node(output)?` or as below.
# Set this graph as main to be able to finalize the context
# Serialize the context and print it to stdout