本文整理汇总了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]]