Backends/SiaNet.Backend.TensorSharp/Cuda/RuntimeCompiler/KernelDiskCache.cs
/// <summary>
/// Gets the specified full source code.
/// </summary>
/// <param name="fullSourceCode">The full source code.</param>
/// <param name="compile">The compile.</param>
/// <returns>System.Byte[].</returns>
Gets the specified full source code.
Gets the specified full source code .
public byte[] Get(string fullSourceCode, Func<string, byte[]> compile)
        {
            var key = KeyFromSource(fullSourceCode);
            byte[] ptx;
            if (memoryCachedKernels.TryGetValue(key, out ptx))
            {
                return ptx;
            }
            else if (TryGetFromFile(key, out ptx))
            {
                memoryCachedKernels.Add(key, ptx);
                return ptx;
            }
            else
            {
                ptx = compile(fullSourceCode);
                memoryCachedKernels.Add(key, ptx);
                WriteToFile(key, ptx);
                return ptx;
            }
        }
public byte [ ] Get ( string fullSourceCode , Func < string , byte [ ] > compile ) { var key = KeyFromSource ( fullSourceCode ) ; byte [ ] ptx ; if ( memoryCachedKernels . TryGetValue ( key , out ptx ) ) { return ptx ; } else if ( TryGetFromFile ( key , out ptx ) ) { memoryCachedKernels . Add ( key , ptx ) ; return ptx ; } else { ptx = compile ( fullSourceCode ) ; memoryCachedKernels . Add ( key , ptx ) ; WriteToFile ( key , ptx ) ; return ptx ; } }
Gets the specified full source code.
Gets the specified full source code .
None
fullSourceCode
string
The full source code.
The full source code .
compile
Func<string, byte[]>
None