Skip to content

Commit

Permalink
Align the naming rule for OpAttributeUnImplemented (apache#3695)
Browse files Browse the repository at this point in the history
  • Loading branch information
cchung100m authored and wweic committed Sep 6, 2019
1 parent 8478940 commit 37ab0f2
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion nnvm/python/nnvm/frontend/darknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _darknet_maxpooling(inputs, attrs):
"""Process the max pool 2d operation."""
kernel = parse_tshape(required_attr(attrs, 'kernel', 'maxpool'))
if len(kernel) != 1:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels for Max Pooling are not supported in frontend Darknet.')

op_name, new_attrs = 'max_pool2d', {}
Expand Down
4 changes: 2 additions & 2 deletions nnvm/python/nnvm/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def impl(inputs, attrs):
def _pooling(inputs, attrs):
kernel = parse_tshape(required_attr(attrs, 'kernel', 'pooling'))
if len(kernel) != 2:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for Pool2D.')
global_pool = 'global' if parse_bool_str(attrs, 'global_pool') else ''
pool_type = required_attr(attrs, 'pool_type', 'pooling')
Expand All @@ -52,7 +52,7 @@ def _pooling(inputs, attrs):

def _batch_norm(inputs, attrs):
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.')
# if parse_bool_str(attrs, 'fix_gamma'):
# _warn_not_used('fix_gamma', 'batch_norm')
Expand Down
4 changes: 2 additions & 2 deletions nnvm/python/nnvm/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _impl(attr):
kernel = attr['kernel_shape']
if len(kernel) == 2:
return prefix + '2d' + surfix
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for operator {}.'.format(prefix))
return _impl

Expand Down Expand Up @@ -178,7 +178,7 @@ def _impl(inputs, attr, params):
attr['padding'] = [pad_v[0], pad_h[0], pad_v[1], pad_h[1]]
else:
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":
attr['count_include_pad'] = False
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ class OpAttributeInvalid(OpError, AttributeError):


@register_error
class OpAttributeUnimplemented(OpError, NotImplementedError):
class OpAttributeUnImplemented(OpError, NotImplementedError):
"""Attribute is not supported in a certain frontend.
Example
-------
.. code:: python
raise OpAttributeUnimplemented(
raise OpAttributeUnImplemented(
"Attribute {} is not supported in operator {}".format(
attr_name, op_name))
"""
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/caffe2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _impl(attr):
kernel = attr['kernel_shape']
if len(kernel) == 2:
return prefix + '2d' + surfix
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Non-2D kernels are not supported for operator {}2d'.format(prefix))

return _impl
Expand Down Expand Up @@ -244,7 +244,7 @@ def _get_axis_from_order_str(order):
return 1
if order == 'NHWC':
return 3
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Order {} is not supported in operator Concat.'.format(order))

return AttrCvt(
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/coreml.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _PoolingLayerParams(op, inexpr, etab):
else:
msg = 'PoolingPaddingType {} is not supported in operator Pooling.'
op_name = op.WhichOneof('PoolingPaddingType')
raise tvm.error.OpAttributeUnimplemented(msg.format(op_name))
raise tvm.error.OpAttributeUnImplemented(msg.format(op_name))

# consume padding layer
if etab.in_padding:
Expand Down Expand Up @@ -280,7 +280,7 @@ def _PaddingLayerParams(op, inexpr, etab):
if op.WhichOneof('PaddingType') == 'constant':
constant = op.constant
if constant.value != 0:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'{} is not supported in operator Padding.'.format(constant.value))
padding = [b.startEdgeSize for b in op.paddingAmounts.borderAmounts]
padding2 = [b.endEdgeSize for b in op.paddingAmounts.borderAmounts]
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _convert_convolution(inexpr, keras_layer, etab):
else:
msg = 'Padding with {} is not supported for operator Convolution ' \
'in frontend Keras.'
raise tvm.error.OpAttributeUnimplemented(msg.format(keras_layer.padding))
raise tvm.error.OpAttributeUnImplemented(msg.format(keras_layer.padding))
if is_deconv:
out = _op.nn.conv2d_transpose(data=inexpr, **params)
else:
Expand Down Expand Up @@ -290,7 +290,7 @@ def _convert_separable_convolution(inexpr, keras_layer, etab):
else:
msg = 'Padding with {} is not supported for operator Separable ' \
'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)
# pointwise conv
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _mx_conv2d(inputs, attrs):

def _mx_conv2d_transpose(inputs, 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.')
kernel_size = attrs.get_int_tuple("kernel")
if len(kernel_size) != 2:
Expand Down Expand Up @@ -222,7 +222,7 @@ def _mx_BlockGrad(inputs, attrs): #pylint: disable=unused-argument

def _mx_batch_norm(inputs, attrs):
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.')
if attrs.get_bool("use_global_stats", False):
_warn_not_used("use_global_stats", "batch_norm")
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __call__(self, inputs, attrs, *args):
new_attrs = {}
for k in attrs.keys():
if k in self._excludes:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Attribute {} in operator {} is not supported.'.format(k, op_name))
elif k in self._disables:
logging.warning("Attribute %s is disabled in relay.%s", k, op_name)
Expand Down Expand Up @@ -517,7 +517,7 @@ def _impl(inputs, attr, params):
attrs['size'] = crop_size
attrs['layout'] = 'NHWC'
if method.lower() == 'nearest':
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Attribute method=nearest is not supported')
else:
attrs['align_corners'] = True
Expand Down
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def convert_conv(self, op, conv_type):
(pad_left, pad_right),
(0, 0)))
else:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Padding format {} is not supported for operator Conv.'.format(padding))

out = _op.nn.conv2d(data=in_expr, weight=weight_expr, **params)
Expand Down Expand Up @@ -786,7 +786,7 @@ def convert_pool2d(self, op, pool_type):
pad_left, pad_right = get_pad_value(input_w, filter_w, stride_w)
params['padding'] = [pad_top, pad_left, pad_bottom, pad_right]
else:
raise tvm.error.OpAttributeUnimplemented(
raise tvm.error.OpAttributeUnImplemented(
'Padding format {} for operator Pool2D is not supported.'.format(padding))

if pool_type == "average":
Expand Down

0 comments on commit 37ab0f2

Please sign in to comment.