Skip to content

Commit

Permalink
Merge branch 'master' into feature-extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
SurajK7 committed Apr 25, 2020
2 parents 66e08ea + b2d3cff commit b9c1e8f
Show file tree
Hide file tree
Showing 27 changed files with 4,191 additions and 1,177 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nix-linux-cu10.yml
Expand Up @@ -29,4 +29,4 @@ jobs:
skipNixBuild: false
name: hasktorch
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
nixBuildArgs: -A libtorch-ffi_cudatoolkit_10_1 -A hasktorch_cudatoolkit_10_1 -A hasktorch-examples_cudatoolkit_10_1 -A hasktorch-experimental_cudatoolkit_10_1
nixBuildArgs: -A libtorch-ffi_cudatoolkit_10_2 -A hasktorch_cudatoolkit_10_2 -A hasktorch-examples_cudatoolkit_10_2 -A hasktorch-experimental_cudatoolkit_10_2
5 changes: 0 additions & 5 deletions cabal.project
Expand Up @@ -3,11 +3,6 @@ source-repository-package
location: git://github.com/hasktorch/pipes-text.git
tag: 3dd3d9519306ea06f0c15ad71bdf57e1dfd0b747

source-repository-package
type: git
location: git://github.com/RyanGlScott/blaze-markup.git
tag: 66b7b3106eb35f57939357e7fb1288f503d6f833

source-repository-package
type: git
location: git://github.com/well-typed/cborg.git
Expand Down
1 change: 1 addition & 0 deletions cabal.project.freeze.ghc810
Expand Up @@ -39,6 +39,7 @@ constraints: any.Cabal ==3.0.2.0,
any.binary ==0.8.8.0,
any.blaze-builder ==0.4.1.0,
any.blaze-html ==0.9.1.2,
any.blaze-markup ==0.8.2.5,
any.bytestring ==0.10.10.0,
any.cabal-doctest ==1.0.8,
any.call-stack ==0.2.0,
Expand Down
15 changes: 13 additions & 2 deletions codegen/src/RenderCommon.hs
Expand Up @@ -341,6 +341,13 @@ isCType p =
Ptr _ -> True
_ -> False

isGenerator :: Parsable -> Bool
isGenerator p =
case p of
Ptr GeneratorType -> True
GeneratorType -> True
_ -> False

