internal static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs, string[] trimOutputs, WorkerFactory.WorkerConfiguration workerConfiguration, IModelExecutionsReporter modelExecutionsReporter = null) { type = ResolveAutoType(type); var compareAgainstType = ResolveAutoType(workerConfiguration.compareAgainstType); Assert.AreNotEqual(type, WorkerFactory.Type.Auto); Assert.AreNotEqual(compareAgainstType, WorkerFactory.Type.Auto); bool compare = type != compareAgainstType; if (WorkerFactory.IsType(type, WorkerFactory.Device.GPU) && !SystemInfo.supportsComputeShaders && !Application.isEditor) { D.LogWarning("Compute shaders are not supported on current platform. Falling back to CSharpFast."); type = WorkerFactory.Type.CSharpBurst; } IVars vars; if (WorkerFactory.IsType(type, WorkerFactory.Device.GPU) || WorkerFactory.IsType(compareAgainstType, WorkerFactory.Device.GPU)) { vars = new ComputeVarsWithSharedModel(); } else { vars = new DefaultVars(); } ITensorAllocator allocator = vars.GetAllocator(); if (workerConfiguration.verbose) { D.Log($"Storage type: {vars.GetType()}. Allocator type: {allocator.GetType()}."); } IOps ops = CreateOps(type, allocator, workerConfiguration.verbose); if (compare) { ops = new CompareOps(ops, CreateOps(compareAgainstType, allocator, workerConfiguration.verbose), workerConfiguration.compareLogLevel, workerConfiguration.compareEpsilon); } if (workerConfiguration.verbose || modelExecutionsReporter != null) { ops = new VerboseOps(ops, workerConfiguration.verbose); } if (Application.isEditor || modelExecutionsReporter != null) { ops = new StatsOps(ops); } model = ValidateModel( PatchModel(model, additionalOutputs, trimOutputs)); ops.SetModelExecutionsReporter(modelExecutionsReporter); return(new GenericWorker(model, ops, vars, workerConfiguration.verbose)); }
public static IWorker CreateWorker(WorkerFactory.Type type, Model model, string[] additionalOutputs, string[] trimOutputs, bool verbose, WorkerFactory.Type compareAgainstType, bool differenceAsError) { type = ResolveAutoType(type); compareAgainstType = ResolveAutoType(compareAgainstType); Assert.AreNotEqual(type, WorkerFactory.Type.Auto); Assert.AreNotEqual(compareAgainstType, WorkerFactory.Type.Auto); bool compare = type != compareAgainstType; if (WorkerFactory.IsType(type, WorkerFactory.Device.GPU) && !SystemInfo.supportsComputeShaders && !Application.isEditor) { D.LogWarning("Compute shaders are not supported on current platform. Falling back to CSharpFast."); type = WorkerFactory.Type.CSharp; } IVars vars; if (WorkerFactory.IsType(type, WorkerFactory.Device.GPU) || WorkerFactory.IsType(compareAgainstType, WorkerFactory.Device.GPU)) { vars = new ComputeVarsWithSharedModel(); } else { vars = new DefaultVars(); } ITensorAllocator allocator = vars.GetAllocator(); if (verbose) { D.Log($"Storage type: {vars.GetType()}. Allocator type: {allocator.GetType()}."); } IOps ops = CreateOps(type, allocator, verbose); if (compare) { ops = new CompareOps(ops, CreateOps(compareAgainstType, allocator, verbose), differenceAsError); } if (verbose) { ops = new VerboseOps(ops); } if (Application.isEditor) { ops = new StatsOps(ops); } model = ValidateModel( PatchModel(model, additionalOutputs, trimOutputs)); return(new GenericWorker(model, ops, vars, verbose)); }
public override string ToString() { return($"(`{name}` {shape}, alloc: {m_TensorAllocator?.GetType()}, onDevice:{m_TensorOnDevice})"); }