Skip to content

Conversation

@apbose
Copy link
Collaborator

@apbose apbose commented Nov 6, 2025

This PR addresses the case of empty tensor in torchTRT based on https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/advanced.html#empty-tensors, and also focuses on concat operation edge case involving empty tensor

TODO: Might have to separate the case of concat from this PR, in the case when torch.Tensor([]) and a rank greater tensor are concatenated, which is a valid case in pytorch but not TRT.

This addressed #3865. Corresponding HF transformers issue raised - huggingface/transformers#42027 where empty tensor should not come in the first place

@apbose apbose self-assigned this Nov 6, 2025
@meta-cla meta-cla bot added the cla signed label Nov 6, 2025
@apbose apbose marked this pull request as draft November 6, 2025 21:51
@github-actions github-actions bot added component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: api [Python] Issues re: Python API component: runtime component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Nov 6, 2025
@github-actions github-actions bot requested a review from peri044 November 6, 2025 21:51
@apbose apbose force-pushed the abose/torchTRT_empty_tensor_handling branch 2 times, most recently from 87ebaf5 to 547022d Compare November 21, 2025 01:06
@apbose apbose marked this pull request as ready for review November 21, 2025 01:06
@apbose apbose force-pushed the abose/torchTRT_empty_tensor_handling branch from 547022d to 5d9d5fc Compare November 25, 2025 05:07
@apbose apbose changed the title Empty tensor handling [WIP] Empty tensor handling Nov 26, 2025
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apbose this maybe be a case where we would want TRT to properly handle this rather than us doing something hacky. Lets raise it with Yuan Yuo. Dummy inputs do not feel like the right solution

auto shape = core::util::toVec(dims);
LOG_DEBUG("Input Name: " << name << " Shape: " << dims);

void* tensor_addr = nullptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly want to avoid having nullptr basically anywhere, we should be looking for some sane default

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

Labels

cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: runtime component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants