[lua-torch-torch7] 01/06: New upstream version 0~20170203-g68f34f6

Zhou Mo cdluminate-guest at moszumanska.debian.org
Mon Feb 6 04:12:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

cdluminate-guest pushed a commit to branch master
in repository lua-torch-torch7.

commit 02760aac942a4a60e845ed54adfae9fe1cc4d5e2
Author: Zhou Mo <cdluminate at gmail.com>
Date:   Mon Feb 6 03:55:37 2017 +0000

    New upstream version 0~20170203-g68f34f6
---
 CMakeLists.txt                |  4 +-
 lib/TH/CMakeLists.txt         |  1 +
 lib/TH/THGenerateAllTypes.h   | 93 ++--------------------------------------
 lib/TH/THGenerateFloatTypes.h | 10 +++++
 lib/TH/THGenerateHalfType.h   |  8 +++-
 lib/TH/THGenerateIntTypes.h   | 23 ++++++++++
 lib/TH/THHalf.c               | 98 +++++++++++++------------------------------
 lib/TH/THHalf.h               | 13 +++---
 lib/TH/generic/THTensorMath.c | 12 +++---
 lib/TH/generic/simd/simd.h    |  4 +-
 paths.lua.in                  | 11 +++++
 11 files changed, 105 insertions(+), 172 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 611258b..095a721 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,8 @@ INCLUDE(TorchExports)
 # Torch libraries
 ADD_SUBDIRECTORY(lib)
 
+CONFIGURE_FILE(paths.lua.in "${CMAKE_CURRENT_BINARY_DIR}/paths.lua")
+
 INCLUDE_DIRECTORIES(BEFORE "${LUA_INCDIR}")
 INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/lib/TH")
 INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/lib/TH")
@@ -71,7 +73,7 @@ INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/lib/luaT")
 LINK_DIRECTORIES("${LUA_LIBDIR}")
 
 SET(src DiskFile.c File.c MemoryFile.c PipeFile.c Storage.c Tensor.c Timer.c utils.c init.c TensorOperator.c TensorMath.c random.c Generator.c)
-SET(luasrc init.lua File.lua Tensor.lua CmdLine.lua FFI.lua Tester.lua TestSuite.lua test/test.lua)
+SET(luasrc init.lua File.lua Tensor.lua CmdLine.lua FFI.lua Tester.lua TestSuite.lua ${CMAKE_CURRENT_BINARY_DIR}/paths.lua test/test.lua)
 
 # Necessary do generate wrapper
 ADD_TORCH_WRAP(tensormathwrap TensorMath.lua)
diff --git a/lib/TH/CMakeLists.txt b/lib/TH/CMakeLists.txt
index ac4dce6..3f66edc 100644
--- a/lib/TH/CMakeLists.txt
+++ b/lib/TH/CMakeLists.txt
@@ -6,6 +6,7 @@ IF(POLICY CMP0026)
 ENDIF()
 
 SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
