Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions torchvision/csrc/io/decoder/audio_sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int AudioSampler::sample(
return result;
}

CHECK_LE(result, outNumSamples);
TORCH_CHECK_LE(result, outNumSamples);

if (result) {
if ((result = av_samples_get_buffer_size(
Expand Down Expand Up @@ -166,7 +166,7 @@ int AudioSampler::sample(

av_free(tmpBuffer);

CHECK_LE(result, outNumSamples);
TORCH_CHECK_LE(result, outNumSamples);

if (result) {
result = av_samples_get_buffer_size(
Expand Down
8 changes: 4 additions & 4 deletions torchvision/csrc/io/decoder/sync_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ void SyncDecoder::AVByteStorage::ensure(size_t n) {
}

uint8_t* SyncDecoder::AVByteStorage::writableTail() {
CHECK_LE(offset_ + length_, capacity_);
TORCH_CHECK_LE(offset_ + length_, capacity_);
return buffer_ + offset_ + length_;
}

void SyncDecoder::AVByteStorage::append(size_t n) {
CHECK_LE(n, tail());
TORCH_CHECK_LE(n, tail());
length_ += n;
}

void SyncDecoder::AVByteStorage::trim(size_t n) {
CHECK_LE(n, length_);
TORCH_CHECK_LE(n, length_);
offset_ += n;
length_ -= n;
}
Expand All @@ -43,7 +43,7 @@ size_t SyncDecoder::AVByteStorage::length() const {
}

size_t SyncDecoder::AVByteStorage::tail() const {
CHECK_LE(offset_ + length_, capacity_);
TORCH_CHECK_LE(offset_ + length_, capacity_);
return capacity_ - offset_ - length_;
}

Expand Down
12 changes: 6 additions & 6 deletions torchvision/csrc/io/decoder/sync_decoder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
fseek(f, 0, SEEK_END);
std::vector<uint8_t> buffer(ftell(f));
rewind(f);
CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
TORCH_CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
Copy link
Contributor

@datumbox datumbox Aug 3, 2022

Choose a reason for hiding this comment

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

This is not just a check. This is a function call that must be performed and then checked for its output. Unfortunately the new TORCH_CHECK_EQ mechanism can skip completely the method call if not in debug mode. This means that the function call will never be done causing issues.

fclose(f);

for (size_t i = 0; i < rounds; ++i) {
Expand All @@ -66,7 +66,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
avgProvUs +=
std::chrono::duration_cast<std::chrono::microseconds>(then - now)
.count();
CHECK_EQ(metadata.size(), 1);
TORCH_CHECK_EQ(metadata.size(), 1);
item.num = metadata[0].num;
item.den = metadata[0].den;
item.fps = metadata[0].fps;
Expand All @@ -90,7 +90,7 @@ size_t measurePerformanceUs(
fseek(f, 0, SEEK_END);
std::vector<uint8_t> buffer(ftell(f));
rewind(f);
CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
TORCH_CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
Copy link
Contributor

Choose a reason for hiding this comment

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

another one

fclose(f);

for (size_t i = 0; i < rounds; ++i) {
Expand Down Expand Up @@ -324,7 +324,7 @@ TEST(SyncDecoder, TestMemoryBuffer) {
fseek(f, 0, SEEK_END);
std::vector<uint8_t> buffer(ftell(f));
rewind(f);
CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
TORCH_CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
Copy link
Contributor

Choose a reason for hiding this comment

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

this one too

fclose(f);
CHECK(decoder.init(
params,
Expand All @@ -349,7 +349,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithFullRead) {
fseek(f, 0, SEEK_END);
std::vector<uint8_t> buffer(ftell(f));
rewind(f);
CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
TORCH_CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
Copy link
Contributor

Choose a reason for hiding this comment

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

this one too

fclose(f);

params.maxSeekableBytes = buffer.size() + 1;
Expand Down Expand Up @@ -388,7 +388,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithPartialRead) {
fseek(f, 0, SEEK_END);
std::vector<uint8_t> buffer(ftell(f));
rewind(f);
CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
TORCH_CHECK_EQ(buffer.size(), fread(buffer.data(), 1, buffer.size(), f));
Copy link
Contributor

Choose a reason for hiding this comment

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

this one too

fclose(f);

params.maxSeekableBytes = buffer.size() / 2;
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/io/decoder/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ std::string generateErrorDesc(int errorCode) {

size_t serialize(const AVSubtitle& sub, ByteStorage* out) {
const auto len = size(sub);
CHECK_LE(len, out->tail());
TORCH_CHECK_LE(len, out->tail());
size_t pos = 0;
if (!Serializer::serializeItem(out->writableTail(), len, pos, sub)) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/io/video/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ std::tuple<torch::Tensor, double> Video::Next() {
static_cast<AVSampleFormat>(format.format.audio.format));
int frameSizeTotal = out.payload->length();

CHECK_EQ(frameSizeTotal % (outAudioChannels * bytesPerSample), 0);
TORCH_CHECK_EQ(frameSizeTotal % (outAudioChannels * bytesPerSample), 0);
int numAudioSamples =
frameSizeTotal / (outAudioChannels * bytesPerSample);

Expand Down
8 changes: 4 additions & 4 deletions torchvision/csrc/io/video_reader/video_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ size_t fillTensor(
}
T* frameData = frame.numel() > 0 ? frame.data_ptr<T>() : nullptr;
int64_t* framePtsData = framePts.data_ptr<int64_t>();
CHECK_EQ(framePts.size(0), (int64_t)msgs.size());
TORCH_CHECK_EQ(framePts.size(0), (int64_t)msgs.size());
size_t avgElementsInFrame = frame.numel() / msgs.size();

size_t offset = 0;
Expand Down Expand Up @@ -320,7 +320,7 @@ torch::List<torch::Tensor> readVideo(
auto numberWrittenBytes = fillVideoTensor(
videoMessages, videoFrame, videoFramePts, header.num, header.den);

CHECK_EQ(numberWrittenBytes, expectedWrittenBytes);
TORCH_CHECK_EQ(numberWrittenBytes, expectedWrittenBytes);

videoTimeBase = torch::zeros({2}, torch::kInt);
int* videoTimeBaseData = videoTimeBase.data_ptr<int>();
Expand Down Expand Up @@ -365,7 +365,7 @@ torch::List<torch::Tensor> readVideo(
frameSizeTotal += audioMessage.payload->length();
}

CHECK_EQ(frameSizeTotal % (outAudioChannels * bytesPerSample), 0);
TORCH_CHECK_EQ(frameSizeTotal % (outAudioChannels * bytesPerSample), 0);
numAudioSamples = frameSizeTotal / (outAudioChannels * bytesPerSample);

audioFrame =
Expand All @@ -380,7 +380,7 @@ torch::List<torch::Tensor> readVideo(

auto numberWrittenBytes = fillAudioTensor(
audioMessages, audioFrame, audioFramePts, header.num, header.den);
CHECK_EQ(
TORCH_CHECK_EQ(
numberWrittenBytes,
numAudioSamples * outAudioChannels * sizeof(float));

Expand Down