-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wisse
committed
Dec 3, 2024
1 parent
27c0dfa
commit cbd224d
Showing
7 changed files
with
70 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ import ( | |
) | ||
|
||
var AcosVersions = ops.OperatorVersions{ | ||
7: ops.NewOperatorConstructor(newAcos(7)), | ||
7: newAcos, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package acosh | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/advancedclimatesystems/gonnx/onnx" | ||
"github.com/advancedclimatesystems/gonnx/ops" | ||
"gorgonia.org/tensor" | ||
) | ||
|
||
// Acosh represents the ONNX acosh operator. | ||
type Acosh struct { | ||
ops.BaseOperator | ||
} | ||
|
||
// newAcosh creates a new acosh operator. | ||
func newAcosh() ops.Operator { | ||
return &Acosh{ | ||
BaseOperator: ops.NewBaseOperator(9, 1, 1, [][]tensor.Dtype{{tensor.Float32, tensor.Float64}}, "acosh"), | ||
} | ||
} | ||
|
||
// Init initializes the acosh operator. | ||
func (c *Acosh) Init(*onnx.NodeProto) error { | ||
return nil | ||
} | ||
|
||
// Apply applies the acosh operator. | ||
func (c *Acosh) Apply(inputs []tensor.Tensor) ([]tensor.Tensor, error) { | ||
var ( | ||
out tensor.Tensor | ||
err error | ||
) | ||
|
||
switch inputs[0].Dtype() { | ||
case tensor.Float32: | ||
out, err = inputs[0].Apply(acosh[float32]) | ||
case tensor.Float64: | ||
out, err = inputs[0].Apply(acosh[float64]) | ||
default: | ||
return nil, ops.ErrInvalidInputType(0, inputs[0].Dtype().String(), c.BaseOperator) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []tensor.Tensor{out}, nil | ||
} | ||
|
||
func acosh[T ops.FloatType](x T) T { | ||
return T(math.Acosh(float64(x))) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ import ( | |
) | ||
|
||
var AcoshVersions = ops.OperatorVersions{ | ||
9: newAcosh9, | ||
9: newAcosh, | ||
} |