未验证 提交 27edf0b2 编写于 作者: 周周周 提交者: GitHub

commit (#54594)

上级 24a3cb52
......@@ -58,7 +58,7 @@ void IdentityOpCleanPass::ApplyImpl(ir::Graph* graph) const {
if (x->Op()->Type() == "scale") {
auto scale = x->Op()->GetAttrIfExists<float>("scale");
auto bias = x->Op()->GetAttrIfExists<float>("bias");
if (std::abs(bias) <= 1e-6 && std::abs(scale - 1) <= 1e-6) {
if (bias == 0 && scale == 1) {
return true;
}
}
......
......@@ -46,7 +46,7 @@ class ScaleOpConverter : public OpConverter {
is_int ? Add1DConstantLayer(
static_cast<int>(bias > 0 ? bias + 0.5 : bias - 0.5))
: Add1DConstantLayer(bias);
bool is_bias_0 = (bias < 1e-06 && bias > -1e-06);
bool is_bias_0 = bias == 0;
std::vector<int32_t> bias_shapes(input->getDimensions().nbDims, 1);
auto* bias_shapes_tensor = Add1DConstantLayer(bias_shapes);
......@@ -69,7 +69,7 @@ class ScaleOpConverter : public OpConverter {
scale_tensor = is_int ? Add1DConstantLayer(static_cast<int>(
scale > 0 ? scale + 0.5 : scale - 0.5))
: Add1DConstantLayer(scale);
is_scale_1 = ((scale - 1.0) < 1e-06 && (scale - 1.0) > -1e-06);
is_scale_1 = scale == 1;
}
std::vector<int32_t> scale_shapes(input->getDimensions().nbDims, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册