Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 92 additions & 23 deletions facto/specdb/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
)
),
Expand Down Expand Up @@ -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
)
),
],
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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=[
Expand Down Expand Up @@ -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
)
),
],
Expand Down Expand Up @@ -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)],
),
Expand Down Expand Up @@ -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)],
),
Expand Down