Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP] Processor moves to device in __call__#43249

Open
zucchini-nlp wants to merge 1 commit into
huggingface:mainfrom
zucchini-nlp:device-batch-features
Open

[WIP] Processor moves to device in __call__#43249
zucchini-nlp wants to merge 1 commit into
huggingface:mainfrom
zucchini-nlp:device-batch-features

Conversation

@zucchini-nlp

@zucchini-nlp zucchini-nlp commented Jan 13, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR allows users to pass the device to processor call and get all inputs in the requested device. Currently the device arg is used only in fast image/video processors. But users get confused by the following case

inputs = processor(images, text, device='cuda', return_tensors='pt')

# Before the PR
print(inputs.input_ids.device) # "cpu"
print(inputs.pixel_values.device) # "cuda"

# After the PR
print(inputs.input_ids.device) # "cuda"
print(inputs.pixel_values.device) # "cuda

Now we will allow either to pass device and get all inputs initialized already on device, or to move to device manually by inputs.to(device)

Fixes #42722

@github-actions

Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43249&sha=703f75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure that OneFormerProcessor place text task_inputs to the same device as other inputs

1 participant