-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Int values read fixes for ONNX protobuf #4
base: main
Are you sure you want to change the base?
Conversation
Different values might be stored in different place within swift protobuf for onnx models
guard !tensor.int64Data.isEmpty else { | ||
throw OnnxError.unsupportedTensorDataType(onnx: tensor.dataType, mps: nil) | ||
} | ||
return constant(tensor.int64Data.rawData, shape: tensor.mpsShape, dataType: targetDataType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
с точки зрения имплементации - это ошибка, потому что все тензоры должны быть либо float32, либо float16 для того чтобы в рантайме не нужно было делать лишние касты. поэтому я предлагаю либо кастить сначала int64/int32/uint/etc. в float16/float32 тут, либо ожидать что в сетке будет только rawData (это можно сделать в питон скрипте ONNX2MPSX). Если же кастить все во float32/float16, то это надо делать не здесь а внутри методов halfs/floats в экстеншене.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Давай тогда притормозим это немного, надо потестить хорошо будет конвертации. В ту же Where ноду надо bool тензор с другой стороны, он все равно, наверное, внутри кастится в float для в step функции, но все же. Надо мерять
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ок)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
заменить на флоты все нельзя
(mpsFileLoc): /Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm:132:0: error: 'mps.gather' op operand #1 must be tensor of int values, but got 'tensor<1xf32>'
case (.float16, _): | ||
guard let values = tensor.halfs else { | ||
guard let values = tensor.halfs, values.rawData.count != 0 else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, кажется что isEmpty проверка более православная чтоли
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я католик, мне можно так 😁
@@ -126,10 +126,31 @@ extension Onnx_TensorProto { | |||
} | |||
|
|||
var ints: [Int]? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю выше в методах halfs/floats добавить конвертацию из int64Data/int32Data/uint64Data
Different values might be stored in different place within swift protobuf for onnx models