Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image decoder for data_pipeline #107

Merged
merged 125 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
0f5a8cf
image decoder header file and constructor
am831 Oct 9, 2023
8932880
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 9, 2023
8bc7f63
png.cc and png.h
am831 Oct 10, 2023
4cef991
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 10, 2023
d92ea92
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Oct 10, 2023
6b94093
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 11, 2023
a499b18
remove png files and import libpng methods
am831 Oct 16, 2023
794c34a
image decoder
am831 Oct 16, 2023
ca13683
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Oct 16, 2023
f751cc8
python binding
am831 Oct 16, 2023
1a7b52a
png decoder progress and py binding
am831 Oct 16, 2023
87b02c7
build py binding
am831 Oct 16, 2023
10bcc14
update init
am831 Oct 16, 2023
d6ecdbb
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 16, 2023
5e36386
png decoder progress
am831 Oct 17, 2023
3f4dc22
png decoder progress
am831 Oct 17, 2023
59f6799
remove print statements
am831 Oct 17, 2023
9ab69a3
populate tensor object with png data
am831 Oct 17, 2023
2cfeca3
remove unnecessary include
am831 Oct 17, 2023
23b0243
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 17, 2023
8a48b9b
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 18, 2023
8d12ed8
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 18, 2023
740366a
more efficient use of memory for populating tensor
am831 Oct 20, 2023
e3c9635
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 20, 2023
3853c64
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Oct 20, 2023
1fc8e45
use get_raw_mutable_storage instead
am831 Oct 20, 2023
18f3c8e
add png to build configs, support float32 tensor
am831 Oct 22, 2023
4b59f2d
fix lint
am831 Oct 22, 2023
c6cdb4b
fix lint
am831 Oct 22, 2023
749b23c
fix lint
am831 Oct 23, 2023
a365cc6
remove type casting
am831 Oct 23, 2023
38ca264
combine png and jpeg decoders into one class
am831 Oct 23, 2023
0587a6b
jpeg decoder
am831 Oct 23, 2023
c58cf8d
fix lint
am831 Oct 23, 2023
4ca5acf
fix lint
am831 Oct 23, 2023
2fc74da
change type cast
am831 Oct 23, 2023
ca9b004
unit test
am831 Oct 24, 2023
ef5757b
add output keys
am831 Oct 24, 2023
d67300a
fix lint
am831 Oct 25, 2023
cd6cf80
change uint8 to unsigned char
am831 Oct 25, 2023
260c580
update workflow configs to install libjpeg v8
am831 Oct 25, 2023
e0dcbd2
change package name
am831 Oct 25, 2023
e3fc72d
pass non const ptr to libjpeg
am831 Oct 25, 2023
b31b48e
change package name
am831 Oct 25, 2023
9be595f
fix typo
am831 Oct 25, 2023
9caad8c
download libjpeg 1.5 and use const data_ptr
am831 Oct 25, 2023
a06b73b
libjpeg 1.5
am831 Oct 25, 2023
c137b87
fix typo
am831 Oct 25, 2023
7554f6a
add init
am831 Oct 25, 2023
34b0092
use setjmp/longjmp for error handling
am831 Oct 26, 2023
949ec83
new classes for resource management
am831 Oct 27, 2023
830c0bc
include new classes in cmakelists
am831 Oct 27, 2023
ac84a96
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 30, 2023
a3213e0
fix include order
am831 Oct 30, 2023
7985768
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Oct 30, 2023
b85a7df
fix double free and seg fault
am831 Oct 31, 2023
38d9f4f
Merge branch 'facebookresearch:main' into img_processing
am831 Oct 31, 2023
5644622
unit test for corrupted images
am831 Oct 31, 2023
1d31fdf
more descriptive test name
am831 Oct 31, 2023
b6bb9ca
fix lint
am831 Oct 31, 2023
2321eba
Merge branch 'main' into img_processing
am831 Nov 1, 2023
21200dd
Merge branch 'main' into img_processing
am831 Nov 2, 2023
3b15252
Merge branch 'main' of https://github.com/facebookresearch/fairseq2 i…
am831 Nov 2, 2023
ee4dde6
Merge branch 'main' of https://github.com/facebookresearch/fairseq2 i…
am831 Nov 4, 2023
ace58ec
Merge branch 'main' into img_processing
am831 Nov 7, 2023
63f4421
Merge branch 'main' into img_processing
am831 Nov 13, 2023
7a2c117
fix lint
am831 Nov 13, 2023
e86a48d
Merge branch 'facebookresearch:main' into img_processing
am831 Nov 14, 2023
57e8724
Merge branch 'facebookresearch:main' into img_processing
am831 Nov 15, 2023
978e07a
Merge branch 'facebookresearch:main' into img_processing
am831 Nov 20, 2023
152324b
Merge branch 'facebookresearch:main' into img_processing
am831 Nov 29, 2023
a4fbf86
Merge branch 'main' into img_processing
am831 Dec 2, 2023
f37366e
clang tidy
am831 Dec 5, 2023
17cdddc
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Dec 5, 2023
7ecea3a
image decoder header file and constructor
am831 Oct 9, 2023
528dec2
png.cc and png.h
am831 Oct 10, 2023
d5fdbc4
remove png files and import libpng methods
am831 Oct 16, 2023
70b1c72
image decoder
am831 Oct 16, 2023
3613c04
python binding
am831 Oct 16, 2023
790f0a9
png decoder progress and py binding
am831 Oct 16, 2023
143770f
build py binding
am831 Oct 16, 2023
38fe657
update init
am831 Oct 16, 2023
7cb73a0
png decoder progress
am831 Oct 17, 2023
aa12050
png decoder progress
am831 Oct 17, 2023
c17c3b3
remove print statements
am831 Oct 17, 2023
0075f0b
populate tensor object with png data
am831 Oct 17, 2023
3efe070
remove unnecessary include
am831 Oct 17, 2023
21239e8
more efficient use of memory for populating tensor
am831 Oct 20, 2023
77b152a
use get_raw_mutable_storage instead
am831 Oct 20, 2023
77fc090
add png to build configs, support float32 tensor
am831 Oct 22, 2023
a129e0e
fix lint
am831 Oct 22, 2023
4663ab2
fix lint
am831 Oct 22, 2023
fd437d8
fix lint
am831 Oct 23, 2023
9c376a4
remove type casting
am831 Oct 23, 2023
3d68352
combine png and jpeg decoders into one class
am831 Oct 23, 2023
cd79257
jpeg decoder
am831 Oct 23, 2023
bb4956f
fix lint
am831 Oct 23, 2023
c67c5e1
fix lint
am831 Oct 23, 2023
03e77db
change type cast
am831 Oct 23, 2023
8e2f083
unit test
am831 Oct 24, 2023
9ce5182
add output keys
am831 Oct 24, 2023
2971652
fix lint
am831 Oct 25, 2023
7b4ab4e
change uint8 to unsigned char
am831 Oct 25, 2023
5c90727
update workflow configs to install libjpeg v8
am831 Oct 25, 2023
9f14881
change package name
am831 Oct 25, 2023
ddbde92
pass non const ptr to libjpeg
am831 Oct 25, 2023
cc34f61
change package name
am831 Oct 25, 2023
8ae6b3a
fix typo
am831 Oct 25, 2023
41ec5ac
download libjpeg 1.5 and use const data_ptr
am831 Oct 25, 2023
3c2105d
libjpeg 1.5
am831 Oct 25, 2023
40faa0f
fix typo
am831 Oct 25, 2023
781689b
add init
am831 Oct 25, 2023
c8c1c63
use setjmp/longjmp for error handling
am831 Oct 26, 2023
98f33e3
new classes for resource management
am831 Oct 27, 2023
fa325d0
include new classes in cmakelists
am831 Oct 27, 2023
df235cb
fix include order
am831 Oct 30, 2023
3c011f7
fix double free and seg fault
am831 Oct 31, 2023
3d88336
unit test for corrupted images
am831 Oct 31, 2023
715a59b
more descriptive test name
am831 Oct 31, 2023
a435ac6
fix lint
am831 Oct 31, 2023
d14936d
fix lint
am831 Nov 13, 2023
ca2ac55
clang tidy
am831 Dec 5, 2023
14aa70a
Update CMake
cbalioglu Dec 6, 2023
41c0f90
Merge branch 'img_processing' of https://github.com/am831/fairseq2 in…
am831 Dec 7, 2023
c981e86
resize test images
am831 Dec 7, 2023
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 .github/workflows/_build_wheel-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
HOMEBREW_NO_INSTALL_UPGRADE: 1
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
brew install libsndfile python@${{ inputs.py }} || true
brew install libjpeg libpng libsndfile python@${{ inputs.py }} || true
- name: Create the Python virtual environment
run: |
/usr/local/bin/python${{ inputs.py }} -m venv ~/venv
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
HOMEBREW_NO_INSTALL_UPGRADE: 1
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
brew install libsndfile python@${{ inputs.py }} || true
brew install libjpeg libpng libsndfile python@${{ inputs.py }} || true
- name: Download wheels and native tests from staging
uses: actions/download-artifact@v3
with:
Expand Down
13 changes: 7 additions & 6 deletions INSTALL_FROM_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@ reusing an existing one to avoid dependency conflicts.
## 3. Install Dependencies

