コード例 #1
0
        /// <summary>
        /// Returns set of backend arguments to configure the
        /// backend (based net being used).
        /// </summary>
        /// <param name="evaluatorDef"></param>
        /// <returns></returns>
        static string BackendArgumentsString(NNEvaluatorDef evaluatorDef)
        {
            // LC0 does not genearlly support Int8; map into FP16 silently
            NNEvaluatorPrecision precision = evaluatorDef.Nets[0].Net.Precision;

            if (precision == NNEvaluatorPrecision.Int8)
            {
                precision = NNEvaluatorPrecision.FP16;
            }

            return(LC0EngineArgs.BackendArgumentsString(evaluatorDef.DeviceIndices, precision, evaluatorDef.EqualFractions));
        }
コード例 #2
0
 public NNEvaluatorEngineTensorRTConfig(string uFFFileName, string engineType, int batchSize, NNEvaluatorPrecision precision, int gPUID,
                                        bool isWDL, bool hasM,
                                        TRTPriorityLevel priorityLevel, bool retrieveValueFCActivations)
 {
     UFFFileName   = uFFFileName;
     EngineType    = engineType;
     MaxBatchSize  = batchSize;
     Precision     = precision;
     GPUID         = gPUID;
     IsWDL         = isWDL;
     HasM          = hasM;
     PriorityLevel = priorityLevel;
     RetrieveValueFCActivations = retrieveValueFCActivations;
 }
コード例 #3
0
        public static NNEvaluatorDef SingleNet(string netID, NNEvaluatorType evaluatorType,
                                               NNEvaluatorPrecision precision,
                                               params int[] gpuIDs)
        {
            NNEvaluatorDeviceDef[] devices = new NNEvaluatorDeviceDef[gpuIDs.Length];
            for (int i = 0; i < gpuIDs.Length; i++)
            {
                devices[i] = new NNEvaluatorDeviceDef(NNDeviceType.GPU, gpuIDs[i]);
            }

            NNEvaluatorDeviceComboType type = gpuIDs.Length == 1 ? NNEvaluatorDeviceComboType.Single
                                                               : NNEvaluatorDeviceComboType.Split;

            return(new NNEvaluatorDef(new NNEvaluatorNetDef(netID, evaluatorType, precision), type, devices));
        }
コード例 #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="engineID"></param>
        /// <param name="uffFN"></param>
        /// <param name="isWDL"></param>
        /// <param name="hasM"></param>
        /// <param name="gpuID"></param>
        /// <param name="type"></param>
        /// <param name="batchSize"></param>
        /// <param name="precision"></param>
        /// <param name="priorityLevel"></param>
        /// <param name="calibPositions"></param>
        /// <param name="retrieveValueFCActivations"></param>
        /// <param name="shared"></param>
        public NNEvaluatorEngineTensorRT(string engineID, string uffFN, bool isWDL, bool hasM, int gpuID,
                                         NNEvaluatorEngineTensorRTConfig.NetTypeEnum type,
                                         int batchSize, NNEvaluatorPrecision precision,
                                         NNEvaluatorEngineTensorRTConfig.TRTPriorityLevel priorityLevel = NNEvaluatorEngineTensorRTConfig.TRTPriorityLevel.High,
                                         List <Position> calibPositions = null, bool retrieveValueFCActivations = false,
                                         bool shared = true)
        {
            Config = new NNEvaluatorEngineTensorRTConfig(uffFN, type == NNEvaluatorEngineTensorRTConfig.NetTypeEnum.Ceres ? "TRT_DJE" : "TRT_LZ0",
                                                         batchSize, precision, gpuID, isWDL, hasM, priorityLevel, retrieveValueFCActivations);

            SessionID       = GetSessionToAttachTo(Config, shared);
            UFFFN           = uffFN;
            GPUID           = gpuID;
            EngineNetworkID = engineID;
            CalibPositions  = calibPositions;
            Precision       = precision;
            PriorityLevel   = priorityLevel;
            Shared          = shared;
            Type            = type;

            //      ShouldRebuild = shouldRebuild;
            RetrieveValueFCActivations = retrieveValueFCActivations;
        }
コード例 #5
0
ファイル: NNEvaluatorLC0.cs プロジェクト: scchess/Ceres
        // TODO: Add a Dispose/Release which calls Dispose on associated LC0DllNNEvaluator

        public NNEvaluatorLC0(INNWeightsFileInfo net, int[] gpuIDs, NNEvaluatorPrecision precision = NNEvaluatorPrecision.FP16)
        {
            if (gpuIDs.Length != 1)
            {
                throw new ArgumentException(nameof(gpuIDs), "Implementation limitation: one GPU id must be specified");
            }
            if (precision != NNEvaluatorPrecision.FP16)
            {
                throw new ArgumentException(nameof(precision), "Implementation: only FP16 supported");
            }

            isWDL = net.IsWDL;
            hasM  = net.HasMovesLeft;

            policies = new CompressedPolicyVector[MAX_BATCH_SIZE];
            w        = new FP16[MAX_BATCH_SIZE];
            l        = isWDL ? new FP16[MAX_BATCH_SIZE] : null;
            m        = isWDL ? new FP16[MAX_BATCH_SIZE] : null;

            // Create NN evaluator and attach to it
            //TODO: set precision
            //LC0Engine engine = LaunchLC0Server.LaunchProcess(net.LC0WeightsFilename, gpuIDs, precision);
            Evaluator = new LC0LibraryNNEvaluator(net.FileName, gpuIDs[0]);
        }
コード例 #6
0
ファイル: NNEvaluatorLC0.cs プロジェクト: scchess/Ceres
 /// <summary>
 /// Constructor when only one GPU is requested.
 /// </summary>
 /// <param name="net"></param>
 /// <param name="gpuID"></param>
 /// <param name="precision"></param>
 public NNEvaluatorLC0(INNWeightsFileInfo net, int gpuID = 0, NNEvaluatorPrecision precision = NNEvaluatorPrecision.FP16)
     : this(net, new int[] { gpuID }, precision)
 {
 }
コード例 #7
0
ファイル: LC0EngineArgs.cs プロジェクト: scchess/Ceres
 public static string PrecisionString(NNEvaluatorPrecision precision)
 => precision switch
 {