File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
torch_numerics/elementwise Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ import torch
2+ from cvxpy .expressions .expression import Expression
3+
4+
5+ class sin :
6+ @staticmethod
7+ def torch_numeric (expr : Expression , values : list [torch .Tensor ]) -> torch .Tensor :
8+ return torch .sin (values [0 ])
9+
10+ class cos :
11+ @staticmethod
12+ def torch_numeric (expr : Expression , values : list [torch .Tensor ]) -> torch .Tensor :
13+ return torch .cos (values [0 ])
Original file line number Diff line number Diff line change 160160 minimum : minimum_tch .torch_numeric ,
161161 power : power_tch .torch_numeric ,
162162 xexp : xexp_tch .torch_numeric ,
163- }
163+ }
164+
165+ try :
166+ # Atoms from cvxpy-ipopt
167+ from cvxpy .atoms .elementwise .trig import sin
168+ from cvxpy .atoms .elementwise .trig import cos
169+ from cvxtorch .torch_numerics .elementwise .trig import sin_tch
170+ from cvxtorch .torch_numerics .elementwise .trig import cos_tch
171+ EXPR2TORCH .extend ({
172+ sin : sin_tch .torch_numeric ,
173+ cos : cos_tch .torch_numeric ,
174+ })
175+ except ImportError :
176+ pass
177+
178+
You can’t perform that action at this time.
0 commit comments