Skip to content

Commit

Permalink
apply code-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui authored and github-actions[bot] committed Feb 10, 2025
1 parent 22a5b7b commit f35a5ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions tools/pnnx/src/load_tnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ static size_t type_to_elemsize(int type)

static int get_tnn_tensor_type(int dt)
{
if (dt == 0) return 1;// fp32
if (dt == 1) return 3;// fp16
if (dt == 2) return 7;// int8
if (dt == 3) return 4;// int32
if (dt == 4) return 13;// bf16
if (dt == 0) return 1; // fp32
if (dt == 1) return 3; // fp16
if (dt == 2) return 7; // int8
if (dt == 3) return 4; // int32
if (dt == 4) return 13; // bf16

fprintf(stderr, "unsupported tnn tensor type %d\n", dt);
return 0; // unknown type
Expand Down
16 changes: 7 additions & 9 deletions tools/pnnx/src/pass_level2/torch_index_select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ class torch_index_select_tnn : public GraphRewriterPass
public:
const char* match_pattern_graph() const
{
return R"PNNXIR(7767517
4 3
pnnx.Input input 0 1 input
pnnx.Attribute op_0 0 1 index @data=(?)i32
tnn.Gather op_1 2 1 input index out arg0=%dim arg1=0 arg2=1
pnnx.Output output 1 0 out
)PNNXIR";
return R "PNNXIR(7767517
4 3 pnnx.Input input 0 1 input
pnnx.Attribute op_0 0 1 index @data
= (?) i32
tnn.Gather op_1 2 1 input index out arg0
= % dim arg1 = 0 arg2 = 1 pnnx.Output output 1 0 out) PNNXIR ";
}

const char* replace_pattern_graph() const
Expand All @@ -78,12 +77,11 @@ pnnx.Output output 1 0 out
{
indices[i] = p[i];
}
op_index->attrs["data"].type = 5;// i64
op_index->attrs["data"].type = 5; // i64
op_index->attrs["data"].shape = {n};
op_index->attrs["data"].data.resize(n * 8);
memcpy((void*)op_index->attrs["data"].data.data(), (const void*)indices.data(), n * 8);


Operator* op_gather = ops.at("select");
op_gather->params["dim"] = captured_params.at("dim");
op_gather->inputnames = {"input", "index"};
Expand Down

0 comments on commit f35a5ea

Please sign in to comment.