def conv_transpose(x, kernel, output_shape, strides, padding, data_format, dilation_rate): # Keras gives every dim on the output_shape, but PlaidML expects to infer the channel dims; so restrict to spatial dims data_format = _normalize_data_format(data_format) if data_format == 'nxc': output_shape = output_shape[1:-1] elif data_format == 'ncx': output_shape = output_shape[2:] else: raise ValueError('Could not parse data_format "{}"'.format(data_format)) rank = x.tensor.shape.ndims - 2 if strides is None: strides = tuple(1 for _ in range(rank)) if dilation_rate is None: dilation_rate = tuple(1 for _ in range(rank)) return _KerasNode( 'conv', tensor=plaidml_op.convolution( x.tensor, kernel.tensor, strides, dilation_rate, [1] * len(strides), [], 1, _normalize_padding(padding), [], data_format, 'xck', 'none', False, # winograd_allowed cur_name(), 'ungrouped', 'data', output_shape))
def conv_transpose(x, kernel, output_shape, strides, padding, data_format, dilation_rate): logger.debug( 'conv_transpose(x: {}, kernel: {}, output_shape: {}, strides: {}, padding: {}, data_format: {}, dilation_rate: {}' .format(x, kernel, output_shape, strides, padding, data_format, dilation_rate)) # Keras gives every dim on the output_shape, but PlaidML expects to infer the channel dims; so restrict to spatial dims data_format = _normalize_data_format(data_format) if data_format == 'nxc': output_shape = output_shape[1:-1] elif data_format == 'ncx': output_shape = output_shape[2:] else: raise ValueError("Could not parse data_format '{}'".format(data_format)) return _KerasNode( 'conv', tensor=plaidml_op.convolution( x.tensor, kernel.tensor, strides, dilation_rate, [1] * len(strides), [], 1, _normalize_padding(padding), [], data_format, 'xck', 'none', False, # winograd_allowed cur_name(), 'ungrouped', 'data', output_shape))
def conv(x, kernel, strides=None, padding='valid', data_format=None, dilation_rate=None, channelwise=False): if channelwise: group_layout = 'in_C' autogroup_mode = 'max' else: group_layout = 'none' autogroup_mode = 'ungrouped' return _KerasNode( 'conv', tensor=plaidml_op.convolution( x.tensor, kernel.tensor, strides, dilation_rate, [1] * len(strides), [], 1, _normalize_padding(padding), [], _normalize_data_format(data_format), 'xck', group_layout, False, # winograd_allowed cur_name(), autogroup_mode, 'none', []))