From ddd66ffad8a7b7ca9039831e1587a60dc7c3f8b5 Mon Sep 17 00:00:00 2001 From: Rodrigo De Castro Date: Fri, 30 Jan 2026 14:53:25 -0800 Subject: [PATCH 1/2] add spec for binary_cross_entropy_backward.default --- facto/specdb/db.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/facto/specdb/db.py b/facto/specdb/db.py index 6dda077..3854144 100644 --- a/facto/specdb/db.py +++ b/facto/specdb/db.py @@ -1298,6 +1298,56 @@ OutArg(ArgType.Tensor), ], ), + Spec( + op="binary_cross_entropy_backward.default", # (Tensor grad_output, Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean) -> Tensor + inspec=[ + InPosArg( + ArgType.Tensor, + name="grad_output", + constraints=[ + cp.Dtype.In(lambda deps: dt._floating), + ], + ), + InPosArg( + ArgType.Tensor, + name="self", + deps=[0], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[0].shape)), + cp.Size.Eq(lambda deps, r, d: deps[0].shape[d]), + ], + ), + InPosArg( + ArgType.Tensor, + name="target", + deps=[0, 1], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[1].shape)), + cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), + ], + ), + InPosArg( + ArgType.TensorOpt, + name="weight", + deps=[0, 1], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[1].shape)), + cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), + ], + ), + InPosArg( + ArgType.Int, + name="reduction", + constraints=[ + cp.Value.In(lambda deps: [0, 1, 2]), + ], + ), + ], + outspec=[OutArg(ArgType.Tensor)], + ), Spec( op="bitwise_and.Scalar", # (Tensor self, Scalar other) -> Tensor inspec=[ From 0de4764032dbe8202a369ead3be50e01d392b83d Mon Sep 17 00:00:00 2001 From: Rodrigo De Castro Date: Fri, 6 Feb 2026 15:32:21 -0800 Subject: [PATCH 2/2] Fix lint formatting issues --- facto/specdb/db.py | 96 +++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/facto/specdb/db.py b/facto/specdb/db.py index 3854144..a166944 100644 --- a/facto/specdb/db.py +++ b/facto/specdb/db.py @@ -1299,54 +1299,54 @@ ], ), Spec( - op="binary_cross_entropy_backward.default", # (Tensor grad_output, Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean) -> Tensor - inspec=[ - InPosArg( - ArgType.Tensor, - name="grad_output", - constraints=[ - cp.Dtype.In(lambda deps: dt._floating), - ], - ), - InPosArg( - ArgType.Tensor, - name="self", - deps=[0], - constraints=[ - cp.Dtype.Eq(lambda deps: deps[0].dtype), - cp.Rank.Eq(lambda deps: len(deps[0].shape)), - cp.Size.Eq(lambda deps, r, d: deps[0].shape[d]), - ], - ), - InPosArg( - ArgType.Tensor, - name="target", - deps=[0, 1], - constraints=[ - cp.Dtype.Eq(lambda deps: deps[0].dtype), - cp.Rank.Eq(lambda deps: len(deps[1].shape)), - cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), - ], - ), - InPosArg( - ArgType.TensorOpt, - name="weight", - deps=[0, 1], - constraints=[ - cp.Dtype.Eq(lambda deps: deps[0].dtype), - cp.Rank.Eq(lambda deps: len(deps[1].shape)), - cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), - ], - ), - InPosArg( - ArgType.Int, - name="reduction", - constraints=[ - cp.Value.In(lambda deps: [0, 1, 2]), - ], - ), - ], - outspec=[OutArg(ArgType.Tensor)], + op="binary_cross_entropy_backward.default", # (Tensor grad_output, Tensor self, Tensor target, Tensor? weight=None, int reduction=Mean) -> Tensor + inspec=[ + InPosArg( + ArgType.Tensor, + name="grad_output", + constraints=[ + cp.Dtype.In(lambda deps: dt._floating), + ], + ), + InPosArg( + ArgType.Tensor, + name="self", + deps=[0], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[0].shape)), + cp.Size.Eq(lambda deps, r, d: deps[0].shape[d]), + ], + ), + InPosArg( + ArgType.Tensor, + name="target", + deps=[0, 1], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[1].shape)), + cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), + ], + ), + InPosArg( + ArgType.TensorOpt, + name="weight", + deps=[0, 1], + constraints=[ + cp.Dtype.Eq(lambda deps: deps[0].dtype), + cp.Rank.Eq(lambda deps: len(deps[1].shape)), + cp.Size.Eq(lambda deps, r, d: deps[1].shape[d]), + ], + ), + InPosArg( + ArgType.Int, + name="reduction", + constraints=[ + cp.Value.In(lambda deps: [0, 1, 2]), + ], + ), + ], + outspec=[OutArg(ArgType.Tensor)], ), Spec( op="bitwise_and.Scalar", # (Tensor self, Scalar other) -> Tensor