+SET(CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/ ${CMAKE_LIBRARY_PATH})
 
 # Can be compiled standalone
 IF(NOT TH_INSTALL_BIN_SUBDIR
diff --git a/lib/TH/THGenerateAllTypes.h b/lib/TH/THGenerateAllTypes.h
index 4a77081..778da9d 100644
--- a/lib/TH/THGenerateAllTypes.h
+++ b/lib/TH/THGenerateAllTypes.h
@@ -2,95 +2,10 @@
 #error "You must define TH_GENERIC_FILE before including THGenerateAllTypes.h"
 #endif
 
-#define real unsigned char
-#define accreal long
-#define Real Byte
-#define THInf UCHAR_MAX
-#define TH_REAL_IS_BYTE
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_BYTE
+#define THGenerateAllTypes
 
-#define real char
-#define accreal long
-#define Real Char
-#define THInf CHAR_MAX
-#define TH_REAL_IS_CHAR
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_CHAR
-
-#define real short
-#define accreal long
-#define Real Short
-#define THInf SHRT_MAX
-#define TH_REAL_IS_SHORT
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_SHORT
-
-#define real int
-#define accreal long
-#define Real Int
-#define THInf INT_MAX
-#define TH_REAL_IS_INT
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_INT
-
-#define real long
-#define accreal long
-#define Real Long
-#define THInf LONG_MAX
-#define TH_REAL_IS_LONG
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_LONG
-
-#define real float
-#define accreal double
-#define Real Float
-#define THInf FLT_MAX
-#define TH_REAL_IS_FLOAT
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_FLOAT
-
-#define real double
-#define accreal double
-#define Real Double
-#define THInf DBL_MAX
-#define TH_REAL_IS_DOUBLE
-#line 1 TH_GENERIC_FILE
-#include TH_GENERIC_FILE
-#undef real
-#undef accreal
-#undef Real
-#undef THInf
-#undef TH_REAL_IS_DOUBLE
+#include "THGenerateFloatTypes.h"
+#include "THGenerateIntTypes.h"
 
+#undef THGenerateAllTypes
 #undef TH_GENERIC_FILE
diff --git a/lib/TH/THGenerateFloatTypes.h b/lib/TH/THGenerateFloatTypes.h
index b6bdd07..639c1f9 100644
--- a/lib/TH/THGenerateFloatTypes.h
+++ b/lib/TH/THGenerateFloatTypes.h
@@ -4,6 +4,8 @@
 
 #define real float
 #define accreal double
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define Real Float
 #define THInf FLT_MAX
 #define TH_REAL_IS_FLOAT
@@ -14,9 +16,13 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_FLOAT
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
 #define real double
 #define accreal double
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define Real Double
 #define THInf DBL_MAX
 #define TH_REAL_IS_DOUBLE
@@ -27,5 +33,9 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_DOUBLE
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
+#ifndef THGenerateAllTypes
 #undef TH_GENERIC_FILE
+#endif
diff --git a/lib/TH/THGenerateHalfType.h b/lib/TH/THGenerateHalfType.h
index 9acc534..c42cb3f 100644
--- a/lib/TH/THGenerateHalfType.h
+++ b/lib/TH/THGenerateHalfType.h
@@ -5,8 +5,10 @@
 #include "THHalf.h"
 #define real THHalf
 #define accreal float
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) TH_half2float(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) TH_float2half(_val)
 #define Real Half
-#define THInf TH_HALF_MAX
+#define THInf TH_HALF_BITS_TO_LITERAL(TH_HALF_INF)
 #define TH_REAL_IS_HALF
 #line 1 TH_GENERIC_FILE
 #include TH_GENERIC_FILE
@@ -15,5 +17,9 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_HALF
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
+#ifndef THGenerateAllTypes
 #undef TH_GENERIC_FILE
+#endif
diff --git a/lib/TH/THGenerateIntTypes.h b/lib/TH/THGenerateIntTypes.h
index a561d89..1d991ca 100644
--- a/lib/TH/THGenerateIntTypes.h
+++ b/lib/TH/THGenerateIntTypes.h
@@ -5,6 +5,8 @@
 #define real unsigned char
 #define accreal long
 #define Real Byte
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define THInf UCHAR_MAX
 #define TH_REAL_IS_BYTE
 #line 1 TH_GENERIC_FILE
@@ -14,11 +16,16 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_BYTE
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
+
 
 #define real char
 #define accreal long
 #define Real Char
 #define THInf CHAR_MAX
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define TH_REAL_IS_CHAR
 #line 1 TH_GENERIC_FILE
 #include TH_GENERIC_FILE
@@ -27,9 +34,13 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_CHAR
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
 #define real short
 #define accreal long
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define Real Short
 #define THInf SHRT_MAX
 #define TH_REAL_IS_SHORT
@@ -40,9 +51,13 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_SHORT
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
 #define real int
 #define accreal long
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define Real Int
 #define THInf INT_MAX
 #define TH_REAL_IS_INT
@@ -53,9 +68,13 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_INT
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
 #define real long
 #define accreal long
+#define TH_CONVERT_REAL_TO_ACCREAL(_val) (accreal)(_val)
+#define TH_CONVERT_ACCREAL_TO_REAL(_val) (real)(_val)
 #define Real Long
 #define THInf LONG_MAX
 #define TH_REAL_IS_LONG
@@ -66,5 +85,9 @@
 #undef Real
 #undef THInf
 #undef TH_REAL_IS_LONG
+#undef TH_CONVERT_REAL_TO_ACCREAL
+#undef TH_CONVERT_ACCREAL_TO_REAL
 
+#ifndef THGenerateAllTypes
 #undef TH_GENERIC_FILE
+#endif
diff --git a/lib/TH/THHalf.c b/lib/TH/THHalf.c
index b0b9bc5..1c46c59 100644
--- a/lib/TH/THHalf.c
+++ b/lib/TH/THHalf.c
@@ -1,62 +1,29 @@
 #include "THHalf.h"
 
