@@ -43,9 +43,9 @@ TORCH_LIBRARY(torchcodec_ns, m) {
4343 m.def (
4444 " _create_from_file_like(int file_like_context, str? seek_mode=None) -> Tensor" );
4545 m.def (
46- " _add_video_stream(Tensor(a!) decoder, *, int? width=None, int? height=None, int? num_threads=None, str? dimension_order=None, int? stream_index=None, str? device=None , str? device_variant=None , (Tensor, Tensor, Tensor)? custom_frame_mappings=None, str? color_conversion_library=None) -> ()" );
46+ " _add_video_stream(Tensor(a!) decoder, *, int? width=None, int? height=None, int? num_threads=None, str? dimension_order=None, int? stream_index=None, str device=\" cpu \" , str device_variant=\" default \" , (Tensor, Tensor, Tensor)? custom_frame_mappings=None, str? color_conversion_library=None) -> ()" );
4747 m.def (
48- " add_video_stream(Tensor(a!) decoder, *, int? width=None, int? height=None, int? num_threads=None, str? dimension_order=None, int? stream_index=None, str? device=None , str? device_variant=None , (Tensor, Tensor, Tensor)? custom_frame_mappings=None) -> ()" );
48+ " add_video_stream(Tensor(a!) decoder, *, int? width=None, int? height=None, int? num_threads=None, str? dimension_order=None, int? stream_index=None, str device=\" cpu \" , str device_variant=\" default \" , (Tensor, Tensor, Tensor)? custom_frame_mappings=None) -> ()" );
4949 m.def (
5050 " add_audio_stream(Tensor(a!) decoder, *, int? stream_index=None, int? sample_rate=None, int? num_channels=None) -> ()" );
5151 m.def (" seek_to_pts(Tensor(a!) decoder, float seconds) -> ()" );
@@ -257,8 +257,8 @@ void _add_video_stream(
257257 std::optional<int64_t > num_threads = std::nullopt ,
258258 std::optional<std::string_view> dimension_order = std::nullopt ,
259259 std::optional<int64_t > stream_index = std::nullopt ,
260- std::optional<std:: string_view> device = std:: nullopt ,
261- std::optional<std:: string_view> device_variant = std:: nullopt ,
260+ std::string_view device = " cpu " ,
261+ std::string_view device_variant = " default " ,
262262 std::optional<std::tuple<at::Tensor, at::Tensor, at::Tensor>>
263263 custom_frame_mappings = std::nullopt ,
264264 std::optional<std::string_view> color_conversion_library = std::nullopt ) {
@@ -289,16 +289,10 @@ void _add_video_stream(
289289 }
290290 }
291291
292- if (!device.has_value ()) {
293- device = " cpu" ;
294- }
295- if (!device_variant.has_value ()) {
296- device_variant = " default" ;
297- }
298- validateDeviceInterface (std::string (*device), std::string (*device_variant));
292+ validateDeviceInterface (std::string (device), std::string (device_variant));
299293
300- videoStreamOptions.device = torch::Device (std::string (* device));
301- videoStreamOptions.deviceVariant = * device_variant;
294+ videoStreamOptions.device = torch::Device (std::string (device));
295+ videoStreamOptions.deviceVariant = device_variant;
302296
303297 std::optional<SingleStreamDecoder::FrameMappings> converted_mappings =
304298 custom_frame_mappings.has_value ()
@@ -317,8 +311,8 @@ void add_video_stream(
317311 std::optional<int64_t > num_threads = std::nullopt ,
318312 std::optional<std::string_view> dimension_order = std::nullopt ,
319313 std::optional<int64_t > stream_index = std::nullopt ,
320- std::optional<std:: string_view> device = std:: nullopt ,
321- std::optional<std:: string_view> device_variant = std:: nullopt ,
314+ std::string_view device = " cpu " ,
315+ std::string_view device_variant = " default " ,
322316 const std::optional<std::tuple<at::Tensor, at::Tensor, at::Tensor>>&
323317 custom_frame_mappings = std::nullopt ) {
324318 _add_video_stream (
0 commit comments