Skip to content

Commit

Permalink
pnnx handle more softmin logsoftmax dtype, fuse static full range sli…
Browse files Browse the repository at this point in the history
…ces to tensor_split
  • Loading branch information
nihui committed Jan 2, 2024
1 parent 1e88fb8 commit bed43b4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/pnnx/src/pass_level2/F_log_softmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class F_log_softmax : public GraphRewriterPass
5 4
pnnx.Input input_0 0 1 input
pnnx.Input input_1 0 1 dim
prim::Constant op_0 0 1 dtype value=None
prim::Constant op_0 0 1 dtype value=*
aten::log_softmax op_1 3 1 input dim dtype out
pnnx.Output output 1 0 out
)PNNXIR";
Expand Down
2 changes: 1 addition & 1 deletion tools/pnnx/src/pass_level2/F_softmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class F_softmin : public GraphRewriterPass
pnnx.Input input_0 0 1 input
pnnx.Input input_1 0 1 dim
aten::neg op_0 1 1 input 6
prim::Constant op_1 0 1 dtype value=None
prim::Constant op_1 0 1 dtype value=*
aten::softmax op_2 3 1 6 dim dtype out
pnnx.Output output 1 0 out
)PNNXIR";
Expand Down
6 changes: 6 additions & 0 deletions tools/pnnx/src/pass_level5/fuse_slice_to_tensor_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ void fuse_slice_to_tensor_split(Graph& graph)
full_dimsize_slice = true;
break;
}
if (!op_in->shape.empty() && end2 == op_in->shape[dim])
{
slice_n_ops.push_back(op2);
full_dimsize_slice = true;
break;
}

tensor_split_indices.push_back(end2);
slice_n_ops.push_back(op2);
Expand Down
2 changes: 1 addition & 1 deletion tools/pnnx/tests/test_pnnx_fuse_slice_to_tensor_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def forward(self, x, y, z):
x0 = x[:3]
x1 = x[3:]

z3 = z[:,:,7:]
z3 = z[:,:,7:z.size(2)]
z2 = z[:,:,4:7]

y0 = y[:2,:]
Expand Down

0 comments on commit bed43b4

Please sign in to comment.