提交 98640b2f 编写于 作者: M Macrobull

float decimal

上级 30be2502
...@@ -88,8 +88,8 @@ parser.add_argument( ...@@ -88,8 +88,8 @@ parser.add_argument(
parser.add_argument( parser.add_argument(
'--precision', '--precision',
'-p', '-p',
type=int, type=float,
default=3, default=3.,
help='assertion decimal for validation', help='assertion decimal for validation',
) )
args = parser.parse_args() args = parser.parse_args()
......
...@@ -85,7 +85,7 @@ def main(**kwargs): ...@@ -85,7 +85,7 @@ def main(**kwargs):
# in fact fluid can not fully clear the context # in fact fluid can not fully clear the context
# continuous validation may be inaccurate # continuous validation may be inaccurate
decimal = kwargs.get('precision', 3) decimal = kwargs.get('precision', 3.)
logger.info('starting validation on desc ...') logger.info('starting validation on desc ...')
passed &= validate( passed &= validate(
......
...@@ -77,11 +77,11 @@ DEFAULT_OP_MAPPING = { ...@@ -77,11 +77,11 @@ DEFAULT_OP_MAPPING = {
'Sqrt': ['sqrt', ['X'], ['Out']], 'Sqrt': ['sqrt', ['X'], ['Out']],
'Tanh': ['tanh', ['X'], ['Out']], 'Tanh': ['tanh', ['X'], ['Out']],
'ThresholdedRelu': ['thresholded_relu', ['X'], ['Out'], dict(alpha='threshold')], 'ThresholdedRelu': ['thresholded_relu', ['X'], ['Out'], dict(alpha='threshold')],
# 'Transpose': ['transpose', ['X'], ['Out']], #'Transpose': ['transpose', ['X'], ['Out']],
'Unsqueeze': ['unsqueeze', ['X'], ['Out']], # attrs bypassed, FIXME: emit unsqueeze2 'Unsqueeze': ['unsqueeze', ['X'], ['Out']], # attrs bypassed, FIXME: emit unsqueeze2
## binary ops ## ## binary ops ##
'Add': ['elementwise_add', ['X', 'Y'], ['Out'], dict(), dict(axis=-1)], 'Add': ['elementwise_add', ['X', 'Y'], ['Out'], dict(), dict(axis=-1)],
# 'AffineGrid': ['affine_grid', ['Theta'], ['Output'], dict(size='out_shape')], #'AffineGrid': ['affine_grid', ['Theta'], ['Output'], dict(size='out_shape')],
'And': ['logical_and', ['X', 'Y'], ['Out']], 'And': ['logical_and', ['X', 'Y'], ['Out']],
'Div': ['elementwise_div', ['X', 'Y'], ['Out'], dict(), dict(axis=-1)], 'Div': ['elementwise_div', ['X', 'Y'], ['Out'], dict(), dict(axis=-1)],
'Equal': ['equal', ['X', 'Y'], ['Out'], dict(), dict(), None, None, False], 'Equal': ['equal', ['X', 'Y'], ['Out'], dict(), dict(), None, None, False],
...@@ -110,7 +110,7 @@ DEFAULT_OP_MAPPING = { ...@@ -110,7 +110,7 @@ DEFAULT_OP_MAPPING = {
'TopK': ['topk', ['X', 'K'], ['Out', 'Indices']], 'TopK': ['topk', ['X', 'K'], ['Out', 'Indices']],
} }
DEFAULT_IOA_CONSTRAINT = { DEFAULT_IOA_CONSTRAINTS = {
'ArgMax': [ 'ArgMax': [
(lambda i, o, a: a.get('keepdims', 1) == 1, (lambda i, o, a: a.get('keepdims', 1) == 1,
'only keepdims = 0 is supported'), 'only keepdims = 0 is supported'),
...@@ -217,8 +217,8 @@ def _default(prog, op_type, inputs, outputs, attrs, *args, name='', **kwargs): ...@@ -217,8 +217,8 @@ def _default(prog, op_type, inputs, outputs, attrs, *args, name='', **kwargs):
fill_name_field, fill_name_field,
) = info ) = info
if fluid_op in DEFAULT_IOA_CONSTRAINT: if fluid_op in DEFAULT_IOA_CONSTRAINTS:
for predicate, message in DEFAULT_IOA_CONSTRAINT[fluid_op]: for predicate, message in DEFAULT_IOA_CONSTRAINTS[fluid_op]:
assert predicate(inputs, outputs, attrs), message assert predicate(inputs, outputs, attrs), message
# bypass if key absent, drop if mapped key is '' or '_' # bypass if key absent, drop if mapped key is '' or '_'
...@@ -552,7 +552,6 @@ def _roi_pool(prog, fluid_op, inputs, outputs, attrs, value_infos, name): ...@@ -552,7 +552,6 @@ def _roi_pool(prog, fluid_op, inputs, outputs, attrs, value_infos, name):
def _interpolate(prog, inputs, outputs, attrs, value_infos, name=''): def _interpolate(prog, inputs, outputs, attrs, value_infos, name=''):
# I/O # I/O
val_x, val_scales = inputs val_x, val_scales = inputs
val_y, = outputs val_y, = outputs
......
...@@ -40,7 +40,7 @@ def validate(fluid_model_filename, ...@@ -40,7 +40,7 @@ def validate(fluid_model_filename,
decimal=3, decimal=3,
save_inference_model=False): save_inference_model=False):
""" """
inferece the converted Paddle fluid model, validate with given golden data inference the converted Paddle fluid model, validate with given golden data
""" """
import numpy as np import numpy as np
...@@ -165,8 +165,8 @@ if __name__ == '__main__': ...@@ -165,8 +165,8 @@ if __name__ == '__main__':
parser.add_argument( parser.add_argument(
'--precision', '--precision',
'-p', '-p',
type=int, type=float,
default=3, default=3.,
help='assertion decimal for validation', help='assertion decimal for validation',
) )
args = parser.parse_args() args = parser.parse_args()
......
...@@ -176,16 +176,13 @@ class Program(object): ...@@ -176,16 +176,13 @@ class Program(object):
self.op_descs = [] self.op_descs = []
self.var_descs = [] self.var_descs = []
def __str__(self): def __repr__(self):
return ('Program(code mutable: {}) with:\n' return ('Program(code mutable: {}) with:\n'
'codes: {}\n' 'codes: {}\n'
'op_descs: {}\n' 'op_descs: {}\n'
'var_descs: {}\n').format(self.code_mutable, self.codes, 'var_descs: {}\n').format(self.code_mutable, self.codes,
self.op_descs, self.var_descs) self.op_descs, self.var_descs)
def __repr__(self):
return self.__str__()
def Code(self, code): def Code(self, code):
""" """
add Python code add Python code
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册