Resolve WES-90 "Integrate signpredictor in courses"
This commit is contained in:
committed by
Jerome Coudron
parent
1a75791d62
commit
746906294b
93
Packages/com.unity.barracuda/Runtime/Plugins/OSX/MacBLAS.cs
Normal file
93
Packages/com.unity.barracuda/Runtime/Plugins/OSX/MacBLAS.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#if UNITY_2018_1_OR_NEWER && (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
using Unity.Collections;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using Unity.Jobs;
|
||||
|
||||
[assembly: AlwaysLinkAssembly]
|
||||
|
||||
namespace Unity.Barracuda
|
||||
{
|
||||
|
||||
[Preserve]
|
||||
public class MacBLAS : BLASPlugin
|
||||
{
|
||||
[DllImport("/System/Library/Frameworks/Accelerate.framework/Accelerate")]
|
||||
static extern unsafe void cblas_sgemm(CBLAS_ORDER __Order, CBLAS_TRANSPOSE __TransA, CBLAS_TRANSPOSE __TransB,
|
||||
int __M, int __N, int __K, float __alpha, float *__A, int __lda, float *__B, int __ldb,
|
||||
float __beta, float *__C, int __ldc);
|
||||
|
||||
public bool IsNative()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsCurrentPlatformSupported()
|
||||
{
|
||||
return Application.platform == RuntimePlatform.OSXEditor ||
|
||||
Application.platform == RuntimePlatform.OSXPlayer;
|
||||
}
|
||||
|
||||
public unsafe void SGEMM(float* Ap, int AM, int AN, float* Bp, int BM, int BN, float* Cp, int CM, int CN,
|
||||
int bs,
|
||||
bool transposeA = false, bool transposeB = false)
|
||||
{
|
||||
cblas_sgemm(CBLAS_ORDER.CblasRowMajor, transposeA ? CBLAS_TRANSPOSE.CblasTrans : CBLAS_TRANSPOSE.CblasNoTrans,
|
||||
transposeB ? CBLAS_TRANSPOSE.CblasTrans : CBLAS_TRANSPOSE.CblasNoTrans,
|
||||
AM, BN, BM, 1.0f, Ap, AN, Bp, BN, 1.0f, Cp, CN);
|
||||
}
|
||||
|
||||
public unsafe JobHandle ScheduleSGEMM(JobHandle dependsOn,
|
||||
float* Ap, int AM, int AN, float* Bp, int BM, int BN, float* Cp, int CM, int CN,
|
||||
int bs,
|
||||
bool transposeA = false, bool transposeB = false)
|
||||
{
|
||||
var job = new SGEMMJob();
|
||||
job.Ap = Ap; job.AM = AM; job.AN = AN;
|
||||
job.Bp = Bp; job.BM = BM; job.BN = BN;
|
||||
job.Cp = Cp; job.CM = CM; job.CN = CN;
|
||||
job.transposeA = transposeA;
|
||||
job.transposeB = transposeB;
|
||||
job.bs = bs;
|
||||
return job.Schedule(dependsOn);
|
||||
}
|
||||
|
||||
unsafe struct SGEMMJob : IJob
|
||||
{
|
||||
[NativeDisableUnsafePtrRestriction][ReadOnly] public unsafe float* Ap;
|
||||
public int AM, AN;
|
||||
[NativeDisableUnsafePtrRestriction][ReadOnly] public unsafe float* Bp;
|
||||
public int BM, BN;
|
||||
[NativeDisableUnsafePtrRestriction] public unsafe float* Cp;
|
||||
public int CM, CN;
|
||||
public int bs;
|
||||
public bool transposeA;
|
||||
public bool transposeB;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
cblas_sgemm(CBLAS_ORDER.CblasRowMajor, transposeA ? CBLAS_TRANSPOSE.CblasTrans : CBLAS_TRANSPOSE.CblasNoTrans,
|
||||
transposeB ? CBLAS_TRANSPOSE.CblasTrans : CBLAS_TRANSPOSE.CblasNoTrans,
|
||||
AM, BN, BM, 1.0f, Ap, AN, Bp, BN, 1.0f, Cp, CN);
|
||||
}
|
||||
}
|
||||
|
||||
internal enum CBLAS_ORDER
|
||||
{
|
||||
CblasRowMajor=101,
|
||||
CblasColMajor=102
|
||||
};
|
||||
|
||||
internal enum CBLAS_TRANSPOSE
|
||||
{
|
||||
CblasNoTrans=111,
|
||||
CblasTrans=112,
|
||||
CblasConjTrans=113,
|
||||
AtlasConj=114
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // UNITY_OSX
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 680f04373f71f48a89408105d3f58a08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Unity.Barracuda.MacBLAS",
|
||||
"references": [
|
||||
"Unity.Barracuda"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor",
|
||||
"macOSStandalone"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": true
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53fc9961397934ed38a573ce1392c80c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user