ehw-fit / tf-approximate Goto Github PK
View Code? Open in Web Editor NEWApproximate layers - TensorFlow extension
License: MIT License
Approximate layers - TensorFlow extension
License: MIT License
Hi, my name is Michele,
thanks for your open-source code. I was looking for a solution for a project and the tf1 library seems to be a great one. Unfortunately, I encountered some problems compiling the library:
axmult.o: axmult.cc
g++ -std=c++14 $^ -c -o $@
axqconv.so: axqconv.cc axmult.cc axmult.h approximate_selector.h
g++ -std=c++14 -Wno-ignored-attributes -Wno-deprecated-declarations -shared $(filter-out %.h, $^) -o $@ -fPIC ${TF_CFLAGS} ${TF_LFLAGS} -O2
Could you help me? :)
Hello,
Thanks for old reply for my issue. I try my addition unit and observe the result. I see error rate cause high error rates for the network. So, I want to train network wit approximate unit.
Is it possible in this framework? Could you do such thing?
Thanks in advance,
Hi,
Thank you for your opening source very much.
I'd like to test the accuracy with my own approximate multipliers. Therefore, I wonder how to generate the multiplication table file.
Dear authors, Thank you for making your idea open source. I looked through the issues raised earlier and could not find similar points raised.
I was going through the repository and saw that we tested the results for 8-bit multipliers. However, for my work, I require 32-bit floating point multipliers. As per my understanding, two changes will be needed. Could you please let me know what more changes might need to be made? Thanks in advance!
FILE * f = fopen("output.bin", "wb");
for(unsigned int a = 0; a < (2^32); a++)
for(unsigned int b = 0; b < (2^32); b++) {
long val = approximate_mult(a, b); // replace by your own function call
fwrite(&val, sizeof(uint16_t), 1, f);
}
fclose(f);
In file python/keras/layers/fake_approx_convolutional.py:
When registering gradient for approximate convolution layer you should replace:
@ops.RegisterGradient("FakeApproxConv2D")
with
@tf.RegisterGradient("ApproxConv2DWithMinMaxVars")
RegisterGradient function takes name of the TF operator not the layer.
Greetings
Ratko
Hi, my name is John Zhou. I really appreciate that you could open source. When I ran the Makefile in the tf1 fold, there was a error as follow:
(tensorflow) zhouhang@zhouhangdeMacBook-Pro axqconv % make
(echo "//automatically generated by makefile" ; cat axmult/mul8u_125K.c axmult/mul8u_12N4.c axmult/mul8u_13QR.c axmult/mul8u_1446.c axmult/mul8u_14VP.c axmult/mul8u_150Q.c axmult/mul8u_17C8.c axmult/mul8u_17KS.c axmult/mul8u_17QU.c axmult/mul8u_185Q.c axmult/mul8u_18DU.c axmult/mul8u_199Z.c axmult/mul8u_19DB.c axmult/mul8u_1AGV.c axmult/mul8u_1JFF.c axmult/mul8u_2AC.c axmult/mul8u_2HH.c axmult/mul8u_2P7.c axmult/mul8u_7C1.c axmult/mul8u_96D.c axmult/mul8u_CK5.c axmult/mul8u_DM1.c axmult/mul8u_EXZ.c axmult/mul8u_FTA.c axmult/mul8u_GS2.c axmult/mul8u_JQQ.c axmult/mul8u_JV3.c axmult/mul8u_KEM.c axmult/mul8u_L40.c axmult/mul8u_NGR.c axmult/mul8u_PKY.c axmult/mul8u_QJD.c axmult/mul8u_QKX.c axmult/mul8u_Y48.c axmult/mul8u_YX7.c axmult/mul8u_ZFB.c) > axmult.cc
python generate_header.py axmult.cc > axmult.h
g++ -std=c++11 -Wno-ignored-attributes -shared axqconv.cc axmult.cc -o axqconv.so -fPIC -O2
axqconv.cc:25:10: fatal error: 'tensorflow/core/framework/op_kernel.h' file not
found
#include "tensorflow/core/framework/op_kernel.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [axqconv.so] Error 1
I think that maybe the version of tensorflow or install environment result in the error. Anaconda + Python3.7 + Tensorflow2.1 is my environment. And I checked out the path, /Users/zhouhang/Anaconda3/anaconda3/envs/tensorflow/lib/python3.7/site-packages/tensorflow_core/core/framework
, op_kernel.h could not be found.
Could you tell me how you build your environment, including python version, tensorflow version and so on. Thank you so much.
Hi, I was wondering if approx_nn_conv_ops_ref.cpp needs to be edited and then, the libApproxGPUOpsTF.so need to be created again if we want to make any changes in the convolution. It seems like in line 300 of this file, prodValueQ is meant for storing the approximate multiplication result in convolution.
I tried to make some changes in convolution there and run the cmake and make commands again but its quite strange that no changes affect the accuracy.
Hi, my name is hai-hai
Thank you for your opening source very much.
I tried to work on resnet54, but found that aproximate result is greatly affect when the kernel=(1 ,1), such as FakeApproxConv2D(kernel_size=(1,1)), I want to know whether the convolution behavior is defined when kernel=(1, 1).
Look forward to your answer and best wish
Hello,
First of all thanks for your work. This is important framework for who work approximate units. However, is there any chance or guidance to change only addition to approximate addition. I checked your code and it is made multiplication in axqconv.cc line:242.
If I change total addition with
" total +=
axm -
static_cast(input_source_value) * filter_offset -
static_cast(filter_source_value) * input_offset +
input_offset * filter_offset;"
with approximate addition, is this a proper change?
Thanks in advance.
Hi,
I am trying to download the singularity container for the GPU implementation.
Unfortunately, after 30 minutes of downloading the download stops with the following message:
FATAL: While pulling from image from http(s): context deadline exceeded (Client.Timeout or context cancellation while reading body)
I tried looking at my singularity.conf file but cannot find a timeout configuration for the client.
Hi! I tried to use the singularity container with the following command on Ubuntu 20.04 (installed inside Windows machine).
singularity shell -H $(pwd) --nv --bind . ../../tf-approximate-gpu.sif
However, it generates the following warnings and error:
WARNING: failed to set O_CLOEXEC flags on image
WARNING: failed to set O_CLOEXEC flags on image
ERROR : Failed to set securebits: Invalid
ERROR : Failed to set securebits: Invalid argument
It would be great if you could help in resolving this issue.
Great Work! Just some questions. For the gradient part, I did not see the actual implementation for gradient operation, but only register using official implementation. If I missed it, please correct me. In this case, are you using approximation only in forwarding stage? Thanks.
Hi,
I run the script as follow:
$mkdir build
$cd build
$cmake -DTFAPPROX_ALLOW_GPU_CONV=OFF ..
$make
and it succeeds finally, just with some warmings(when $make).
......
[100%] Linking CXX shared library libApproxGPUOpsTF.dylib
[100%] Built target ApproxGPUOpsTF
But I could not find where libApproxGPUOpsTF.so is?
The folder ‘build’ contains
CMakeCache.txt ,Makefile , containers ,src ,
CMakeFiles , cmake_install.cmake, libApproxGPUOpsTF.dylib.
hello, I want to express my gratitude for sharing your open source code. I came across your project while searching for solutions related to approximate multipliers, and I'm eager to incorporate your code into my work.
Given my specific requirements, I prefer not to rely on libraries that include pre-built multipliers. Could you kindly provide guidance on how I can effectively integrate your code into my project?
Hi, my name is John.
Thank for your opening source. In your code, the quantization of weight and activation are both UINT8[0, 255] , so unsigned 88 multipilers are used. If I would like to quantize the weight and activation to [-127, 127], using the signed 88 multipliers, how to adjust the code could achieve the aim?Thanks again.
Greetings,
I tried to build FakeApproxConv2D from source files in Singularity and Docker container which are based on tensorflow/tensorflow:2.1.0-gpu-py3 image. In both cases build passes but I get low accuracy while classifying MNIST dataset using script examples/examples/fake_approx_eval.py. On the other hand, if I use prebuilt singularity container, everything works well. Unfortunatelly, cmake isn't installed in published singularity container.
FATAL: container creation failed: mount error: can't mount image /proc/self/fd/9: failed to mount squashfs filesystem: invalid argument.
I have python 3.8 and singularity 3.0.3 installed
Hi,
I just wanted to install the tf approx, but I couldn't do that, as I got the error on this link:
"https://ehw.fit.vutbr.cz/tf-approximate/tf-approximate-gpu.sif"
Would you please help us for this purpose?
Thanks alot.
Salar Shakibhamedan
Ph.D. Student,
ICT Group
TU Wien.
Hi my name is moh.
Thank for your opening source. I followed the steps you gave to build the environment, but the result is incorrect when using GPU for evaluation, and the result is correct when using CPU evaluation.
Hello,
while trying to install the tf2 version of tf-approximate I ran into a dead link:
singularity pull https://ehw.fit.vutbr.cz/tf-approximate/tf-approximate-gpu.sif
# or wget command can be used
wget https://ehw.fit.vutbr.cz/tf-approximate/tf-approximate-gpu.sif
# or just download the file using web browser
wont work as the link to the .sif file is broken and does not work anymore.
Additionally, Singularity (which now seems to be called Apptainer) has its own broken installation and is not available in the Debian/Ubuntu apt repositories.
I'm kindly asking for a re-upload.
Furthermore, installing from source is not fully explained, as for example the make command currently gives me errors regarding missing or changed parameters of used functions (I assume the API has changed over time and thus is only compatible to certain tensorflow verisons). That could be circumvented if the container is available.
Hence, currently it is a bit difficult to get tf-approximate running. I'm welcome for any hints of what I can try to get it running too.
Hi! I want to build TFapprox with tensorflow 2.3 but it gives me error with cmake. I was wondering what could be the other requirements for building the environment with tensorflow 2.3. I mean, cuda, cudnn, cmake, GCC etc. versions?
Looking forward to your response.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.