-/*
- * Copyright 1993-2014 NVIDIA Corporation.  All rights reserved.
- *
- * NOTICE TO LICENSEE:
- *
- * This source code and/or documentation ("Licensed Deliverables") are
- * subject to NVIDIA intellectual property rights under U.S. and
- * international Copyright laws.
- *
- * These Licensed Deliverables contained herein is PROPRIETARY and
- * CONFIDENTIAL to NVIDIA and is being provided under the terms and
- * conditions of a form of NVIDIA software license agreement by and
- * between NVIDIA and Licensee ("License Agreement") or electronically
- * accepted by Licensee.  Notwithstanding any terms or conditions to
- * the contrary in the License Agreement, reproduction or disclosure
- * of the Licensed Deliverables to any third party without the express
- * written consent of NVIDIA is prohibited.
- *
- * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
- * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
- * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
- * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
- * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
- * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
- * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
- * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
- * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
- * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THESE LICENSED DELIVERABLES.
- *
- * U.S. Government End Users.  These Licensed Deliverables are a
- * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
- * 1995), consisting of "commercial computer software" and "commercial
- * computer software documentation" as such terms are used in 48
- * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
- * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
- * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
- * U.S. Government End Users acquire the Licensed Deliverables with
- * only those rights set forth herein.
- *
- * Any use of the Licensed Deliverables in individual and commercial
- * software must include, in the user documentation and internal
- * comments to the code, the above Disclaimer and U.S. Government End
- * Users Notice.
- */
+/* Copyright 1993-2014 NVIDIA Corporation.  All rights reserved. */
+
+THHalf TH_float2half(float f)
+{
+  THHalf h;
+  TH_float2halfbits(&f, &h.x);
+  return h;
+}
+
+TH_API float TH_half2float(THHalf h)
+{
+  float f;
+  TH_halfbits2float(&h.x, &f);
+  return f;
+}
 
 // Host functions for converting between FP32 and FP16 formats
-// Paulius Micikevicius (pauliusm at nvidia.com)
 
-float TH_half2float(THHalf h)
+void TH_halfbits2float(unsigned short* src, float* res)
 {
-    unsigned sign = ((h.x >> 15) & 1);
-    unsigned exponent = ((h.x >> 10) & 0x1f);
-    unsigned mantissa = ((h.x & 0x3ff) << 13);
+    unsigned h = *src;
+    unsigned sign = ((h >> 15) & 1);
+    unsigned exponent = ((h >> 10) & 0x1f);
+    unsigned mantissa = ((h & 0x3ff) << 13);
 
     if (exponent == 0x1f) {  /* NaN or Inf */
         mantissa = (mantissa ? (sign = 0, 0x7fffff) : 0);
@@ -76,35 +43,31 @@ float TH_half2float(THHalf h)
         exponent += 0x70;
     }
 
-    int temp = ((sign << 31) | (exponent << 23) | mantissa);
-
-    return *((float*)((void*)&temp));
+    *(unsigned*)res = ((sign << 31) | (exponent << 23) | mantissa);
 }
 
-THHalf TH_float2half(float f)
+void TH_float2halfbits(float* src, unsigned short* dest)
 {
-    THHalf ret;
-
-    unsigned x = *((int*)(void*)(&f));
+    unsigned x = *(unsigned*)src;
     unsigned u = (x & 0x7fffffff), remainder, shift, lsb, lsb_s1, lsb_m1;
     unsigned sign, exponent, mantissa;
 
     // Get rid of +NaN/-NaN case first.
     if (u > 0x7f800000) {
-        ret.x = 0x7fffU;
-        return ret;
+      *dest = 0x7fffU;
+      return ;
     }
   
     sign = ((x >> 16) & 0x8000);
   
     // Get rid of +Inf/-Inf, +0/-0.
     if (u > 0x477fefff) {
-        ret.x = sign | 0x7c00U;
-        return ret;
+      *dest = sign | 0x7c00U;
+      return; 
     }
     if (u < 0x33000001) {
-        ret.x = (sign | 0x0000);
-        return ret;
+      *dest = (sign | 0x0000);
+      return;
     }
 
     exponent = ((u >> 23) & 0xff);
@@ -133,6 +96,5 @@ THHalf TH_float2half(float f)
         }
     }  
 
-    ret.x = (sign | (exponent << 10) | mantissa);  
-    return ret;
+    *dest = (sign | (exponent << 10) | mantissa);  
 }
