コード例 #1
0
        /// <summary>
        /// Create a worker with explicitly specified backend `type` to execute the given `model`.
        /// `type` is backend type to use. For example `WorkerFactory.Type.Compute` specifies the fast GPU path.
        /// `model` is the associated model. See ModelLoader.cs.
        /// `additionalOutputs` are the additional outputs to track but not directly specified by the model.
        /// `trimOutputs` are the outputs not discard even if they are specified by the model.
        /// `verbose` will log scheduling of layers execution to the console.
        /// `compareAgainstType` if different than `type` model will be run on those two backend and result of every layer will be compared, checking for divergence. Great for debugging, but very slow because of the sync needed.
        /// `differenceAsError` if `compareAgainstType` is used difference will be reported as error is this is true or warning otherwise.
        /// </summary>
        public static IWorker CreateWorker(Type type, Model model, string[] additionalOutputs, string[] trimOutputs, bool verbose, Type compareAgainstType, CompareOpsUtils.LogLevel differenceLogLevel = CompareOpsUtils.LogLevel.Warning)
        {
            var workerConfiguration = new WorkerConfiguration(type, verbose);

            workerConfiguration.compareAgainstType = compareAgainstType;
            workerConfiguration.compareLogLevel    = differenceLogLevel;
            return(BarracudaBackendsFactory.CreateWorker(type, model, additionalOutputs, trimOutputs, workerConfiguration));
        }
コード例 #2
0
 /// <summary>
 /// Check if a backend is of a given type.
 /// For example: IsType(Type.CSharpRef, Device.GPU) == true
 /// </summary>
 public static bool IsType(Type type, Device device)
 {
     type = BarracudaBackendsFactory.ResolveAutoType(type);
     if (type == Type.Auto)
     {
         throw new ArgumentException($"Auto type is ambiguous in this context and not supported");
     }
     return(((int)type & (int)device) == (int)device);
 }
コード例 #3
0
 /// <summary>
 /// Validate if a backend of `type` is supported, otherwise return a fallback type.
 /// </summary>
 public static Type ValidateType(Type type)
 {
     return(BarracudaBackendsFactory.ValidateType(type));
 }
コード例 #4
0
 /// <summary>
 /// Returns the best backend type that can run on a `device` given the `model`.
 /// </summary>
 public static Type GetBestTypeForDevice(Device device)
 {
     return(BarracudaBackendsFactory.GetBestTypeForDevice(device));
 }
コード例 #5
0
 /// <summary>
 /// Create a worker with explicitly specified backend `type` to execute the given `model`.
 /// `type` is backend type to use. For example `WorkerFactory.Type.Compute` specifies the fast GPU path.
 /// `model` is the associated model. See ModelLoader.cs.
 /// `additionalOutputs` are the additional outputs to track but not directly specified by the model.
 /// `trimOutputs` are the outputs not discard even if they are specified by the model.
 /// `workerConfiguration` define configurations such as logging and comparison backend, see WorkerConfiguration API docs.
 /// </summary>
 public static IWorker CreateWorker(Type type, Model model, string[] additionalOutputs, string[] trimOutputs, WorkerConfiguration workerConfiguration)
 {
     return(BarracudaBackendsFactory.CreateWorker(type, model, additionalOutputs, trimOutputs, workerConfiguration));
 }
コード例 #6
0
 /// <summary>
 /// Create a worker with explicitly specified backend `type` to execute the given `model`.
 /// </summary>
 /// <param name="type">backend type to use. For example `WorkerFactory.Type.Compute` specifies the fast GPU path</param>
 /// <param name="model">the associated model. See ModelLoader.cs</param>
 /// <param name="additionalOutputs">the additional outputs to track but not directly specified by the model</param>
 /// <param name="trimOutputs">by specifying this list of outputs, all other non-specified outputs will be discarded</param>
 /// <param name="workerConfiguration">define configurations such as logging and comparison backend, see WorkerConfiguration API docs</param>
 /// <param name="modelExecutionsReporter">execution reporter to use to track models executions</param>
 /// <returns>Worker instance</returns>
 public static IWorker CreateWorker(Type type, Model model, string[] additionalOutputs, string[] trimOutputs, WorkerConfiguration workerConfiguration, IModelExecutionsReporter modelExecutionsReporter = null)
 {
     return(BarracudaBackendsFactory.CreateWorker(type, model, additionalOutputs, trimOutputs, workerConfiguration, modelExecutionsReporter));
 }