Skip to content

Using the DyNet Fork

Keith Alcock edited this page Feb 22, 2022 · 12 revisions

The intial versions of fatdynet did not require particularly many changes to the original DyNet source code, and those changes could be documented on these wiki pages. Beginning with version 0.2.3, zip support was added, which entailed too many changes to track in the same way. The DyNet repository was consequently forked. Then it no longer made sense to separately track the several simple changes required of the original code. These have been incorporated into the fork and in some cases propagated back to the original project, although they have not necessarily been included in a release. It is therefore recommended that people interested in compiling DyNet for use in a fatdynet way make use of this forked version.

These instructions explain how compiling this forked version differs from compiling the original version.


On Mac OS X

Install homebrew, if you don't have it:

No changes in instruction

Install necessary tools:

No changes in instruction

Clone DyNet:

Use git clone https://github.com/kwalcock/dynet.git instead.

Compile the C++ DyNet with SWIG support:

Do not edit any of the files. Leave build.sbt, dynet_swig.i, and others unchanged.

Change the cmake command to

cmake .. -DEIGEN3_INCLUDE_DIR=<eigen_directory> -DENABLE_CPP_EXAMPLES=ON -DENABLE_SWIG=ON -DENABLE_ZIP=ON -DENABLE_NONNATIVE=ON -DENABLE_RELOCATABLE=ON -DSCALA_VERSION=2.12.4

depending on where eigen3 was installed. This command is recorded in cmake.mac-intel.sh. A similar command, with the addition of -DENABLE_APPLE=ON is recorded in cmake.mac-m1.sh to account for machines running on Apple silicon.

There are no other changes in this section.

Check that the compilation succeeded (C++):

This section is new. You may want to try the ser-par test program which isn't part of the original DyNet.

$ cd examples
$ ./ser-par
$ cd ..

Check that the compilation succeeded (Scala):

No changes in instruction

Check that the compilation succeeded (Python):

No changes in instruction

On Linux

The directory structure includes a few additions, but it is not necessary to access them.

Tool

No changes in instruction

Code

  1. For DyNet, use git clone https://github.com/kwalcock/dynet.git and do not checkout any tags.
  2. Do not edit any of build.sbt, dynet_swig.i, io.cc,

Build

The cmake command should be changed to account for the additional functionality: cmake .. -DSCALA_VERSION=2.11.11 -DEIGEN3_INCLUDE_DIR=../../eigen -DENABLE_CPP_EXAMPLES=ON -DENABLE_SWIG=ON -DENABLE_ZIP=ON -DENABLE_NONNATIVE=ON -DENABLE_RELOCATABLE=ON. This command is recorded in cmake.linux.sh.

Test

In addition to the other tests, one might run the ser-par example:

$ cd examples
$ ./ser-par
$ cd ..

Update

Again the cmake command should be changed: cmake .. -DSCALA_VERSION=2.12.4 -DEIGEN3_INCLUDE_DIR=../../eigen -DENABLE_CPP_EXAMPLES=ON -DENABLE_SWIG=ON -DENABLE_ZIP=ON -DENABLE_NONNATIVE=ON -DENABLE_RELOCATABLE=ON.

The example C++ program should not have changed, so there is no reason to revisit it.

The directory structure includes a few additions, but it is not necessary to access them.

Tool

No changes in instruction

Code

Download from https://github.com/kwalcock/dynet/archive/master.zip.

Do not edit any of the files dynet_swig.i or io.cc.

Build

Change the cmake command to cmake .. -DSWIG_EXECUTABLE=D:/Users/you/Projects/dynet/swigwin-3.0.12/swigwin-3.0.12/swig.exe -DSWIG_DIR=D:/Users/you/Projects/dynet/swigwin-3.0.12/swigwin-3.0.12 -DEIGEN3_INCLUDE_DIR=D:/Users/you/Projects/dynet/eigen-eigen-b2e267dc99d4/eigen-eigen-b2e267dc99d4 -DENABLE_CPP_EXAMPLES=ON -DENABLE_SWIG=ON -DENABLE_ZIP=ON -DENABLE_RELOCATABLE=ON -G"Visual Studio 14 2015 Win64", adjusted as needed for your directory structure. This command is recorded in cmake.windows.sh.

Test

You might additionally build and run the ser-par project.

Update

No changes in instruction