IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Add matrix-multiply illustration.

master
Stanislaw Adaszewski 4 years ago
parent
commit
dd41ba9bd0
2 changed files with 900 additions and 0 deletions
  1. +839
    -0
      docs/matrix-multiply.svg
  2. +61
    -0
      src/icosagon/fastconv.py

+ 839
- 0
docs/matrix-multiply.svg View File

@@ -0,0 +1,839 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="matrix-multiply.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.06"
inkscape:cx="442.13641"
inkscape:cy="826.66981"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1001"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:snap-global="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#de4900;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect815"
width="20.941383"
height="20.114748"
x="14.416583"
y="14.516284" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="23.234007"
y="26.342777"
id="text819"><tspan
sodipodi:role="line"
id="tspan817"
x="23.234007"
y="26.342777"
style="stroke-width:0.19288115">x</tspan></text>
<rect
y="18.511679"
x="49.726513"
height="12.424885"
width="12.935495"
id="rect821"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#3300de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<text
id="text825"
y="26.089155"
x="53.128155"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="26.089155"
x="53.128155"
id="tspan823"
sodipodi:role="line">w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan827">1</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#3300de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect829"
width="12.935495"
height="12.424885"
x="65.157005"
y="18.511679" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="68.558655"
y="26.089155"
id="text835"><tspan
sodipodi:role="line"
id="tspan833"
x="68.558655"
y="26.089155"
style="stroke-width:0.19288115">w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan853">2</tspan></tspan></text>
<rect
y="18.511679"
x="80.587502"
height="12.424885"
width="12.935495"
id="rect837"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#3300de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<text
id="text843"
y="26.089155"
x="83.989136"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="26.089155"
x="83.989136"
id="tspan841"
sodipodi:role="line">w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan855">3</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#3300de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect845"
width="12.935495"
height="12.424885"
x="96.018005"
y="18.511679" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="99.419655"
y="26.089155"
id="text851"><tspan
sodipodi:role="line"
id="tspan849"
x="99.419655"
y="26.089155"
style="stroke-width:0.19288115">w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan857">4</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#3300de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect859"
width="67.631081"
height="19.589043"
x="45.868889"
y="14.654056" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="39.572586"
y="27.444956"
id="text863"><tspan
sodipodi:role="line"
id="tspan861"
x="39.572586"
y="27.444956"
style="stroke-width:0.19288115">*</tspan></text>
<text
id="text867"
y="26.386621"
x="117.36007"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="26.386621"
x="117.36007"
id="tspan865"
sodipodi:role="line">=</tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
id="rect869"
width="12.935495"
height="12.424885"
x="129.1015"
y="18.511679" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="129.32812"
y="26.089155"
id="text875"><tspan
sodipodi:role="line"
id="tspan873"
x="129.32812"
y="26.089155"
style="stroke-width:0.19288115">x*w<tspan
id="tspan871"
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115">1</tspan></tspan></text>
<rect
y="18.511679"
x="144.53198"
height="12.424885"
width="12.935495"
id="rect877"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal" />
<text
id="text883"
y="26.089155"
x="144.75862"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="26.089155"
x="144.75862"
id="tspan881"
sodipodi:role="line">x*w<tspan
id="tspan879"
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115">2</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
id="rect885"
width="12.935495"
height="12.424885"
x="159.96251"
y="18.511679" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="160.1891"
y="26.089155"
id="text891"><tspan
sodipodi:role="line"
id="tspan889"
x="160.1891"
y="26.089155"
style="stroke-width:0.19288115">x*w<tspan
id="tspan887"
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115">3</tspan></tspan></text>
<rect
y="18.511679"
x="175.39304"
height="12.424885"
width="12.935495"
id="rect893"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal" />
<text
id="text899"
y="26.089155"
x="175.61966"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="26.089155"
x="175.61966"
id="tspan897"
sodipodi:role="line">x*w<tspan
id="tspan895"
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115">4</tspan></tspan></text>
<rect
y="14.654056"
x="125.24387"
height="19.589043"
width="67.631081"
id="rect901"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
y="49.405224"
x="49.420624"
height="12.424885"
width="12.935495"
id="rect922"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<text
id="text928"
y="56.9827"
x="49.647247"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="56.9827"
x="49.647247"
id="tspan926"
sodipodi:role="line">x*w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan924">1</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect930"
width="12.935495"
height="12.424885"
x="64.851105"
y="49.405224" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="65.077744"
y="56.9827"
id="text936"><tspan
sodipodi:role="line"
id="tspan934"
x="65.077744"
y="56.9827"
style="stroke-width:0.19288115">x*w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan932">2</tspan></tspan></text>
<rect
y="49.405224"
x="80.281631"
height="12.424885"
width="12.935495"
id="rect938"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<text
id="text944"
y="56.9827"
x="80.508224"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="56.9827"
x="80.508224"
id="tspan942"
sodipodi:role="line">x*w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan940">3</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect946"
width="12.935495"
height="12.424885"
x="95.712158"
y="49.405224" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="95.938782"
y="56.9827"
id="text952"><tspan
sodipodi:role="line"
id="tspan950"
x="95.938782"
y="56.9827"
style="stroke-width:0.19288115">x*w<tspan
style="font-size:3.34327316px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan948">4</tspan></tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect954"
width="67.631081"
height="19.589043"
x="45.562996"
y="45.5476" />
<text
id="text958"
y="58.136627"
x="39.572586"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="58.136627"
x="39.572586"
id="tspan956"
sodipodi:role="line">*</tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00c3de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
id="rect960"
width="12.935495"
height="12.424885"
x="49.089653"
y="-31.175264"
transform="rotate(90)" />
<rect
y="-31.175264"
x="64.520134"
height="12.424885"
width="12.935495"
id="rect962"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00c3de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
transform="rotate(90)" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00c3de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
id="rect964"
width="12.935495"
height="12.424885"
x="79.950661"
y="-31.175264"
transform="rotate(90)" />
<rect
y="-31.175264"
x="95.381187"
height="12.424885"
width="12.935495"
id="rect966"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00c3de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke;font-variant-east_asian:normal"
transform="rotate(90)" />
<rect
y="-35.032883"
x="45.232025"
height="19.589043"
width="67.631081"
id="rect968"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00c3de;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
transform="rotate(90)" />
<text
id="text986"
y="56.930447"
x="22.10532"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="56.930447"
x="22.10532"
id="tspan984"
sodipodi:role="line">A<tspan
style="font-size:64.99999762%;baseline-shift:sub"
id="tspan988">1</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="22.10532"
y="72.805443"
id="text994"><tspan
sodipodi:role="line"
id="tspan992"
x="22.10532"
y="72.805443"
style="stroke-width:0.19288115">A<tspan
id="tspan990"
style="font-size:64.99999762%;baseline-shift:sub">2</tspan></tspan></text>
<text
id="text1000"
y="87.622101"
x="22.10532"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
style="stroke-width:0.19288115"
y="87.622101"
x="22.10532"
id="tspan998"
sodipodi:role="line">A<tspan
style="font-size:64.99999762%;baseline-shift:sub"
id="tspan996">3</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="22.10532"
y="103.49709"
id="text1006"><tspan
sodipodi:role="line"
id="tspan1004"
x="22.10532"
y="103.49709"
style="stroke-width:0.19288115">A<tspan
id="tspan1002"
style="font-size:64.99999762%;baseline-shift:sub">4</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="117.36007"
y="57.078293"
id="text1010"><tspan
sodipodi:role="line"
id="tspan1008"
x="117.36007"
y="57.078293"
style="stroke-width:0.19288115">=</tspan></text>
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1014"
width="12.935495"
height="12.424885"
x="128.79561"
y="49.405224" />
<rect
y="49.405224"
x="144.2261"
height="12.424885"
width="12.935495"
id="rect1016"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1018"
width="12.935495"
height="12.424885"
x="159.65663"
y="49.405224" />
<rect
y="49.405224"
x="175.08719"
height="12.424885"
width="12.935495"
id="rect1020"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
y="45.5476"
x="124.93797"
height="66.846992"
width="67.631088"
id="rect1022"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
y="65.280228"
x="128.79561"
height="12.424885"
width="12.935495"
id="rect1024"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1026"
width="12.935495"
height="12.424885"
x="144.2261"
y="65.280228" />
<rect
y="65.280228"
x="159.65663"
height="12.424885"
width="12.935495"
id="rect1028"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1030"
width="12.935495"
height="12.424885"
x="175.08719"
y="65.280228" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1032"
width="12.935495"
height="12.424885"
x="128.79561"
y="81.15522" />
<rect
y="81.15522"
x="144.2261"
height="12.424885"
width="12.935495"
id="rect1034"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1036"
width="12.935495"
height="12.424885"
x="159.65663"
y="81.15522" />
<rect
y="81.15522"
x="175.08719"
height="12.424885"
width="12.935495"
id="rect1038"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
y="97.030212"
x="128.79561"
height="12.424885"
width="12.935495"
id="rect1040"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1042"
width="12.935495"
height="12.424885"
x="144.2261"
y="97.030212" />
<rect
y="97.030212"
x="159.65663"
height="12.424885"
width="12.935495"
id="rect1044"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<rect
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#00de52;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="rect1046"
width="12.935495"
height="12.424885"
x="175.08719"
y="97.030212" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="128.65828"
y="56.453533"
id="text1052"><tspan
sodipodi:role="line"
x="128.65828"
y="56.453533"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1056">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1067">1</tspan>*x*w<tspan
style="font-size:65%;baseline-shift:sub"
id="tspan1093">1</tspan></tspan></text>
<text
id="text1075"
y="56.453533"
x="144.53329"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1073"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="56.453533"
x="144.53329"
sodipodi:role="line">A<tspan
id="tspan1069"
style="font-size:2.82222223px;baseline-shift:sub">1</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1071">2</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="159.87915"
y="56.453533"
id="text1083"><tspan
sodipodi:role="line"
x="159.87915"
y="56.453533"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1081">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1077">1</tspan>*x*w<tspan
id="tspan1079"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">3</tspan></tspan></text>
<text
id="text1091"
y="56.453533"
x="174.69585"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1089"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="56.453533"
x="174.69585"
sodipodi:role="line">A<tspan
id="tspan1085"
style="font-size:2.82222223px;baseline-shift:sub">1</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1087">4</tspan></tspan></text>
<text
id="text1101"
y="72.328529"
x="128.65828"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1099"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="72.328529"
x="128.65828"
sodipodi:role="line">A<tspan
id="tspan1095"
style="font-size:2.82222223px;baseline-shift:sub">2</tspan>*x*w<tspan
id="tspan1097"
style="font-size:64.99999762%;baseline-shift:sub">1</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="144.53329"
y="72.328529"
id="text1109"><tspan
sodipodi:role="line"
x="144.53329"
y="72.328529"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1107">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1103">2</tspan>*x*w<tspan
id="tspan1105"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">2</tspan></tspan></text>
<text
id="text1117"
y="72.328529"
x="159.87915"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1115"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="72.328529"
x="159.87915"
sodipodi:role="line">A<tspan
id="tspan1111"
style="font-size:2.82222223px;baseline-shift:sub">2</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1113">3</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="174.69585"
y="72.328529"
id="text1125"><tspan
sodipodi:role="line"
x="174.69585"
y="72.328529"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1123">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1119">2</tspan>*x*w<tspan
id="tspan1121"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">4</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="128.65828"
y="88.203522"
id="text1133"><tspan
sodipodi:role="line"
x="128.65828"
y="88.203522"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1131">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1127">3</tspan>*x*w<tspan
style="font-size:64.99999762%;baseline-shift:sub"
id="tspan1129">1</tspan></tspan></text>
<text
id="text1141"
y="88.203522"
x="144.53329"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1139"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="88.203522"
x="144.53329"
sodipodi:role="line">A<tspan
id="tspan1135"
style="font-size:2.82222223px;baseline-shift:sub">3</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1137">2</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="159.87915"
y="88.203522"
id="text1149"><tspan
sodipodi:role="line"
x="159.87915"
y="88.203522"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1147">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1143">3</tspan>*x*w<tspan
id="tspan1145"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">3</tspan></tspan></text>
<text
id="text1157"
y="88.203522"
x="174.69585"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1155"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="88.203522"
x="174.69585"
sodipodi:role="line">A<tspan
id="tspan1151"
style="font-size:2.82222223px;baseline-shift:sub">3</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1153">4</tspan></tspan></text>
<text
id="text1165"
y="104.07851"
x="128.65828"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1163"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="104.07851"
x="128.65828"
sodipodi:role="line">A<tspan
id="tspan1159"
style="font-size:2.82222223px;baseline-shift:sub">4</tspan>*x*w<tspan
id="tspan1161"
style="font-size:64.99999762%;baseline-shift:sub">1</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="144.53329"
y="104.07851"
id="text1173"><tspan
sodipodi:role="line"
x="144.53329"
y="104.07851"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1171">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1167">4</tspan>*x*w<tspan
id="tspan1169"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">2</tspan></tspan></text>
<text
id="text1181"
y="104.07851"
x="159.87915"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
xml:space="preserve"><tspan
id="tspan1179"
style="font-size:2.82222223px;stroke-width:0.19288115"
y="104.07851"
x="159.87915"
sodipodi:role="line">A<tspan
id="tspan1175"
style="font-size:2.82222223px;baseline-shift:sub">4</tspan>*x*w<tspan
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115"
id="tspan1177">3</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:5.14349747px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.19288115"
x="174.69585"
y="104.07851"
id="text1189"><tspan
sodipodi:role="line"
x="174.69585"
y="104.07851"
style="font-size:2.82222223px;stroke-width:0.19288115"
id="tspan1187">A<tspan
style="font-size:2.82222223px;baseline-shift:sub"
id="tspan1183">4</tspan>*x*w<tspan
id="tspan1185"
style="font-size:2.82222223px;baseline-shift:sub;stroke-width:0.19288115">4</tspan></tspan></text>
<ellipse
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ff0400;stroke-width:0.72899967;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path1191"
transform="rotate(45)"
ry="8.4866343"
rx="49.835232"
cy="-55.708145"
cx="168.62175" />
</g>
</svg>

