Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Swopper050 committed Dec 2, 2024
1 parent 5a6800d commit aea9bcf
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 100 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test_ci: ## Run tests using normal test runner for ci output.

test_data: ## Creates test data from the ONNX test module.
rm -R ./test_data; mkdir ./test_data; touch ./test_data/
git clone --depth 1 --branch v1.15.0 https://github.com/onnx/onnx.git temp_onnx
git clone --depth 1 --branch v1.17.0 https://github.com/onnx/onnx.git temp_onnx
cp -r temp_onnx/onnx/backend/test/data/node/* ./test_data
rm -Rf temp_onnx

Expand Down
2 changes: 1 addition & 1 deletion ops/constant/constant_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (c *Constant1) Init(n *onnx.NodeProto) error {
attr := attributes[0]

switch attr.GetName() {
case "value":
case value:

Check failure on line 29 in ops/constant/constant_1.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: value

Check failure on line 29 in ops/constant/constant_1.go

View workflow job for this annotation

GitHub Actions / tests

undefined: value

Check failure on line 29 in ops/constant/constant_1.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: value

Check failure on line 29 in ops/constant/constant_1.go

View workflow job for this annotation

GitHub Actions / lint

undefined: value
t, err := onnx.TensorFromProto(attr.GetT())
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions ops/constant/constant_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func (c *Constant11) Init(n *onnx.NodeProto) error {
attr := attributes[0]

switch attr.GetName() {
case "sparse_value":
case sparseValue:

Check failure on line 30 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / tests

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sparseValue
return ops.ErrUnsupportedAttribute(attr.GetName(), c)
case "value":
case value:

Check failure on line 32 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: value

Check failure on line 32 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / tests

undefined: value

Check failure on line 32 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: value

Check failure on line 32 in ops/constant/constant_11.go

View workflow job for this annotation

GitHub Actions / lint

undefined: value
t, err := onnx.TensorFromProto(attr.GetT())
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions ops/constant/constant_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ func (c *Constant12) Init(n *onnx.NodeProto) error {
attr := attributes[0]

switch attr.GetName() {
case "sparse_value", "value_string", "value_strings":
case sparseValue, valueString, valueStrings:

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: valueString

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: valueStrings

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: valueString

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: valueStrings

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: valueString

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: valueStrings

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sparseValue

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: valueString

Check failure on line 30 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: valueStrings
return ops.ErrUnsupportedAttribute(attr.GetName(), c)
case "value":
case value:

Check failure on line 32 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: value

Check failure on line 32 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: value

Check failure on line 32 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: value

Check failure on line 32 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: value
t, err := onnx.TensorFromProto(attr.GetT())
if err != nil {
return err
}

c.value = t
case "value_float":
case valueFloat:

Check failure on line 39 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: valueFloat

Check failure on line 39 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: valueFloat

Check failure on line 39 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: valueFloat

Check failure on line 39 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: valueFloat
c.value = tensor.New(tensor.FromScalar(attr.GetF()))
case "value_floats":
case valueFloats:

Check failure on line 41 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: valueFloats

Check failure on line 41 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: valueFloats

Check failure on line 41 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: valueFloats

Check failure on line 41 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / lint

undefined: valueFloats
floats := attr.GetFloats()
c.value = tensor.New(tensor.WithShape(len(floats)), tensor.WithBacking(floats))
case "value_int":
case valueInt:

Check failure on line 44 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_amd64

undefined: valueInt

Check failure on line 44 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / tests

undefined: valueInt

Check failure on line 44 in ops/constant/constant_12.go

View workflow job for this annotation

GitHub Actions / build_arm64

undefined: valueInt
c.value = tensor.New(tensor.FromScalar(attr.GetI()))
case "value_ints":
case valueInts:
ints := attr.GetInts()
c.value = tensor.New(tensor.WithShape(len(ints)), tensor.WithBacking(ints))
default:
Expand Down
12 changes: 6 additions & 6 deletions ops/constant/constant_13.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ func (c *Constant13) Init(n *onnx.NodeProto) error {
attr := attributes[0]

switch attr.GetName() {
case "sparse_value", "value_string", "value_strings":
case sparseValue, valueString, valueStrings:
return ops.ErrUnsupportedAttribute(attr.GetName(), c)
case "value":
case value:
t, err := onnx.TensorFromProto(attr.GetT())
if err != nil {
return err
}

c.value = t
case "value_float":
case valueFloat:
c.value = tensor.New(tensor.FromScalar(attr.GetF()))
case "value_floats":
case valueFloats:
floats := attr.GetFloats()
c.value = tensor.New(tensor.WithShape(len(floats)), tensor.WithBacking(floats))
case "value_int":
case valueInt:
c.value = tensor.New(tensor.FromScalar(attr.GetI()))
case "value_ints":
case valueInts:
ints := attr.GetInts()
c.value = tensor.New(tensor.WithShape(len(ints)), tensor.WithBacking(ints))
default:
Expand Down
2 changes: 1 addition & 1 deletion ops/constant/constant_9.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (c *Constant9) Init(n *onnx.NodeProto) error {
attr := attributes[0]

switch attr.GetName() {
case "value":
case value:
t, err := onnx.TensorFromProto(attr.GetT())
if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion ops/flatten/flatten_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newFlatten1() ops.Operator {
func (f *Flatten1) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "axis":
case axis:
f.axis = int(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), f)
Expand All @@ -40,6 +40,7 @@ func (f *Flatten1) Init(n *onnx.NodeProto) error {
// Apply applies the flatten operator.
func (f *Flatten1) Apply(inputs []tensor.Tensor) ([]tensor.Tensor, error) {
inputShape := inputs[0].Shape()

out, ok := inputs[0].Clone().(tensor.Tensor)
if !ok {
return nil, ops.ErrTypeAssert("tensor.Tensor", inputs[0].Clone())
Expand Down
2 changes: 1 addition & 1 deletion ops/flatten/flatten_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newFlatten11() ops.Operator {
func (f *Flatten11) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "axis":
case axis:
f.axis = int(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), f)
Expand Down
2 changes: 1 addition & 1 deletion ops/flatten/flatten_13.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newFlatten13() ops.Operator {
func (f *Flatten13) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "axis":
case axis:
f.axis = int(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), f)
Expand Down
3 changes: 2 additions & 1 deletion ops/flatten/flatten_9.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newFlatten9() ops.Operator {
func (f *Flatten9) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "axis":
case axis:
f.axis = int(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), f)
Expand All @@ -40,6 +40,7 @@ func (f *Flatten9) Init(n *onnx.NodeProto) error {
// Apply applies the flatten operator.
func (f *Flatten9) Apply(inputs []tensor.Tensor) ([]tensor.Tensor, error) {
inputShape := inputs[0].Shape()

out, ok := inputs[0].Clone().(tensor.Tensor)
if !ok {
return nil, ops.ErrTypeAssert("tensor.Tensor", inputs[0].Clone())
Expand Down
2 changes: 1 addition & 1 deletion ops/gather/gather_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (g *Gather1) Init(n *onnx.NodeProto) error {
if len(attributes) == 1 {
attr := attributes[0]

if attr.GetName() == "axis" {
if attr.GetName() == axis {
g.axis = int(attr.GetI())
} else {
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
2 changes: 1 addition & 1 deletion ops/gather/gather_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (g *Gather11) Init(n *onnx.NodeProto) error {
if len(attributes) == 1 {
attr := attributes[0]

if attr.GetName() == "axis" {
if attr.GetName() == axis {
g.axis = int(attr.GetI())
} else {
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
2 changes: 1 addition & 1 deletion ops/gather/gather_13.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (g *Gather13) Init(n *onnx.NodeProto) error {
if len(attributes) == 1 {
attr := attributes[0]

if attr.GetName() == "axis" {
if attr.GetName() == axis {
g.axis = int(attr.GetI())
} else {
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
8 changes: 4 additions & 4 deletions ops/gemm/gemm_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func newGemm11() ops.Operator {
func (g *Gemm11) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "alpha":
case alpha:
g.alpha = attr.GetF()
case "beta":
case beta:
g.beta = attr.GetF()
case "transA":
case transA:
g.transA = ops.Int64ToBool(attr.GetI())
case "transB":
case transB:
g.transB = ops.Int64ToBool(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
8 changes: 4 additions & 4 deletions ops/gemm/gemm_13.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func newGemm13() ops.Operator {
func (g *Gemm13) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "alpha":
case alpha:
g.alpha = attr.GetF()
case "beta":
case beta:
g.beta = attr.GetF()
case "transA":
case transA:
g.transA = ops.Int64ToBool(attr.GetI())
case "transB":
case transB:
g.transB = ops.Int64ToBool(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
8 changes: 4 additions & 4 deletions ops/gemm/gemm_7.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func newGemm7() ops.Operator {
func (g *Gemm7) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "alpha":
case alpha:
g.alpha = attr.GetF()
case "beta":
case beta:
g.beta = attr.GetF()
case "transA":
case transA:
g.transA = ops.Int64ToBool(attr.GetI())
case "transB":
case transB:
g.transB = ops.Int64ToBool(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
8 changes: 4 additions & 4 deletions ops/gemm/gemm_9.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func newGemm9() ops.Operator {
func (g *Gemm9) Init(n *onnx.NodeProto) error {
for _, attr := range n.GetAttribute() {
switch attr.GetName() {
case "alpha":
case alpha:
g.alpha = attr.GetF()
case "beta":
case beta:
g.beta = attr.GetF()
case "transA":
case transA:
g.transA = ops.Int64ToBool(attr.GetI())
case "transB":
case transB:
g.transB = ops.Int64ToBool(attr.GetI())
default:
return ops.ErrInvalidAttribute(attr.GetName(), g)
Expand Down
2 changes: 1 addition & 1 deletion ops/matmul/matmul_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (m *MatMul1) GetInputTypeConstraints() [][]tensor.Dtype {

// String implements the stringer interface, and can be used to format errors or messages.
func (m *MatMul1) String() string {
return "matmul13 operator"
return "matmul1 operator"
}

// broadcastTensors broadcasts both tensors for the matmul operator. It is almost identical
Expand Down
2 changes: 1 addition & 1 deletion ops/matmul/matmul_9.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (m *MatMul9) GetInputTypeConstraints() [][]tensor.Dtype {

// String implements the stringer interface, and can be used to format errors or messages.
func (m *MatMul9) String() string {
return "matmul13 operator"
return "matmul9 operator"
}

// broadcastTensors broadcasts both tensors for the matmul operator. It is almost identical
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemax/reduce_max_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMax1) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemax/reduce_max_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMax11) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemax/reduce_max_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMax12) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemax/reduce_max_13.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMax13) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemin/reduce_min_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMin1) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemin/reduce_min_11.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMin11) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
4 changes: 2 additions & 2 deletions ops/reducemin/reduce_min_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func (r *ReduceMin12) Init(n *onnx.NodeProto) error {

for _, attr := range attributes {
switch attr.GetName() {
case "axes":
case axes:
axes, err := ops.AnyToIntSlice(attr.GetInts())
if err != nil {
return err
}

r.axes = axes
case "keepdims":
case keepDims:
r.keepDims = attr.GetI() == 1
default:
return ops.ErrInvalidAttribute(attr.GetName(), r)
Expand Down
Loading

0 comments on commit aea9bcf

Please sign in to comment.