|
1 | 1 | # Broadcasting Tutorial
|
2 | 2 |
|
3 |
| -This tutorial shows how to efficiently use broadcasting in Nada using Nada Numpy. |
| 3 | +[](https://colab.research.google.com/github/NillionNetwork/nada-numpy/blob/main/examples/broadcasting/broadcasting.ipynb) |
4 | 4 |
|
5 |
| -```python |
6 |
| -from nada_dsl import * |
| 5 | +This tutorial shows how to efficiently use broadcasting in Nada using Nada Numpy. |
7 | 6 |
|
8 |
| -# Step 0: Nada Numpy is imported with this line |
9 |
| -import nada_numpy as na |
| 7 | +## 🚨 Limitations |
| 8 | +The choice for blind computing implies certain trade-offs in comparison to conventional computing. What you gain in privacy, you pay in extra computational overhead & capacity constraints. |
10 | 9 |
|
| 10 | +Therefore, you will notice that large-scale computational workloads may lead to long compilation and/or execution times or hitting network capacity guardrails. |
11 | 11 |
|
12 |
| -def nada_main(): |
13 |
| - # Step 1: We use Nada Numpy wrapper to create "Party0", "Party1" and "Party2" |
14 |
| - parties = na.parties(3) |
| 12 | +That said, the Nillion team is working around the clock to push the boundaries of this technology and bring the potential of blind computing to reality 🚀 |
15 | 13 |
|
16 |
| - # Step 2: Party0 creates an array of dimension (3, ) with name "A" |
17 |
| - a = na.array([3], parties[0], "A", SecretInteger) |
| 14 | +👉 This example has been tested on local devnet with arrays of up to 1000 elements. |
18 | 15 |
|
19 |
| - # Step 3: Party1 creates an array of dimension (3, ) with name "B" |
20 |
| - b = na.array([3], parties[1], "B", SecretInteger) |
| 16 | +## ➡️ Stay in touch |
| 17 | +If you want to get involved in the blind computing community and be the first to know all big updates, join our Discord |
21 | 18 |
|
22 |
| - # Step 4: Party0 creates an array of dimension (3, ) with name "C" |
23 |
| - c = na.array([3], parties[0], "C", SecretInteger) |
| 19 | +[](https://discord.gg/nillionnetwork) |
24 | 20 |
|
25 |
| - # Step 5: Party1 creates an array of dimension (3, ) with name "D" |
26 |
| - d = na.array([3], parties[1], "D", SecretInteger) |
| 21 | +And if you want to contribute to the blind computing revolution, we welcome open-source contributors! |
27 | 22 |
|
28 |
| - # Step 4: The result is of computing SIMD operations on top of the elements of the array |
29 |
| - # SIMD operations are performed on all the elements of the array. |
30 |
| - # The equivalent would be: for i in range(3): result += a[i] + b[i] - c[i] * d[i] |
31 |
| - result = a + b - c * d |
32 |
| - # Step 5: We can use result.output() to produce the output for Party2 and variable name "my_output" |
33 |
| - return result.output(parties[2], "my_output") |
34 |
| -``` |
35 |
| - |
36 |
| -0. We import Nada Numpy using `import nada_numpy as na`. |
37 |
| -1. We create an array of parties, with our wrapper using `parties = na.parties(3)` which creates an array of parties named: `Party0`, `Party1` and `Party2`. |
38 |
| -2. We create our input array `a` with `na.array([3], parties[0], "A")`, meaning our array will have dimension 3, `Party0` will be in charge of giving its inputs and the name of the variable is `"A"`. |
39 |
| -3. We create our input array `b` with `na.array([3], parties[1], "B")`, meaning our array will have dimension 3, `Party1` will be in charge of giving its inputs and the name of the variable is `"B"`. |
40 |
| -4. We create our input array `c` with `na.array([3], parties[1], "C")`, meaning our array will have dimension 3, `Party0` will be in charge of giving its inputs and the name of the variable is `"C"`. |
41 |
| -5. We create our input array `d` with `na.array([3], parties[1], "D")`, meaning our array will have dimension 3, `Party1` will be in charge of giving its inputs and the name of the variable is `"D"`. |
42 |
| -5. Finally, we use Nada Numpy to produce the outputs of the array like: `result.output(parties[2], "my_output")` establishing that the output party will be `Party2`and the name of the output variable will be `my_output`. |
43 |
| -# How to run the tutorial. |
44 |
| - |
45 |
| -1. First, we need to compile the nada program running: `nada build`. |
46 |
| -2. (Optional) Then, we can test our program is running with: `nada test`. |
47 |
| -3. Finally, we can call our Nada program via the Nillion python client by running: `python3 main.py` |
| 23 | +[](https://github.com/orgs/NillionNetwork/discussions) |
0 commit comments