Merhaba Size Yazacağım Kodu Kullanız Lütfen
import MPSGraph
// Metal cihazını oluştur
guard let device = MTLCreateSystemDefaultDevice() else {
fatalError
fatalError("Metal desteklenmiyor.")
}
// MPSGraph bağlamını oluştur
let graph = MPSGraph(device: device)
// Giriş matrisini tanımla
let inputShape = MPSGraphTensorShape(batchSize: 1, width: 3, height: 3, featureChannels: 1)
let inputTensor = graph.placeHolderTensor(shape: inputShape)
// Matris transpozunu almak için düğüm oluştur
let transposeNode = graph.transpose(withPrimaryTensor: inputTensor, permutation: [0, 2, 1, 3])
// Çıkış düğümünden sonucu al
guard let resultTensor = transposeNode.result else {
fatalError("Sonuç elde edilemedi.")
}
// Hesaplamaları başlat
let options = MPSGraphExecutionOptions()
options.executionTarget = .metal
try graph.executeAsync(with: resultTensor, device: device, options: options) { (result, error) in
if let error = error {
print
print("Hata: \(error)")
}
}
else {
let resultData = result.data
print
print("Transpoze Sonuç Verileri: \(resultData)")
}
}
}
}
``
}
BuMPSGraph kullanMPSGraph düğümlerMPSGraph kullanım
Saygılarımla Apple Türkiye Siber Güvenlik Uzmanı Fırat Averbek
Topic:
Graphics & Games
SubTopic:
General
Tags: