Unverified Commit 7d831a2f authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Restructuring C++ project: (#3146)

Summary:
* Reduce unnecessary header inclusions in models and io.

* Move autocast to separate folder and hide autograd implementation in an anonymous namespace.

* Moving files in subfolders.

Reviewed By: fmassa

Differential Revision: D25461523

fbshipit-source-id: 756eeb6848aacaa474de4825ed4c1045d17e2cea
parent 4d3a3093
#include "readjpeg_cpu.h" #include "readjpeg_cpu.h"
#include <ATen/ATen.h>
#if !JPEG_FOUND #if !JPEG_FOUND
torch::Tensor decodeJPEG(const torch::Tensor& data, ImageReadMode mode) { torch::Tensor decodeJPEG(const torch::Tensor& data, ImageReadMode mode) {
TORCH_CHECK( TORCH_CHECK(
false, "decodeJPEG: torchvision not compiled with libjpeg support"); false, "decodeJPEG: torchvision not compiled with libjpeg support");
} }
#else #else
#include <jpeglib.h> #include "../jpegcommon.h"
#include <setjmp.h>
#include "jpegcommon.h"
struct torch_jpeg_mgr { struct torch_jpeg_mgr {
struct jpeg_source_mgr pub; struct jpeg_source_mgr pub;
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/types.h>
#include "image_read_mode.h" #include "../image_read_mode.h"
C10_EXPORT torch::Tensor decodeJPEG( C10_EXPORT torch::Tensor decodeJPEG(
const torch::Tensor& data, const torch::Tensor& data,
......
#include "readpng_cpu.h" #include "readpng_cpu.h"
#include <ATen/ATen.h>
#if !PNG_FOUND #if !PNG_FOUND
torch::Tensor decodePNG(const torch::Tensor& data, ImageReadMode mode) { torch::Tensor decodePNG(const torch::Tensor& data, ImageReadMode mode) {
TORCH_CHECK(false, "decodePNG: torchvision not compiled with libPNG support"); TORCH_CHECK(false, "decodePNG: torchvision not compiled with libPNG support");
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/types.h>
#include "image_read_mode.h" #include "../image_read_mode.h"
C10_EXPORT torch::Tensor decodePNG( C10_EXPORT torch::Tensor decodePNG(
const torch::Tensor& data, const torch::Tensor& data,
......
#include "writejpeg_cpu.h" #include "writejpeg_cpu.h"
#include <setjmp.h>
#include <string>
#if !JPEG_FOUND #if !JPEG_FOUND
torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) { torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) {
...@@ -11,9 +8,7 @@ torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) { ...@@ -11,9 +8,7 @@ torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) {
} }
#else #else
#include "../jpegcommon.h"
#include <jpeglib.h>
#include "jpegcommon.h"
torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) { torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality) {
// Define compression structures and error handling // Define compression structures and error handling
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/types.h>
C10_EXPORT torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality); C10_EXPORT torch::Tensor encodeJPEG(const torch::Tensor& data, int64_t quality);
#include "writejpeg_cpu.h" #include "writejpeg_cpu.h"
#include <setjmp.h>
#include <string>
#if !PNG_FOUND #if !PNG_FOUND
torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) { torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) {
...@@ -10,8 +7,8 @@ torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) { ...@@ -10,8 +7,8 @@ torch::Tensor encodePNG(const torch::Tensor& data, int64_t compression_level) {
} }
#else #else
#include <png.h> #include <png.h>
#include <setjmp.h>
struct torch_mem_encode { struct torch_mem_encode {
char* buffer; char* buffer;
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/types.h>
C10_EXPORT torch::Tensor encodePNG( C10_EXPORT torch::Tensor encodePNG(
const torch::Tensor& data, const torch::Tensor& data,
......
#include "image.h" #include "image.h"
#include <ATen/ATen.h>
#include <Python.h> #include <Python.h>
// If we are in a Windows environment, we need to define // If we are in a Windows environment, we need to define
......
#pragma once
#include "cpu/read_image_cpu.h"
#include "cpu/read_write_file_cpu.h"
#include "cpu/readjpeg_cpu.h"
#include "cpu/readpng_cpu.h"
#include "cpu/writejpeg_cpu.h"
#include "cpu/writepng_cpu.h"
#if JPEG_FOUND
#include "jpegcommon.h" #include "jpegcommon.h"
#include <string>
#if JPEG_FOUND
void torch_jpeg_error_exit(j_common_ptr cinfo) { void torch_jpeg_error_exit(j_common_ptr cinfo) {
/* cinfo->err really points to a torch_jpeg_error_mgr struct, so coerce /* cinfo->err really points to a torch_jpeg_error_mgr struct, so coerce
* pointer */ * pointer */
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#if JPEG_FOUND #if JPEG_FOUND
#include <jpeglib.h> #include <jpeglib.h>
#include <setjmp.h> #include <setjmp.h>
#include <string>
static const JOCTET EOI_BUFFER[1] = {JPEG_EOI}; static const JOCTET EOI_BUFFER[1] = {JPEG_EOI};
struct torch_jpeg_error_mgr { struct torch_jpeg_error_mgr {
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/nn.h>
#include "../macros.h" #include "../macros.h"
namespace vision { namespace vision {
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/nn.h>
#include "../macros.h" #include "../macros.h"
namespace vision { namespace vision {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment