Beispiel #1
0
        protected override ITest create(DataType dt, string strName, int nDeviceID, EngineParameter.Engine engine = EngineParameter.Engine.DEFAULT)
        {
            string strPath = TestBase.CudaPath;

            if (dt == DataType.DOUBLE)
            {
                CudaDnn <double> .SetDefaultCudaPath(strPath);

                return(new DataLayerTest <double>(strName, nDeviceID, this));
            }
            else
            {
                CudaDnn <float> .SetDefaultCudaPath(strPath);

                return(new DataLayerTest <float>(strName, nDeviceID, this));
            }
        }
Beispiel #2
0
        public TestBase(string strName, int nDeviceID = DEFAULT_DEVICE_ID, EngineParameter.Engine engine = EngineParameter.Engine.DEFAULT, object tag = null, bool bHalf = false)
        {
            m_bHalf = bHalf;

            // If an auto test has set the GPUID, us it instead.
            LocalDataStoreSlot lds = Thread.GetNamedDataSlot("GPUID");

            if (lds != null)
            {
                object obj = Thread.GetData(lds);
                if (obj != null)
                {
                    string strGpuId = obj.ToString();
                    if (!string.IsNullOrEmpty(strGpuId))
                    {
                        int nVal;

                        if (int.TryParse(strGpuId, out nVal) && nDeviceID < 4)
                        {
                            nDeviceID = nVal;
                        }
                    }
                }
            }

            // If an auto test has set the IMGDB_VER, use it instead of the default.
            LocalDataStoreSlot ldsv = Thread.GetNamedDataSlot("IMGDBVER");

            if (ldsv != null)
            {
                object obj = Thread.GetData(ldsv);
                if (obj != null)
                {
                    string strImgDbVer = obj.ToString();
                    if (!string.IsNullOrEmpty(strImgDbVer))
                    {
                        int nVal;

                        if (int.TryParse(strImgDbVer, out nVal) && (nVal == 0 || nVal == 1))
                        {
                            m_imgDbVer = (IMGDB_VERSION)nVal;
                        }
                    }
                }
            }

            // If an auto test has set the CULTURE, use it instead of the default.
            LocalDataStoreSlot ldsc = Thread.GetNamedDataSlot("CULTURE");

            if (ldsc != null)
            {
                object obj = Thread.GetData(ldsc);
                if (obj != null)
                {
                    string strCulture = obj.ToString();
                    if (!string.IsNullOrEmpty(strCulture))
                    {
                        m_defaultCulture = Thread.CurrentThread.CurrentCulture;
                        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(strCulture);
                    }
                }
            }

            LocalDataStoreSlot ldsp = Thread.GetNamedDataSlot("CUDAPATH");

            if (ldsp != null)
            {
                object obj = Thread.GetData(ldsp);
                if (obj != null)
                {
                    m_strCudaPath = obj.ToString();
                }
            }

            string strPath = CudaPath;

            CudaDnn <float> .SetDefaultCudaPath(strPath);

            CudaDnn <double> .SetDefaultCudaPath(strPath);

            m_strName = strName;

            if (create_count == 1)
            {
                ITest iTestF = create(DataType.FLOAT, strName, nDeviceID, engine);
                if (iTestF != null)
                {
                    iTestF.SetParent(this);
                    iTestF.initialize();
                    m_rgTests.Add(iTestF);
                }

                ITest iTestD = create(DataType.DOUBLE, strName, nDeviceID, engine);
                if (iTestD != null)
                {
                    iTestD.SetParent(this);
                    iTestD.initialize();
                    m_rgTests.Add(iTestD);
                }
            }
            else
            {
                for (int i = 0; i < create_count; i++)
                {
                    ITest iTestF = create(i, DataType.FLOAT, strName, nDeviceID, engine);
                    if (iTestF != null)
                    {
                        iTestF.SetParent(this);
                        iTestF.initialize();
                        m_rgTests.Add(iTestF);
                    }

                    ITest iTestD = create(i, DataType.DOUBLE, strName, nDeviceID, engine);
                    if (iTestD != null)
                    {
                        iTestD.SetParent(this);
                        iTestD.initialize();
                        m_rgTests.Add(iTestD);
                    }
                }
            }
        }