caffe2/python/onnx/onnxifi.py
def onnxifi_caffe2_net(
        pred_net,
        input_shapes,
        populate_shapes=False,
        debug=False):
    """
    Transfrom the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
    """
    # Hacky way to infer shapes as not all our operators have shape inference function.
    # Normally this is not needed
    shape_hints = {}
    if populate_shapes:
        input_data = {}
        for k, v in input_shapes.items():
            input_data[k] = np.random.randn(*v).astype(np.float32)
        shape_hints = _infer_shapes(pred_net, input_data)

    for k, v in input_shapes.items():
        shape_hints[k] = v
    pred_net_str = C.onnxifi(pred_net.SerializeToString(),
                                       shape_hints,
                                       debug)
    pred_net_cut = caffe2_pb2.NetDef()
    pred_net_cut.ParseFromString(pred_net_str)
    return pred_net_cut

    Transfrom the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
    
Transfrom the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
Transfrom the caffe2_net by collapsing ONNXIFI - runnable nodes into Onnxifi c2 ops
def onnxifi_caffe2_net(
        pred_net,
        input_shapes,
        populate_shapes=False,
        debug=False):
    shape_hints = {}
    if populate_shapes:
        input_data = {}
        for k, v in input_shapes.items():
            input_data[k] = np.random.randn(*v).astype(np.float32)
        shape_hints = _infer_shapes(pred_net, input_data)
    for k, v in input_shapes.items():
        shape_hints[k] = v
    pred_net_str = C.onnxifi(pred_net.SerializeToString(),
                                       shape_hints,
                                       debug)
    pred_net_cut = caffe2_pb2.NetDef()
    pred_net_cut.ParseFromString(pred_net_str)
    return pred_net_cut
def onnxifi_caffe2_net ( pred_net , input_shapes , populate_shapes = False , debug = False ) : shape_hints = { } if populate_shapes : input_data = { } for k , v in input_shapes . items ( ) : input_data [ k ] = np . random . randn ( * v ) . astype ( np . float32 ) shape_hints = _infer_shapes ( pred_net , input_data ) for k , v in input_shapes . items ( ) : shape_hints [ k ] = v pred_net_str = C . onnxifi ( pred_net . SerializeToString ( ) , shape_hints , debug ) pred_net_cut = caffe2_pb2 . NetDef ( ) pred_net_cut . ParseFromString ( pred_net_str ) return pred_net_cut
Transfrom the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
Transfrom the caffe2_net by collapsing ONNXIFI - runnable nodes into Onnxifi c2 ops
"""
    Transfrom the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
    """ # Hacky way to infer shapes as not all our operators have shape inference function. # Normally this is not needed
pred_net
input_shapes
populate_shapes
debug