### 3.1 System Dependencies
fairseq2 has a dependency on
[libsndfile](https://github.com/libsndfile/libsndfile) that can be installed via
the system package manager on most Linux distributions, or via Homebrew on
fairseq2 depends on [libjpeg](https://libjpeg.sourceforge.net),
[libpng](http://www.libpng.org/pub/png/libpng.html), and
[libsndfile](https://github.com/libsndfile/libsndfile), which can be installed
via the system package manager on most Linux distributions, or via Homebrew on
macOS.

For Ubuntu-based systems, run:

```sh
sudo apt install libsndfile-dev
sudo apt install libjpeg8-dev libpng-dev libsndfile-dev
```

Similarly, on Fedora, run:

```sh
sudo dnf install libsndfile-devel
sudo dnf install libjpeg-devel libpng-devel libsndfile-devel
```

For other Linux distributions, please consult its documentation on how to
Expand All @@ -76,7 +77,7 @@ install packages.
For macOS, you can use Homebrew:

```sh
brew install libsndfile
brew install libjpeb libpng libsndfile
```

### 3.2 PyTorch
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ fairseq2 is also used by various external projects such as:
## Installing on Linux

### System Dependencies
fairseq2 has a dependency on
[libsndfile](https://github.com/libsndfile/libsndfile) that can be installed via
the system package manager on most Linux distributions. For Ubuntu-based
fairseq2 depends on [libjpeg](https://libjpeg.sourceforge.net),
[libpng](http://www.libpng.org/pub/png/libpng.html), and
[libsndfile](https://github.com/libsndfile/libsndfile), which can be installed
via the system package manager on most Linux distributions. For Ubuntu-based
systems, run:

```sh
sudo apt install libsndfile1
sudo apt install libjpeg8 libpng16-16 libsndfile1
```

Similarly, on Fedora, run:

```sh
sudo dnf install libsndfile
sudo dnf install libjpeg libpng libsndfile
```

For other Linux distributions, please consult its documentation on how to
Expand Down Expand Up @@ -139,12 +140,13 @@ pip install fairseq2\
## Installing on macOS

### System Dependencies
fairseq2 has a dependency on
[libsndfile](https://github.com/libsndfile/libsndfile) that can be installed via
Homebrew:
fairseq2 depends on [libjpeg](https://libjpeg.sourceforge.net),
[libpng](http://www.libpng.org/pub/png/libpng.html), and
[libsndfile](https://github.com/libsndfile/libsndfile), which can be installed
via Homebrew:

```sh
brew install libsndfile
brew install libjpeg libpng libsndfile
```

### pip
Expand Down
13 changes: 13 additions & 0 deletions fairseq2n/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ option(FAIRSEQ2N_TREAT_WARNINGS_AS_ERRORS
OFF
)

option(FAIRSEQ2N_SUPPORT_IMAGE
#DESCRIPTION
"Supports JPEG/PNG decoding."
#VALUE
ON
)

option(FAIRSEQ2N_USE_LIBTORCH
#DESCRIPTION
"Uses libtorch instead of PyTorch."
Expand Down Expand Up @@ -160,6 +167,12 @@ find_package(SndFile 1.0.25 REQUIRED)

find_package(Threads REQUIRED)

if(FAIRSEQ2N_SUPPORT_IMAGE)
find_package(JPEG REQUIRED)

find_package(PNG REQUIRED)
endif()

if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
find_package(TBB 2021.8 REQUIRED)
endif()
Expand Down
5 changes: 5 additions & 0 deletions fairseq2n/cmake/summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function(fairseq2n_print_project_summary)
message(STATUS " FAIRSEQ2N_SANITIZERS : ${FAIRSEQ2N_SANITIZERS}")
endif()
message(STATUS " FAIRSEQ2N_TREAT_WARNINGS_AS_ERRORS : ${FAIRSEQ2N_TREAT_WARNINGS_AS_ERRORS}")
message(STATUS " FAIRSEQ2N_SUPPORT_IMAGE : ${FAIRSEQ2N_SUPPORT_IMAGE}")
message(STATUS " FAIRSEQ2N_USE_LIBTORCH : ${FAIRSEQ2N_USE_LIBTORCH}")
message(STATUS " FAIRSEQ2N_USE_CUDA : ${FAIRSEQ2N_USE_CUDA}")
if(FAIRSEQ2N_USE_CUDA)
Expand All @@ -50,6 +51,10 @@ function(fairseq2n_print_project_summary)
if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
message(STATUS " Intel oneTBB : ${TBB_VERSION}")
endif()
if(FAIRSEQ2N_SUPPORT_IMAGE)
message(STATUS " libjpeg : ${JPEG_VERSION}")
message(STATUS " libpng : ${PNG_VERSION_STRING}")
endif()
message(STATUS " libsndfile : ${SndFile_VERSION}")
message(STATUS "")
endfunction()
7 changes: 7 additions & 0 deletions fairseq2n/python/src/fairseq2n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ def supports_cuda() -> bool:
return _supports_cuda() # type: ignore[no-any-return]


def supports_image() -> bool:
"""Return ``True`` if fairseq2n supports JPEG/PNG decoding."""
from fairseq2n.bindings import _supports_image # type: ignore[attr-defined]

return _supports_image() # type: ignore[no-any-return]


def cuda_version() -> Optional[Tuple[int, int]]:
"""Return the version of CUDA that fairseq2n supports.

Expand Down
2 changes: 2 additions & 0 deletions fairseq2n/python/src/fairseq2n/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ target_sources(py_bindings
init.cc
memory.cc
data/audio.cc
data/image.cc
data/data_pipeline.cc
data/init.cc
data/image.cc
data/string.cc
data/text/converters.cc
data/text/init.cc
Expand Down
45 changes: 45 additions & 0 deletions fairseq2n/python/src/fairseq2n/bindings/data/image.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "fairseq2n/bindings/module.h"

#include <cstdint>
#include <memory>

#include <ATen/Device.h>
#include <ATen/ScalarType.h>

#include <fairseq2n/float.h>
#include <fairseq2n/data/image/image_decoder.h>

namespace py = pybind11;

namespace fairseq2n {

void
def_image(py::module_ &data_module)
{
py::module_ m = data_module.def_submodule("image");

// ImageDecoder
py::class_<image_decoder, std::shared_ptr<image_decoder>>(m, "ImageDecoder")
.def(
py::init([](
std::optional<at::Device> maybe_device,
bool pin_memory)
{
auto opts = image_decoder_options()
.maybe_device(maybe_device).pin_memory(pin_memory);

return std::make_shared<image_decoder>(opts);
}),
py::arg("device") = std::nullopt,
py::arg("pin_memory") = false)
.def("__call__", &image_decoder::operator(), py::call_guard<py::gil_scoped_release>{});

map_functors().register_<image_decoder>();
}
} // namespace fairseq2n
2 changes: 2 additions & 0 deletions fairseq2n/python/src/fairseq2n/bindings/data/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def_data(py::module_ &base)

def_audio(m);

def_image(m);

def_data_pipeline(m);

def_string(m);
Expand Down
7 changes: 7 additions & 0 deletions fairseq2n/python/src/fairseq2n/bindings/init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ PYBIND11_MODULE(bindings, m)
return supports_cuda;
});

m.def(
"_supports_image",
[]
{
return supports_image;
});

// See https://github.com/llvm/llvm-project/issues/57123.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code-return"
Expand Down
3 changes: 3 additions & 0 deletions fairseq2n/python/src/fairseq2n/bindings/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace fairseq2n {
void
def_audio(pybind11::module_ &data_module);

void
def_image(pybind11::module_ &data_module);

void
def_data(pybind11::module_ &base_module);

Expand Down
39 changes: 35 additions & 4 deletions fairseq2n/src/fairseq2n/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ target_sources(fairseq2n
data/audio/detail/sndfile.cc
data/detail/file.cc
data/detail/file_system.cc
data/image/image_decoder.cc
data/text/string_splitter.cc
data/text/string_to_int_converter.cc
data/text/string_to_tensor_converter.cc
Expand All @@ -69,6 +70,14 @@ target_sources(fairseq2n
data/text/sentencepiece/sp_processor.cc
)

if(FAIRSEQ2N_SUPPORT_IMAGE)
target_sources(fairseq2n
PRIVATE
data/image/detail/jpeg_decompress_struct.cc
data/image/detail/png_read_struct.cc
)
endif()

if(FAIRSEQ2N_USE_CUDA)
target_sources(fairseq2n
PRIVATE
Expand All @@ -80,8 +89,8 @@ fairseq2n_set_compile_options(fairseq2n)

target_compile_features(fairseq2n PUBLIC cxx_std_17)

if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
target_compile_definitions(fairseq2n PRIVATE FAIRSEQ2N_USE_TBB)
if(FAIRSEQ2N_SUPPORT_IMAGE)
target_compile_definitions(fairseq2n PRIVATE FAIRSEQ2N_SUPPORT_IMAGE)
endif()

if(FAIRSEQ2N_USE_CUDA)
Expand All @@ -90,6 +99,10 @@ if(FAIRSEQ2N_USE_CUDA)
target_compile_definitions(fairseq2n PRIVATE FAIRSEQ2N_USE_CUDA)
endif()

if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
target_compile_definitions(fairseq2n PRIVATE FAIRSEQ2N_USE_TBB)
endif()

if(PROJECT_IS_TOP_LEVEL)
set(system)
else()
Expand All @@ -102,6 +115,9 @@ target_include_directories(fairseq2n ${system}
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
)

find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)

target_link_libraries(fairseq2n
PRIVATE
${CMAKE_DL_LIBS}
Expand All @@ -114,18 +130,23 @@ target_link_libraries(fairseq2n
Threads::Threads
sentencepiece-static
SndFile::sndfile
PNG::PNG
JPEG::JPEG
PUBLIC
torch
)

if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
target_link_libraries(fairseq2n PRIVATE TBB::tbb)
if(FAIRSEQ2N_SUPPORT_IMAGE)
target_link_libraries(fairseq2n PRIVATE JPEG::JPEG PNG::PNG)
endif()

if(FAIRSEQ2N_USE_CUDA)
target_link_libraries(fairseq2n PRIVATE CUDA::cudart)
endif()

if(FAIRSEQ2N_THREAD_LIB STREQUAL "tbb")
target_link_libraries(fairseq2n PRIVATE TBB::tbb)
endif()

fairseq2n_set_link_options(fairseq2n)

Expand Down Expand Up @@ -174,10 +195,20 @@ install(
# Library Configuration
# ------------------------------------------------------------

if(FAIRSEQ2N_SUPPORT_IMAGE)
set(SUPPORTS_IMAGE "true")
else()
set(SUPPORTS_IMAGE "false")
endif()

if(FAIRSEQ2N_USE_CUDA)
set(USES_CUDA "true")

set(CUDA_VERSION_MAJOR "${CUDAToolkit_VERSION_MAJOR}")
set(CUDA_VERSION_MINOR "${CUDAToolkit_VERSION_MINOR}")
else()
set(USES_CUDA "false")

set(CUDA_VERSION_MAJOR "std::nullopt")
set(CUDA_VERSION_MINOR "std::nullopt")
endif()
Expand Down
6 changes: 4 additions & 2 deletions fairseq2n/src/fairseq2n/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ constexpr std::int32_t version_major = @PROJECT_VERSION_MAJOR@;
constexpr std::int32_t version_minor = @PROJECT_VERSION_MINOR@;
constexpr std::int32_t version_patch = @PROJECT_VERSION_PATCH@;

constexpr bool supports_image = @SUPPORTS_IMAGE@;

constexpr bool supports_cuda = @USES_CUDA@;

constexpr std::optional<std::int32_t> cuda_version_major = @CUDA_VERSION_MAJOR@;
constexpr std::optional<std::int32_t> cuda_version_minor = @CUDA_VERSION_MINOR@;

constexpr bool supports_cuda = cuda_version_major.has_value();

} // namespace fairseq2n
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.error_ptr
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#include "fairseq2n/data/image/detail/jpeg_decompress_struct.h"

namespace fairseq2n::detail {

jpeg_decompress::jpeg_decompress() : cinfo() {
jpeg_create_decompress(&cinfo);
}

jpeg_decompress::~jpeg_decompress() {
if(cinfo.err != nullptr) {
jpeg_destroy_decompress(&cinfo);
}
}

jpeg_decompress_struct& jpeg_decompress::get() {
return cinfo;
}

} // namespace fairseq2n::detail
Loading