(self, data)
| 29 | self.unknown_speed_emb = nn.Embedding(1, dim) |
| 30 | |
| 31 | def forward(self, data) -> torch.Tensor: |
| 32 | polygon_center = data["map"]["polygon_center"] |
| 33 | polygon_type = data["map"]["polygon_type"].long() |
| 34 | polygon_on_route = data["map"]["polygon_on_route"].long() |
| 35 | polygon_tl_status = data["map"]["polygon_tl_status"].long() |
| 36 | polygon_has_speed_limit = data["map"]["polygon_has_speed_limit"] |
| 37 | polygon_speed_limit = data["map"]["polygon_speed_limit"] |
| 38 | point_position = data["map"]["point_position"] |
| 39 | point_vector = data["map"]["point_vector"] |
| 40 | point_orientation = data["map"]["point_orientation"] |
| 41 | valid_mask = data["map"]["valid_mask"] |
| 42 | |
| 43 | if self.use_lane_boundary: |
| 44 | polygon_feature = torch.cat( |
| 45 | [ |
| 46 | point_position[:, :, 0] - polygon_center[..., None, :2], |
| 47 | point_vector[:, :, 0], |
| 48 | torch.stack( |
| 49 | [ |
| 50 | point_orientation[:, :, 0].cos(), |
| 51 | point_orientation[:, :, 0].sin(), |
| 52 | ], |
| 53 | dim=-1, |
| 54 | ), |
| 55 | point_position[:, :, 1] - point_position[:, :, 0], |
| 56 | point_position[:, :, 2] - point_position[:, :, 0], |
| 57 | ], |
| 58 | dim=-1, |
| 59 | ) |
| 60 | else: |
| 61 | polygon_feature = torch.cat( |
| 62 | [ |
| 63 | point_position[:, :, 0] - polygon_center[..., None, :2], |
| 64 | point_vector[:, :, 0], |
| 65 | torch.stack( |
| 66 | [ |
| 67 | point_orientation[:, :, 0].cos(), |
| 68 | point_orientation[:, :, 0].sin(), |
| 69 | ], |
| 70 | dim=-1, |
| 71 | ), |
| 72 | ], |
| 73 | dim=-1, |
| 74 | ) |
| 75 | |
| 76 | bs, M, P, C = polygon_feature.shape |
| 77 | valid_mask = valid_mask.view(bs * M, P) |
| 78 | polygon_feature = polygon_feature.reshape(bs * M, P, C) |
| 79 | |
| 80 | x_polygon = self.polygon_encoder(polygon_feature, valid_mask).view(bs, M, -1) |
| 81 | |
| 82 | x_type = self.type_emb(polygon_type) |
| 83 | x_on_route = self.on_route_emb(polygon_on_route) |
| 84 | x_tl_status = self.traffic_light_emb(polygon_tl_status) |
| 85 | x_speed_limit = torch.zeros(bs, M, self.dim, device=x_polygon.device) |
| 86 | x_speed_limit[polygon_has_speed_limit] = self.speed_limit_emb( |
| 87 | polygon_speed_limit[polygon_has_speed_limit].unsqueeze(-1) |
| 88 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected