diff --git a/facto/specdb/db.py b/facto/specdb/db.py index 93a45cd..677a93e 100644 --- a/facto/specdb/db.py +++ b/facto/specdb/db.py @@ -6,9 +6,10 @@ import math +import torch + import facto.specdb.function as fn import facto.utils.dtypes as dt -import torch from facto.inputgen.argument.type import ArgType from facto.inputgen.specs.model import ( ConstraintProducer as cp, @@ -705,7 +706,14 @@ Spec( op="acos.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Ge(lambda deps, dtype, struct: -1.0), + cp.Value.Le(lambda deps, dtype, struct: 1.0), + ], + ), ], outspec=[ OutArg(ArgType.Tensor), @@ -714,7 +722,13 @@ Spec( op="acosh.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Ge(lambda deps, dtype, struct: 1.0), + ], + ), ], outspec=[ OutArg(ArgType.Tensor), @@ -1175,7 +1189,14 @@ Spec( op="asin.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Ge(lambda deps, dtype, struct: -1.0), + cp.Value.Le(lambda deps, dtype, struct: 1.0), + ], + ), ], outspec=[ OutArg(ArgType.Tensor), @@ -1231,7 +1252,14 @@ Spec( op="atanh.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: -1.0), + cp.Value.Lt(lambda deps, dtype, struct: 1.0), + ], + ), ], outspec=[ OutArg(ArgType.Tensor), @@ -2069,10 +2097,9 @@ cp.Value.Ne( lambda deps, dtype, struct: ( 0 - if (deps[0].numel() > 0 and math.prod(struct) > 0) + if deps[0].numel() > 0 + and math.prod(struct) > 0 and deps[1] is not None - and torch.promote_types(deps[0].dtype, dtype) - not in dt._floating else None ) ), @@ -2348,10 +2375,7 @@ cp.Value.Ne( lambda deps, dtype, struct: ( 0 - if (deps[0].numel() > 0 and math.prod(struct) > 0) - and torch.promote_types(deps[0].dtype, dtype) - not in dt._floating - else None + if deps[0].numel() > 0 and math.prod(struct) > 0 else None ) ), ], @@ -2795,7 +2819,13 @@ Spec( op="log.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: 0.0), + ], + ), ], outspec=[ OutArg( @@ -2810,7 +2840,13 @@ Spec( op="log10.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: 0.0), + ], + ), ], outspec=[ OutArg( @@ -2825,7 +2861,13 @@ Spec( op="log1p.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: -1.0), + ], + ), ], outspec=[ OutArg( @@ -2840,7 +2882,13 @@ Spec( op="log2.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: 0.0), + ], + ), ], outspec=[ OutArg( @@ -2913,7 +2961,19 @@ Spec( op="logit.default", # (Tensor self, float? eps=None) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + deps=[1], + constraints=[ + cp.Value.Ge( + lambda deps, dtype, struct: 0.0 if deps[0] is None else None + ), + cp.Value.Le( + lambda deps, dtype, struct: 1.0 if deps[0] is None else None + ), + ], + ), InPosArg(ArgType.FloatOpt, name="eps"), ], outspec=[ @@ -4136,10 +4196,7 @@ cp.Value.Ne( lambda deps, dtype, struct: ( 0 - if (deps[0].numel() > 0 and math.prod(struct) > 0) - and torch.promote_types(deps[0].dtype, dtype) - not in dt._floating - else None + if deps[0].numel() > 0 and math.prod(struct) > 0 else None ) ), ], @@ -4453,7 +4510,13 @@ Spec( op="rsqrt.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Gt(lambda deps, dtype, struct: 0.0), + ], + ), ], outspec=[OutArg(ArgType.Tensor)], ), @@ -5029,7 +5092,13 @@ Spec( op="sqrt.default", # (Tensor self) -> Tensor inspec=[ - InPosArg(ArgType.Tensor, name="self"), + InPosArg( + ArgType.Tensor, + name="self", + constraints=[ + cp.Value.Ge(lambda deps, dtype, struct: 0.0), + ], + ), ], outspec=[OutArg(ArgType.Tensor)], ),