serde.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:ngraph 作者: NervanaSystems 项目源码 文件源码
def _serialize_graph(ops):
    """
    Serializes a graph and returns the actual protobuf python object (rather than serialized
    byte string as done by `serialize_graph`).
    """
    assert isinstance(ops, Iterable), "Ops passed into `serialize_graph` must be an iterable"
    ops = Op.all_op_references(ops)

    pb_ops = []
    pb_edges = []
    for op in ops:
        pb_ops.append(op_to_protobuf(op))
        add_edges(pb_edges, pb_ops, op)

    graph_def = ops_pb.GraphDef()
    for edge in pb_edges:
        temp = graph_def.edges.add()
        temp.CopyFrom(edge)
    for op in pb_ops:
        temp = graph_def.ops.add()
        temp.CopyFrom(op)
    return graph_def
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号