示例#1
0
        public TileCompiler(Dictionary <string, object> options = null) : base(new Context())
        {
            if (!_context.IsAllocated)
            {
                CompilerStatusMessage = _context.LastStatusString;
                // TODO: [vermorel] An exception should be thrown here.
                // REMARK: [allisterb] Throw PlaidMLApiException on failure.
                throw new PlaidMLApiException <TileCompiler>(this, "Could not allocate Context.");
            }

            Options          = options;
            SessionId        = Settings.StartNewSession();
            DeviceEnumerator = new DeviceEnumerator(_context);
            if (!DeviceEnumerator.IsAllocated)
            {
                CompilerStatusMessage = DeviceEnumerator.LastStatusString;
                return;
            }

            if (DeviceEnumerator.ValidDevices.Count < 1)
            {
                Error("No valid devices available.");
                return;
            }

            IsAllocated            = true;
            KernelDevice           = OpenFirstDevice();
            KernelDeviceProperties = JsonConvert.DeserializeObject <Dictionary <string, object> >
                                         (KernelDevice.DeviceConfig.Details);
            Initialized = true;
        }
示例#2
0
        public DeviceConfig(Context ctx, DeviceEnumerator enumerator, ulong index) : base(ctx)
        {
            _ptr = plaidml.__Internal.PlaidmlGetDevconf(_context, enumerator, index);
            if (_ptr.IsZero())
            {
                ReportApiCallError("plaidml_get_devconf");
                throw new PlaidMLApiException <DeviceConfig>(this, "Could not get device config.");
            }

            Enumerator  = enumerator;
            Index       = index;
            IsAllocated = true;
        }