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.
с точки зрения имплементации - это ошибка, потому что все тензоры должны быть либо float32, либо float16 для того чтобы в рантайме не нужно было делать лишние касты. поэтому я предлагаю либо кастить сначала int64/int32/uint/etc. в float16/float32 тут, либо ожидать что в сетке будет только rawData (это можно сделать в питон скрипте ONNX2MPSX). Если же кастить все во float32/float16, то это надо делать не здесь а внутри методов halfs/floats в экстеншене.
There was a problem hiding this comment.
Давай тогда притормозим это немного, надо потестить хорошо будет конвертации. В ту же Where ноду надо bool тензор с другой стороны, он все равно, наверное, внутри кастится в float для в step функции, но все же. Надо мерять
There was a problem hiding this comment.
заменить на флоты все нельзя
(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.
btw, кажется что isEmpty проверка более православная чтоли
There was a problem hiding this comment.
я католик, мне можно так 😁
| @@ -126,10 +126,31 @@ extension Onnx_TensorProto { | |||
| } | |||
|
|
|||
| var ints: [Int]? { | |||
There was a problem hiding this comment.
предлагаю выше в методах halfs/floats добавить конвертацию из int64Data/int32Data/uint64Data
Different values might be stored in different place within swift protobuf for onnx models