Exemple #1
0
def RunNetOnce(net):
    return C.run_net_once(StringfyProto(net))
Exemple #2
0
else:
    device_opts.device_type = caffe2_pb2.HIP
    device_opts.hip_gpu_id = 0
    print('Running on HIP')
    if use_gpu == 2:
        engine_list = ['MIOPEN', '']
        C.set_global_engine_pref({caffe2_pb2.HIP : engine_list})
        print('Using MIOPEN')

C.feed_blob('data', img, device_opts.SerializeToString())

init_def = caffe2_pb2.NetDef()
with open(INIT_NET, 'rb') as f:
    init_def.ParseFromString(f.read())
    init_def.device_option.CopyFrom(device_opts)
    C.run_net_once(init_def.SerializeToString())

net_def = caffe2_pb2.NetDef()
with open(PREDICT_NET, 'rb') as f:
    net_def.ParseFromString(f.read())
    net_def.device_option.CopyFrom(device_opts)
    C.create_net(net_def.SerializeToString())

C.feed_blob('data', img, device_opts.SerializeToString())
### Debug code
"""
for b in workspace.Blobs():
    x = workspace.FetchBlob(b)
    if type(x) != str:
        print(str(b) + ': ' + str(x.shape))