예제 #1
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);
 }
예제 #2
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));
 }
예제 #3
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));
 }
예제 #4
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 the 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, bool differenceAsError = false)
 {
     return(BarracudaBackendsFactory.CreateWorker(type, model, additionalOutputs, trimOutputs, verbose, compareAgainstType, differenceAsError));
 }
예제 #5
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);
     Assert.AreNotEqual(type, Type.Auto);
     return(((int)type & (int)device) == (int)device);
 }