Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"**.ipynb_checkpoints",
"auto_examples/*.ipynb",
# "auto_examples/*.md5",
"conf.py",
]
nitpicky = True

Expand Down Expand Up @@ -164,7 +165,14 @@
# nb_execution_cache_path = ''

# Exclude (POSIX) glob patterns for notebooks
# nb_execution_excludepatterns = ()
# These notebooks have errors that need to be fixed in future PRs:
# - explanation/* and reference/* contain @egraph.class_ usage which is now deprecated
# - tut_2_datalog.py uses incorrect check() syntax with ==
nb_execution_excludepatterns = (
"explanation/*",
"reference/*",
"tutorials/tut_2_datalog.py",
)

# Execution timeout (seconds)
nb_execution_timeout = 60 * 10
Expand All @@ -176,7 +184,7 @@
# nb_execution_allow_errors = False

# Raise an exception on failed execution, rather than emitting a warning
nb_execution_raise_on_error = False
nb_execution_raise_on_error = True

# Print traceback to stderr on execution error
nb_execution_show_tb = True
Expand Down
70 changes: 70 additions & 0 deletions docs/sg_execution_times.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

:orphan:

.. _sphx_glr_sg_execution_times:


Computation times
=================
**00:00.407** total execution time for 12 files **from all galleries**:

.. container::

.. raw:: html

<style scoped>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
</style>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready( function () {
$('table.sg-datatable').DataTable({order: [[1, 'desc']]});
} );
</script>

.. list-table::
:header-rows: 1
:class: table table-striped sg-datatable

* - Example
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_examples_lambda_.py` (``../python/egglog/examples/lambda_.py``)
- 00:00.170
- 0.0
* - :ref:`sphx_glr_auto_examples_fib.py` (``../python/egglog/examples/fib.py``)
- 00:00.113
- 0.0
* - :ref:`sphx_glr_auto_examples_ndarrays.py` (``../python/egglog/examples/ndarrays.py``)
- 00:00.044
- 0.0
* - :ref:`sphx_glr_auto_examples_matrix.py` (``../python/egglog/examples/matrix.py``)
- 00:00.018
- 0.0
* - :ref:`sphx_glr_auto_examples_jointree.py` (``../python/egglog/examples/jointree.py``)
- 00:00.014
- 0.0
* - :ref:`sphx_glr_auto_examples_multiset.py` (``../python/egglog/examples/multiset.py``)
- 00:00.012
- 0.0
* - :ref:`sphx_glr_auto_examples_resolution.py` (``../python/egglog/examples/resolution.py``)
- 00:00.009
- 0.0
* - :ref:`sphx_glr_auto_examples_bool.py` (``../python/egglog/examples/bool.py``)
- 00:00.007
- 0.0
* - :ref:`sphx_glr_auto_examples_higher_order_functions.py` (``../python/egglog/examples/higher_order_functions.py``)
- 00:00.006
- 0.0
* - :ref:`sphx_glr_auto_examples_eqsat_basic.py` (``../python/egglog/examples/eqsat_basic.py``)
- 00:00.006
- 0.0
* - :ref:`sphx_glr_auto_examples_schedule_demo.py` (``../python/egglog/examples/schedule_demo.py``)
- 00:00.004
- 0.0
* - :ref:`sphx_glr_auto_examples_bignum.py` (``../python/egglog/examples/bignum.py``)
- 00:00.003
- 0.0
28 changes: 16 additions & 12 deletions docs/tutorials/getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"metadata": {},
"outputs": [],
"source": [
"@egraph.class_\n",
"class Dim(Expr):\n",
" \"\"\"\n",
" A dimension of a matix.\n",
Expand All @@ -108,16 +107,17 @@
"tags": []
},
"source": [
"As you can see, you must wrap any class with the `egraph.class_` to register\n",
"it with the egraph and be able to use it like a Python class.\n",
"As you can see, you can define a class that inherits from `Expr` to create\n",
"a new type in the e-graph. The class will be automatically registered when you use it.\n",
"\n",
"### Testing in a notebook\n",
"\n",
"We can try out this by [creating a new notebook](https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook) which imports this file:\n",
"\n",
"```python\n",
"from matrix import *\n",
"```\n"
"```\n",
""
]
},
{
Expand Down Expand Up @@ -408,7 +408,8 @@
}
],
"source": [
"egraph.simplify(res, 10)"
"egraph.run(10)\n",
"egraph.extract(res)\n"
]
},
{
Expand All @@ -429,7 +430,6 @@
"metadata": {},
"outputs": [],
"source": [
"@egraph.class_\n",
"class Matrix(Expr):\n",
" @classmethod\n",
" def identity(cls, dim: Dim) -> Matrix:\n",
Expand Down Expand Up @@ -459,7 +459,7 @@
" \"\"\"\n",
"\n",
"\n",
"@egraph.function\n",
"@function\n",
"def kron(a: Matrix, b: Matrix) -> Matrix:\n",
" \"\"\"\n",
" Kronecker product of two matrices.\n",
Expand Down Expand Up @@ -530,8 +530,10 @@
"x = Matrix.identity(Dim.named(\"x\"))\n",
"y = Matrix.identity(Dim.named(\"y\"))\n",
"x_mult_y = x @ y\n",
"print(egraph.simplify(x_mult_y.ncols(), 10))\n",
"print(egraph.simplify(x_mult_y.nrows(), 10))"
"egraph.run(10)\n",
"print(egraph.extract(x_mult_y.ncols()))\n",
"egraph.run(10)\n",
"print(egraph.extract(x_mult_y.nrows()))"
]
},
{
Expand Down Expand Up @@ -1096,7 +1098,8 @@
")\n",
"# Create an example which should equal the kronecker product of A and B\n",
"ex1 = kron(Matrix.identity(n), B) @ kron(A, Matrix.identity(m))\n",
"egraph.simplify(ex1, 20)"
"egraph.run(20)\n",
"egraph.extract(ex1)\n"
]
},
{
Expand Down Expand Up @@ -1209,7 +1212,8 @@
],
"source": [
"ex2 = kron(Matrix.identity(p), C) @ kron(A, Matrix.identity(m))\n",
"egraph.simplify(ex2, 20)"
"egraph.run(20)\n",
"egraph.extract(ex2)\n"
]
},
{
Expand Down Expand Up @@ -1243,4 +1247,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading