Skip to content

Commit

Permalink
onboarding fixes - add init target to makefile, add script that creat…
Browse files Browse the repository at this point in the history
…es a cabal.project.local w/ reasonable defaults
  • Loading branch information
austinvhuang committed Nov 8, 2018
1 parent 805666d commit e432307
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 32 deletions.
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
UNAME:=$(shell uname)
PWD:=$(shell pwd)
GHC_VERSION:=$(shell ghc --version | cut -d' ' -f 8)

clean:
rm -rf dist{,-newbuild}

init:
# (cd ffi/deps && ./build-aten.sh)
$(info GHC version detected ${GHC_VERSION})
ifeq ($(GHC_VERSION),8.4.2)
ln -fs cabal/project.freeze-8.4.2 cabal.project.freeze
else ifeq ($(GHC_VERSION),8.4.3)
ln -fs cabal/project.freeze-8.4.3 cabal.project.freeze
else ifeq ($(GHC_VERSION),8.4.4)
ln -fs cabal/project.freeze-8.4.4 cabal.project.freeze
else ifeq ($(GHC_VERSION),8.6.1)
ln -fs cabal/project.freeze-8.6.1 cabal.project.freeze
else
$(error GHC version must be 8.4.2, 8.4.3, 8.4.4, or 8.6.1)
endif
$(info defaulting to CPU configuration)
./make_cabal_local.sh
# cabal new-update
cabal new-build all

purge:
rm -rf vendor
git checkout -- vendor
rm -rf dist-newstyle
git submodule update --init --recursive

build:
Expand All @@ -27,7 +46,6 @@ codegen: codegen-th codegen-thc
dev:
sos -e 'dist' -p '.*hsig$$' -p '.*hs$$' -p '.*cabal$$' -p 'cabal.project$$' -c 'cabal new-build all'

# lasso is broken
run-examples:
for ex in ad \
bayesian-regression \
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages:
ffi/codegen/*.cabal
-- ffi/codegen/*.cabal

ffi/types/th/*.cabal
ffi/types/thc/*.cabal
Expand Down
2 changes: 1 addition & 1 deletion cabal.project.freeze
2 changes: 1 addition & 1 deletion cabal/project.freeze-8.4.3
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ constraints: any.Cabal ==2.2.0.1,
any.managed ==1.0.6,
any.math-functions ==0.3.0.2,
math-functions -system-expm1,
any.megaparsec ==7.0.3,
any.megaparsec ==6.5.0,
megaparsec -dev,
any.memory ==0.14.18,
memory +support_basement +support_bytestring +support_deepseq +support_foundation,
Expand Down
8 changes: 4 additions & 4 deletions examples/experimental/autoencoder/ae.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type DataDim = 256

data Autoencoder = Autoencoder {
enc1 :: Linear DataDim 64
enc2 :: Linear 256 64
enc3 :: Linear 64 32
dec1 :: Linear 32 64
dec2 :: Linear 64 DataDim
, enc2 :: Linear 256 64
, enc3 :: Linear 64 32
, dec1 :: Linear 32 64
, dec2 :: Linear 64 DataDim
} deriving (Generic, Show)

instance Backprop Autoencoder where
Expand Down
22 changes: 0 additions & 22 deletions examples/hasktorch-examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,6 @@ executable bayesian-regression
default-extensions: NoStarIsType
else

executable autoencoder
main-is: ae.hs
hs-source-dirs: experimental/autoencoder
default-language: Haskell2010
build-depends:
base (==4.7 || >4.7) && <5,
hasktorch (==0.0.1 || >0.0.1) && <0.0.2,
microlens ==0.4.8 || >0.4.8,
dimensions ==1.0 || >1.0,
safe-exceptions ==0.1.0 || >0.1.0,
singletons ==2.2 || >2.2

if flag(cuda)
cpp-options: -DCUDA
build-depends:
cuda -any
else

if impl(ghc >=8.6)
default-extensions: NoStarIsType
else

executable download-mnist
main-is: DownloadMNIST.hs
hs-source-dirs: experimental/download-mnist
Expand Down
14 changes: 14 additions & 0 deletions make_cabal_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash -eu

echo "
extra-lib-dirs: $PWD/ffi/deps/aten/build/lib/
extra-include-dirs: $PWD/ffi/deps/aten/build/include/
extra-include-dirs: $PWD/ffi/deps/aten/build/include/TH
extra-include-dirs: $PWD/ffi/deps/aten/build/include/THNN
extra-include-dirs: $PWD/ffi/deps/aten/build/include/THC
extra-include-dirs: $PWD/ffi/deps/aten/build/include/THCUNN
package *
flags: -cuda +lite
" > cabal.project.local

0 comments on commit e432307

Please sign in to comment.