本文整理匯總了Python中caffe2.python.core.InjectDeviceCopiesAmongNets方法的典型用法代碼示例。如果您正苦於以下問題:Python core.InjectDeviceCopiesAmongNets方法的具體用法?Python core.InjectDeviceCopiesAmongNets怎麽用?Python core.InjectDeviceCopiesAmongNets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類caffe2.python.core
的用法示例。
在下文中一共展示了core.InjectDeviceCopiesAmongNets方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convert_model_gpu
# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import InjectDeviceCopiesAmongNets [as 別名]
def convert_model_gpu(args, net, init_net):
assert args.device == 'gpu'
ret_net = copy.deepcopy(net)
ret_init_net = copy.deepcopy(init_net)
cdo_cuda = mutils.get_device_option_cuda()
cdo_cpu = mutils.get_device_option_cpu()
CPU_OPS = [
["CollectAndDistributeFpnRpnProposals", None],
["GenerateProposals", None],
["BBoxTransform", None],
["BoxWithNMSLimit", None],
]
CPU_BLOBS = ["im_info", "anchor"]
@op_filter()
def convert_op_gpu(op):
for x in CPU_OPS:
if mutils.filter_op(op, type=x[0], inputs=x[1]):
return None
op.device_option.CopyFrom(cdo_cuda)
return [op]
@op_filter()
def convert_init_op_gpu(op):
if op.output[0] in CPU_BLOBS:
op.device_option.CopyFrom(cdo_cpu)
else:
op.device_option.CopyFrom(cdo_cuda)
return [op]
convert_op_in_proto(ret_init_net.Proto(), convert_init_op_gpu)
convert_op_in_proto(ret_net.Proto(), convert_op_gpu)
ret = core.InjectDeviceCopiesAmongNets([ret_init_net, ret_net])
return [ret[0][1], ret[0][0]]
示例2: convert_model_gpu
# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import InjectDeviceCopiesAmongNets [as 別名]
def convert_model_gpu(args, net, init_net):
assert args.device == 'gpu'
ret_net = copy.deepcopy(net)
ret_init_net = copy.deepcopy(init_net)
cdo_cuda = mutils.get_device_option_cuda()
cdo_cpu = mutils.get_device_option_cpu()
CPU_OPS = [
["GenerateProposals", None],
["BBoxTransform", None],
["BoxWithNMSLimit", None],
]
CPU_BLOBS = ["im_info", "anchor"]
@op_filter()
def convert_op_gpu(op):
for x in CPU_OPS:
if mutils.filter_op(op, type=x[0], inputs=x[1]):
return None
op.device_option.CopyFrom(cdo_cuda)
return [op]
@op_filter()
def convert_init_op_gpu(op):
if op.output[0] in CPU_BLOBS:
op.device_option.CopyFrom(cdo_cpu)
else:
op.device_option.CopyFrom(cdo_cuda)
return [op]
convert_op_in_proto(ret_init_net.Proto(), convert_init_op_gpu)
convert_op_in_proto(ret_net.Proto(), convert_op_gpu)
ret = core.InjectDeviceCopiesAmongNets([ret_init_net, ret_net])
return [ret[0][1], ret[0][0]]
示例3: convert_model_gpu
# 需要導入模塊: from caffe2.python import core [as 別名]
# 或者: from caffe2.python.core import InjectDeviceCopiesAmongNets [as 別名]
def convert_model_gpu(args, net, init_net):
assert args.device == "gpu"
ret_net = copy.deepcopy(net)
ret_init_net = copy.deepcopy(init_net)
cdo_cuda = mutils.get_device_option_cuda()
cdo_cpu = mutils.get_device_option_cpu()
CPU_OPS = [
["CollectAndDistributeFpnRpnProposals", None],
["GenerateProposals", None],
["BBoxTransform", None],
["BoxWithNMSLimit", None],
]
CPU_BLOBS = ["im_info", "anchor"]
@op_filter()
def convert_op_gpu(op):
for x in CPU_OPS:
if mutils.filter_op(op, type=x[0], inputs=x[1]):
return None
op.device_option.CopyFrom(cdo_cuda)
return [op]
@op_filter()
def convert_init_op_gpu(op):
if op.output[0] in CPU_BLOBS:
op.device_option.CopyFrom(cdo_cpu)
else:
op.device_option.CopyFrom(cdo_cuda)
return [op]
convert_op_in_proto(ret_init_net.Proto(), convert_init_op_gpu)
convert_op_in_proto(ret_net.Proto(), convert_op_gpu)
ret = core.InjectDeviceCopiesAmongNets([ret_init_net, ret_net])
return [ret[0][1], ret[0][0]]