-
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.
Rewrote abs operator so it shares code
- Loading branch information
wisse
committed
Dec 3, 2024
1 parent
a7eb0a9
commit 1ae421c
Showing
5 changed files
with
160 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package abs | ||
|
||
import ( | ||
"github.com/advancedclimatesystems/gonnx/onnx" | ||
"github.com/advancedclimatesystems/gonnx/ops" | ||
"gorgonia.org/tensor" | ||
) | ||
|
||
var absTypeConstraint = [][]tensor.Dtype{ | ||
{tensor.Uint8, tensor.Uint16, tensor.Uint32, tensor.Uint64, tensor.Int8, tensor.Int16, tensor.Int32, tensor.Int64, tensor.Float32, tensor.Float64}, | ||
} | ||
|
||
// Abs represents the ONNX abs operator. | ||
type Abs struct { | ||
ops.BaseOperator | ||
} | ||
|
||
// newAbs creates a new abs operator. | ||
func newAbs(version int, typeConstraint [][]tensor.Dtype) *Abs { | ||
return &Abs{ | ||
BaseOperator: ops.NewBaseOperator( | ||
version, | ||
1, | ||
1, | ||
typeConstraint, | ||
"abs", | ||
), | ||
} | ||
} | ||
|
||
// Init initializes the abs operator. | ||
func (a *Abs) Init(*onnx.NodeProto) error { | ||
return nil | ||
} | ||
|
||
// Apply applies the abs operator. | ||
func (a *Abs) Apply(inputs []tensor.Tensor) ([]tensor.Tensor, error) { | ||
out, err := tensor.Abs(inputs[0]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []tensor.Tensor{out}, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.