Skip to content

Commit 44b6d23

Browse files
author
liuxinwei
committed
更新文档
1 parent 6e7ac3b commit 44b6d23

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

doc/topics/frontend/tf/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# TensorFlow 前端
22

3+
参考:
4+
1. [TF1 转换为 TF2](https://www.tensorflow.org/guide/migrate/migrate_tf2?hl=zh-cn)
5+
36
```{toctree}
47
tf1
58
pb2onnx

tests/Conv2dTransposeReshapeConcat.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730
],
731731
"metadata": {
732732
"kernelspec": {
733-
"display_name": "py312x",
733+
"display_name": "Python 3",
734734
"language": "python",
735735
"name": "python3"
736736
},
@@ -744,7 +744,7 @@
744744
"name": "python",
745745
"nbconvert_exporter": "python",
746746
"pygments_lexer": "ipython3",
747-
"version": "3.1.undefined"
747+
"version": "3.12.3"
748748
}
749749
},
750750
"nbformat": 4,

tests/test.ipynb

+47-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,51 @@
2424
"import set_env"
2525
]
2626
},
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+
},
2772
{
2873
"cell_type": "code",
2974
"execution_count": 2,
@@ -168,7 +213,7 @@
168213
],
169214
"metadata": {
170215
"kernelspec": {
171-
"display_name": "tvmz",
216+
"display_name": "Python 3",
172217
"language": "python",
173218
"name": "python3"
174219
},
@@ -182,7 +227,7 @@
182227
"name": "python",
183228
"nbconvert_exporter": "python",
184229
"pygments_lexer": "ipython3",
185-
"version": "3.12.4"
230+
"version": "3.12.2"
186231
}
187232
},
188233
"nbformat": 4,

tests/yolo-test.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@
10301030
],
10311031
"metadata": {
10321032
"kernelspec": {
1033-
"display_name": "xin",
1033+
"display_name": "Python 3",
10341034
"language": "python",
10351035
"name": "python3"
10361036
},

tests/yolo.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@
10771077
],
10781078
"metadata": {
10791079
"kernelspec": {
1080-
"display_name": "xin",
1080+
"display_name": "Python 3",
10811081
"language": "python",
10821082
"name": "python3"
10831083
},

0 commit comments

Comments
 (0)