Skip to content

Commit 1690a5f

Browse files
committed
Renaming public image methods to match the ones on python.
1 parent 7136251 commit 1690a5f

14 files changed

+40
-36
lines changed

torchvision/csrc/io/image/cpu/read_image_impl.cpp renamed to torchvision/csrc/io/image/cpu/decode_image.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "read_image_impl.h"
1+
#include "decode_image.h"
22

3-
#include "readjpeg_impl.h"
4-
#include "readpng_impl.h"
3+
#include "decode_jpeg.h"
4+
#include "decode_png.h"
55

66
namespace vision {
77
namespace image {
@@ -20,9 +20,9 @@ torch::Tensor decode_image(const torch::Tensor& data, ImageReadMode mode) {
2020
const uint8_t png_signature[4] = {137, 80, 78, 71}; // == "\211PNG"
2121

2222
if (memcmp(jpeg_signature, datap, 3) == 0) {
23-
return decodeJPEG(data, mode);
23+
return decode_jpeg(data, mode);
2424
} else if (memcmp(png_signature, datap, 4) == 0) {
25-
return decodePNG(data, mode);
25+
return decode_png(data, mode);
2626
} else {
2727
TORCH_CHECK(
2828
false,

torchvision/csrc/io/image/cpu/readjpeg_impl.cpp renamed to torchvision/csrc/io/image/cpu/decode_jpeg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "readjpeg_impl.h"
1+
#include "decode_jpeg.h"
22
#include "jpegcommon.h"
33

44
namespace vision {
@@ -7,9 +7,9 @@ namespace image {
77
using namespace detail;
88

99
#if !JPEG_FOUND
10-
torch::Tensor decodeJPEG(const torch::Tensor& data, ImageReadMode mode) {
10+
torch::Tensor decode_jpeg(const torch::Tensor& data, ImageReadMode mode) {
1111
TORCH_CHECK(
12-
false, "decodeJPEG: torchvision not compiled with libjpeg support");
12+
false, "decode_jpeg: torchvision not compiled with libjpeg support");
1313
}
1414
#else
1515

@@ -73,7 +73,7 @@ static void torch_jpeg_set_source_mgr(
7373

7474
} // namespace
7575

76-
torch::Tensor decodeJPEG(const torch::Tensor& data, ImageReadMode mode) {
76+
torch::Tensor decode_jpeg(const torch::Tensor& data, ImageReadMode mode) {
7777
// Check that the input tensor dtype is uint8
7878
TORCH_CHECK(data.dtype() == torch::kU8, "Expected a torch.uint8 tensor");
7979
// Check that the input tensor is 1-dimensional

torchvision/csrc/io/image/cpu/readjpeg_impl.h renamed to torchvision/csrc/io/image/cpu/decode_jpeg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace vision {
77
namespace image {
88

9-
C10_EXPORT torch::Tensor decodeJPEG(
9+
C10_EXPORT torch::Tensor decode_jpeg(
1010
const torch::Tensor& data,
1111
ImageReadMode mode = IMAGE_READ_MODE_UNCHANGED);
1212

torchvision/csrc/io/image/cpu/readpng_impl.cpp renamed to torchvision/csrc/io/image/cpu/decode_png.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
#include "readpng_impl.h"
1+
#include "decode_png.h"
22
#include "pngcommon.h"
33

44
namespace vision {
55
namespace image {
66

77
#if !PNG_FOUND
8-
torch::Tensor decodePNG(const torch::Tensor& data, ImageReadMode mode) {
9-
TORCH_CHECK(false, "decodePNG: torchvision not compiled with libPNG support");
8+
torch::Tensor decode_png(const torch::Tensor& data, ImageReadMode mode) {
9+
TORCH_CHECK(
10+
false, "decode_png: torchvision not compiled with libPNG support");
1011
}
1112
#else
1213

13-
torch::Tensor decodePNG(const torch::Tensor& data, ImageReadMode mode) {
14+
torch::Tensor decode_png(const torch::Tensor& data, ImageReadMode mode) {
1415
// Check that the input tensor dtype is uint8
1516
TORCH_CHECK(data.dtype() == torch::kU8, "Expected a torch.uint8 tensor");
1617
// Check that the input tensor is 1-dimensional

torchvision/csrc/io/image/cpu/readpng_impl.h renamed to torchvision/csrc/io/image/cpu/decode_png.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace vision {
77
namespace image {
88

9-
C10_EXPORT torch::Tensor decodePNG(
9+
C10_EXPORT torch::Tensor decode_png(
1010
const torch::Tensor& data,
1111
ImageReadMode mode = IMAGE_READ_MODE_UNCHANGED);
1212

torchvision/csrc/io/image/cpu/writejpeg_impl.cpp renamed to torchvision/csrc/io/image/cpu/encode_jpeg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "writejpeg_impl.h"
1+
#include "encode_jpeg.h"
22

33
#include "jpegcommon.h"
44

@@ -9,14 +9,14 @@ using namespace detail;
99

1010
#if !JPEG_FOUND
1111

12-
torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) {
12+
torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
1313
TORCH_CHECK(
14-
false, "encodeJPEG: torchvision not compiled with libjpeg support");
14+
false, "encode_jpeg: torchvision not compiled with libjpeg support");
1515
}
1616

1717
#else
1818

19-
torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) {
19+
torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
2020
// Define compression structures and error handling
2121
struct jpeg_compress_struct cinfo;
2222
struct torch_jpeg_error_mgr jerr;

torchvision/csrc/io/image/cpu/writejpeg_impl.h renamed to torchvision/csrc/io/image/cpu/encode_jpeg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace vision {
66
namespace image {
77

8-
C10_EXPORT torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality);
8+
C10_EXPORT torch::Tensor encode_jpeg(
9+
const torch::Tensor& data,
10+
int64_t quality);
911

1012
} // namespace image
1113
} // namespace vision

torchvision/csrc/io/image/cpu/writepng_impl.cpp renamed to torchvision/csrc/io/image/cpu/encode_png.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "writejpeg_impl.h"
1+
#include "encode_jpeg.h"
22

33
#include "pngcommon.h"
44

@@ -7,8 +7,9 @@ namespace image {
77

88
#if !PNG_FOUND
99

10-
torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) {
11-
TORCH_CHECK(false, "encodePNG: torchvision not compiled with libpng support");
10+
torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
11+
TORCH_CHECK(
12+
false, "encode_png: torchvision not compiled with libpng support");
1213
}
1314

1415
#else
@@ -66,7 +67,7 @@ void torch_png_write_data(
6667

6768
} // namespace
6869

69-
torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) {
70+
torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
7071
// Define compression structures and error handling
7172
png_structp png_write;
7273
png_infop info_ptr;

torchvision/csrc/io/image/cpu/writepng_impl.h renamed to torchvision/csrc/io/image/cpu/encode_png.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace vision {
66
namespace image {
77

8-
C10_EXPORT torch::Tensor encodePNG(
8+
C10_EXPORT torch::Tensor encode_png(
99
const torch::Tensor& data,
1010
int64_t compression_level);
1111

torchvision/csrc/io/image/cpu/read_write_file_impl.cpp renamed to torchvision/csrc/io/image/cpu/read_write_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "read_write_file_impl.h"
1+
#include "read_write_file.h"
22

33
#include <sys/stat.h>
44

torchvision/csrc/io/image/image.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ namespace vision {
1515
namespace image {
1616

1717
static auto registry = torch::RegisterOperators()
18-
.op("image::decode_png", &decodePNG)
19-
.op("image::encode_png", &encodePNG)
20-
.op("image::decode_jpeg", &decodeJPEG)
21-
.op("image::encode_jpeg", &encodeJPEG)
18+
.op("image::decode_png", &decode_png)
19+
.op("image::encode_png", &encode_png)
20+
.op("image::decode_jpeg", &decode_jpeg)
21+
.op("image::encode_jpeg", &encode_jpeg)
2222
.op("image::read_file", &read_file)
2323
.op("image::write_file", &write_file)
2424
.op("image::decode_image", &decode_image);

torchvision/csrc/io/image/image.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3-
#include "cpu/read_image_impl.h"
4-
#include "cpu/read_write_file_impl.h"
5-
#include "cpu/readjpeg_impl.h"
6-
#include "cpu/readpng_impl.h"
7-
#include "cpu/writejpeg_impl.h"
8-
#include "cpu/writepng_impl.h"
3+
#include "cpu/decode_image.h"
4+
#include "cpu/decode_jpeg.h"
5+
#include "cpu/decode_png.h"
6+
#include "cpu/encode_jpeg.h"
7+
#include "cpu/encode_png.h"
8+
#include "cpu/read_write_file.h"

0 commit comments

Comments
 (0)