isNotStar :: Parameter -> Bool
isNotStar p =
case p of
Expand Down Expand Up @@ -437,7 +444,9 @@ functionToCpp is_managed add_type_initials prefix suffix fn =
else "Ptr"
types_list :: [Text]
types_list = flip map parameters' $ \p ->
if isCType (ptype p)
if is_managed && isGenerator (ptype p)
then [st|#{pointer} #{parsableToHsType GeneratorType}|]
else if isCType (ptype p)
then [st|#{parsableToHsType (ptype p)}|]
else [st|#{pointer} #{parsableToHsType (ptype p)}|]
types :: Text
Expand Down Expand Up @@ -539,7 +548,9 @@ methodToCpp class' is_constructor is_managed add_type_initials prefix suffix fn
else "Ptr"
types_list :: [Text]
types_list = flip map parameters' $ \p ->
if isCType (ptype p)
if is_managed && isGenerator (ptype p)
then [st|#{pointer} #{parsableToHsType GeneratorType}|]
else if isCType (ptype p)
then [st|#{parsableToHsType (ptype p)}|]
else [st|#{pointer} #{parsableToHsType (ptype p)}|]
types :: Text
Expand Down
8 changes: 4 additions & 4 deletions default.nix
Expand Up @@ -15,8 +15,8 @@ in
${shared.nullIfDarwin "hasktorch-examples_cudatoolkit_9_2"} = shared.hasktorch-examples_cudatoolkit_9_2;
${shared.nullIfDarwin "hasktorch-experimental_cudatoolkit_9_2"} = shared.hasktorch-experimental_cudatoolkit_9_2;

${shared.nullIfDarwin "libtorch-ffi_cudatoolkit_10_1"} = shared.libtorch-ffi_cudatoolkit_10_1;
${shared.nullIfDarwin "hasktorch_cudatoolkit_10_1"} = shared.hasktorch_cudatoolkit_10_1;
${shared.nullIfDarwin "hasktorch-examples_cudatoolkit_10_1"} = shared.hasktorch-examples_cudatoolkit_10_1;
${shared.nullIfDarwin "hasktorch-experimental_cudatoolkit_10_1"} = shared.hasktorch-experimental_cudatoolkit_10_1;
${shared.nullIfDarwin "libtorch-ffi_cudatoolkit_10_2"} = shared.libtorch-ffi_cudatoolkit_10_2;
${shared.nullIfDarwin "hasktorch_cudatoolkit_10_2"} = shared.hasktorch_cudatoolkit_10_2;
${shared.nullIfDarwin "hasktorch-examples_cudatoolkit_10_2"} = shared.hasktorch-examples_cudatoolkit_10_2;
${shared.nullIfDarwin "hasktorch-experimental_cudatoolkit_10_2"} = shared.hasktorch-experimental_cudatoolkit_10_2;
}
14 changes: 8 additions & 6 deletions deps/get-deps.sh
Expand Up @@ -8,16 +8,17 @@
set -eu

usage_exit() {
echo "Usage: $0 [-n] [-c] [-a "cpu" or "cu92" or "cu101"] [-s]" 1>&2
echo "Usage: $0 [-n] [-c] [-a "cpu" or "cu92" or "cu101" or "cu102"] [-s]" 1>&2
echo " -n # Use nightly libtorch w/ -l" 1>&2
echo " # Use libtorch-1.4.0 w/o -l" 1>&2
echo " # Use libtorch-1.5.0 w/o -l" 1>&2
echo "" 1>&2
echo " -c # Download libtorch from hasktorch's site w/ -c" 1>&2
echo " # Download libtorch from pytorch's site w/o -c" 1>&2
echo "" 1>&2
echo " -a cpu # Use CPU without CUDA" 1>&2
echo " -a cu92 # Use CUDA-9" 1>&2
echo " -a cu101 # Use CUDA-10" 1>&2
echo " -a cu101 # Use CUDA-10.1" 1>&2
echo " -a cu102 # Use CUDA-10.2" 1>&2
echo "" 1>&2
echo " -s # Skip download" 1>&2
echo "" 1>&2
Expand All @@ -29,7 +30,7 @@ USE_NIGHTLY=0
USE_BINARY_FOR_CI=0
COMPUTE_ARCH=cpu
SKIP_DOWNLOAD=0
VERSION=1.4.0
VERSION=1.5.0

while getopts nca:sh OPT
do
Expand Down Expand Up @@ -90,7 +91,8 @@ if [ "$SKIP_DOWNLOAD" = 0 ] ; then
case "${COMPUTE_ARCH}" in
"cpu" ) URL=https://download.pytorch.org/libtorch/${COMPUTE_ARCH}/libtorch-cxx11-abi-shared-with-deps-${VERSION}%2Bcpu.zip ;;
"cu92" ) URL=https://download.pytorch.org/libtorch/${COMPUTE_ARCH}/libtorch-cxx11-abi-shared-with-deps-${VERSION}%2Bcu92.zip ;;
"cu101" ) URL=https://download.pytorch.org/libtorch/${COMPUTE_ARCH}/libtorch-cxx11-abi-shared-with-deps-${VERSION}.zip ;;
"cu101" ) URL=https://download.pytorch.org/libtorch/${COMPUTE_ARCH}/libtorch-cxx11-abi-shared-with-deps-${VERSION}%2Bcu101.zip ;;
"cu102" ) URL=https://download.pytorch.org/libtorch/${COMPUTE_ARCH}/libtorch-cxx11-abi-shared-with-deps-${VERSION}.zip ;;
esac
wget -O libtorch-cxx11-abi-shared-with-deps-${VERSION}.zip "$URL"
unzip libtorch-cxx11-abi-shared-with-deps-${VERSION}.zip
Expand Down Expand Up @@ -126,11 +128,11 @@ $PYTHON aten/src/ATen/gen.py \
-s aten/src/ATen \
-d build/aten/src/ATen \
aten/src/ATen/Declarations.cwrap \
aten/src/THNN/generic/THNN.h \
aten/src/THCUNN/generic/THCUNN.h \
aten/src/ATen/nn.yaml \
aten/src/ATen/native/native_functions.yaml


# Sanitize "name: n" fields to be strings rather than booleans in Declarations.yaml

case "$(uname)" in
Expand Down
2 changes: 1 addition & 1 deletion deps/pytorch
Submodule pytorch updated 2771 files
2 changes: 1 addition & 1 deletion examples/shell.nix
Expand Up @@ -8,4 +8,4 @@ if cudaVersion == null
then shared.shell-hasktorch-examples_cpu
else if cudaVersion == 9
then shared.shell-hasktorch-examples_cudatoolkit_9_2
else shared.shell-hasktorch-examples_cudatoolkit_10_1
else shared.shell-hasktorch-examples_cudatoolkit_10_2
2 changes: 1 addition & 1 deletion experimental/shell.nix
Expand Up @@ -8,4 +8,4 @@ if cudaVersion == null
then shared.shell-hasktorch-experimental_cpu
else if cudaVersion == 9
then shared.shell-hasktorch-experimental_cudatoolkit_9_2
else shared.shell-hasktorch-experimental_cudatoolkit_10_1
else shared.shell-hasktorch-experimental_cudatoolkit_10_2
2 changes: 1 addition & 1 deletion hasktorch/hasktorch.cabal
Expand Up @@ -65,7 +65,7 @@ library
ghc-options: -fplugin GHC.TypeLits.Normalise -fplugin GHC.TypeLits.KnownNat.Solver -fplugin GHC.TypeLits.Extra.Solver -fconstraint-solver-iterations=0
build-depends: async
, base >= 4.7 && < 5
, libtorch-ffi == 1.4.*
, libtorch-ffi == 1.5.*
, finite-typelits
-- , ghc-typelits-extra >= 0.3.1
-- , ghc-typelits-knownnat >= 0.7
Expand Down
2 changes: 1 addition & 1 deletion hasktorch/shell.nix
Expand Up @@ -8,4 +8,4 @@ if cudaVersion == null
then shared.shell-hasktorch_cpu
else if cudaVersion == 9
then shared.shell-hasktorch_cudatoolkit_9_2
else shared.shell-hasktorch_cudatoolkit_10_1
else shared.shell-hasktorch_cudatoolkit_10_2

0 comments on commit b9c1e8f

Please sign in to comment.