From f265e82722cdb38a4c3997c2763c41e7818d3138 Mon Sep 17 00:00:00 2001 From: Jan Pfeifer Date: Tue, 27 Aug 2024 12:07:03 +0200 Subject: [PATCH 1/4] Removed some panics and dependency to github.com/gomlx/exceptions from dtypes. --- dtypes/dtypes.go | 40 +++++++++++++++++++++++++++++----------- dtypes/dtypes_test.go | 23 +++++++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 dtypes/dtypes_test.go diff --git a/dtypes/dtypes.go b/dtypes/dtypes.go index 2464621..c65c044 100644 --- a/dtypes/dtypes.go +++ b/dtypes/dtypes.go @@ -1,14 +1,30 @@ package dtypes import ( - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/dtypes/bfloat16" + "github.com/pkg/errors" "github.com/x448/float16" "math" "reflect" "strconv" ) +// panicf panics with formatted description. +// +// It is only used for "bugs in the code" -- when parameters don't follow the specifications. +// In principle it should never happen -- the same way nil-pointer panics should never happen. +func panicf(format string, args ...any) { + panic(errors.Errorf(format, args...)) +} + +func init() { + // Only works for 32 and 64 bits platforms. + // TODO: find some compile-time check. + if strconv.IntSize != 32 && strconv.IntSize != 64 { + panicf("cannot use int of %d bits with gopjrt -- only platforms with int32 or int64 are supported", strconv.IntSize) + } +} + // Generate automatic C-to-Go boilerplate code for pjrt_c_api.h. //go:generate go run ../cmd/dtypes_codegen @@ -31,7 +47,7 @@ func FromGenericsType[T Supported]() DType { case 64: return Int64 default: - exceptions.Panicf("Cannot use int of %d bits with gopjrt -- try using int32 or int64", strconv.IntSize) + panicf("Cannot use int of %d bits with gopjrt -- try using int32 or int64", strconv.IntSize) } case int64: return Int64 @@ -75,7 +91,7 @@ func FromGoType(t reflect.Type) DType { case 64: return Int64 default: - exceptions.Panicf("cannot use int of %d bits with GoMLX -- try using int32 or int64", strconv.IntSize) + panicf("cannot use int of %d bits with GoMLX -- try using int32 or int64", strconv.IntSize) } case reflect.Int64: return Int64 @@ -177,8 +193,10 @@ func (dtype DType) GoType() reflect.Type { return reflect.TypeOf(complex128(0)) default: - exceptions.Panicf("unknown dtype %q (%d) in DType.GoType", dtype, dtype) - panic(nil) // Quiet lint warning. + // This should never happen, except if someone entered an invalid DType number beyond the values + // defined. + panicf("unknown dtype %q (%d) in DType.GoType", dtype, dtype) + panic(nil) } } @@ -224,9 +242,9 @@ func (dtype DType) LowestValue() any { return bfloat16.Inf(-1) default: - exceptions.Panicf("LowestValue for dtype %s not defined", dtype) + // For invalid dtypes (like complex numbers), return zero. + return reflect.New(dtype.GoType()).Elem().Interface() } - return 0 // Never reaches here. } // HighestValue for dtype converted to the corresponding Go type. @@ -265,9 +283,9 @@ func (dtype DType) HighestValue() any { return bfloat16.Inf(1) default: - exceptions.Panicf("LowestValue for dtype %s not defined", dtype) + // For invalid dtypes (like complex numbers), return zero. + return reflect.New(dtype.GoType()).Elem().Interface() } - return 0 // Never reaches here. } // SmallestNonZeroValueForDType is the smallest non-zero value dtypes. @@ -307,8 +325,8 @@ func (dtype DType) SmallestNonZeroValueForDType() any { return bfloat16.SmallestNonzero // 1p-24, see discussion in https://github.com/x448/float16/pull/46 default: - exceptions.Panicf("SmallestNonZeroValueForDType not defined for dtype %s", dtype) - panic(nil) // Removes lint warning. + // For invalid dtypes (like complex numbers), return zero. + return reflect.New(dtype.GoType()).Elem().Interface() } } diff --git a/dtypes/dtypes_test.go b/dtypes/dtypes_test.go new file mode 100644 index 0000000..fec8990 --- /dev/null +++ b/dtypes/dtypes_test.go @@ -0,0 +1,23 @@ +package dtypes + +import ( + "github.com/gomlx/gopjrt/dtypes/bfloat16" + "github.com/stretchr/testify/require" + "github.com/x448/float16" + "math" + "testing" +) + +func TestDType_HighestLowestSmallestValues(t *testing.T) { + require.True(t, math.IsInf(Float64.HighestValue().(float64), 1)) + require.True(t, math.IsInf(float64(Float32.LowestValue().(float32)), -1)) + _, ok := Float16.SmallestNonZeroValueForDType().(float16.Float16) + require.True(t, ok) + _, ok = BFloat16.SmallestNonZeroValueForDType().(bfloat16.BFloat16) + require.True(t, ok) + + // Complex numbers don't define Highest of Lowest, and instead return 0 + require.Equal(t, complex64(0), Complex64.HighestValue().(complex64)) + require.Equal(t, complex128(0), Complex128.LowestValue().(complex128)) + require.Equal(t, complex64(0), Complex64.SmallestNonZeroValueForDType().(complex64)) +} From 9d49024d2a7ff510519ac6bd28b91ee8c161fc62 Mon Sep 17 00:00:00 2001 From: Jan Pfeifer Date: Tue, 27 Aug 2024 12:07:36 +0200 Subject: [PATCH 2/4] Improve to documentation. --- xlabuilder/shape.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xlabuilder/shape.go b/xlabuilder/shape.go index b0bc04f..dbda736 100644 --- a/xlabuilder/shape.go +++ b/xlabuilder/shape.go @@ -33,7 +33,8 @@ type Shape struct { } // MakeShape filled with the values given. -// It doesn't work for tuple shapes. +// +// The dimensions must be >= 1, and it doesn't work for tuple shapes. func MakeShape(dtype dtypes.DType, dimensions ...int) Shape { s := Shape{Dimensions: slices.Clone(dimensions), DType: dtype} for _, dim := range dimensions { From 3b0298274cab9d379e0460b403bd06378fa5be0f Mon Sep 17 00:00:00 2001 From: Jan Pfeifer Date: Tue, 27 Aug 2024 12:19:55 +0200 Subject: [PATCH 3/4] Removed dependency on github.com/gomlx/exceptions. --- cmd/dtypes_codegen/enums.go | 12 ++++++++++-- cmd/xlabuilder_codegen/main.go | 12 ++++++++++-- docs/coverage.out | 31 ++++++++++++++++--------------- dtypes/dtypes.go | 2 +- go.mod | 2 -- go.sum | 4 ---- pjrt/loadedexecutables.go | 3 +-- pjrt/pjrt.go | 10 ++++++++++ xlabuilder/literal.go | 9 ++------- xlabuilder/shape.go | 3 +-- xlabuilder/special_ops.go | 5 ++--- xlabuilder/xlabuilder.go | 11 +++++++++-- xlabuilder/xlacomputation.go | 5 ++--- 13 files changed, 64 insertions(+), 45 deletions(-) diff --git a/cmd/dtypes_codegen/enums.go b/cmd/dtypes_codegen/enums.go index cd7fb96..4333439 100644 --- a/cmd/dtypes_codegen/enums.go +++ b/cmd/dtypes_codegen/enums.go @@ -2,9 +2,9 @@ package main import ( "fmt" - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/protos/xla_data" "github.com/janpfeifer/must" + "github.com/pkg/errors" "os" "os/exec" "regexp" @@ -17,6 +17,14 @@ const ( DTypeEnumGoFileName = "gen_dtype_enum.go" ) +// panicf panics with formatted description. +// +// It is only used for "bugs in the code" -- when parameters don't follow the specifications. +// In principle, it should never happen -- the same way nil-pointer panics should never happen. +func panicf(format string, args ...any) { + panic(errors.Errorf(format, args...)) +} + var aliases = map[string]string{ "INVALID": "InvalidDType", "PRED": "Bool", @@ -121,7 +129,7 @@ func generateEnums(contents string) { var enumV *enumValue matches := reEnums.FindStringSubmatch(contents) if len(matches) == 0 { - exceptions.Panicf("failed to match PJRT_Buffer_Types enum from pjrt_c_api.h") + panicf("failed to match PJRT_Buffer_Types enum from pjrt_c_api.h") } for _, line := range strings.Split(matches[2], "\n") { if line == "" { diff --git a/cmd/xlabuilder_codegen/main.go b/cmd/xlabuilder_codegen/main.go index 7b3194c..31b1e45 100644 --- a/cmd/xlabuilder_codegen/main.go +++ b/cmd/xlabuilder_codegen/main.go @@ -4,8 +4,8 @@ package main import ( "bufio" "fmt" - "github.com/gomlx/exceptions" "github.com/janpfeifer/must" + "github.com/pkg/errors" "os" "strings" ) @@ -17,6 +17,14 @@ type OpInfo struct { Comments []string } +// panicf panics with formatted description. +// +// It is only used for "bugs in the code" -- when parameters don't follow the specifications. +// In principle, it should never happen -- the same way nil-pointer panics should never happen. +func panicf(format string, args ...any) { + panic(errors.Errorf(format, args...)) +} + func main() { // Read op_types.xt opsInfo := make([]OpInfo, 0, 200) @@ -40,7 +48,7 @@ func main() { } parts := strings.Split(line, ":") if len(parts) != 2 { - exceptions.Panicf("Invalid op definition in %q:%d : %q", OpTypesFileName, lineNum, line) + panicf("Invalid op definition in %q:%d : %q", OpTypesFileName, lineNum, line) } if len(comments) == 0 { comments = append(comments, fmt.Sprintf("%s returns the Op that represents the output of the corresponding operation.", parts[0])) diff --git a/docs/coverage.out b/docs/coverage.out index b75db28..caf395c 100644 --- a/docs/coverage.out +++ b/docs/coverage.out @@ -90,24 +90,25 @@ github.com/gomlx/gopjrt/pjrt/gen_chelper.go:62: cMallocArrayAndSet 100.0% github.com/gomlx/gopjrt/pjrt/gen_chelper.go:73: cDataToSlice 100.0% github.com/gomlx/gopjrt/pjrt/gen_chelper.go:79: cCharArray 100.0% github.com/gomlx/gopjrt/pjrt/gen_chelper.go:86: cStrFree 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:37: newLoadedExecutable 64.7% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:67: Destroy 91.7% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:86: destroyOrLog 66.7% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:94: getExecutable 80.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:122: Execute 100.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:152: OnDevices 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:187: OnDevicesByNum 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:211: DonateAll 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:220: DonateNone 100.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:234: Donate 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:245: SetDonate 0.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:262: Done 88.6% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:319: allocatePerDeviceBufferList 88.9% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:339: freePerDeviceBufferList 100.0% -github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:348: gatherPerDeviceBufferList 100.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:36: newLoadedExecutable 64.7% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:66: Destroy 91.7% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:85: destroyOrLog 66.7% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:93: getExecutable 80.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:121: Execute 100.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:151: OnDevices 0.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:186: OnDevicesByNum 0.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:210: DonateAll 0.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:219: DonateNone 100.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:233: Donate 0.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:244: SetDonate 0.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:261: Done 88.6% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:318: allocatePerDeviceBufferList 88.9% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:338: freePerDeviceBufferList 100.0% +github.com/gomlx/gopjrt/pjrt/loadedexecutables.go:347: gatherPerDeviceBufferList 100.0% github.com/gomlx/gopjrt/pjrt/namedvalues.go:20: pjrtNamedValuesToMap 25.0% github.com/gomlx/gopjrt/pjrt/namedvalues.go:50: mallocArrayPJRT_NamedValue 6.7% github.com/gomlx/gopjrt/pjrt/namedvalues.go:101: destroyPJRT_NamedValue 0.0% +github.com/gomlx/gopjrt/pjrt/pjrt.go:17: panicf 0.0% github.com/gomlx/gopjrt/pjrt/plugins.go:32: pjrtPluginInitialize 100.0% github.com/gomlx/gopjrt/pjrt/plugins.go:40: pjrtPluginAttributes 87.5% github.com/gomlx/gopjrt/pjrt/plugins.go:54: newPlugin 75.0% diff --git a/dtypes/dtypes.go b/dtypes/dtypes.go index c65c044..8f5f5b2 100644 --- a/dtypes/dtypes.go +++ b/dtypes/dtypes.go @@ -12,7 +12,7 @@ import ( // panicf panics with formatted description. // // It is only used for "bugs in the code" -- when parameters don't follow the specifications. -// In principle it should never happen -- the same way nil-pointer panics should never happen. +// In principle, it should never happen -- the same way nil-pointer panics should never happen. func panicf(format string, args ...any) { panic(errors.Errorf(format, args...)) } diff --git a/go.mod b/go.mod index 59c97c8..a73cea9 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,7 @@ module github.com/gomlx/gopjrt go 1.23 require ( - github.com/chenxingqiang/go-floatx v0.0.0-20240103165049-2f5e300cb3c3 github.com/chewxy/math32 v1.10.1 - github.com/gomlx/exceptions v0.0.3 github.com/janpfeifer/gonb v0.10.1 github.com/janpfeifer/must v0.0.2 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 6650806..1d7caf0 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/chenxingqiang/go-floatx v0.0.0-20240103165049-2f5e300cb3c3 h1:2m11dpwbI3ccPgDbAbJ8X6fonuzsi54n70duaraoLn8= -github.com/chenxingqiang/go-floatx v0.0.0-20240103165049-2f5e300cb3c3/go.mod h1:7v935pWqAb/hfUDQyVXq8eXUoXWa7Mub1xEuRbtTFWE= github.com/chewxy/math32 v1.10.1 h1:LFpeY0SLJXeaiej/eIp2L40VYfscTvKh/FSEZ68uMkU= github.com/chewxy/math32 v1.10.1/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -8,8 +6,6 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gomlx/exceptions v0.0.3 h1:HKnTgEjj4jlmhr8zVFkTP9qmV1ey7ypYYosQ8GzXWuM= -github.com/gomlx/exceptions v0.0.3/go.mod h1:uHL0TQwJ0xaV2/snJOJV6hSE4yRmhhfymuYgNredGxU= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/janpfeifer/gonb v0.10.1 h1:yk29LAN5EF0OMKdnXd6xWTmlI/Tedajk7ssVu/1eBis= diff --git a/pjrt/loadedexecutables.go b/pjrt/loadedexecutables.go index fa52bb9..6dcafe6 100644 --- a/pjrt/loadedexecutables.go +++ b/pjrt/loadedexecutables.go @@ -7,7 +7,6 @@ package pjrt */ import "C" import ( - "github.com/gomlx/exceptions" "github.com/pkg/errors" "k8s.io/klog/v2" "runtime" @@ -327,7 +326,7 @@ func allocatePerDeviceBufferList(numDevices int, buffers []*Buffer) ***C.PJRT_Bu } if buffers[idxBuffer].cBuffer == nil { // Buffer given, but it's cBuffer is nil -> probably it has already been destroyed. - exceptions.Panicf("buffers[%d].cBuffer is nil, has it already been destroyed!?", idxBuffer) + panicf("buffers[%d].cBuffer is nil, has it already been destroyed!?", idxBuffer) } return buffers[idxBuffer].cBuffer }) diff --git a/pjrt/pjrt.go b/pjrt/pjrt.go index fe842c6..7280cc5 100644 --- a/pjrt/pjrt.go +++ b/pjrt/pjrt.go @@ -1,9 +1,19 @@ // Package pjrt implements a Go wrapper for the PJRT_C_API. package pjrt +import "github.com/pkg/errors" + // Generate automatic C-to-Go boilerplate code for pjrt_c_api.h. //go:generate go run ../cmd/pjrt_codegen // Since CGO C types cannot cross boundaries of a package (see issue https://github.com/golang/go/issues/13467) // We make a copy of chelper.go for every sub-directory that needs it. //go:generate go run ../cmd/copy_go_code --original=chelper.go + +// panicf panics with formatted description. +// +// It is only used for "bugs in the code" -- when parameters don't follow the specifications. +// In principle, it should never happen -- the same way nil-pointer panics should never happen. +func panicf(format string, args ...any) { + panic(errors.Errorf(format, args...)) +} diff --git a/xlabuilder/literal.go b/xlabuilder/literal.go index 5b47e81..b1b6782 100644 --- a/xlabuilder/literal.go +++ b/xlabuilder/literal.go @@ -5,7 +5,6 @@ package xlabuilder */ import "C" import ( - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/dtypes" "github.com/gomlx/gopjrt/dtypes/bfloat16" "github.com/pkg/errors" @@ -98,12 +97,8 @@ func NewScalarLiteralFromFloat64(value float64, dtype dtypes.DType) (*Literal, e return NewScalarLiteral(bfloat16.FromFloat32(float32(value))), nil default: var convertedValue reflect.Value - panicMsg := exceptions.Try(func() { - convertedValue = reflect.ValueOf(value).Convert(dtype.GoType()) - }) - if panicMsg != nil { - return nil, errors.Errorf("failed to convert %g to dtype %s: %v", value, dtype, panicMsg) - } + convertedValue = reflect.ValueOf(value) + convertedValue = convertedValue.Convert(dtype.GoType()) l, err := NewLiteralFromShape(MakeShape(dtype)) if err != nil { return nil, err diff --git a/xlabuilder/shape.go b/xlabuilder/shape.go index dbda736..473b1c7 100644 --- a/xlabuilder/shape.go +++ b/xlabuilder/shape.go @@ -6,7 +6,6 @@ package xlabuilder import "C" import ( "fmt" - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/dtypes" "github.com/gomlx/gopjrt/protos/xla_data" "github.com/pkg/errors" @@ -39,7 +38,7 @@ func MakeShape(dtype dtypes.DType, dimensions ...int) Shape { s := Shape{Dimensions: slices.Clone(dimensions), DType: dtype} for _, dim := range dimensions { if dim <= 0 { - exceptions.Panicf("shapes.Make(%+v): cannot create a shape with an axis with dimension <= 0", s) + panicf("shapes.Make(%+v): cannot create a shape with an axis with dimension <= 0", s) } } return s diff --git a/xlabuilder/special_ops.go b/xlabuilder/special_ops.go index b5b9603..62d230d 100644 --- a/xlabuilder/special_ops.go +++ b/xlabuilder/special_ops.go @@ -2,7 +2,6 @@ package xlabuilder import ( "fmt" - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/dtypes" "github.com/gomlx/gopjrt/protos/xla_data" "github.com/pkg/errors" @@ -119,7 +118,7 @@ func DecodeIota(op *Op) (shape Shape, iotaAxis int) { func Identity(input *Op) *Op { builder := input.builder if builder.IsNil() { - exceptions.Panicf("trying to access XlaBuilder that is nil or already destroyed") + panicf("trying to access XlaBuilder that is nil or already destroyed") } op := newOp(IdentityOp) op.OpInputs = []*Op{input} @@ -455,7 +454,7 @@ func Slice(x *Op, starts, limits, strides []int) (*Op, error) { func DecodeSlice(op *Op) (starts, limits, strides []int) { rank := op.OpInputs[0].Shape.Rank() if len(op.IntsArg) != 3*rank { - exceptions.Panicf("DecodeSlice() has input of rank %d, but arguments don't have 3*%d elements, instead got %d", + panicf("DecodeSlice() has input of rank %d, but arguments don't have 3*%d elements, instead got %d -- probably the op as not a SliceOp?", rank, 3*rank, len(op.IntsArg)) } starts = op.IntsArg[0:rank] diff --git a/xlabuilder/xlabuilder.go b/xlabuilder/xlabuilder.go index ecaf3f0..2700309 100644 --- a/xlabuilder/xlabuilder.go +++ b/xlabuilder/xlabuilder.go @@ -6,7 +6,6 @@ package xlabuilder */ import "C" import ( - "github.com/gomlx/exceptions" "github.com/pkg/errors" "runtime" "unsafe" @@ -18,6 +17,14 @@ import ( // We make a copy of chelper.go for every sub-directory that needs it. //go:generate go run ../cmd/copy_go_code --original=chelper.go +// panicf panics with formatted description. +// +// It is only used for "bugs in the code" -- when parameters don't follow the specifications. +// In principle, it should never happen -- the same way nil-pointer panics should never happen. +func panicf(format string, args ...any) { + panic(errors.Errorf(format, args...)) +} + // XlaBuilder is used to create "computations" (XlaComputation), that are like "StableHLO" functions. // // In turn XlaComputation can be exported to a serialized `HloModuleProto` (a binary blob) and used by a PJRT plugin @@ -163,7 +170,7 @@ func (b *XlaBuilder) Build(outputOp *Op) (*XlaComputation, error) { // It takes as input the computationName that is going to be built with it. func (b *XlaBuilder) CreateSubBuilder(computationName string) *XlaBuilder { if b.IsNil() { - exceptions.Panicf("trying to access XlaBuilder that is nil or already destroyed") + panicf("trying to access XlaBuilder that is nil or already destroyed") } cName := C.CString(computationName) defer cFree(cName) diff --git a/xlabuilder/xlacomputation.go b/xlabuilder/xlacomputation.go index 87de081..7e996d2 100644 --- a/xlabuilder/xlacomputation.go +++ b/xlabuilder/xlacomputation.go @@ -6,7 +6,6 @@ package xlabuilder */ import "C" import ( - "github.com/gomlx/exceptions" "github.com/gomlx/gopjrt/cbuffer" "runtime" "unsafe" @@ -69,7 +68,7 @@ func (comp *XlaComputation) Name() string { // See XlaComputation documentation on how to pretty-print the computation as text HLO. func (comp *XlaComputation) SerializedHLO() *cbuffer.CBuffer { if comp.IsNil() { - exceptions.Panicf("XlaComputation is nil, maybe it has already been destroyed?") + panicf("XlaComputation is nil, maybe it has already been destroyed?") } defer runtime.KeepAlive(comp) if comp == nil || comp.cXlaComputation == nil { @@ -86,7 +85,7 @@ func (comp *XlaComputation) SerializedHLO() *cbuffer.CBuffer { // Alternatively, see XlaComputation documentation on how to pretty-print the computation as text HLO. func (comp *XlaComputation) TextHLO() string { if comp.IsNil() { - exceptions.Panicf("XlaComputation is nil, maybe it has already been destroyed?") + panicf("XlaComputation is nil, maybe it has already been destroyed?") } defer runtime.KeepAlive(comp) if comp == nil || comp.cXlaComputation == nil { From 3b63a31a0ab51ae167d6015ce9e5c2d9c8196ef9 Mon Sep 17 00:00:00 2001 From: Jan Pfeifer Date: Tue, 27 Aug 2024 12:22:04 +0200 Subject: [PATCH 4/4] Updated CHANGELOG. --- docs/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b16c74b..944f2eb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,7 @@ -# Nexxt +# v0.3.1 * Fixed +/-Inf for bfloat16. +* Removed dependencies on "github.com/gomlx/exceptions". # v0.3.0 Some of the API now returns errors instead of panic