| 164 | |
| 165 | |
| 166 | class FlopEstimator2D1DNotExact(FlopEstimatorExact): |
| 167 | common_factor = 16 # this value should be at least 16 |
| 168 | max_thw = 16934400 # 720 * 480 * 49 |
| 169 | max_t = 49 |
| 170 | max_hw = 1920 * 1920 |
| 171 | |
| 172 | def __init__(self, t, h, w, hw_value_arr: np.ndarray, |
| 173 | t_arr: np.ndarray) -> None: |
| 174 | self.size = self.net_size(t, h, w) |
| 175 | t, h, w = self.size |
| 176 | hw_idx = find_nearest_equal_or_smaller_value( |
| 177 | h * w, hw_value_arr, return_idx=True) |
| 178 | t_idx = find_nearest_equal_or_smaller_value(t, t_arr, return_idx=True) |
| 179 | self.size_not_exact = (t_idx, hw_idx) |
| 180 | self.thw = np.prod(self.size) |
| 181 | |
| 182 | def __eq__(self, other) -> None: |
| 183 | return self.size_not_exact == other.size_not_exact |
| 184 | |
| 185 | def __lt__(self, other) -> None: |
| 186 | return self.size_not_exact != other.size_not_exact and self.thw < other.thw |
| 187 | |
| 188 | def __gt__(self, other) -> None: |
| 189 | return self.size_not_exact != other.size_not_exact and self.thw > other.thw |
| 190 | |
| 191 | def __hash__(self, ): |
| 192 | return hash(self.size_not_exact) |
| 193 | |
| 194 | def __str__(self) -> str: |
| 195 | return str(self.size) |
| 196 | |
| 197 | |
| 198 | # class FlopEstimator3DNotExact(FlopEstimator2D1DNotExact): |