3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
8 from caffe2.python
import schema
9 from caffe2.python.layers.layers
import (
17 def __init__(self, model, input_record, axis=1,
18 name='concat', **kwargs):
19 super(Concat, self).__init__(model, name, input_record, **kwargs)
22 "Incorrect input type. Excpected Struct, but received: {0}".\
26 for field_name, field_type
in input_record.fields.items():
28 "Incorrect input type for {}. Excpected Scalar, but got: {}".\
29 format(field_name, field_type)
32 assert len(field_type.field_type().shape) >= axis,\
33 "Concat expects that limited dimensions of the input tensor" 34 shapes.append(list(field_type.field_type().shape))
38 concat_dim += shape[axis - 1]
40 assert shape == shapes[0],\
41 "Shapes {0} and {1} are not compatible for Concat".\
42 format(shape, shapes[0])
43 output_dims = shapes[0]
44 output_dims[axis - 1] = concat_dim
47 (np.float32, output_dims),
48 model.net.NextScopedBlob(name +
'_output'))
50 def add_ops(self, net):