Skip to content

Commit 0ca966e

Browse files
authored
Merge pull request #25 from marian-nmt/romang/example-library-readme
Replace the marian-example-library submodule with README
2 parents 299123b + ac2f162 commit 0ca966e

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

.gitmodules

-4
This file was deleted.

example-library

-1
This file was deleted.

example-library/README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Example: Marian as a library
2+
3+
This serves as a minimal example of a CMake project with a [marian][marian]
4+
dependency. The dependency to Marian in that repository is facilitated by a
5+
submodule to [marian-dev]. The complete code is available from the
6+
[marian-example-library] repository.
7+
8+
9+
## Usage
10+
11+
### Compile
12+
```shell
13+
git clone https://github.com/marian-nmt/marian-example-library
14+
cd marian-example-library
15+
mkdir build
16+
cd build
17+
cmake ..
18+
cmake --build .
19+
```
20+
21+
### Run
22+
```shell
23+
./example
24+
```
25+
26+
## About this example
27+
The code in [src/main.cpp](src/main.cpp) builds a simple expression graph using
28+
Marian. It mirrors the example found in Marian's [developer
29+
documentation][dev_docs].
30+
31+
The expression graph represents `z = x*y + sin(x)`, with an absolute-error
32+
applied to `z` as a loss function. It performs a forward and backward
33+
evaluation of the graph, and a single update of the graph parameters from a
34+
`Stochastic Gradient Descent` optimizer. Following the example, `x` takes the
35+
place of a learnable parameter.
36+
37+
After the parameter update, the graph parameters are saved to
38+
`example-model.npz`. You can inspect its contents with
39+
[`script/read-npz.py`](/script/read-npz.py).
40+
41+
Please refer to the [marian][marian] project for further documentation.
42+
43+
## About this repository
44+
There are example CI builds available for
45+
- Ubuntu
46+
- MacOS
47+
- Windows
48+
49+
These compile and run the example executable.
50+
51+
Additionally, the Marian submodule is updatable via dependabot.
52+
53+
<!-- Links -->
54+
[marian]: https://marian-nmt.github.io/
55+
[marian-dev]: https://github.com/marian-nmt/marian-dev
56+
[marian-example-library]: https://github.com/marian-nmt/marian-example-library
57+
[dev_docs]: https://marian-nmt.github.io/docs/api/graph.html

0 commit comments

Comments
 (0)