Skip to content

from_dlpack in spacy-transformers #741

@svlandeg

Description

@svlandeg

The test suite for spacy-transformers breaks in my local environment since PR #686

numpy                             1.23.1
spacy                             3.4.1        (current master)
spacy-transformers                1.1.2        (current master)
thinc                             8.1.0        (current master)
torch                             1.9.0+cu111

e.g. when I run test_model_sequence_classification, it crashes at https://github.com/explosion/thinc/blob/master/thinc/util.py#L365:

>           torch_tensor = torch.utils.dlpack.from_dlpack(xp_tensor)
E           RuntimeError: from_dlpack received an invalid capsule. Note that DLTensor capsules can be consumed only once, so you might have already constructed a tensor from it once.

But, when I look at the code behind from_dlpack and run this directly (having confirmed my system doesn't hit the if statement checking the device):

dlpack = xp_tensor.__dlpack__()
torch_tensor = torch._C._from_dlpack(dlpack)

Then the test flies through.

Can anyone reproduce the failing tests on the spacy-transformers test suite with a relatively new numpy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions