Skip to content

Commit 6adb7dc

Browse files
committed
make shape a vec
1 parent dfa5bcb commit 6adb7dc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/torchcodec/_core/pybind_ops.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,16 @@ int64_t create_from_file_like(
4444

4545
int64_t encode_audio_to_file_like(
4646
uintptr_t data_ptr,
47-
py::list shape,
47+
const std::vector<int64_t>& shape,
4848
int64_t sample_rate,
4949
std::string_view format,
5050
py::object file_like,
5151
std::optional<int64_t> bit_rate = std::nullopt,
5252
std::optional<int64_t> num_channels = std::nullopt) {
53-
// Convert Python list to vector
54-
auto shape_vec = shape.cast<std::vector<int64_t>>();
55-
5653
// Create tensor from existing data pointer (enforcing float32)
5754
auto tensor_options = torch::TensorOptions().dtype(torch::kFloat32);
5855
auto samples = torch::from_blob(
59-
reinterpret_cast<void*>(data_ptr), shape_vec, tensor_options);
56+
reinterpret_cast<void*>(data_ptr), shape, tensor_options);
6057

6158
AudioStreamOptions audioStreamOptions;
6259
audioStreamOptions.bitRate = bit_rate;

0 commit comments

Comments
 (0)