diff --git a/lib/TH/THHalf.h b/lib/TH/THHalf.h
index 0549d21..0f9807b 100644
--- a/lib/TH/THHalf.h
+++ b/lib/TH/THHalf.h
@@ -18,23 +18,24 @@ typedef struct __thalign__(2){
 } __THHalf;
 
 typedef struct __thalign__(4) {
-    unsigned int x;
+  unsigned int x;
 } __THHalf2;
 
 typedef __THHalf THHalf;
 typedef __THHalf2 THHalf2;
 
-/* numeric limits */
+TH_API void TH_float2halfbits(float*, unsigned short*);
+TH_API void TH_halfbits2float(unsigned short*, float*);
 
-
-TH_API THHalf TH_float2half(float a);
-TH_API float TH_half2float(THHalf a);
+TH_API THHalf TH_float2half(float);
+TH_API float  TH_half2float(THHalf);
 
 #ifndef TH_HALF_BITS_TO_LITERAL
 # define TH_HALF_BITS_TO_LITERAL(n) { n }
 #endif
 
-#define TH_HALF_MAX TH_HALF_BITS_TO_LITERAL(0x7BFF)
+#define TH_HALF_ZERO 0x0U
+#define TH_HALF_INF  0x7C00U
 
 #undef __thalign__
 #endif
diff --git a/lib/TH/generic/THTensorMath.c b/lib/TH/generic/THTensorMath.c
index 78ee056..d1e7420 100644
--- a/lib/TH/generic/THTensorMath.c
+++ b/lib/TH/generic/THTensorMath.c
@@ -99,7 +99,7 @@ void THTensor_(nonzero)(THLongTensor *subscript, THTensor *tensor)
   long dim;
   long div = 1;
 #ifdef TH_REAL_IS_HALF
-#define IS_NONZERO(val) (TH_half2float(val)!=0)
+#define IS_NONZERO(val) ((val.x & 0x7fff) != 0)
 #else
 #define IS_NONZERO(val) ((val)!=0)
 #endif
@@ -2074,10 +2074,6 @@ void THTensor_(catArray)(THTensor *result, THTensor **inputs, int numInputs, int
         // accumulate the size over the dimension we want to cat on.
         // Empty tensors are allowed
         dimSize += i < inputs[j]->nDimension ? inputs[j]->size[i] : THMin(inputs[j]->nDimension, 1);
-        if(inputs[j]->nDimension)
-        {
-          allContiguous = allContiguous && THTensor_(isContiguous)(inputs[j]);
-        }
       }
     }
     else
@@ -2108,6 +2104,12 @@ void THTensor_(catArray)(THTensor *result, THTensor **inputs, int numInputs, int
   {
     THTensor_(resize)(result, size, NULL);
 
+    // Check contiguity of all inputs and result
+    for (i = 0; i < numInputs; i++) {
+      if(inputs[i]->nDimension) {
+        allContiguous = allContiguous && THTensor_(isContiguous)(inputs[i]);
+      }
+    }
     allContiguous = allContiguous && THTensor_(isContiguous)(result);
 
     // First path is for contiguous inputs along dim 1
diff --git a/lib/TH/generic/simd/simd.h b/lib/TH/generic/simd/simd.h
index ee53e2c..aa3b722 100644
--- a/lib/TH/generic/simd/simd.h
+++ b/lib/TH/generic/simd/simd.h
@@ -53,7 +53,7 @@ enum SIMDExtensions
 };
 
 
-#if defined(__arm__)
+#if defined(__arm__) || defined(__aarch64__) // incl. armel, armhf, arm64
 
  #if defined(__NEON__)
 
@@ -80,7 +80,7 @@ static inline uint32_t detectHostSIMDExtensions()
   return SIMDExtension_VSX;
 }
 
- #else
+ #else //PPC64 without VSX
 
 static inline uint32_t detectHostSIMDExtensions()
 {
diff --git a/paths.lua.in b/paths.lua.in
new file mode 100644
index 0000000..287770b
--- /dev/null
+++ b/paths.lua.in
@@ -0,0 +1,11 @@
+local paths = {}
+
+paths.install_prefix = [[@Torch_INSTALL_PREFIX@]]
+paths.install_bin = [[@Torch_INSTALL_BIN@]]
+paths.install_man = [[@Torch_INSTALL_MAN@]]
+paths.install_lib = [[@Torch_INSTALL_LIB@]]
+paths.install_share = [[@Torch_INSTALL_SHARE@]]
+paths.install_include = [[@Torch_INSTALL_INCLUDE@]]
+paths.install_cmake = [[@Torch_INSTALL_CMAKE@]]
+
+return paths

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/lua-torch-torch7.git



More information about the debian-science-commits mailing list