Skip to content

Commit

Permalink
Add sample for exercising the compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
stellaraccident committed Jul 9, 2020
1 parent efbcf0a commit 70595bd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/samples/compiled_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run full pipeline with:
# -npcomp-cpa-type-inference -numpy-public-functions-to-tensor -convert-numpy-to-tcf -canonicalize

import numpy as np
from npcomp.compiler import test_config

import_global = test_config.create_import_dump_decorator()

global_data = (np.zeros((2, 3)) + [1.0, 2.0, 3.0] * np.reshape([1.0, 2.0],
(2, 1)))

a = np.asarray([1.0, 2.0], dtype=np.float32)
b = np.asarray([3.0, 4.0], dtype=np.float32)


@import_global
def global_add():
return np.add(a, np.add(b, a))

0 comments on commit 70595bd

Please sign in to comment.