Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Uselessly spends time materializing tensor proto that will never be used #79

Open
ezyang opened this issue Dec 1, 2017 · 0 comments
Open

Comments

@ezyang
Copy link
Collaborator

ezyang commented Dec 1, 2017

In backend.py:

        # Caffe2 predictor requires all input blobs (including the
        # real model inputs) are initialized in init_net
        for value_info in graph_def.input:
            if value_info.name in initialized:
                continue
            op_def = caffe2_pb2.OperatorDef()
            op_def.output.extend([value_info.name])
            op_def.type = 'GivenTensorFill'

            shape = list(d.dim_value for d in value_info.type.tensor_type.shape.dim)
            # TODO: Putting this in the init net will make it run faster, but it
            # causes some tests to fail...
            # shape = (1,)

            shape_arg = op_def.arg.add()
            shape_arg.name = 'shape'
            shape_arg.ints.extend(shape)

            values_arg = op_def.arg.add()
            values_arg.name = 'values'
            values_arg.floats.extend(np.ones(shape).flatten().tolist())

            init_net.op.extend([op_def])

This is pretty pointless (we never actually use the values from the init net) AND it's really expensive (because we materialize a tensor proto for the inputs.) The shape hack used to work by Caffe2 rejects it now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant