Efficient Implementation of Stochastic Inference on Heterogeneous Clusters and Spiking Neural Networks