|
25 | 25 | _log = logging.getLogger(__name__) |
26 | 26 |
|
27 | 27 |
|
28 | | -class _GridSamplerStorageWorkaround: |
29 | | - # Temporary upstream workaround: |
30 | | - # `nemotron_ocr_cpp.indirect_grid_sample_forward(...)` intermittently |
31 | | - # raises "Tensor doesn't have storage" for tensors that appear valid from |
32 | | - # Python. Retry the failed call once with fresh owned contiguous tensors. |
33 | | - def __init__(self, original_sampler: Any): |
34 | | - self._original_sampler = original_sampler |
35 | | - |
36 | | - def __call__(self, input_tensor: Any, grid: Any, input_indices: Any) -> Any: |
37 | | - # Workaround call site for the upstream custom-op storage bug. |
38 | | - try: |
39 | | - return self._original_sampler(input_tensor, grid, input_indices) |
40 | | - except RuntimeError as exc: |
41 | | - if "doesn't have storage" not in str(exc): |
42 | | - raise |
43 | | - return self._original_sampler( |
44 | | - input_tensor.contiguous().clone(), |
45 | | - grid.contiguous().clone(), |
46 | | - input_indices.contiguous().clone(), |
47 | | - ) |
48 | | - |
49 | | - |
50 | 28 | class NemotronOcrPrediction(TypedDict): |
51 | 29 | """Exact prediction schema returned by `nemotron_ocr`.""" |
52 | 30 |
|
@@ -93,11 +71,6 @@ def __init__( |
93 | 71 | self.reader = NemotronOCR( |
94 | 72 | model_dir=None if model_dir is None else str(model_dir) |
95 | 73 | ) |
96 | | - # Install the storage workaround only at the upstream grid-sampler |
97 | | - # boundary, keeping the rest of the Nemotron integration unchanged. |
98 | | - self.reader.grid_sampler = _GridSamplerStorageWorkaround( |
99 | | - self.reader.grid_sampler |
100 | | - ) |
101 | 74 |
|
102 | 75 | @staticmethod |
103 | 76 | def _fail_runtime(message: str) -> None: |
|
0 commit comments