+ 61
- 0
src/icosagon/fastconv.py View File

@@ -7,6 +7,67 @@ import torch
from .weights import init_glorot
def _cat(matrices: List[torch.Tensor]):
if len(matrices) == 0:
raise ValueError('Empty list passed to _cat()')
n = sum(a.is_sparse for a in matrices)
if n != 0 and n != len(matrices):
raise ValueError('All matrices must have the same layout (dense or sparse)')
if not all(a.shape[1:] == matrices[0].shape[1:]):
raise ValueError('All matrices must have the same dimensions apart from dimension 0')
if not matrices[0].is_sparse:
return torch.cat(matrices)
total_rows = sum(a.shape[0] for a in matrices)
indices = []
values = []
row_offset = 0
for a in matrices:
ind = a._indices().clone()
val = a._values()
ind[0] += row_offset
ind = ind.transpose(0, 1)
indices.append(ind)
values.append(val)
row_offset += a.shape[0]
indices = torch.cat(indices).transpose(0, 1)
values = torch.cat(values)
res = _sparse_coo_tensor(indices, values)
return res
class FastGraphConv(torch.nn.Module):
def __init__(self,
in_channels: int,
out_channels: int,
adjacency_matrix: List[torch.Tensor],
**kwargs):
self.in_channels = in_channels
self.out_channels = out_channels
self.weight = torch.cat([
init_glorot(in_channels, out_channels) \
for _ in adjacency_matrix
], dim=1)
self.adjacency_matrix = _cat(adjacency_matrix)
def forward(self, x):
x = torch.sparse.mm(x, self.weight) \
if x.is_sparse \
else torch.mm(x, self.weight)
x = torch.sparse.mm(self.adjacency_matrix, x) \
if self.adjacency_matrix.is_sparse \
else torch.mm(self.adjacency_matrix, x)
return x
class FastConvLayer(torch.nn.Module):
adjacency_matrix: List[torch.Tensor]
adjacency_matrix_backward: List[torch.Tensor]


Loading…
Cancel
Save