data = hmarray.random((32, 3, 224, 224), _range=(0, 255)) data.sync_ocl() return data num_trials = 10 hm_time = 0 caffe_time = 0 # warmup for _ in range(2): data = get_data() forward(data) caffe_net.forward_all(data=data) data = get_data() cl.clFinish(queue) for i in range(num_trials): start = time.clock() forward(data) hm_time += time.clock() - start start = time.clock() caffe_net.forward_all(data=data) caffe_time += time.clock() - start import hmcaffe.proto.caffe_pb2 as pb from google.protobuf import text_format net_param = pb.NetParameter() with open(prototxt, "rb") as f:
caffe_net.forward_all(data=data) for blob_name in caffe_net.blobs.keys(): blob = globals()[blob_name] blob.sync_host() if "_diff" in blob_name: continue print("Checking blob {}".format(blob_name)) caffe_blob = caffe_net.blobs[blob_name].data np.testing.assert_array_almost_equal(blob, caffe_blob, decimal=1) caffe_prob = caffe_net.blobs['prob'].data prob.sync_host() np.testing.assert_array_almost_equal(prob, caffe_prob, decimal=4) data = get_data() cl.clFinish(queues[0]) for i in range(num_trials): start = time.clock() forward(data) hm_time += time.clock() - start start = time.clock() caffe_net.forward_all(data=data) caffe_time += time.clock() - start # for blob_name in caffe_net.blobs.keys(): # blob = globals()[blob_name] # blob.sync_host() # if "_diff" in blob_name: # continue # print("Checking blob {}".format(blob_name)) # caffe_blob = caffe_net.blobs[blob_name].data
caffe_net.forward_all(data=data) for blob_name in caffe_net.blobs.keys(): blob = globals()[blob_name] blob.sync_host() if "_diff" in blob_name: continue print ("Checking blob {}".format(blob_name)) caffe_blob = caffe_net.blobs[blob_name].data np.testing.assert_array_almost_equal(blob, caffe_blob, decimal=1) caffe_prob = caffe_net.blobs["prob"].data prob.sync_host() np.testing.assert_array_almost_equal(prob, caffe_prob, decimal=4) data = get_data() cl.clFinish(queues[0]) for i in range(num_trials): start = time.clock() forward(data) hm_time += time.clock() - start start = time.clock() caffe_net.forward_all(data=data) caffe_time += time.clock() - start # for blob_name in caffe_net.blobs.keys(): # blob = globals()[blob_name] # blob.sync_host() # if "_diff" in blob_name: # continue # print("Checking blob {}".format(blob_name)) # caffe_blob = caffe_net.blobs[blob_name].data