MCPcopy Create free account
hub / github.com/apple/ml-sharp / _create_surface_layer

Method _create_surface_layer

src/sharp/models/initializer.py:159–172  ·  view source on GitHub ↗

Create multiple surface layers.

(
            depth: torch.Tensor,
            depth_pooling_mode: str,
        )

Source from the content-addressed store, hash-verified

157 )
158
159 def _create_surface_layer(
160 depth: torch.Tensor,
161 depth_pooling_mode: str,
162 ) -> torch.Tensor:
163 """Create multiple surface layers."""
164 disparity = 1.0 / depth
165 if depth_pooling_mode == "min":
166 disparity = torch.max_pool2d(disparity, self.stride, self.stride)
167 elif depth_pooling_mode == "max":
168 disparity = -torch.max_pool2d(-disparity, self.stride, self.stride)
169 else:
170 raise ValueError(f"Invalid depth pooling mode {depth_pooling_mode}.")
171
172 return disparity[:, :, None, :, :]
173
174 # Input disparity dimensions:
175 # (batch_size, num_channels in (1, 2), height, width)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected