Skip to content

Commit b00797d

Browse files
committed
py:优化printtensor的format
1 parent b106f16 commit b00797d

12 files changed

Lines changed: 302 additions & 229 deletions

File tree

excuter/op-mem-ompsimd/src/deepx/op/print.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ namespace deepx::op{
1515
string name=this->args[0];
1616
if (mem.existstensor(name)){
1717
auto t=mem.gettensor<T>(name);
18-
tensorfunc::print<T>(*t);
18+
if (this->args.size() == 1){
19+
tensorfunc::print<T>(*t);
20+
}else{
21+
tensorfunc::print<T>(*t, this->args[1]);
22+
}
1923
}else{
2024
cout<<"<print> "<<name<<" not found"<<endl;
2125
}

excuter/op-mem-ompsimd/src/deepx/tensorfunc/print.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ namespace deepx::tensorfunc
3131
}
3232
else if constexpr (std::is_same_v<T, float>)
3333
{
34-
format = "%.2f";
34+
format = "%.4f";
3535
}
3636
else if constexpr (std::is_same_v<T, double>)
3737
{
38-
format = "%.2f";
38+
format = "%.4f";
3939
}
4040
}
4141
t.shape.print();

front/py/deepx/nn/functional/print.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from deepx.scheduler import send
55

66
OpNode.register("print")
7-
def printtensor(t:Tensor):
8-
ir=DeepxIR("print",'', [t.node.name], [])
7+
def printtensor(t:Tensor,format=''):
8+
ir=DeepxIR("print",'', [t.node.name,format], [])
99
send(ir)
1010
return ''
1111

front/py/examples/2_ir/6_math.dot

Lines changed: 0 additions & 38 deletions
This file was deleted.

front/py/examples/2_ir/6_math.dot.svg

Lines changed: 0 additions & 171 deletions
This file was deleted.

front/py/examples/2_ir/6_math.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Computational Graph
2+
digraph {
3+
rankdir=TB
4+
node [shape=record]
5+
132560372090576 [label="t
6+
(10, 10)" color=skyblue fillcolor=aliceblue fontname="Sans-Serif" labeljust=l shape=box style=filled]
7+
132560372104592 [label="var_1
8+
-1" color=orange fillcolor=moccasin fontname="Sans-Serif" labeljust=l shape=box style=filled]
9+
132558398381392 [label="var_2
10+
1" color=orange fillcolor=moccasin fontname="Sans-Serif" labeljust=l shape=box style=filled]
11+
132558397716416 [label=uniform color=darkslategray fillcolor=lightgray fontname="Courier Bold" labeljust=l shape=box style=filled]
12+
132558396599424 [label="relu_t
13+
(10, 10)" color=skyblue fillcolor=aliceblue fontname="Sans-Serif" labeljust=l shape=box style=filled]
14+
132558396599568 [label=max_scalar color=darkslategray fillcolor=lightgray fontname="Courier Bold" labeljust=l shape=box style=filled]
15+
132558396599808 [label="var_3
16+
0" color=orange fillcolor=moccasin fontname="Sans-Serif" labeljust=l shape=box style=filled]
17+
132558397716416 -> 132560372090576 [arrowsize=0.8 color=gray40 penwidth=1.2]
18+
132560372104592 -> 132558397716416 [arrowsize=0.8 color=gray40 penwidth=1.2]
19+
132558398381392 -> 132558397716416 [arrowsize=0.8 color=gray40 penwidth=1.2]
20+
132558396599568 -> 132558396599424 [arrowsize=0.8 color=gray40 penwidth=1.2]
21+
132560372090576 -> 132558396599568 [arrowsize=0.8 color=gray40 penwidth=1.2]
22+
132558396599808 -> 132558396599568 [arrowsize=0.8 color=gray40 penwidth=1.2]
23+
}

0 commit comments

Comments
 (0)