Skip to content

Commit

Permalink
[TorchCodec] Use correct type for impl_abstract functions (#75)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #75

All the metadata functions return value are strings not tensors, plus torch.empty_like can't apply to an empty string.

Reviewed By: scotts, NicolasHug, ahmadsharif1

Differential Revision: D59609638

fbshipit-source-id: 44d12ba355ae34db8cbe1365f25536f1fa109f2f
  • Loading branch information
kaiyuey authored and facebook-github-bot committed Jul 11, 2024
1 parent 5af75ad commit dc140e5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/torchcodec/decoders/_core/video_decoder_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,23 @@ def get_frames_in_range_abstract(


@impl_abstract("torchcodec_ns::get_json_metadata")
def get_json_metadata_abstract(decoder: torch.Tensor) -> torch.Tensor:
return torch.empty_like("") # type: ignore[arg-type]
def get_json_metadata_abstract(decoder: torch.Tensor) -> str:
return ""


@impl_abstract("torchcodec_ns::get_container_json_metadata")
def get_container_json_metadata_abstract(decoder: torch.Tensor) -> torch.Tensor:
return torch.empty_like("") # type: ignore[arg-type]
def get_container_json_metadata_abstract(decoder: torch.Tensor) -> str:
return ""


@impl_abstract("torchcodec_ns::get_stream_json_metadata")
def get_stream_json_metadata_abstract(
decoder: torch.Tensor, stream_idx: int
) -> torch.Tensor:
return torch.empty_like("") # type: ignore[arg-type]
def get_stream_json_metadata_abstract(decoder: torch.Tensor, stream_idx: int) -> str:
return ""


@impl_abstract("torchcodec_ns::_get_json_ffmpeg_library_versions")
def _get_json_ffmpeg_library_versions_abstract() -> torch.Tensor:
return torch.empty_like("") # type: ignore[arg-type]
def _get_json_ffmpeg_library_versions_abstract() -> str:
return ""


@impl_abstract("torchcodec_ns::scan_all_streams_to_update_metadata")
Expand Down

0 comments on commit dc140e5

Please sign in to comment.