Rewrite knn by using builtins.
Merge pull request #202 from fegin/master

Rewrite knn by using builtins.