summaryrefslogtreecommitdiff
path: root/aten/src
diff options
context:
space:
mode:
Diffstat (limited to 'aten/src')
-rw-r--r--aten/src/ATen/CMakeLists.txt16
-rw-r--r--aten/src/ATen/PinnedMemoryAllocator.cpp6
-rw-r--r--aten/src/ATen/cudnn/Descriptors.cpp11
-rw-r--r--aten/src/ATen/native/Normalization.cpp4
-rw-r--r--aten/src/ATen/native/cpu/ReduceOpsKernel.cpp1
-rw-r--r--aten/src/TH/THDiskFile.c66
-rw-r--r--aten/src/TH/THFilePrivate.h42
-rw-r--r--aten/src/TH/THGeneral.c13
-rw-r--r--aten/src/TH/THMemoryFile.c86
-rw-r--r--aten/src/THNN/generic/SpatialAdaptiveAveragePooling.c18
-rw-r--r--aten/src/THNN/generic/SpatialAdaptiveMaxPooling.c24
-rw-r--r--aten/src/THNN/generic/VolumetricAdaptiveAveragePooling.c26
-rw-r--r--aten/src/THNN/generic/VolumetricAdaptiveMaxPooling.c28
13 files changed, 181 insertions, 160 deletions
diff --git a/aten/src/ATen/CMakeLists.txt b/aten/src/ATen/CMakeLists.txt
index a12378a081..13670aa73e 100644
--- a/aten/src/ATen/CMakeLists.txt
+++ b/aten/src/ATen/CMakeLists.txt
@@ -237,6 +237,22 @@ ELSE()
ENDIF()
ADD_DEPENDENCIES(ATen aten_files_are_generated)
+if(NOT MSVC)
+ target_compile_options(ATen
+ PRIVATE
+ -Wall
+ -Wextra
+ -fexceptions
+ -Wno-missing-field-initializers
+ -Wno-type-limits
+ -Wno-unused-parameter
+ -Wno-unknown-pragmas)
+
+ if ($ENV{WERROR})
+ target_compile_options(ATen PRIVATE -Werror)
+ endif()
+endif()
+
set(TBB_ROOT_DIR "${PROJECT_SOURCE_DIR}/../third_party/tbb")
set(TBB_BUILD_STATIC ON CACHE BOOL " " FORCE)
set(TBB_BUILD_SHARED OFF CACHE BOOL " " FORCE)
diff --git a/aten/src/ATen/PinnedMemoryAllocator.cpp b/aten/src/ATen/PinnedMemoryAllocator.cpp
index 8a417546a4..ae750fcfdd 100644
--- a/aten/src/ATen/PinnedMemoryAllocator.cpp
+++ b/aten/src/ATen/PinnedMemoryAllocator.cpp
@@ -16,7 +16,9 @@ void* PinnedMemoryAllocator::allocate(std::size_t n) const {
#if AT_CUDA_ENABLED()
return state->cudaHostAllocator->malloc(nullptr, n);
#else
- (void)n; // avoid unused parameter warning
+ // avoid unused parameter warning
+ (void)state;
+ (void)n;
throw std::runtime_error("pinned memory requires CUDA");
#endif
}
@@ -26,6 +28,8 @@ void PinnedMemoryAllocator::deallocate(void* ptr) const {
#if AT_CUDA_ENABLED()
return state->cudaHostAllocator->free(nullptr, ptr);
#else
+ // avoid unused parameter warning
+ (void)state;
(void)ptr; // avoid unused parameter warning
throw std::runtime_error("pinned memory requires CUDA");
#endif
diff --git a/aten/src/ATen/cudnn/Descriptors.cpp b/aten/src/ATen/cudnn/Descriptors.cpp
index d153447da4..aafaebf163 100644
--- a/aten/src/ATen/cudnn/Descriptors.cpp
+++ b/aten/src/ATen/cudnn/Descriptors.cpp
@@ -1,6 +1,11 @@
#include "Descriptors.h"
+
#include <ATen/ATen.h>
+#include <ostream>
+#include <sstream>
+#include <string>
+
namespace at { namespace native {
namespace {
@@ -63,6 +68,12 @@ std::string cudnnTypeToString(cudnnDataType_t dtype) {
return "CUDNN_DATA_INT32";
case CUDNN_DATA_INT8x4:
return "CUDNN_DATA_INT8x4";
+#if CUDNN_VERSION >= 7100
+ case CUDNN_DATA_UINT8:
+ return "CUDNN_DATA_UINT8";
+ case CUDNN_DATA_UINT8x4:
+ return "CUDNN_DATA_UINT8x4";
+#endif
default:
std::ostringstream oss;
oss << "(unknown data-type " << static_cast<int>(dtype) << ")";
diff --git a/aten/src/ATen/native/Normalization.cpp b/aten/src/ATen/native/Normalization.cpp
index 11b7193d97..3d77e90ed3 100644
--- a/aten/src/ATen/native/Normalization.cpp
+++ b/aten/src/ATen/native/Normalization.cpp
@@ -54,7 +54,9 @@ Tensor batch_norm(
&& input.size(0) <= 131070
&& cudnn_enabled && CUDNN_VERSION >= 5110L);
#else
- (void)cudnn_enabled; // avoid unused parameter warning
+ // avoid unused parameter warning
+ (void)use_cudnn;
+ (void)cudnn_enabled;
#endif
#if AT_CUDNN_ENABLED()
diff --git a/aten/src/ATen/native/cpu/ReduceOpsKernel.cpp b/aten/src/ATen/native/cpu/ReduceOpsKernel.cpp
index 4e4c6d9e2b..cfb4269045 100644
--- a/aten/src/ATen/native/cpu/ReduceOpsKernel.cpp
+++ b/aten/src/ATen/native/cpu/ReduceOpsKernel.cpp
@@ -127,6 +127,7 @@ struct Reduction {
});
if (cols_rounded != cols) {
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
scalar_t buf[WIDTH];
// Initializes the entire (tiny) array to avoid uninitialized warnings
diff --git a/aten/src/TH/THDiskFile.c b/aten/src/TH/THDiskFile.c
index 41cc254f6d..ee06b8bdf8 100644
--- a/aten/src/TH/THDiskFile.c
+++ b/aten/src/TH/THDiskFile.c
@@ -48,10 +48,10 @@ size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
#endif
#define READ_WRITE_METHODS(TYPE, TYPEC, ASCII_READ_ELEM, ASCII_WRITE_ELEM) \
- static size_t THDiskFile_read##TYPEC(THFile *self, TYPE *data, size_t n) \
+ static ssize_t THDiskFile_read##TYPEC(THFile *self, TYPE *data, ssize_t n) \
{ \
THDiskFile *dfself = (THDiskFile*)(self); \
- size_t nread = 0L; \
+ ssize_t nread = 0L; \
\
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file"); \
THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file"); \
@@ -64,7 +64,7 @@ size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
} \
else \
{ \
- size_t i; \
+ ssize_t i; \
for(i = 0; i < n; i++) \
{ \
ASCII_READ_ELEM; /* increment here result and break if wrong */ \
@@ -87,10 +87,10 @@ size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
return nread; \
} \
\
- static size_t THDiskFile_write##TYPEC(THFile *self, TYPE *data, size_t n) \
+ static ssize_t THDiskFile_write##TYPEC(THFile *self, TYPE *data, ssize_t n) \
{ \
THDiskFile *dfself = (THDiskFile*)(self); \
- size_t nwrite = 0L; \
+ ssize_t nwrite = 0L; \
\
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file"); \
THArgCheck(dfself->file.isWritable, 1, "attempt to write in a read-only file"); \
@@ -116,7 +116,7 @@ size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
} \
else \
{ \
- size_t i; \
+ ssize_t i; \
for(i = 0; i < n; i++) \
{ \
ASCII_WRITE_ELEM; \
@@ -173,20 +173,20 @@ static void THDiskFile_synchronize(THFile *self)
fflush(dfself->handle);
}
-static void THDiskFile_seek(THFile *self, size_t position)
+static void THDiskFile_seek(THFile *self, ssize_t position)
{
THDiskFile *dfself = (THDiskFile*)(self);
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
#if defined(_WIN64)
- THArgCheck(position <= (size_t)INT64_MAX, 2, "position must be smaller than INT64_MAX");
+ THArgCheck(position <= INT64_MAX, 2, "position must be smaller than INT64_MAX");
if(_fseeki64(dfself->handle, (int64_t)position, SEEK_SET) < 0)
#elif defined(_WIN32)
- THArgCheck(position <= (size_t)LONG_MAX, 2, "position must be smaller than LONG_MAX");
+ THArgCheck(position <= LONG_MAX, 2, "position must be smaller than LONG_MAX");
if(fseek(dfself->handle, (int32_t)position, SEEK_SET) < 0)
#else
- THArgCheck(position <= (size_t)LLONG_MAX, 2, "position must be smaller than LLONG_MAX");
+ THArgCheck(position <= LLONG_MAX, 2, "position must be smaller than LLONG_MAX");
if(fseeko(dfself->handle, (off_t)position, SEEK_SET) < 0)
#endif
{
@@ -216,7 +216,7 @@ static void THDiskFile_seekEnd(THFile *self)
}
}
-static size_t THDiskFile_position(THFile *self)
+static ssize_t THDiskFile_position(THFile *self)
{
THDiskFile *dfself = (THDiskFile*)(self);
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
@@ -229,7 +229,7 @@ static size_t THDiskFile_position(THFile *self)
off_t offset = ftello(dfself->handle);
#endif
if (offset > -1)
- return (size_t)offset;
+ return (ssize_t)offset;
else if(!dfself->file.isQuiet)
THError("unable to obtain disk file offset (maybe a long overflow occurred)");
@@ -246,14 +246,14 @@ static void THDiskFile_close(THFile *self)
/* Little and Big Endian */
-static void THDiskFile_reverseMemory(void *dst, const void *src, size_t blockSize, size_t numBlocks)
+static void THDiskFile_reverseMemory(void *dst, const void *src, ssize_t blockSize, ssize_t numBlocks)
{
if(blockSize > 1)
{
- size_t halfBlockSize = blockSize/2;
+ ssize_t halfBlockSize = blockSize/2;
char *charSrc = (char*)src;
char *charDst = (char*)dst;
- size_t b, i;
+ ssize_t b, i;
for(b = 0; b < numBlocks; b++)
{
for(i = 0; i < halfBlockSize; i++)
@@ -369,10 +369,10 @@ READ_WRITE_METHODS(double, Double,
/* For Long we need to rewrite everything, because of the special management of longSize */
-static size_t THDiskFile_readLong(THFile *self, int64_t *data, size_t n)
+static ssize_t THDiskFile_readLong(THFile *self, int64_t *data, ssize_t n)
{
THDiskFile *dfself = (THDiskFile*)(self);
- size_t nread = 0L;
+ ssize_t nread = 0L;
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file");
@@ -389,7 +389,7 @@ static size_t THDiskFile_readLong(THFile *self, int64_t *data, size_t n)
nread = fread__(data, 4, n, dfself->handle);
if(!dfself->isNativeEncoding && (nread > 0))
THDiskFile_reverseMemory(data, data, 4, nread);
- size_t i;
+ ssize_t i;
for(i = nread; i > 0; i--)
data[i-1] = ((int *)data)[i-1];
}
@@ -398,7 +398,7 @@ static size_t THDiskFile_readLong(THFile *self, int64_t *data, size_t n)
int big_endian = !THDiskFile_isLittleEndianCPU();
int32_t *buffer = THAlloc(8*n);
nread = fread__(buffer, 8, n, dfself->handle);
- size_t i;
+ ssize_t i;
for(i = nread; i > 0; i--)
data[i-1] = buffer[2*(i-1) + big_endian];
THFree(buffer);
@@ -408,7 +408,7 @@ static size_t THDiskFile_readLong(THFile *self, int64_t *data, size_t n)
}
else
{
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
int ret = fscanf(dfself->handle, "%" PRId64, &data[i]); if(ret <= 0) break; else nread++;
@@ -431,10 +431,10 @@ static size_t THDiskFile_readLong(THFile *self, int64_t *data, size_t n)
return nread;
}
-static size_t THDiskFile_writeLong(THFile *self, int64_t *data, size_t n)
+static ssize_t THDiskFile_writeLong(THFile *self, int64_t *data, ssize_t n)
{
THDiskFile *dfself = (THDiskFile*)(self);
- size_t nwrite = 0L;
+ ssize_t nwrite = 0L;
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
THArgCheck(dfself->file.isWritable, 1, "attempt to write in a read-only file");
@@ -457,7 +457,7 @@ static size_t THDiskFile_writeLong(THFile *self, int64_t *data, size_t n)
} else if(dfself->longSize == 4)
{
int32_t *buffer = THAlloc(4*n);
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
buffer[i] = (int32_t) data[i];
if(!dfself->isNativeEncoding)
@@ -469,7 +469,7 @@ static size_t THDiskFile_writeLong(THFile *self, int64_t *data, size_t n)
{
int big_endian = !THDiskFile_isLittleEndianCPU();
int32_t *buffer = THAlloc(8*n);
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
buffer[2*i + !big_endian] = 0;
@@ -483,7 +483,7 @@ static size_t THDiskFile_writeLong(THFile *self, int64_t *data, size_t n)
}
else
{
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
int ret = fprintf(dfself->handle, "%" PRId64, data[i]); if(ret <= 0) break; else nwrite++;
@@ -504,7 +504,7 @@ static size_t THDiskFile_writeLong(THFile *self, int64_t *data, size_t n)
return nwrite;
}
-static size_t THDiskFile_readString(THFile *self, const char *format, char **str_)
+static ssize_t THDiskFile_readString(THFile *self, const char *format, char **str_)
{
THDiskFile *dfself = (THDiskFile*)(self);
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
@@ -518,8 +518,8 @@ static size_t THDiskFile_readString(THFile *self, const char *format, char **str
if(format[1] == 'a')
{
char *p = THAlloc(TBRS_BSZ);
- size_t total = TBRS_BSZ;
- size_t pos = 0;
+ ssize_t total = TBRS_BSZ;
+ ssize_t pos = 0;
for (;;)
{
@@ -549,9 +549,9 @@ static size_t THDiskFile_readString(THFile *self, const char *format, char **str
else
{
char *p = THAlloc(TBRS_BSZ);
- size_t total = TBRS_BSZ;
- size_t pos = 0;
- size_t size;
+ ssize_t total = TBRS_BSZ;
+ ssize_t pos = 0;
+ ssize_t size;
for (;;)
{
@@ -594,10 +594,10 @@ static size_t THDiskFile_readString(THFile *self, const char *format, char **str
}
-static size_t THDiskFile_writeString(THFile *self, const char *str, size_t size)
+static ssize_t THDiskFile_writeString(THFile *self, const char *str, ssize_t size)
{
THDiskFile *dfself = (THDiskFile*)(self);
- size_t nwrite;
+ ssize_t nwrite;
THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
THArgCheck(dfself->file.isWritable, 1, "attempt to write in a read-only file");
diff --git a/aten/src/TH/THFilePrivate.h b/aten/src/TH/THFilePrivate.h
index c7f2e8b7c0..93bbaa0287 100644
--- a/aten/src/TH/THFilePrivate.h
+++ b/aten/src/TH/THFilePrivate.h
@@ -21,30 +21,30 @@ struct THFileVTable
{
int (*isOpened)(THFile *self);
- size_t (*readByte)(THFile *self, uint8_t *data, size_t n);
- size_t (*readChar)(THFile *self, int8_t *data, size_t n);
- size_t (*readShort)(THFile *self, int16_t *data, size_t n);
- size_t (*readInt)(THFile *self, int32_t *data, size_t n);
- size_t (*readLong)(THFile *self, int64_t *data, size_t n);
- size_t (*readFloat)(THFile *self, float *data, size_t n);
- size_t (*readDouble)(THFile *self, double *data, size_t n);
- size_t (*readHalf)(THFile *self, THHalf *data, size_t n);
- size_t (*readString)(THFile *self, const char *format, char **str_);
-
- size_t (*writeByte)(THFile *self, uint8_t *data, size_t n);
- size_t (*writeChar)(THFile *self, int8_t *data, size_t n);
- size_t (*writeShort)(THFile *self, int16_t *data, size_t n);
- size_t (*writeInt)(THFile *self, int32_t *data, size_t n);
- size_t (*writeLong)(THFile *self, int64_t *data, size_t n);
- size_t (*writeFloat)(THFile *self, float *data, size_t n);
- size_t (*writeDouble)(THFile *self, double *data, size_t n);
- size_t (*writeHalf)(THFile *self, THHalf *data, size_t n);
- size_t (*writeString)(THFile *self, const char *str, size_t size);
+ ssize_t (*readByte)(THFile *self, uint8_t *data, ssize_t n);
+ ssize_t (*readChar)(THFile *self, int8_t *data, ssize_t n);
+ ssize_t (*readShort)(THFile *self, int16_t *data, ssize_t n);
+ ssize_t (*readInt)(THFile *self, int32_t *data, ssize_t n);
+ ssize_t (*readLong)(THFile *self, int64_t *data, ssize_t n);
+ ssize_t (*readFloat)(THFile *self, float *data, ssize_t n);
+ ssize_t (*readDouble)(THFile *self, double *data, ssize_t n);
+ ssize_t (*readHalf)(THFile *self, THHalf *data, ssize_t n);
+ ssize_t (*readString)(THFile *self, const char *format, char **str_);
+
+ ssize_t (*writeByte)(THFile *self, uint8_t *data, ssize_t n);
+ ssize_t (*writeChar)(THFile *self, int8_t *data, ssize_t n);
+ ssize_t (*writeShort)(THFile *self, int16_t *data, ssize_t n);
+ ssize_t (*writeInt)(THFile *self, int32_t *data, ssize_t n);
+ ssize_t (*writeLong)(THFile *self, int64_t *data, ssize_t n);
+ ssize_t (*writeFloat)(THFile *self, float *data, ssize_t n);
+ ssize_t (*writeDouble)(THFile *self, double *data, ssize_t n);
+ ssize_t (*writeHalf)(THFile *self, THHalf *data, ssize_t n);
+ ssize_t (*writeString)(THFile *self, const char *str, ssize_t size);
void (*synchronize)(THFile *self);
- void (*seek)(THFile *self, size_t position);
+ void (*seek)(THFile *self, ssize_t position);
void (*seekEnd)(THFile *self);
- size_t (*position)(THFile *self);
+ ssize_t (*position)(THFile *self);
void (*close)(THFile *self);
void (*free)(THFile *self);
};
diff --git a/aten/src/TH/THGeneral.c b/aten/src/TH/THGeneral.c
index b6ed9737e6..00c209aec2 100644
--- a/aten/src/TH/THGeneral.c
+++ b/aten/src/TH/THGeneral.c
@@ -159,19 +159,6 @@ void THSetGCHandler( void (*torchGCFunction_)(void *data), void *data )
torchGCData = data;
}
-/* it is guaranteed the allocated size is not bigger than PTRDIFF_MAX */
-static ptrdiff_t getAllocSize(void *ptr) {
-#if defined(__unix) && defined(HAVE_MALLOC_USABLE_SIZE)
- return malloc_usable_size(ptr);
-#elif defined(__APPLE__)
- return malloc_size(ptr);
-#elif defined(_WIN32)
- if(ptr) { return _msize(ptr); } else { return 0; }
-#else
- return 0;
-#endif
-}
-
static void* THAllocInternal(ptrdiff_t size)
{
void *ptr;
diff --git a/aten/src/TH/THMemoryFile.c b/aten/src/TH/THMemoryFile.c
index cbbcfc1f5d..ca86f374e9 100644
--- a/aten/src/TH/THMemoryFile.c
+++ b/aten/src/TH/THMemoryFile.c
@@ -10,8 +10,8 @@ typedef struct THMemoryFile__
{
THFile file;
THCharStorage *storage;
- size_t size;
- size_t position;
+ ssize_t size;
+ ssize_t position;
int longSize;
} THMemoryFile;
@@ -46,9 +46,9 @@ static int8_t *THMemoryFile_strnextspace(int8_t *str_, int8_t *c_)
return NULL;
}
-static void THMemoryFile_grow(THMemoryFile *self, size_t size)
+static void THMemoryFile_grow(THMemoryFile *self, ssize_t size)
{
- size_t missingSpace;
+ ssize_t missingSpace;
if(size <= self->size)
return;
@@ -100,10 +100,10 @@ static int THMemoryFile_mode(const char *mode, int *isReadable, int *isWritable)
/********************************************************/
#define READ_WRITE_METHODS(TYPE, TYPEC, ASCII_READ_ELEM, ASCII_WRITE_ELEM, INSIDE_SPACING) \
- static size_t THMemoryFile_read##TYPEC(THFile *self, TYPE *data, size_t n) \
+ static ssize_t THMemoryFile_read##TYPEC(THFile *self, TYPE *data, ssize_t n) \
{ \
THMemoryFile *mfself = (THMemoryFile*)self; \
- size_t nread = 0; \
+ ssize_t nread = 0; \
\
THArgCheck(mfself->storage != NULL, 1, "attempt to use a closed file"); \
THArgCheck(mfself->file.isReadable, 1, "attempt to read in a write-only file"); \
@@ -113,18 +113,18 @@ static int THMemoryFile_mode(const char *mode, int *isReadable, int *isWritable)
\
if(mfself->file.isBinary) \
{ \
- size_t nByte = sizeof(TYPE)*n; \
- size_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position); \
+ ssize_t nByte = sizeof(TYPE)*n; \
+ ssize_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position); \
nread = nByteRemaining/sizeof(TYPE); \
memmove(data, mfself->storage->data+mfself->position, nread*sizeof(TYPE)); \
mfself->position += nread*sizeof(TYPE); \
} \
else \
{ \
- size_t i; \
+ ssize_t i; \
for(i = 0; i < n; i++) \
{ \
- size_t nByteRead = 0; \
+ ssize_t nByteRead = 0; \
int8_t spaceChar = 0; \
int8_t *spacePtr = THMemoryFile_strnextspace(mfself->storage->data+mfself->position, &spaceChar); \
ASCII_READ_ELEM; \
@@ -155,7 +155,7 @@ static int THMemoryFile_mode(const char *mode, int *isReadable, int *isWritable)
return nread; \
} \
\
- static size_t THMemoryFile_write##TYPEC(THFile *self, TYPE *data, size_t n) \
+ static ssize_t THMemoryFile_write##TYPEC(THFile *self, TYPE *data, ssize_t n) \
{ \
THMemoryFile *mfself = (THMemoryFile*)self; \
\
@@ -167,7 +167,7 @@ static int THMemoryFile_mode(const char *mode, int *isReadable, int *isWritable)
\
if(mfself->file.isBinary) \
{ \
- size_t nByte = sizeof(TYPE)*n; \
+ ssize_t nByte = sizeof(TYPE)*n; \
THMemoryFile_grow(mfself, mfself->position+nByte); \
memmove(mfself->storage->data+mfself->position, data, nByte); \
mfself->position += nByte; \
@@ -179,7 +179,7 @@ static int THMemoryFile_mode(const char *mode, int *isReadable, int *isWritable)
} \
else \
{ \
- size_t i; \
+ ssize_t i; \
for(i = 0; i < n; i++) \
{ \
ssize_t nByteWritten; \
@@ -243,7 +243,7 @@ static void THMemoryFile_synchronize(THFile *self)
THArgCheck(mfself->storage != NULL, 1, "attempt to use a closed file");
}
-static void THMemoryFile_seek(THFile *self, size_t position)
+static void THMemoryFile_seek(THFile *self, ssize_t position)
{
THMemoryFile *mfself = (THMemoryFile*)self;
@@ -268,7 +268,7 @@ static void THMemoryFile_seekEnd(THFile *self)
mfself->position = mfself->size;
}
-static size_t THMemoryFile_position(THFile *self)
+static ssize_t THMemoryFile_position(THFile *self)
{
THMemoryFile *mfself = (THMemoryFile*)self;
THArgCheck(mfself->storage != NULL, 1, "attempt to use a closed file");
@@ -299,7 +299,7 @@ static void THMemoryFile_free(THFile *self)
/* 1) */
READ_WRITE_METHODS(uint8_t, Byte,
- size_t ret = (mfself->position + n <= mfself->size ? n : mfself->size-mfself->position); \
+ ssize_t ret = (mfself->position + n <= mfself->size ? n : mfself->size-mfself->position); \
if(spacePtr) *spacePtr = spaceChar; \
nByteRead = ret; \
nread = ret; \
@@ -314,7 +314,7 @@ READ_WRITE_METHODS(uint8_t, Byte,
/* DEBUG: we should check if %n is count or not as a element (so ret might need to be ret-- on some systems) */
/* Note that we do a trick for char */
READ_WRITE_METHODS(int8_t, Char,
- size_t ret = (mfself->position + n <= mfself->size ? n : mfself->size-mfself->position); \
+ ssize_t ret = (mfself->position + n <= mfself->size ? n : mfself->size-mfself->position); \
if(spacePtr) *spacePtr = spaceChar; \
nByteRead = ret; \
nread = ret; \
@@ -355,10 +355,10 @@ READ_WRITE_METHODS(double, Double,
int THDiskFile_isLittleEndianCPU(void);
-static size_t THMemoryFile_readLong(THFile *self, int64_t *data, size_t n)
+static ssize_t THMemoryFile_readLong(THFile *self, int64_t *data, ssize_t n)
{
THMemoryFile *mfself = (THMemoryFile*)self;
- size_t nread = 0L;
+ ssize_t nread = 0L;
THArgCheck(mfself->storage != NULL, 1, "attempt to use a closed file");
THArgCheck(mfself->file.isReadable, 1, "attempt to read in a write-only file");
@@ -370,18 +370,18 @@ static size_t THMemoryFile_readLong(THFile *self, int64_t *data, size_t n)
{
if(mfself->longSize == 0 || mfself->longSize == sizeof(int64_t))
{
- size_t nByte = sizeof(int64_t)*n;
- size_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
+ ssize_t nByte = sizeof(int64_t)*n;
+ ssize_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
nread = nByteRemaining/sizeof(int64_t);
memmove(data, mfself->storage->data+mfself->position, nread*sizeof(int64_t));
mfself->position += nread*sizeof(int64_t);
} else if(mfself->longSize == 4)
{
- size_t nByte = 4*n;
- size_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
+ ssize_t nByte = 4*n;
+ ssize_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
int32_t *storage = (int32_t *)(mfself->storage->data + mfself->position);
nread = nByteRemaining/4;
- size_t i;
+ ssize_t i;
for(i = 0; i < nread; i++)
data[i] = storage[i];
mfself->position += nread*4;
@@ -389,11 +389,11 @@ static size_t THMemoryFile_readLong(THFile *self, int64_t *data, size_t n)
else /* if(mfself->longSize == 8) */
{
int big_endian = !THDiskFile_isLittleEndianCPU();
- size_t nByte = 8*n;
+ ssize_t nByte = 8*n;
int32_t *storage = (int32_t *)(mfself->storage->data + mfself->position);
- size_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
+ ssize_t nByteRemaining = (mfself->position + nByte <= mfself->size ? nByte : mfself->size-mfself->position);
nread = nByteRemaining/8;
- size_t i;
+ ssize_t i;
for(i = 0; i < nread; i++)
data[i] = storage[2*i + big_endian];
mfself->position += nread*8;
@@ -401,10 +401,10 @@ static size_t THMemoryFile_readLong(THFile *self, int64_t *data, size_t n)
}
else
{
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
- size_t nByteRead = 0;
+ ssize_t nByteRead = 0;
int8_t spaceChar = 0;
int8_t *spacePtr = THMemoryFile_strnextspace(mfself->storage->data+mfself->position, &spaceChar);
int nByteRead_; int ret = sscanf((char*) mfself->storage->data+mfself->position, "%" PRId64 "%n", &data[i], &nByteRead_); nByteRead = nByteRead_; if(ret <= 0) break; else nread++;
@@ -435,7 +435,7 @@ static size_t THMemoryFile_readLong(THFile *self, int64_t *data, size_t n)
return nread;
}
-static size_t THMemoryFile_writeLong(THFile *self, int64_t *data, size_t n)
+static ssize_t THMemoryFile_writeLong(THFile *self, int64_t *data, ssize_t n)
{
THMemoryFile *mfself = (THMemoryFile*)self;
@@ -449,16 +449,16 @@ static size_t THMemoryFile_writeLong(THFile *self, int64_t *data, size_t n)
{
if(mfself->longSize == 0 || mfself->longSize == sizeof(int64_t))
{
- size_t nByte = sizeof(int64_t)*n;
+ ssize_t nByte = sizeof(int64_t)*n;
THMemoryFile_grow(mfself, mfself->position+nByte);
memmove(mfself->storage->data+mfself->position, data, nByte);
mfself->position += nByte;
} else if(mfself->longSize == 4)
{
- size_t nByte = 4*n;
+ ssize_t nByte = 4*n;
THMemoryFile_grow(mfself, mfself->position+nByte);
int32_t *storage = (int32_t *)(mfself->storage->data + mfself->position);
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
storage[i] = (int32_t) data[i];
mfself->position += nByte;
@@ -466,10 +466,10 @@ static size_t THMemoryFile_writeLong(THFile *self, int64_t *data, size_t n)
else /* if(mfself->longSize == 8) */
{
int big_endian = !THDiskFile_isLittleEndianCPU();
- size_t nByte = 8*n;
+ ssize_t nByte = 8*n;
THMemoryFile_grow(mfself, mfself->position+nByte);
int32_t *storage = (int32_t *)(mfself->storage->data + mfself->position);
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
storage[2*i + !big_endian] = 0;
@@ -485,7 +485,7 @@ static size_t THMemoryFile_writeLong(THFile *self, int64_t *data, size_t n)
}
else
{
- size_t i;
+ ssize_t i;
for(i = 0; i < n; i++)
{
ssize_t nByteWritten;
@@ -525,14 +525,14 @@ static size_t THMemoryFile_writeLong(THFile *self, int64_t *data, size_t n)
return n;
}
-static int8_t* THMemoryFile_cloneString(const int8_t *str, ptrdiff_t size)
+static int8_t* THMemoryFile_cloneString(const int8_t *str, ssize_t size)
{
int8_t *cstr = THAlloc(size);
memcpy(cstr, str, size);
return cstr;
}
-static size_t THMemoryFile_readString(THFile *self, const char *format, char **str_)
+static ssize_t THMemoryFile_readString(THFile *self, const char *format, char **str_)
{
THMemoryFile *mfself = (THMemoryFile*)self;
@@ -552,7 +552,7 @@ static size_t THMemoryFile_readString(THFile *self, const char *format, char **s
if(format[1] == 'a')
{
- size_t str_size = mfself->size-mfself->position;
+ ssize_t str_size = mfself->size-mfself->position;
*str_ = (char*) THMemoryFile_cloneString(mfself->storage->data+mfself->position, str_size);
mfself->position = mfself->size;
@@ -563,8 +563,8 @@ static size_t THMemoryFile_readString(THFile *self, const char *format, char **s
{
int8_t *p = mfself->storage->data+mfself->position;
int eolFound = 0;
- size_t posEol;
- size_t i;
+ ssize_t posEol;
+ ssize_t i;
for(i = 0; i < mfself->size-mfself->position; i++)
{
if(p[i] == '\n')
@@ -583,7 +583,7 @@ static size_t THMemoryFile_readString(THFile *self, const char *format, char **s
}
else /* well, we read all! */
{
- size_t str_size = mfself->size-mfself->position;
+ ssize_t str_size = mfself->size-mfself->position;
*str_ = (char*) THMemoryFile_cloneString(mfself->storage->data+mfself->position, str_size);
mfself->position = mfself->size;
@@ -596,7 +596,7 @@ static size_t THMemoryFile_readString(THFile *self, const char *format, char **s
return 0;
}
-static size_t THMemoryFile_writeString(THFile *self, const char *str, size_t size)
+static ssize_t THMemoryFile_writeString(THFile *self, const char *str, ssize_t size)
{
THMemoryFile *mfself = (THMemoryFile*)self;
diff --git a/aten/src/THNN/generic/SpatialAdaptiveAveragePooling.c b/aten/src/THNN/generic/SpatialAdaptiveAveragePooling.c
index 6e38275789..e71f5b1cf9 100644
--- a/aten/src/THNN/generic/SpatialAdaptiveAveragePooling.c
+++ b/aten/src/THNN/generic/SpatialAdaptiveAveragePooling.c
@@ -74,17 +74,17 @@ void THNN_(SpatialAdaptiveAveragePooling_updateOutput)(
int dimH = 1;
int dimW = 2;
int64_t sizeB = 1;
- int64_t sizeD;
- int64_t isizeH;
- int64_t isizeW;
+ int64_t sizeD = 0;
+ int64_t isizeH = 0;
+ int64_t isizeW = 0;
- int64_t istrideB;
- int64_t istrideD;
- int64_t istrideH;
- int64_t istrideW;
+ int64_t istrideB = 0;
+ int64_t istrideD = 0;
+ int64_t istrideH = 0;
+ int64_t istrideW = 0;
- real *input_data;
- real *output_data;
+ real *input_data = nullptr;
+ real *output_data = nullptr;
THNN_ARGCHECK(input->nDimension == 3 || input->nDimension == 4, 2, input,
diff --git a/aten/src/THNN/generic/SpatialAdaptiveMaxPooling.c b/aten/src/THNN/generic/SpatialAdaptiveMaxPooling.c
index 541dca8128..0255ea9829 100644
--- a/aten/src/THNN/generic/SpatialAdaptiveMaxPooling.c
+++ b/aten/src/THNN/generic/SpatialAdaptiveMaxPooling.c
@@ -83,18 +83,18 @@ void THNN_(SpatialAdaptiveMaxPooling_updateOutput)(
int dimW = 2;
int dimH = 1;
int64_t sizeB = 1;
- int64_t sizeD;
- int64_t isizeH;
- int64_t isizeW;
-
- int64_t istrideD;
- int64_t istrideH;
- int64_t istrideW;
- int64_t istrideB;
-
- real *input_data;
- real *output_data;
- THIndex_t *indices_data;
+ int64_t sizeD = 0;
+ int64_t isizeH = 0;
+ int64_t isizeW = 0;
+
+ int64_t istrideD = 0;
+ int64_t istrideH = 0;
+ int64_t istrideW = 0;
+ int64_t istrideB = 0;
+
+ real *input_data = nullptr;
+ real *output_data = nullptr;
+ THIndex_t *indices_data = nullptr;
THNN_ARGCHECK(input->nDimension == 3 || input->nDimension == 4, 2, input,
diff --git a/aten/src/THNN/generic/VolumetricAdaptiveAveragePooling.c b/aten/src/THNN/generic/VolumetricAdaptiveAveragePooling.c
index 314f62dc2c..01bb9db4aa 100644
--- a/aten/src/THNN/generic/VolumetricAdaptiveAveragePooling.c
+++ b/aten/src/THNN/generic/VolumetricAdaptiveAveragePooling.c
@@ -89,19 +89,19 @@ void THNN_(VolumetricAdaptiveAveragePooling_updateOutput)(
int dimH = 2;
int dimW = 3;
int64_t sizeB = 1;
- int64_t sizeD;
- int64_t isizeT;
- int64_t isizeH;
- int64_t isizeW;
-
- int64_t istrideB;
- int64_t istrideD;
- int64_t istrideT;
- int64_t istrideH;
- int64_t istrideW;
-
- real *input_data;
- real *output_data;
+ int64_t sizeD = 0;
+ int64_t isizeT = 0;
+ int64_t isizeH = 0;
+ int64_t isizeW = 0;
+
+ int64_t istrideB = 0;
+ int64_t istrideD = 0;
+ int64_t istrideT = 0;
+ int64_t istrideH = 0;
+ int64_t istrideW = 0;
+
+ real *input_data = nullptr;
+ real *output_data = nullptr;
THNN_ARGCHECK(input->nDimension == 4 || input->nDimension == 5, 2, input,
diff --git a/aten/src/THNN/generic/VolumetricAdaptiveMaxPooling.c b/aten/src/THNN/generic/VolumetricAdaptiveMaxPooling.c
index 73de996414..6e17e579d9 100644
--- a/aten/src/THNN/generic/VolumetricAdaptiveMaxPooling.c
+++ b/aten/src/THNN/generic/VolumetricAdaptiveMaxPooling.c
@@ -100,20 +100,20 @@ void THNN_(VolumetricAdaptiveMaxPooling_updateOutput)(
int dimH = 2;
int dimW = 3;
int64_t sizeB = 1;
- int64_t sizeD;
- int64_t isizeT;
- int64_t isizeH;
- int64_t isizeW;
-
- int64_t istrideB;
- int64_t istrideD;
- int64_t istrideT;
- int64_t istrideH;
- int64_t istrideW;
-
- real *input_data;
- real *output_data;
- THIndex_t *indices_data;
+ int64_t sizeD = 0;
+ int64_t isizeT = 0;
+ int64_t isizeH = 0;
+ int64_t isizeW = 0;
+
+ int64_t istrideB = 0;
+ int64_t istrideD = 0;
+ int64_t istrideT = 0;
+ int64_t istrideH = 0;
+ int64_t istrideW = 0;
+
+ real *input_data = nullptr;
+ real *output_data = nullptr;
+ THIndex_t *indices_data = nullptr;
THNN_ARGCHECK(input->nDimension == 4 || input->nDimension == 5, 2, input,
"4D or 5D (batch mode) tensor expected for input, but got: %s");