|
12 | 12 | " - `apply` method, which is responsible for generating files or anything you want with the given `ugraph`"
|
13 | 13 | ]
|
14 | 14 | },
|
| 15 | + { |
| 16 | + "cell_type": "markdown", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "### The `Backend` interface\n", |
| 20 | + "\n", |
| 21 | + "1. the class attribute `TARGET` should be overwriten and be of type `str`.\n", |
| 22 | + " - the value of `TARGET` should be unique or `ValueError` will be raised\n", |
| 23 | + "2. one should overwrite the `default_config` class property\n", |
| 24 | + "3. the first argument of `__init__` should be the config dictionary\n", |
| 25 | + " - this dictionary can be generated via a toml file (recommended)\n", |
| 26 | + " - this dictionary should be of the same format as the value returned by `default_config` class property\n", |
| 27 | + "\n", |
| 28 | + "Here is a simple example:" |
| 29 | + ] |
| 30 | + }, |
15 | 31 | {
|
16 | 32 | "cell_type": "code",
|
17 | 33 | "execution_count": 1,
|
18 | 34 | "metadata": {
|
19 | 35 | "ExecuteTime": {
|
20 |
| - "end_time": "2020-05-15T06:16:52.700065Z", |
21 |
| - "start_time": "2020-05-15T06:16:52.266124Z" |
| 36 | + "end_time": "2020-05-27T03:50:50.714504Z", |
| 37 | + "start_time": "2020-05-27T03:50:50.242148Z" |
22 | 38 | }
|
23 | 39 | },
|
24 | 40 | "outputs": [],
|
|
59 | 75 | " }\n"
|
60 | 76 | ]
|
61 | 77 | },
|
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": 2, |
| 81 | + "metadata": { |
| 82 | + "ExecuteTime": { |
| 83 | + "end_time": "2020-05-27T03:51:06.947435Z", |
| 84 | + "start_time": "2020-05-27T03:51:06.943073Z" |
| 85 | + } |
| 86 | + }, |
| 87 | + "outputs": [ |
| 88 | + { |
| 89 | + "name": "stdout", |
| 90 | + "output_type": "stream", |
| 91 | + "text": [ |
| 92 | + "dummy-backend backend\n" |
| 93 | + ] |
| 94 | + } |
| 95 | + ], |
| 96 | + "source": [ |
| 97 | + "print(DummyBackend.TARGET, DummyBackend.COMPONENT)" |
| 98 | + ] |
| 99 | + }, |
62 | 100 | {
|
63 | 101 | "cell_type": "markdown",
|
64 | 102 | "metadata": {},
|
65 | 103 | "source": [
|
66 |
| - "## Backend Registration" |
| 104 | + "Basically, this dummy backend takes a graph and generate a `.c` file which will print out all the operators in the graph." |
| 105 | + ] |
| 106 | + }, |
| 107 | + { |
| 108 | + "cell_type": "markdown", |
| 109 | + "metadata": {}, |
| 110 | + "source": [ |
| 111 | + "## Backend Registration\n", |
| 112 | + "\n", |
| 113 | + "Once you create a `Backend`, you can registrate it via `BackendManager` as following:" |
67 | 114 | ]
|
68 | 115 | },
|
69 | 116 | {
|
70 | 117 | "cell_type": "code",
|
71 |
| - "execution_count": 2, |
| 118 | + "execution_count": 3, |
72 | 119 | "metadata": {
|
73 | 120 | "ExecuteTime": {
|
74 |
| - "end_time": "2020-05-15T06:16:52.724946Z", |
75 |
| - "start_time": "2020-05-15T06:16:52.714719Z" |
| 121 | + "end_time": "2020-05-27T03:51:19.277175Z", |
| 122 | + "start_time": "2020-05-27T03:51:19.265963Z" |
76 | 123 | }
|
77 | 124 | },
|
78 | 125 | "outputs": [
|
|
82 | 129 | "__main__.DummyBackend"
|
83 | 130 | ]
|
84 | 131 | },
|
85 |
| - "execution_count": 2, |
| 132 | + "execution_count": 3, |
86 | 133 | "metadata": {},
|
87 | 134 | "output_type": "execute_result"
|
88 | 135 | }
|
|
102 | 149 | },
|
103 | 150 | {
|
104 | 151 | "cell_type": "code",
|
105 |
| - "execution_count": 3, |
| 152 | + "execution_count": 4, |
106 | 153 | "metadata": {
|
107 | 154 | "ExecuteTime": {
|
108 |
| - "end_time": "2020-05-15T06:16:53.407285Z", |
109 |
| - "start_time": "2020-05-15T06:16:53.399436Z" |
| 155 | + "end_time": "2020-05-27T03:51:22.426714Z", |
| 156 | + "start_time": "2020-05-27T03:51:22.416453Z" |
110 | 157 | }
|
111 | 158 | },
|
112 | 159 | "outputs": [],
|
|
116 | 163 | },
|
117 | 164 | {
|
118 | 165 | "cell_type": "code",
|
119 |
| - "execution_count": 4, |
| 166 | + "execution_count": 5, |
120 | 167 | "metadata": {
|
121 | 168 | "ExecuteTime": {
|
122 |
| - "end_time": "2020-05-15T06:16:58.423617Z", |
123 |
| - "start_time": "2020-05-15T06:16:54.435841Z" |
| 169 | + "end_time": "2020-05-27T03:51:28.055665Z", |
| 170 | + "start_time": "2020-05-27T03:51:23.803717Z" |
124 | 171 | }
|
125 | 172 | },
|
126 | 173 | "outputs": [],
|
|
130 | 177 | },
|
131 | 178 | {
|
132 | 179 | "cell_type": "code",
|
133 |
| - "execution_count": 5, |
| 180 | + "execution_count": 6, |
134 | 181 | "metadata": {
|
135 | 182 | "ExecuteTime": {
|
136 |
| - "end_time": "2020-05-15T06:16:58.447131Z", |
137 |
| - "start_time": "2020-05-15T06:16:58.426076Z" |
| 183 | + "end_time": "2020-05-27T03:51:30.645094Z", |
| 184 | + "start_time": "2020-05-27T03:51:30.638159Z" |
138 | 185 | }
|
139 | 186 | },
|
140 | 187 | "outputs": [
|
|
158 | 205 | },
|
159 | 206 | {
|
160 | 207 | "cell_type": "code",
|
161 |
| - "execution_count": 6, |
| 208 | + "execution_count": 7, |
162 | 209 | "metadata": {
|
163 | 210 | "ExecuteTime": {
|
164 |
| - "end_time": "2020-05-15T06:16:58.606631Z", |
165 |
| - "start_time": "2020-05-15T06:16:58.457135Z" |
| 211 | + "end_time": "2020-05-27T03:52:03.395036Z", |
| 212 | + "start_time": "2020-05-27T03:52:03.258055Z" |
166 | 213 | }
|
167 | 214 | },
|
168 | 215 | "outputs": [
|
|
234 | 281 | ]
|
235 | 282 | },
|
236 | 283 | {
|
237 |
| - "cell_type": "code", |
238 |
| - "execution_count": null, |
| 284 | + "cell_type": "markdown", |
239 | 285 | "metadata": {},
|
240 |
| - "outputs": [], |
241 | 286 | "source": []
|
242 | 287 | }
|
243 | 288 | ],
|
|
257 | 302 | "name": "python",
|
258 | 303 | "nbconvert_exporter": "python",
|
259 | 304 | "pygments_lexer": "ipython3",
|
260 |
| - "version": "3.6.8" |
| 305 | + "version": "3.7.2" |
261 | 306 | },
|
262 | 307 | "toc": {
|
263 | 308 | "base_numbering": 1,
|
|
0 commit comments