Assert that we are working with a properly shaped image. Performs the check statically if possible (i.e. if the shape is statically known). Otherwise adds a control dependency to an assert op that checks the dynamic shape. Args: image: >= 3-D Tensor of size [*, height, width, depth]
(image)
| 176 | |
| 177 | |
| 178 | def _AssertAtLeast3DImage(image): |
| 179 | """Assert that we are working with a properly shaped image. |
| 180 | |
| 181 | Performs the check statically if possible (i.e. if the shape |
| 182 | is statically known). Otherwise adds a control dependency |
| 183 | to an assert op that checks the dynamic shape. |
| 184 | |
| 185 | Args: |
| 186 | image: >= 3-D Tensor of size [*, height, width, depth] |
| 187 | |
| 188 | Raises: |
| 189 | ValueError: if image.shape is not a [>= 3] vector. |
| 190 | |
| 191 | Returns: |
| 192 | If the shape of `image` could be verified statically, `image` is |
| 193 | returned unchanged, otherwise there will be a control dependency |
| 194 | added that asserts the correct dynamic shape. |
| 195 | """ |
| 196 | return control_flow_ops.with_dependencies( |
| 197 | _CheckAtLeast3DImage(image, require_static=False), image) |
| 198 | |
| 199 | |
| 200 | def _CheckAtLeast3DImage(image, require_static=True): |
no test coverage detected