| 36 | } |
| 37 | |
| 38 | bool HasDynamicShapeOutput(NodeDef* node_def) { |
| 39 | AttrValue attr_value = (*node_def->mutable_attr())["_output_shapes"]; |
| 40 | |
| 41 | Status s = AttrValueHasType(attr_value, "list(shape)"); |
| 42 | if (!s.ok()) { |
| 43 | s = AttrValueHasType(attr_value, "shape"); |
| 44 | if (!s.ok()) return true; |
| 45 | for (auto d : attr_value.shape().dim()) { |
| 46 | if (d.size() == -1) return true; |
| 47 | } |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | for (const auto& v : attr_value.list().shape()) { |
| 52 | for (auto d : v.dim()) { |
| 53 | if (d.size() == -1) return true; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | std::unordered_map<std::string, bool> GetNodesHasDynamicShapeMap(const GraphDef& gdef) { |
| 61 | // NOTE(jiankeng.pt): should be optimized via topological sort algorithm later |