Co-authored-by: Dalong <39682259+eedalong@users.noreply.github.com>
This commit is contained in:
Cheng Lai
2022-03-20 10:12:27 +08:00
committed by GitHub
parent 8fb5ff1b16
commit aefdd40ee6
4 changed files with 19 additions and 359 deletions

View File

@@ -51,7 +51,7 @@ Communication的Allreduce操作来完成。
### 模型并行
![模型并行系统:算子内并行](../img/ch09/ch10-model-parallel-intra-op.svg)
![模型并行系统:算子内并行](../img/ch09/ch10-model-parallel-intra-op.png)
:width:`800px`
:label:`ch10-model-parallel-intra-op`

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@@ -1,346 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
xml:space="preserve"
width="272"
height="108"
viewBox="0 0 272 108"
sodipodi:docname="ch10-model-parallel-intra-op.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs6"><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath18"><path
d="M 0,0 H 699 V 365 H 0 Z"
id="path16" /></clipPath></defs><sodipodi:namedview
id="namedview4"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.72103004"
inkscape:cx="-35.366071"
inkscape:cy="188.61905"
inkscape:window-width="1920"
inkscape:window-height="1137"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g22" /><g
id="g8"
inkscape:groupmode="layer"
inkscape:label="ch10-model-parallel-intra-op"
transform="matrix(1.3333333,0,0,-1.3333333,-376.66666,387.33332)"><g
id="g10" /><g
id="g22"><path
d="M 76.5,304.4994 C 76.5,317.2023 86.79769,327.5 99.50053,327.5 H 675.4995 c 12.7028,0 23.0005,-10.2977 23.0005,-23.0006 V 212.5006 C 698.5,199.7977 688.2023,189.5 675.4995,189.5 H 99.50053 C 86.79769,189.5 76.5,199.7977 76.5,212.5006 Z"
style="fill:#e7e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path24" /><g
id="g26"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,76.5,327.5)"><path
d="M 0,292107.2 C 0,130780.8 130780.7,0 292106.8,0 H 7607294 c 161325,0 292106,130780.8 292106,292107.2 V 1460493 c 0,161326 -130781,292107 -292106,292107 H 292106.8 C 130780.7,1752600 0,1621819 0,1460493 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:50800, 38100;stroke-dashoffset:0;stroke-opacity:1"
id="path28" /></g><path
d="m 599.5,291.5 h 72 v -82 h -72 z"
style="fill:#a9d18e;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path30" /><g
id="g32"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,599.5,291.5)"><path
d="M 0,0 H 914400 V 1041400 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path34" /></g><path
d="m 282.5,290.5 h 204 v -81 h -204 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path36" /><g
id="g38"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,282.5,290.5)"><path
d="M 0,0 H 2590800 V 1028700 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path40" /></g><path
d="m 98.5,290.5 h 72 v -81 h -72 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path42" /><g
id="g44"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,98.5,290.5)"><path
d="M 0,0 H 914400 V 1028700 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path46" /></g><g
id="g48"
transform="translate(611.9691,-118)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text52"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan50">算⼦</tspan></text></g><g
id="g54"
transform="translate(647.9691,-118)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text58"><tspan
x="0"
y="0"
id="tspan56">2</tspan></text></g><g
id="g60"
transform="translate(11.91087,-120)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text64"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan62">设备</tspan></text></g><g
id="g66"
transform="translate(47.91087,-120)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text70"><tspan
x="0"
y="0"
id="tspan68">1</tspan></text></g><path
d="M 76.5,151.4994 C 76.5,164.2023 86.79769,174.5 99.50053,174.5 H 675.4995 c 12.7028,0 23.0005,-10.2977 23.0005,-23.0006 V 59.50057 c 0,-12.70286 -10.2977,-23.00056 -23.0005,-23.00056 H 99.50053 C 86.79769,36.50001 76.5,46.79771 76.5,59.50057 Z"
style="fill:#e7e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path72" /><g
id="g74"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,76.5,174.5)"><path
d="M 0,292107.2 C 0,130780.8 130780.7,0 292106.8,0 H 7607294 c 161325,0 292106,130780.8 292106,292107.2 V 1460493 c 0,161326 -130781,292107 -292106,292107 H 292106.8 C 130780.7,1752600 0,1621819 0,1460493 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:50800, 38100;stroke-dashoffset:0;stroke-opacity:1"
id="path76" /></g><g
id="g78"
transform="translate(14.94685,-272)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text82"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan80">设备</tspan></text></g><g
id="g84"
transform="translate(50.94685,-272)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text88"><tspan
x="0"
y="0"
id="tspan86">2</tspan></text></g><path
d="m 98.5,291.5 h 72 v -82 h -72 z"
style="fill:#9dc3e6;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path90" /><g
id="g92"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,98.5,291.5)"><path
d="M 0,0 H 914400 V 1041400 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path94" /></g><g
id="g96"
transform="translate(115.8845,-119)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text100"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan98">数据</tspan></text></g><path
d="m 282.5,290.5 h 102 v -81 h -102 z"
style="fill:#a9d18e;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path102" /><g
id="g104"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,282.5,290.5)"><path
d="M 0,0 H 1295400 V 1028700 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path106" /></g><g
id="g108"
transform="translate(311.0483,-119)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text112"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan110">分区</tspan></text></g><g
id="g114"
transform="translate(347.0483,-119)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text118"><tspan
x="0"
y="0"
id="tspan116">1</tspan></text></g><path
d="m 281.5,134.5 h 204 v -78 h -204 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path120" /><g
id="g122"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,281.5,134.5)"><path
d="M 0,0 H 2590800 V 990600 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path124" /></g><path
d="m 383.5,134.5 h 102 v -78 h -102 z"
style="fill:#a9d18e;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path126" /><g
id="g128"
transform="matrix(7.874016e-5,0,0,-7.874016e-5,383.5,134.5)"><path
d="M 0,0 H 1295400 V 990600 H 0 Z"
style="fill:none;stroke:#000000;stroke-width:12700;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:8;stroke-dasharray:none;stroke-opacity:1"
id="path130" /></g><g
id="g132"
transform="translate(413.9496,-276)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text136"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan134">分区</tspan></text></g><g
id="g138"
transform="translate(449.9496,-276)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text142"><tspan
x="0"
y="0"
id="tspan140">2</tspan></text></g><g
id="g144"
transform="translate(194.7052,-138)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text148"><tspan
x="0 10.9998 18.003599 27.0054 36.007198 45.008999 52.012798 61.014599 68.018402"
y="0"
sodipodi:role="line"
id="tspan146">Broadcast</tspan></text></g><g
id="g150"
transform="translate(195.7052,-160)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text154"><tspan
x="0 18 36 54"
y="0"
sodipodi:role="line"
id="tspan152">(⼴播)</tspan></text></g><path
d="m 170.5101,252.75 100.1402,-0.449 -0.0202,-4.5 -100.1402,0.449 z m 97.9104,4.061 13.4696,-6.8104 -13.5301,-6.6895 z"
style="fill:#4472c4;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path156" /><path
d="m 172.3316,251.8069 104.1661,-145.989 -3.6632,-2.6137 -104.1661,145.9889 z m 106.5224,-141.5438 2.3465,-14.90995 -13.3359,7.06875 z"
style="fill:#4472c4;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path158" /><path
d="M 487.3168,94.33215 593.8032,240.0888 590.1696,242.7434 483.6832,96.98676 Z m 108.7926,141.28515 2.5135,14.8827 -13.4142,-6.9188 z"
style="fill:#4472c4;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path160" /><path
d="m 486.5148,247.5079 101.6879,0.6682 -0.0296,4.4999 -101.6879,-0.6682 z m 99.4675,-3.8465 13.4553,6.8386 -13.544,6.6611 z"
style="fill:#4472c4;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path162" /><g
id="g164"
transform="translate(505.24,-137)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text168"><tspan
x="0 14.0004 22.996799 29.005199 39.009602 47.015999"
y="0"
sodipodi:role="line"
id="tspan166">Gather</tspan></text></g><g
id="g170"
transform="translate(508.24,-159)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text174"><tspan
x="0"
y="0"
id="tspan172">(</tspan></text></g><g
id="g176"
transform="translate(513.24,-159)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text180"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan178">合并</tspan></text></g><g
id="g182"
transform="translate(549.24,-159)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text186"><tspan
x="0"
y="0"
id="tspan184">)</tspan></text></g><g
id="g188"
transform="translate(368.2626,-62)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text192"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan190">算⼦</tspan></text></g><g
id="g194"
transform="translate(404.2626,-62)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text198"><tspan
x="0"
y="0"
id="tspan196">1</tspan></text></g><g
id="g200"
transform="translate(368.4133,-216)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text204"><tspan
x="0 18"
y="0"
sodipodi:role="line"
id="tspan202">算⼦</tspan></text></g><g
id="g206"
transform="translate(404.4133,-216)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text210"><tspan
x="0"
y="0"
id="tspan208">1</tspan></text></g><g
id="g212"
transform="translate(380.2,-23)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text216"><tspan
x="0 18 36 54"
y="0"
sodipodi:role="line"
id="tspan214">程序分区</tspan></text></g><g
id="g218"
transform="translate(452.2,-23)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text222"><tspan
x="0"
y="0"
id="tspan220">1</tspan></text></g><g
id="g224"
transform="translate(381.4626,-348)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text228"><tspan
x="0 18 36 54"
y="0"
sodipodi:role="line"
id="tspan226">程序分区</tspan></text></g><g
id="g230"
transform="translate(453.4626,-348)"><text
transform="matrix(1,0,0,-1,0,365)"
style="font-variant:normal;font-weight:normal;font-size:18px;font-family:STSongti-SC;-inkscape-font-specification:STSongti-SC-Regular;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text234"><tspan
x="0"
y="0"
id="tspan232">2</tspan></text></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -9,27 +9,33 @@ import os
root_path = "./"
html_root_path = "_build/html/"
def get_html_list():
index_html_path = os.path.join(root_path,html_root_path ,"index.html")
index_html_path = os.path.join(root_path, html_root_path, "index.html")
index_soup = BeautifulSoup(open(index_html_path))
content_list = index_soup.find(name="div", attrs={"class":"globaltoc"}).\
content_list = index_soup.find(name="div", attrs={"class": "globaltoc"}). \
find_all(name="a", attrs={"class": "reference internal"})
html_list = [os.path.join(html_root_path,content_name["href"]) for content_name in content_list]
html_list = [os.path.join(html_root_path, content_name["href"]) for content_name in content_list]
return html_list
def format_table():
html_list = get_html_list()
for html_file in html_list:
soup = BeautifulSoup(open(html_file))
all_tables = soup.find_all(name="table", attrs={"class":"docutils align-default"})
for table in all_tables:
table["style"] = "margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:20px;"
try:
soup = BeautifulSoup(open(html_file))
all_tables = soup.find_all(name="table", attrs={"class": "docutils align-default"})
for table in all_tables:
table["style"] = "margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:20px;"
if len(all_tables):
write_out_file = open(html_file, mode="w")
write_out_file.write(soup.prettify())
write_out_file.close()
except:
pass
if len(all_tables):
write_out_file = open(html_file, mode="w")
write_out_file.write(soup.prettify())
write_out_file.close()
if __name__ == "__main__":
format_table()