Imported from https://github.com/ehw-fit/tf-approximate