|
24 | 24 | "import set_env"
|
25 | 25 | ]
|
26 | 26 | },
|
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": 2, |
| 30 | + "metadata": {}, |
| 31 | + "outputs": [], |
| 32 | + "source": [ |
| 33 | + "path = \"/media/pc/data/board/arria10/lxw/tasks/tools/npuusertools/models/tests/pytorch/demo/test.pt\"" |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "cell_type": "code", |
| 38 | + "execution_count": 10, |
| 39 | + "metadata": {}, |
| 40 | + "outputs": [], |
| 41 | + "source": [ |
| 42 | + "import torch\n", |
| 43 | + "from tvm import relay\n", |
| 44 | + "m = torch.jit.load(path)\n", |
| 45 | + "shape = 1, 3, 24, 40\n", |
| 46 | + "mod, params = relay.frontend.pytorch.from_pytorch(m, [(\"x\", shape)], use_parser_friendly_name=False)\n", |
| 47 | + "mod = relay.transform.InferType()(mod)" |
| 48 | + ] |
| 49 | + }, |
| 50 | + { |
| 51 | + "cell_type": "code", |
| 52 | + "execution_count": 11, |
| 53 | + "metadata": {}, |
| 54 | + "outputs": [ |
| 55 | + { |
| 56 | + "name": "stdout", |
| 57 | + "output_type": "stream", |
| 58 | + "text": [ |
| 59 | + "fn (%x: Tensor[(1, 3, 24, 40), float32] /* ty=Tensor[(1, 3, 24, 40), float32] span=aten::_convolution_0.x:0:0 */, %aten::_convolution_0.weight: Tensor[(16, 3, 3, 3), float32] /* ty=Tensor[(16, 3, 3, 3), float32] span=aten::_convolution_0.weight:0:0 */, %aten::_convolution_0.bias: Tensor[(16), float32] /* ty=Tensor[(16), float32] span=aten::_convolution_0.bias:0:0 */, %aten::_convolution_1.weight: Tensor[(16, 32, 3, 3), float32] /* ty=Tensor[(16, 32, 3, 3), float32] span=aten::_convolution_1.weight:0:0 */, %aten::_convolution_1.bias: Tensor[(32), float32] /* ty=Tensor[(32), float32] span=aten::_convolution_1.bias:0:0 */) -> Tensor[(1, 32, 24, 40), float32] {\n", |
| 60 | + " %0 = nn.conv2d(%x, %aten::_convolution_0.weight, padding=[1, 1, 1, 1], channels=16, kernel_size=[3, 3]) /* ty=Tensor[(1, 16, 24, 40), float32] span=aten::_convolution_0:0:0 */;\n", |
| 61 | + " %1 = nn.bias_add(%0, %aten::_convolution_0.bias) /* ty=Tensor[(1, 16, 24, 40), float32] span=aten::_convolution_0:0:0 */;\n", |
| 62 | + " %2 = nn.conv2d_transpose(%1, %aten::_convolution_1.weight, channels=32, kernel_size=[3, 3], padding=[1, 1, 1, 1]) /* ty=Tensor[(1, 32, 24, 40), float32] span=aten::_convolution_1:0:0 */;\n", |
| 63 | + " nn.bias_add(%2, %aten::_convolution_1.bias) /* ty=Tensor[(1, 32, 24, 40), float32] span=aten::_convolution_1:0:0 */\n", |
| 64 | + "} /* ty=fn (Tensor[(1, 3, 24, 40), float32], Tensor[(16, 3, 3, 3), float32], Tensor[(16), float32], Tensor[(16, 32, 3, 3), float32], Tensor[(32), float32]) -> Tensor[(1, 32, 24, 40), float32] */\n" |
| 65 | + ] |
| 66 | + } |
| 67 | + ], |
| 68 | + "source": [ |
| 69 | + "print(mod[\"main\"])" |
| 70 | + ] |
| 71 | + }, |
27 | 72 | {
|
28 | 73 | "cell_type": "code",
|
29 | 74 | "execution_count": 2,
|
|
168 | 213 | ],
|
169 | 214 | "metadata": {
|
170 | 215 | "kernelspec": {
|
171 |
| - "display_name": "tvmz", |
| 216 | + "display_name": "Python 3", |
172 | 217 | "language": "python",
|
173 | 218 | "name": "python3"
|
174 | 219 | },
|
|
182 | 227 | "name": "python",
|
183 | 228 | "nbconvert_exporter": "python",
|
184 | 229 | "pygments_lexer": "ipython3",
|
185 |
| - "version": "3.12.4" |
| 230 | + "version": "3.12.2" |
186 | 231 | }
|
187 | 232 | },
|
188 | 233 | "nbformat": 4,
|
|
0 commit comments