Skip to content

Commit

Permalink
Merge branch 'Tencent:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lrw04 authored Aug 7, 2023
2 parents 6ea41cc + 60fedae commit 51ccd56
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tools/pnnx/src/pass_level1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void pass_level1(const torch::jit::Module& mod, const std::shared_ptr<torch::jit
// sub_mod.dump(true, true, true);

op->attrs["data"] = sub_mod.attr(name).toTensor();
op->outputs[0]->type = op->attrs["data"].type;
op->outputs[0]->shape = op->attrs["data"].shape;
}
}
else if (n->kind() == c10::prim::Constant) // || n->kind() == c10::prim::ListConstruct)
Expand Down
3 changes: 3 additions & 0 deletions tools/pnnx/src/pass_level3/fuse_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ static void fuse_expression(Graph& graph, Operand* operand, std::string& expr, s
int64_t v;
zip.read_file(operand->name, (char*)&v);

if (v == std::numeric_limits<int64_t>::max()) v = INT_MAX;
if (v == std::numeric_limits<int64_t>::min()) v = INT_MIN;

char tmp[32];
sprintf(tmp, "%ld", v);
expr += tmp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ void eliminate_reshape_shape_expression(Graph& graph)
if (op_expr->outputs[0]->consumers.size() == 0)
{
// remove expression operator
op_expr->inputs[0]->remove_consumer(op_expr);
for (auto x : op_expr->inputs)
{
x->remove_consumer(op_expr);
}

Operand* op_expr_out = op_expr->outputs[0];

Expand Down
5 changes: 5 additions & 0 deletions tools/pnnx/src/pass_level5/eval_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ static std::string eval_expression(const Operator* op)
if (t == "int")
{
int r = int(af);
if (token_is_interger_literal(a))
{
r = std::stoi(a);
}

exprstack.push(std::to_string(r));
}
if (t == "abs")
Expand Down

0 comments on commit 51ccd56

Please sign in to comment.