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.