Example #1
0
    public YOLOHandler(NNHandler nn)
    {
        this.nn = nn;
        cpuOps  = BarracudaUtils.CreateOps(WorkerFactory.Type.CSharpRef);

        inputWidthHeight = nn.model.inputs[0].shape[1];
    }
Example #2
0
        protected Dictionary <string, Barracuda.Tensor> PrepareBarracudaInputs(IEnumerable <Tensor> infInputs)
        {
            var inputs = new Dictionary <string, Barracuda.Tensor>();

            foreach (var inp in _inferenceInputs)
            {
                inputs[inp.Name] = BarracudaUtils.ToBarracuda(inp);
            }

            return(inputs);
        }
    public YOLOHandler(NNHandler nn)
    {
        this.nn = nn;
        ops     = BarracudaUtils.CreateOps(WorkerFactory.Type.Compute);
        cpuOps  = BarracudaUtils.CreateOps(WorkerFactory.Type.CSharp);

        inputWidthHeight = nn.model.inputs[0].shape[1];
        premulTensor     = new Tensor(1, 1, new float[] { 255 });

        PerformanceCounter.GetInstance()?.AddCounter(stopwatch);
    }
Example #4
0
        protected List <Tensor> FetchBarracudaOutputs(string[] names)
        {
            var outputs = new List <Tensor>();

            foreach (var name in names)
            {
                var outp = _engine.Peek(name);
                outputs.Add(BarracudaUtils.FromBarracuda(outp, name));
            }

            return(outputs);
        }
        /// <summary>
        /// Generates the Tensor inputs that are expected to be present in the Model.
        /// </summary>
        /// <returns>Tensor IEnumerable with the expected Tensor inputs</returns>
        public IEnumerable <Tensor> GetInputTensors()
        {
            List <Tensor> tensors = new List <Tensor>();

            if (_model == null)
            {
                return(tensors);
            }

            foreach (var input in _model.inputs)
            {
                tensors.Add(new Tensor
                {
                    Name      = input.name,
                    ValueType = Tensor.TensorType.FloatingPoint,
                    Data      = null,
                    Shape     = input.shape.Select(i => (long)i).ToArray()
                });
            }

            foreach (var mem in _model.memories)
            {
                //Debug.Log($"{mem.input}: {mem.shape} -> {BarracudaUtils.FromBarracuda(mem.shape).Length}");
                tensors.Add(new Tensor
                {
                    Name      = mem.input,
                    ValueType = Tensor.TensorType.FloatingPoint,
                    Data      = null,
                    Shape     = BarracudaUtils.FromBarracuda(mem.shape)
                });
            }

            tensors.Sort((el1, el2) => el1.Name.CompareTo(el2.Name));

            return(tensors);
        }