Skip to content

Commit

Permalink
fix unary and binary operators on beignet
Browse files Browse the repository at this point in the history
  • Loading branch information
hughperkins committed Nov 9, 2016
1 parent 79dc5cf commit 8d2ac50
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 29 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,30 @@ Piccie of running Aymeric Damien's [linear_regression.py](https://github.com/hug
| test_tf2.py | ok | ok |
| test_tf3.py | fails for pow | ok |
| test_tf4.py | fails for all | ok |
| test_blas.py | ok | ok |
| test_blas.py | ok | not ok |
| test_reductions.py | fails for all except reduce_mean | ok |
| [linear_regression.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/linear_regression.py) | runs, but cost seems wrong | ok |
| [logistic_regression.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/logistic_regression.py) | epoch 1 ok, then memory error | ok |
| [nearest_neighbor.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/nearest_neighbor.py) | accuracy 0.12, seems a bit low... | ok |
| [multilayer_perceptron.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/3_NeuralNetworks/multilayer_perceptron.py) | cost is nan | a bit slow, otherwise seems ok |
| [recurrent_network.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/3_NeuralNetworks/recurrent_network.py) | loss nan, accuracy broken | cost looks ok, accuracy seems broken |

## Test results, on v0.12.0 wheel

| test | Intel HD5500 | NVIDIA K520 |
|----- |-------|-----|
|test_tf.py| ok | ok |
| test_tf2.py | ok | ok |
| test_tf3.py | all ok, except `not_equal` | all ok, except `not_equal` |
| test_tf4.py | ok :-) | ok |
| test_blas.py | runs ok, but segfault at end | not tested |
| test_reductions.py | all pass :-) | not tested |
| [linear_regression.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/linear_regression.py) | runs, but spamtastic | not tested |
| [logistic_regression.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/logistic_regression.py) | either slow or blocked | not tested |
| [nearest_neighbor.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/2_BasicModels/nearest_neighbor.py) | either slow or blocked | not tested |
| [multilayer_perceptron.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/3_NeuralNetworks/multilayer_perceptron.py) | either slow or blocked | not tested |
| [recurrent_network.py](https://github.com/hughperkins/TensorFlow-Examples/blob/enforce-gpu/examples/3_NeuralNetworks/recurrent_network.py) | either slow or blocked | not tested |

## Design/architecture

- tensorflow code stays 100% [NVIDIA® CUDA™](https://www.nvidia.com/object/cuda_home_new.html)
Expand All @@ -120,6 +136,9 @@ Piccie of running Aymeric Damien's [linear_regression.py](https://github.com/hug

## News

- Nov 9:
- fixed unary and binary operators on beignet
- note that the tools/bazel.rc.templ has changed. Please make sure to copy the new value into tools/bazel.rc, or re-run configure (probably need to do `bazel clean` anyway, so might as well do `./configure`)
- Nov 1:
- building clew, CLBlast, easycl, cocl as shared libraries now, rather than static
- hopefully this will facilitate debugging things on the HD5500 on my laptop, since dont need to build/install entire wheel, for `libcocl` tweaks
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/stream_executor/cl/test/test_tf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test(tf_func, py_func):
'maximum': 'np.maximum(a,b)',
'pow': 'np.power(a,b)',
'squared_difference': '(a - b) * (a - b)',
'not_equal': 'np.not_equal(a, b)'
#'not_equal': 'np.not_equal(a, b)'
}
for tf_func, py_func in funcs.items():
test(tf_func, py_func)
7 changes: 4 additions & 3 deletions tensorflow/stream_executor/cl/test/test_tf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ def test(tf_func, py_func):
a -= 0.5

ar, cr = sess.run((tf_a, tf_c), {tf_a: a})
print('ar', ar)
print('cr', cr)
print('original ', ar)
c_py = eval(py_func)
diff = np.abs(c_py - cr).max()
print('expected ', c_py)
print('gpu ', cr)
print('diff', diff)
assert diff < 1e-4, 'failed for %s' % tf_func

Expand All @@ -29,7 +30,7 @@ def test(tf_func, py_func):
'tanh': 'np.tanh(a)',
'neg': 'np.negative(a)',
'exp': 'np.exp(a)',
# 'sigmoid': '1/(1+np.exp(-a))',
'sigmoid': '1/(1+np.exp(-a))',
'sqrt': 'np.sqrt(a)',
'log': 'np.log(a)',
'abs': 'np.abs(a)',
Expand Down
19 changes: 0 additions & 19 deletions tensorflow/tools/cocl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,3 @@ filegroup(
name = "empty",
srcs = [],
)

cc_binary(
name = "testcu",
srcs = [
'test/testcu.cu.cc',
],
linkopts = [
'-lcocl',
'-lOpenCL',
],
deps = [
"@cocl//:cocl-headers",
"@usr_local_lib//:libcocl",
"@usr_lib_x8664linux//:libopencl",
],
copts = [
'-x', 'cuda',
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PREFIX_DIR = os.path.dirname(GCC_HOST_COMPILER_PATH)
# COCL_PATH = '/usr/local/bin/cocl'
COCL_PATH = CURRENT_DIR + '/../../../../../third_party/cuda-on-cl/bin/cocl'
# print('COCL_PATH', COCL_PATH)
bazel_rc_path = CURRENT_DIR + '/../../../../../tools/bazel.rc'


def Log(s):
Expand Down Expand Up @@ -234,12 +235,19 @@ def InvokeNvcc(argv, log=False):
for include in add_includes:
includes_string += ' -I%s' % include

with open(bazel_rc_path, 'r') as f:
bazelrc_contents = f.read()
cocl_options = []
for line in bazelrc_contents.split('\n'):
if line.startswith('build --define COCL_OPTIONS='):
cocl_options = line.split('=')[1].split(';')

# print('compiling srcs [%s] to out [%s]' % (str(srcs), str(out)))
cmd = (COCL_PATH + ' ' + nvccopts +
# ' --compiler-options "' + host_compiler_options + ' -fPIC"' +
' ' + includes_string + ' ' +
' --compiler-bindir=' + GCC_HOST_COMPILER_PATH +
' -I . ' +
' -I . ' + ' '.join(cocl_options) + ' ' +
'-fPIC ' +
' -x cu ' + opt + includes + ' -c ' + out + ' ' + srcs)
# print('cmd', cmd)
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/tools/pip_package/build_pip_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function main() {
cp third_party/cuda-on-cl/build/libcocl.so ${TMPDIR}/tensorflow/third_party/cuda-on-cl/
cp third_party/cuda-on-cl/build/libeasycl.so ${TMPDIR}/tensorflow/third_party/cuda-on-cl/
cp third_party/cuda-on-cl/build/libclew.so ${TMPDIR}/tensorflow/third_party/cuda-on-cl/
cp third_party/cuda-on-cl/build/clblast/libclblast.so ${TMPDIR}/tensorflow/third_party/cuda-on-cl/
cp third_party/cuda-on-cl/build/libclblast.so ${TMPDIR}/tensorflow/third_party/cuda-on-cl/
touch ${TMPDIR}/tensorflow/third_party/__init__.py
touch ${TMPDIR}/tensorflow/third_party/cuda-on-cl/__init__.py
cp tensorflow/tools/pip_package/MANIFEST.in ${TMPDIR}
Expand Down
4 changes: 2 additions & 2 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ cc_library(
":cuda-on-cl/build/libclew.so",
":cuda-on-cl/build/libeasycl.so",
":cuda-on-cl/build/libcocl.so",
":cuda-on-cl/build/clblast/libclblast.so",
":cuda-on-cl/build/libclblast.so",
],
srcs = [
'cuda-on-cl/build/libclew.so',
'cuda-on-cl/build/libeasycl.so',
'cuda-on-cl/build/libcocl.so',
'cuda-on-cl/build/clblast/libclblast.so',
'cuda-on-cl/build/libclblast.so',
],
hdrs = glob([
'cuda-on-cl/src/EasyCL/thirdparty/clew/include/clew.h',
Expand Down
2 changes: 1 addition & 1 deletion third_party/cuda-on-cl
1 change: 1 addition & 0 deletions tools/bazel.rc.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
build:cuda --define=using_cuda=true --define=using_cuda_nvcc=true

build --crosstool_top=//tensorflow/tools/cocl:toolchain
build --define COCL_OPTIONS=--devicell-opt;inline;--devicell-opt;mem2reg;--devicell-opt;instcombine;--devicell-opt;O2
build --force_python=py$PYTHON_MAJOR_VERSION
build --host_force_python=py$PYTHON_MAJOR_VERSION
build --python$PYTHON_MAJOR_VERSION_path=$PYTHON_BINARY
Expand Down

0 comments on commit 8d2ac50

Please sign in to comment.