Skip to content

Commit d0d0f69

Browse files
committed
Remove the monkeypatch
Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
1 parent b200c65 commit d0d0f69

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

docling/models/stages/ocr/nemotron_ocr_model.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@
2525
_log = logging.getLogger(__name__)
2626

2727

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-
5028
class NemotronOcrPrediction(TypedDict):
5129
"""Exact prediction schema returned by `nemotron_ocr`."""
5230

@@ -93,11 +71,6 @@ def __init__(
9371
self.reader = NemotronOCR(
9472
model_dir=None if model_dir is None else str(model_dir)
9573
)
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-
)
10174

10275
@staticmethod
10376
def _fail_runtime(message: str) -> None:

0 commit comments

Comments
 (0)