Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
ec0e9e12
Unverified
Commit
ec0e9e12
authored
Jul 27, 2022
by
vfdev
Committed by
GitHub
Jul 27, 2022
Browse files
Replaced CHECK_ by TORCH_CHECK_ (#6322)
parent
6aacf497
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
18 deletions
+18
-18
torchvision/csrc/io/decoder/audio_sampler.cpp
torchvision/csrc/io/decoder/audio_sampler.cpp
+2
-2
torchvision/csrc/io/decoder/sync_decoder.cpp
torchvision/csrc/io/decoder/sync_decoder.cpp
+4
-4
torchvision/csrc/io/decoder/sync_decoder_test.cpp
torchvision/csrc/io/decoder/sync_decoder_test.cpp
+6
-6
torchvision/csrc/io/decoder/util.cpp
torchvision/csrc/io/decoder/util.cpp
+1
-1
torchvision/csrc/io/video/video.cpp
torchvision/csrc/io/video/video.cpp
+1
-1
torchvision/csrc/io/video_reader/video_reader.cpp
torchvision/csrc/io/video_reader/video_reader.cpp
+4
-4
No files found.
torchvision/csrc/io/decoder/audio_sampler.cpp
View file @
ec0e9e12
...
@@ -121,7 +121,7 @@ int AudioSampler::sample(
...
@@ -121,7 +121,7 @@ int AudioSampler::sample(
return
result
;
return
result
;
}
}
CHECK_LE
(
result
,
outNumSamples
);
TORCH_
CHECK_LE
(
result
,
outNumSamples
);
if
(
result
)
{
if
(
result
)
{
if
((
result
=
av_samples_get_buffer_size
(
if
((
result
=
av_samples_get_buffer_size
(
...
@@ -166,7 +166,7 @@ int AudioSampler::sample(
...
@@ -166,7 +166,7 @@ int AudioSampler::sample(
av_free
(
tmpBuffer
);
av_free
(
tmpBuffer
);
CHECK_LE
(
result
,
outNumSamples
);
TORCH_
CHECK_LE
(
result
,
outNumSamples
);
if
(
result
)
{
if
(
result
)
{
result
=
av_samples_get_buffer_size
(
result
=
av_samples_get_buffer_size
(
...
...
torchvision/csrc/io/decoder/sync_decoder.cpp
View file @
ec0e9e12
...
@@ -19,17 +19,17 @@ void SyncDecoder::AVByteStorage::ensure(size_t n) {
...
@@ -19,17 +19,17 @@ void SyncDecoder::AVByteStorage::ensure(size_t n) {
}
}
uint8_t
*
SyncDecoder
::
AVByteStorage
::
writableTail
()
{
uint8_t
*
SyncDecoder
::
AVByteStorage
::
writableTail
()
{
CHECK_LE
(
offset_
+
length_
,
capacity_
);
TORCH_
CHECK_LE
(
offset_
+
length_
,
capacity_
);
return
buffer_
+
offset_
+
length_
;
return
buffer_
+
offset_
+
length_
;
}
}
void
SyncDecoder
::
AVByteStorage
::
append
(
size_t
n
)
{
void
SyncDecoder
::
AVByteStorage
::
append
(
size_t
n
)
{
CHECK_LE
(
n
,
tail
());
TORCH_
CHECK_LE
(
n
,
tail
());
length_
+=
n
;
length_
+=
n
;
}
}
void
SyncDecoder
::
AVByteStorage
::
trim
(
size_t
n
)
{
void
SyncDecoder
::
AVByteStorage
::
trim
(
size_t
n
)
{
CHECK_LE
(
n
,
length_
);
TORCH_
CHECK_LE
(
n
,
length_
);
offset_
+=
n
;
offset_
+=
n
;
length_
-=
n
;
length_
-=
n
;
}
}
...
@@ -43,7 +43,7 @@ size_t SyncDecoder::AVByteStorage::length() const {
...
@@ -43,7 +43,7 @@ size_t SyncDecoder::AVByteStorage::length() const {
}
}
size_t
SyncDecoder
::
AVByteStorage
::
tail
()
const
{
size_t
SyncDecoder
::
AVByteStorage
::
tail
()
const
{
CHECK_LE
(
offset_
+
length_
,
capacity_
);
TORCH_
CHECK_LE
(
offset_
+
length_
,
capacity_
);
return
capacity_
-
offset_
-
length_
;
return
capacity_
-
offset_
-
length_
;
}
}
...
...
torchvision/csrc/io/decoder/sync_decoder_test.cpp
View file @
ec0e9e12
...
@@ -50,7 +50,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
...
@@ -50,7 +50,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
fseek
(
f
,
0
,
SEEK_END
);
fseek
(
f
,
0
,
SEEK_END
);
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
rewind
(
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
));
fclose
(
f
);
fclose
(
f
);
for
(
size_t
i
=
0
;
i
<
rounds
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
rounds
;
++
i
)
{
...
@@ -66,7 +66,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
...
@@ -66,7 +66,7 @@ void gotFilesStats(std::vector<VideoFileStats>& stats) {
avgProvUs
+=
avgProvUs
+=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
then
-
now
)
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
then
-
now
)
.
count
();
.
count
();
CHECK_EQ
(
metadata
.
size
(),
1
);
TORCH_
CHECK_EQ
(
metadata
.
size
(),
1
);
item
.
num
=
metadata
[
0
].
num
;
item
.
num
=
metadata
[
0
].
num
;
item
.
den
=
metadata
[
0
].
den
;
item
.
den
=
metadata
[
0
].
den
;
item
.
fps
=
metadata
[
0
].
fps
;
item
.
fps
=
metadata
[
0
].
fps
;
...
@@ -90,7 +90,7 @@ size_t measurePerformanceUs(
...
@@ -90,7 +90,7 @@ size_t measurePerformanceUs(
fseek
(
f
,
0
,
SEEK_END
);
fseek
(
f
,
0
,
SEEK_END
);
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
rewind
(
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
));
fclose
(
f
);
fclose
(
f
);
for
(
size_t
i
=
0
;
i
<
rounds
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
rounds
;
++
i
)
{
...
@@ -324,7 +324,7 @@ TEST(SyncDecoder, TestMemoryBuffer) {
...
@@ -324,7 +324,7 @@ TEST(SyncDecoder, TestMemoryBuffer) {
fseek
(
f
,
0
,
SEEK_END
);
fseek
(
f
,
0
,
SEEK_END
);
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
rewind
(
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
));
fclose
(
f
);
fclose
(
f
);
CHECK
(
decoder
.
init
(
CHECK
(
decoder
.
init
(
params
,
params
,
...
@@ -349,7 +349,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithFullRead) {
...
@@ -349,7 +349,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithFullRead) {
fseek
(
f
,
0
,
SEEK_END
);
fseek
(
f
,
0
,
SEEK_END
);
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
rewind
(
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
));
fclose
(
f
);
fclose
(
f
);
params
.
maxSeekableBytes
=
buffer
.
size
()
+
1
;
params
.
maxSeekableBytes
=
buffer
.
size
()
+
1
;
...
@@ -388,7 +388,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithPartialRead) {
...
@@ -388,7 +388,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithPartialRead) {
fseek
(
f
,
0
,
SEEK_END
);
fseek
(
f
,
0
,
SEEK_END
);
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
std
::
vector
<
uint8_t
>
buffer
(
ftell
(
f
));
rewind
(
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
));
fclose
(
f
);
fclose
(
f
);
params
.
maxSeekableBytes
=
buffer
.
size
()
/
2
;
params
.
maxSeekableBytes
=
buffer
.
size
()
/
2
;
...
...
torchvision/csrc/io/decoder/util.cpp
View file @
ec0e9e12
...
@@ -265,7 +265,7 @@ std::string generateErrorDesc(int errorCode) {
...
@@ -265,7 +265,7 @@ std::string generateErrorDesc(int errorCode) {
size_t
serialize
(
const
AVSubtitle
&
sub
,
ByteStorage
*
out
)
{
size_t
serialize
(
const
AVSubtitle
&
sub
,
ByteStorage
*
out
)
{
const
auto
len
=
size
(
sub
);
const
auto
len
=
size
(
sub
);
CHECK_LE
(
len
,
out
->
tail
());
TORCH_
CHECK_LE
(
len
,
out
->
tail
());
size_t
pos
=
0
;
size_t
pos
=
0
;
if
(
!
Serializer
::
serializeItem
(
out
->
writableTail
(),
len
,
pos
,
sub
))
{
if
(
!
Serializer
::
serializeItem
(
out
->
writableTail
(),
len
,
pos
,
sub
))
{
return
0
;
return
0
;
...
...
torchvision/csrc/io/video/video.cpp
View file @
ec0e9e12
...
@@ -321,7 +321,7 @@ std::tuple<torch::Tensor, double> Video::Next() {
...
@@ -321,7 +321,7 @@ std::tuple<torch::Tensor, double> Video::Next() {
static_cast
<
AVSampleFormat
>
(
format
.
format
.
audio
.
format
));
static_cast
<
AVSampleFormat
>
(
format
.
format
.
audio
.
format
));
int
frameSizeTotal
=
out
.
payload
->
length
();
int
frameSizeTotal
=
out
.
payload
->
length
();
CHECK_EQ
(
frameSizeTotal
%
(
outAudioChannels
*
bytesPerSample
),
0
);
TORCH_
CHECK_EQ
(
frameSizeTotal
%
(
outAudioChannels
*
bytesPerSample
),
0
);
int
numAudioSamples
=
int
numAudioSamples
=
frameSizeTotal
/
(
outAudioChannels
*
bytesPerSample
);
frameSizeTotal
/
(
outAudioChannels
*
bytesPerSample
);
...
...
torchvision/csrc/io/video_reader/video_reader.cpp
View file @
ec0e9e12
...
@@ -91,7 +91,7 @@ size_t fillTensor(
...
@@ -91,7 +91,7 @@ size_t fillTensor(
}
}
T
*
frameData
=
frame
.
numel
()
>
0
?
frame
.
data_ptr
<
T
>
()
:
nullptr
;
T
*
frameData
=
frame
.
numel
()
>
0
?
frame
.
data_ptr
<
T
>
()
:
nullptr
;
int64_t
*
framePtsData
=
framePts
.
data_ptr
<
int64_t
>
();
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
avgElementsInFrame
=
frame
.
numel
()
/
msgs
.
size
();
size_t
offset
=
0
;
size_t
offset
=
0
;
...
@@ -320,7 +320,7 @@ torch::List<torch::Tensor> readVideo(
...
@@ -320,7 +320,7 @@ torch::List<torch::Tensor> readVideo(
auto
numberWrittenBytes
=
fillVideoTensor
(
auto
numberWrittenBytes
=
fillVideoTensor
(
videoMessages
,
videoFrame
,
videoFramePts
,
header
.
num
,
header
.
den
);
videoMessages
,
videoFrame
,
videoFramePts
,
header
.
num
,
header
.
den
);
CHECK_EQ
(
numberWrittenBytes
,
expectedWrittenBytes
);
TORCH_
CHECK_EQ
(
numberWrittenBytes
,
expectedWrittenBytes
);
videoTimeBase
=
torch
::
zeros
({
2
},
torch
::
kInt
);
videoTimeBase
=
torch
::
zeros
({
2
},
torch
::
kInt
);
int
*
videoTimeBaseData
=
videoTimeBase
.
data_ptr
<
int
>
();
int
*
videoTimeBaseData
=
videoTimeBase
.
data_ptr
<
int
>
();
...
@@ -365,7 +365,7 @@ torch::List<torch::Tensor> readVideo(
...
@@ -365,7 +365,7 @@ torch::List<torch::Tensor> readVideo(
frameSizeTotal
+=
audioMessage
.
payload
->
length
();
frameSizeTotal
+=
audioMessage
.
payload
->
length
();
}
}
CHECK_EQ
(
frameSizeTotal
%
(
outAudioChannels
*
bytesPerSample
),
0
);
TORCH_
CHECK_EQ
(
frameSizeTotal
%
(
outAudioChannels
*
bytesPerSample
),
0
);
numAudioSamples
=
frameSizeTotal
/
(
outAudioChannels
*
bytesPerSample
);
numAudioSamples
=
frameSizeTotal
/
(
outAudioChannels
*
bytesPerSample
);
audioFrame
=
audioFrame
=
...
@@ -380,7 +380,7 @@ torch::List<torch::Tensor> readVideo(
...
@@ -380,7 +380,7 @@ torch::List<torch::Tensor> readVideo(
auto
numberWrittenBytes
=
fillAudioTensor
(
auto
numberWrittenBytes
=
fillAudioTensor
(
audioMessages
,
audioFrame
,
audioFramePts
,
header
.
num
,
header
.
den
);
audioMessages
,
audioFrame
,
audioFramePts
,
header
.
num
,
header
.
den
);
CHECK_EQ
(
TORCH_
CHECK_EQ
(
numberWrittenBytes
,
numberWrittenBytes
,
numAudioSamples
*
outAudioChannels
*
sizeof
(
float
));
numAudioSamples
*
outAudioChannels
*
sizeof
(
float
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment