diff --git a/src/imperative/cached_op.cc b/src/imperative/cached_op.cc index 07c7871c6045..b49cad4eb77b 100644 --- a/src/imperative/cached_op.cc +++ b/src/imperative/cached_op.cc @@ -290,7 +290,7 @@ bool CachedOp::CheckDynamicShapeExists(const Context& default_ctx, CheckAndInferShape(&g, std::move(shape_inputs), true, {0, 0}, {0, 0}, &contain_dynamic_shape); - if (contain_dynamic_shape && erase_result) { + if (!config_.static_shape && erase_result) { g.attrs.erase("shape"); g.attrs.erase("shape_inputs"); }