Commit f9ba0db3 by Neo Chien Committed by Tianqi Chen

Align the naming rule for OpAttributeUnImplemented (#3695)

parent 163532bb
...@@ -78,7 +78,7 @@ def _darknet_maxpooling(inputs, attrs): ...@@ -78,7 +78,7 @@ def _darknet_maxpooling(inputs, attrs):
"""Process the max pool 2d operation.""" """Process the max pool 2d operation."""
kernel = parse_tshape(required_attr(attrs, 'kernel', 'maxpool')) kernel = parse_tshape(required_attr(attrs, 'kernel', 'maxpool'))
if len(kernel) != 1: if len(kernel) != 1:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels for Max Pooling are not supported in frontend Darknet.') 'Non-2D kernels for Max Pooling are not supported in frontend Darknet.')
op_name, new_attrs = 'max_pool2d', {} op_name, new_attrs = 'max_pool2d', {}
......
...@@ -32,7 +32,7 @@ def _rename(new_name): ...@@ -32,7 +32,7 @@ def _rename(new_name):
def _pooling(inputs, attrs): def _pooling(inputs, attrs):
kernel = parse_tshape(required_attr(attrs, 'kernel', 'pooling')) kernel = parse_tshape(required_attr(attrs, 'kernel', 'pooling'))
if len(kernel) != 2: if len(kernel) != 2:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for Pool2D.') 'Non-2D kernels are not supported for Pool2D.')
global_pool = 'global' if parse_bool_str(attrs, 'global_pool') else '' global_pool = 'global' if parse_bool_str(attrs, 'global_pool') else ''
pool_type = required_attr(attrs, 'pool_type', 'pooling') pool_type = required_attr(attrs, 'pool_type', 'pooling')
...@@ -52,7 +52,7 @@ def _pooling(inputs, attrs): ...@@ -52,7 +52,7 @@ def _pooling(inputs, attrs):
def _batch_norm(inputs, attrs): def _batch_norm(inputs, attrs):
if parse_bool_str(attrs, 'output_mean_var'): if parse_bool_str(attrs, 'output_mean_var'):
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Attribute "output_mean_var" is not supported in operator batch_norm.') 'Attribute "output_mean_var" is not supported in operator batch_norm.')
# if parse_bool_str(attrs, 'fix_gamma'): # if parse_bool_str(attrs, 'fix_gamma'):
# _warn_not_used('fix_gamma', 'batch_norm') # _warn_not_used('fix_gamma', 'batch_norm')
......
...@@ -84,7 +84,7 @@ def _dimension_picker(prefix, surfix=''): ...@@ -84,7 +84,7 @@ def _dimension_picker(prefix, surfix=''):
kernel = attr['kernel_shape'] kernel = attr['kernel_shape']
if len(kernel) == 2: if len(kernel) == 2:
return prefix + '2d' + surfix return prefix + '2d' + surfix
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for operator {}.'.format(prefix)) 'Non-2D kernels are not supported for operator {}.'.format(prefix))
return _impl return _impl
...@@ -177,7 +177,7 @@ def _pooling(name): ...@@ -177,7 +177,7 @@ def _pooling(name):
attr['padding'] = [pad_v[0], pad_h[0], pad_v[1], pad_h[1]] attr['padding'] = [pad_v[0], pad_h[0], pad_v[1], pad_h[1]]
else: else:
msg = 'Value {} in attribute "padding" of operator Pooling is not valid.' msg = 'Value {} in attribute "padding" of operator Pooling is not valid.'
raise tvm.error.OpAttributeUnimplemented(msg.format(attr['padding'])) raise tvm.error.OpAttributeUnImplemented(msg.format(attr['padding']))
if name == "avg_pool": if name == "avg_pool":
attr['count_include_pad'] = False attr['count_include_pad'] = False
......
...@@ -99,14 +99,14 @@ class OpAttributeInvalid(OpError, AttributeError): ...@@ -99,14 +99,14 @@ class OpAttributeInvalid(OpError, AttributeError):
@register_error @register_error
class OpAttributeUnimplemented(OpError, NotImplementedError): class OpAttributeUnImplemented(OpError, NotImplementedError):
"""Attribute is not supported in a certain frontend. """Attribute is not supported in a certain frontend.
Example Example
------- -------
.. code:: python .. code:: python
raise OpAttributeUnimplemented( raise OpAttributeUnImplemented(
"Attribute {} is not supported in operator {}".format( "Attribute {} is not supported in operator {}".format(
attr_name, op_name)) attr_name, op_name))
""" """
...@@ -33,7 +33,7 @@ def dimension_picker(prefix, surfix=''): ...@@ -33,7 +33,7 @@ def dimension_picker(prefix, surfix=''):
kernel = attr['kernel_shape'] kernel = attr['kernel_shape']
if len(kernel) == 2: if len(kernel) == 2:
return prefix + '2d' + surfix return prefix + '2d' + surfix
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for operator {}2d'.format(prefix)) 'Non-2D kernels are not supported for operator {}2d'.format(prefix))
return _impl return _impl
...@@ -244,7 +244,7 @@ class Concat(Caffe2OpConverter): ...@@ -244,7 +244,7 @@ class Concat(Caffe2OpConverter):
return 1 return 1
if order == 'NHWC': if order == 'NHWC':
return 3 return 3
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Order {} is not supported in operator Concat.'.format(order)) 'Order {} is not supported in operator Concat.'.format(order))
return AttrCvt( return AttrCvt(
......
...@@ -207,7 +207,7 @@ def _PoolingLayerParams(op, inexpr, etab): ...@@ -207,7 +207,7 @@ def _PoolingLayerParams(op, inexpr, etab):
else: else:
msg = 'PoolingPaddingType {} is not supported in operator Pooling.' msg = 'PoolingPaddingType {} is not supported in operator Pooling.'
op_name = op.WhichOneof('PoolingPaddingType') op_name = op.WhichOneof('PoolingPaddingType')
raise tvm.error.OpAttributeUnimplemented(msg.format(op_name)) raise tvm.error.OpAttributeUnImplemented(msg.format(op_name))
# consume padding layer # consume padding layer
if etab.in_padding: if etab.in_padding:
...@@ -280,7 +280,7 @@ def _PaddingLayerParams(op, inexpr, etab): ...@@ -280,7 +280,7 @@ def _PaddingLayerParams(op, inexpr, etab):
if op.WhichOneof('PaddingType') == 'constant': if op.WhichOneof('PaddingType') == 'constant':
constant = op.constant constant = op.constant
if constant.value != 0: if constant.value != 0:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'{} is not supported in operator Padding.'.format(constant.value)) '{} is not supported in operator Padding.'.format(constant.value))
padding = [b.startEdgeSize for b in op.paddingAmounts.borderAmounts] padding = [b.startEdgeSize for b in op.paddingAmounts.borderAmounts]
padding2 = [b.endEdgeSize for b in op.paddingAmounts.borderAmounts] padding2 = [b.endEdgeSize for b in op.paddingAmounts.borderAmounts]
......
...@@ -242,7 +242,7 @@ def _convert_convolution(inexpr, keras_layer, etab): ...@@ -242,7 +242,7 @@ def _convert_convolution(inexpr, keras_layer, etab):
else: else:
msg = 'Padding with {} is not supported for operator Convolution ' \ msg = 'Padding with {} is not supported for operator Convolution ' \
'in frontend Keras.' 'in frontend Keras.'
raise tvm.error.OpAttributeUnimplemented(msg.format(keras_layer.padding)) raise tvm.error.OpAttributeUnImplemented(msg.format(keras_layer.padding))
if is_deconv: if is_deconv:
out = _op.nn.conv2d_transpose(data=inexpr, **params) out = _op.nn.conv2d_transpose(data=inexpr, **params)
else: else:
...@@ -290,7 +290,7 @@ def _convert_separable_convolution(inexpr, keras_layer, etab): ...@@ -290,7 +290,7 @@ def _convert_separable_convolution(inexpr, keras_layer, etab):
else: else:
msg = 'Padding with {} is not supported for operator Separable ' \ msg = 'Padding with {} is not supported for operator Separable ' \
'Convolution in frontend Keras.' 'Convolution in frontend Keras.'
raise tvm.error.OpAttributeUnimplemented(msg.format(keras_layer.padding)) raise tvm.error.OpAttributeUnImplemented(msg.format(keras_layer.padding))
depthconv = _op.nn.conv2d(data=inexpr, **params0) depthconv = _op.nn.conv2d(data=inexpr, **params0)
# pointwise conv # pointwise conv
......
...@@ -143,7 +143,7 @@ def _mx_conv2d(inputs, attrs): ...@@ -143,7 +143,7 @@ def _mx_conv2d(inputs, attrs):
def _mx_conv2d_transpose(inputs, attrs): def _mx_conv2d_transpose(inputs, attrs):
if "target_shape" in attrs.attrs: if "target_shape" in attrs.attrs:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Attribute "target_shape" is not supported for operator Conv2D-transpose.') 'Attribute "target_shape" is not supported for operator Conv2D-transpose.')
kernel_size = attrs.get_int_tuple("kernel") kernel_size = attrs.get_int_tuple("kernel")
if len(kernel_size) != 2: if len(kernel_size) != 2:
...@@ -222,7 +222,7 @@ def _mx_BlockGrad(inputs, attrs): #pylint: disable=unused-argument ...@@ -222,7 +222,7 @@ def _mx_BlockGrad(inputs, attrs): #pylint: disable=unused-argument
def _mx_batch_norm(inputs, attrs): def _mx_batch_norm(inputs, attrs):
if attrs.get_bool("output_mean_var", False): if attrs.get_bool("output_mean_var", False):
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Attribute "output_mean_var" is not supported for operator Batch Norm.') 'Attribute "output_mean_var" is not supported for operator Batch Norm.')
if attrs.get_bool("use_global_stats", False): if attrs.get_bool("use_global_stats", False):
_warn_not_used("use_global_stats", "batch_norm") _warn_not_used("use_global_stats", "batch_norm")
......
...@@ -130,7 +130,7 @@ class AttrCvt(object): ...@@ -130,7 +130,7 @@ class AttrCvt(object):
new_attrs = {} new_attrs = {}
for k in attrs.keys(): for k in attrs.keys():
if k in self._excludes: if k in self._excludes:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Attribute {} in operator {} is not supported.'.format(k, op_name)) 'Attribute {} in operator {} is not supported.'.format(k, op_name))
elif k in self._disables: elif k in self._disables:
logging.warning("Attribute %s is disabled in relay.%s", k, op_name) logging.warning("Attribute %s is disabled in relay.%s", k, op_name)
...@@ -517,7 +517,7 @@ def _crop_and_resize(): ...@@ -517,7 +517,7 @@ def _crop_and_resize():
attrs['size'] = crop_size attrs['size'] = crop_size
attrs['layout'] = 'NHWC' attrs['layout'] = 'NHWC'
if method.lower() == 'nearest': if method.lower() == 'nearest':
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Attribute method=nearest is not supported') 'Attribute method=nearest is not supported')
else: else:
attrs['align_corners'] = True attrs['align_corners'] = True
......
...@@ -683,7 +683,7 @@ class OperatorConverter(object): ...@@ -683,7 +683,7 @@ class OperatorConverter(object):
(pad_left, pad_right), (pad_left, pad_right),
(0, 0))) (0, 0)))
else: else:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Padding format {} is not supported for operator Conv.'.format(padding)) 'Padding format {} is not supported for operator Conv.'.format(padding))
out = _op.nn.conv2d(data=in_expr, weight=weight_expr, **params) out = _op.nn.conv2d(data=in_expr, weight=weight_expr, **params)
...@@ -786,7 +786,7 @@ class OperatorConverter(object): ...@@ -786,7 +786,7 @@ class OperatorConverter(object):
pad_left, pad_right = get_pad_value(input_w, filter_w, stride_w) pad_left, pad_right = get_pad_value(input_w, filter_w, stride_w)
params['padding'] = [pad_top, pad_left, pad_bottom, pad_right] params['padding'] = [pad_top, pad_left, pad_bottom, pad_right]
else: else:
raise tvm.error.OpAttributeUnimplemented( raise tvm.error.OpAttributeUnImplemented(
'Padding format {} for operator Pool2D is not supported.'.format(padding)) 'Padding format {} for operator Pool2D is not supported.'.format(padding))
if pool_type == "average": if pool_type == "average":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment