I need to reshape a tensor A to shape S that is not available at the compile time. I would like to compute the shape S inside the graph and then reshape the tensor A to the shape S. Is this even possible with MPS?
Post
Replies
Boosts
Views
Activity
I would like to generate and run ML program inside an app.
I got familiar with the coremltools and MIL format, however I can't seem to find any resources on how to generate mlmodel/mlpackage files using Swift on the device.
Is there any Swift equivalent of coremltools? Or is there a way to translate MIL description of a ML program into instance of a MLModel? Or something similar.
Hello,
printing the dataType property some tensor, results in a non-disclosing "MPSDataType" string. Is this intended? If so, how do I get string representation of type of the tensor please?
let graph = MPSGraph()
print(graph.constant(23.0, dataType: .float32).dataType)
// prints "MPSDataType", and not "f32" or something useful
Hello,
I am trying to implement numpy.arrange using MPSGraph primitives. Along the way I got to this code, which I would expect is correct, however the program crashes with information about type mismatch.
What am I doing wrong?
Code
let G = MPSGraph()
let length = G.constant(9, shape: [1], dataType: .int32)
let base = G.constant(1, shape: [1], dataType: .int32)
let template = G.broadcast(base, shapeTensor: length, name: nil)
let r = G.for(
numberOfIterations: length,
initialBodyArguments: [template],
// just return the argument
body: { i, args in [args[0]] },
name: nil
)
Error
-:22:11: error: 'scf.for' op types mismatch between 0th iter operand and defined value
-:22:11: note: see current operation: %19 = "scf.for"(%16, %17, %18, %12) ( {
^bb0(%arg1: index, %arg2: tensor<*xi32>): // no predecessors
%21 = "tensor.from_elements"(%arg1) : (index) -> tensor<1xindex>
%22 = "mps.cast"(%21) {resultElementType = i32} : (tensor<1xindex>) -> tensor<1xi32>
"scf.yield"(%arg2) : (tensor<*xi32>) -> ()
}) : (index, index, index, tensor<9xi32>) -> tensor<*xi32>
/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph_Sim/MetalPerformanceShadersGraph-2.0.22/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphExecutable.mm:1052: failed assertion `Error: MLIR pass manager failed'
P.S. Is there a way I can return differently-shaped tensor from each iteration? In other words:
body: { i, args in
[G.concatTensors([args[0], i], dimension: 0, name: nil)]
}
Is it possible to have object texture that is different for each eye? Or maybe having a eye index information in the shader?
With rendering slightly different colors for each eye, you can achieve extremely satisfying visuals (iridescence/holographic-like) or increase perceptual contrast where it is needed.