-
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.
POC: new design for multiple operator versions
- Loading branch information
wisse
committed
Dec 3, 2024
1 parent
8100156
commit a7eb0a9
Showing
12 changed files
with
449 additions
and
317 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,55 @@ | ||
package ops | ||
|
||
import ( | ||
"fmt" | ||
|
||
"gorgonia.org/tensor" | ||
) | ||
|
||
// Concrete implementation for shared operator methods | ||
type BaseOperator struct { | ||
name string | ||
version int | ||
minInputs int | ||
maxInputs int | ||
inputTypeConstraints [][]tensor.Dtype | ||
} | ||
|
||
func NewBaseOperator(version, minInputs, maxInputs int, inputTypeConstraints [][]tensor.Dtype, name string) BaseOperator { | ||
return BaseOperator{ | ||
name: name, | ||
version: version, | ||
minInputs: minInputs, | ||
maxInputs: maxInputs, | ||
inputTypeConstraints: inputTypeConstraints, | ||
} | ||
} | ||
|
||
// ValidateInputs validates the inputs for the operator. | ||
func (f BaseOperator) ValidateInputs(inputs []tensor.Tensor) ([]tensor.Tensor, error) { | ||
return ValidateInputs(f, inputs) | ||
} | ||
|
||
// Version returns the | ||
func (f BaseOperator) Version() int { | ||
return f.version | ||
} | ||
|
||
// GetMinInputs returns the minimum number of input tensors. | ||
func (f BaseOperator) GetMinInputs() int { | ||
return f.minInputs | ||
} | ||
|
||
// GetMaxInputs returns the maximum number of input tensors. | ||
func (f BaseOperator) GetMaxInputs() int { | ||
return f.maxInputs | ||
} | ||
|
||
// GetInputTypeConstraints returns allowed input types. | ||
func (f BaseOperator) GetInputTypeConstraints() [][]tensor.Dtype { | ||
return f.inputTypeConstraints | ||
} | ||
|
||
func (f BaseOperator) String() string { | ||
return fmt.Sprintf("%s v%d", f.name, f.version) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.