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

float decimal

上级 30be2502
......@@ -88,8 +88,8 @@ parser.add_argument(
parser.add_argument(
'--precision',
'-p',
type=int,
default=3,
type=float,
default=3.,
help='assertion decimal for validation',
)
args = parser.parse_args()
......
......@@ -85,7 +85,7 @@ def main(**kwargs):
# in fact fluid can not fully clear the context
# continuous validation may be inaccurate
decimal = kwargs.get('precision', 3)
decimal = kwargs.get('precision', 3.)
logger.info('starting validation on desc ...')
passed &= validate(
......
......@@ -77,11 +77,11 @@ DEFAULT_OP_MAPPING = {
'Sqrt': ['sqrt', ['X'], ['Out']],
'Tanh': ['tanh', ['X'], ['Out']],
'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
## binary ops ##
'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']],
'Div': ['elementwise_div', ['X', 'Y'], ['Out'], dict(), dict(axis=-1)],
'Equal': ['equal', ['X', 'Y'], ['Out'], dict(), dict(), None, None, False],
......@@ -110,7 +110,7 @@ DEFAULT_OP_MAPPING = {
'TopK': ['topk', ['X', 'K'], ['Out', 'Indices']],
}
DEFAULT_IOA_CONSTRAINT = {
DEFAULT_IOA_CONSTRAINTS = {
'ArgMax': [
(lambda i, o, a: a.get('keepdims', 1) == 1,
'only keepdims = 0 is supported'),
......@@ -217,8 +217,8 @@ def _default(prog, op_type, inputs, outputs, attrs, *args, name='', **kwargs):
fill_name_field,
) = info
if fluid_op in DEFAULT_IOA_CONSTRAINT:
for predicate, message in DEFAULT_IOA_CONSTRAINT[fluid_op]:
if fluid_op in DEFAULT_IOA_CONSTRAINTS:
for predicate, message in DEFAULT_IOA_CONSTRAINTS[fluid_op]:
assert predicate(inputs, outputs, attrs), message
# 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):
def _interpolate(prog, inputs, outputs, attrs, value_infos, name=''):
# I/O
val_x, val_scales = inputs
val_y, = outputs
......
......@@ -40,7 +40,7 @@ def validate(fluid_model_filename,
decimal=3,
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
......@@ -165,8 +165,8 @@ if __name__ == '__main__':
parser.add_argument(
'--precision',
'-p',
type=int,
default=3,
type=float,
default=3.,
help='assertion decimal for validation',
)
args = parser.parse_args()
......
......@@ -176,16 +176,13 @@ class Program(object):
self.op_descs = []
self.var_descs = []
def __str__(self):
def __repr__(self):
return ('Program(code mutable: {}) with:\n'
'codes: {}\n'
'op_descs: {}\n'
'var_descs: {}\n').format(self.code_mutable, self.codes,
self.op_descs, self.var_descs)
def __repr__(self):
return self.__str__()
def Code(self, code):
"""
add Python code
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册