@Override public void computeFeatureMap() { FeatureMap input = (FeatureMap) featureMapInput[0]; Allocation frameAllocation = input.getFeatureMap(); FeatureMap output = (FeatureMap) featureMapOutput; Allocation outAllocation = output.getFeatureMap(); scriptPooling.set_in_blob(frameAllocation); scriptPooling.set_out_blob(outAllocation); int outputChannelAligned = getOutputChannelAligned(); Script.LaunchOptions options = new Script.LaunchOptions(); options.setX(0, outputChannelAligned / 4).setY(0, outputShape[1] * outputShape[2]); if(globalPooling){ options.setX(0, outputChannelAligned / 4).setY(0, 1); scriptPooling.forEach_global_pooling_2d(options); float[][][][] data = input.getData(); float[][][][] data2 = output.getData(); int len = data.length; } else if(kernelType.equalsIgnoreCase("MAX")) { scriptPooling.forEach_max_pooling_2d(options); } else if(kernelType.equalsIgnoreCase("AVE")){ scriptPooling.forEach_mean_pooling_2d(options); } }
ScriptC.LaunchOptions option = new Script.LaunchOptions(); boolean useIntrinsicBlas = false; option.setX(0, getInputChannelAligned() / 4).setY(0, outputHeight * outputWidth); scriptConvolution.forEach_conv_dw4(option); return; scriptConvolution.set_ColData(colAllocation); option.setX(0, kernelH * kernelW).setY(0, outputHeight * outputWidth); scriptConvolution.forEach_conv_im2col2(option); option.setX(0, getOutputChannelAligned() / 4).setY(0, outputHeight * outputWidth); scriptConvolution.forEach_conv1x1(option); option.setX(0, getInputChannelAligned() / 4).setY(0, outputHeight * outputWidth); scriptConvolution.forEach_conv_dw4(option); option.setX(0, outputChannelAligned / blockSize).setY(0, outputHeight * outputWidth); scriptConvolution.forEach_conv4n(option);
Allocation outAllocation = output.getFeatureMap(); scriptEltwise.set_OutputData(outAllocation); Script.LaunchOptions options = new Script.LaunchOptions(); int outputChannelAligned = getOutputChannelAligned(); options.setX(0, outputChannelAligned / 4).setY(0, outputShape[1] * outputShape[2]);
scriptConcat.set_channelOffset(channelOffset); scriptConcat.set_in_Blob(frameAllocation); Script.LaunchOptions option = new Script.LaunchOptions(); if(useVector) { option.setX(0, inBlock).setY(0, h * w); scriptConcat.forEach_compute_in4out4(option); option.setX(0, inChannel).setY(0, h * w); scriptConcat.forEach_compute(option);
@Override public void computeFeatureMap() { int n = inputShape[0][0]; int h = inputShape[0][1]; int w = inputShape[0][2]; int c = inputShape[0][3]; int channelAligned = getInputChannelAligned(); FeatureMap input = (FeatureMap) featureMapInput[0]; Allocation inAllocation = input.getFeatureMap(); if(inAllocation.getElement().getVectorSize()==4){ softmaxScript.set_channelAligned(channelAligned); } else{ softmaxScript.set_channelAligned(c); } softmaxScript.set_inBlob(inAllocation); Script.LaunchOptions option = new Script.LaunchOptions(); option.setX(0, n * h * w * c); softmaxScript.forEach_compute_exp(option); option.setX(0, n * h * w); softmaxScript.forEach_compute_exp_sum(option); option.setX(0, n * h * w * c); softmaxScript.forEach_compute(option); featureMapOutput = featureMapInput[0]; }
@Override public void computeFeatureMap(){ FeatureMap input = (FeatureMap) featureMapInput[0]; Allocation frameAllocation = input.getFeatureMap(); FeatureMap output = (FeatureMap) featureMapOutput; Allocation outAllocation = output.getFeatureMap(); innerProductScript.set_In_Blob(frameAllocation); innerProductScript.set_Out_Blob(outAllocation); Script.LaunchOptions option = new Script.LaunchOptions(); if(numOutput % 128==0){ int thread_group = 1; option.setX(0, outputShape[0] * numOutput / 4 / thread_group); //option.setY(0, numOutput / 4 / thread_group); innerProductScript.set_thread_group(thread_group); innerProductScript.forEach_compute_f8fn_1(option); } else{ option.setX(0, outputShape[0]); option.setY(0, numOutput); innerProductScript.forEach_compute_f8f1(option); } } }
@Override public void computeFeatureMap(){ FeatureMap input = (FeatureMap) featureMapInput[0]; FeatureMap output = (FeatureMap) featureMapOutput; lrnScript.set_in_blob(input.getFeatureMap()); lrnScript.set_out_blob(output.getFeatureMap()); Script.LaunchOptions option = new Script.LaunchOptions(); int channel = outputShape[3]; int channelAligned = getInputChannelAligned(); switch (normRegion) { case "ACROSS_CHANNELS": option.setX(0, channel).setY(0, outputShape[1] * outputShape[2]); lrnScript.forEach_cross_channel(option); break; case "WITHIN_CHANNEL": option.setX(0, channelAligned / 4).setY(0, outputShape[1] * outputShape[2]); lrnScript.forEach_within_channel(option); break; default: LogUtil.e(TAG, "lrn type illegal:" + normRegion); break; } } }
@Override public void computeFeatureMap() { FeatureMap fm = (FeatureMap) featureMapInput[0]; Allocation fmInput = fm.getFeatureMap(); FeatureMap roi = (FeatureMap) featureMapInput[1]; Allocation roiInput = roi.getFeatureMap(); FeatureMap output = (FeatureMap) featureMapOutput; Allocation outAllocation = output.getFeatureMap(); roiPoolScript.set_fmap_blob(fmInput); roiPoolScript.set_roi_blob(roiInput); roiPoolScript.set_out_blob(outAllocation); int roiCount = inputShape[1][0]; int channel = inputShape[1][3]; if(channel==256){ Script.LaunchOptions option = new Script.LaunchOptions(); option.setX(0, roiCount * pooledH * pooledW); roiPoolScript.forEach_compute_channel256(option); } else { roiPoolScript.forEach_compute_vector(outAllocation); } }
@Override public void computeFeatureMap() { FeatureMap input = (FeatureMap) featureMapInput[0]; FeatureMap output = (FeatureMap) featureMapOutput; scriptCFlatten.set_InputData(input.getFeatureMap()); scriptCFlatten.set_OutputData(output.getFeatureMap()); Allocation frameAllocation = input.getFeatureMap(); if(!input.isMatrix2D()){ output.setFeatureMap(input.getFeatureMap()); return; } if (inputShape[0][3] % 4 == 0) { Script.LaunchOptions options = new Script.LaunchOptions(); options.setX(0, getInputChannelAligned() / 4) .setY(0, inputShape[0][1] * inputShape[0][2]); scriptCFlatten.forEach_compute_vector4(options); } else { scriptCFlatten.forEach_compute(frameAllocation); } }
@Override public void computeFeatureMap() { FeatureMap input = (FeatureMap)featureMapInput[0]; Allocation frameAllocation = input.getFeatureMap(); if(input.isPad4()) { Script.LaunchOptions option = new Script.LaunchOptions(); option.setX(0, getOutputChannelAligned() / 4).setY(0, outputShape[1] * outputShape[2]); scriptBatchNorm.set_InputData(frameAllocation); scriptBatchNorm.forEach_compute_vector4(option); } else { scriptBatchNorm.forEach_compute(frameAllocation, frameAllocation); } featureMapOutput = featureMapInput[0]; } }
@Override public void computeFeatureMap() { FeatureMap input = (FeatureMap)featureMapInput[0]; Allocation frameAllocation = input.getFeatureMap(); if (!input.isPad4()) { Script.LaunchOptions options = new Script.LaunchOptions(); options.setX(0, getOutputChannelAligned() / 4).setY(0, outputShape[1] * outputShape[2]); scriptDropout.set_InputData(frameAllocation); scriptDropout.set_OutputData(frameAllocation); scriptDropout.forEach_compute_vector4(options); } else { scriptDropout.forEach_compute(frameAllocation, frameAllocation); } featureMapOutput = featureMapInput[0]; }
@Override public void computeFeatureMap() { FeatureMap input = (FeatureMap) featureMapInput[0]; FeatureMap output = (FeatureMap) featureMapOutput; scriptDeconvolution.set_inputHeight(inputShape[0][1]); scriptDeconvolution.set_inputWidth(inputShape[0][2]); scriptDeconvolution.set_outputHeight(outputShape[1]); scriptDeconvolution.set_outputWidth(outputShape[2]); scriptDeconvolution.set_InputData(input.getFeatureMap()); scriptDeconvolution.set_OutputData(output.getFeatureMap()); Script.LaunchOptions options = new Script.LaunchOptions(); options.setX(0, getOutputChannelAligned() / 4).setY(0, outputShape[1] * outputShape[2]); //TODO: support no grouped deconvolution scriptDeconvolution.forEach_deconv_dw4(options); }
@Override public void computeFeatureMap(){ int count = inputShape[0][0]; Allocation bottomData = ((FeatureMap)featureMapInput[0]).getFeatureMap(); Allocation bottomRois = ((FeatureMap)featureMapInput[0]).getFeatureMap(); Allocation topData = ((FeatureMap)featureMapInput[0]).getFeatureMap(); psroiPooling.set_bottom_data(bottomData); psroiPooling.set_bottom_rois(bottomRois); psroiPooling.set_top_data(topData); Script.LaunchOptions option = new Script.LaunchOptions(); option.setX(0, pooledH * pooledW * outputDim); psroiPooling.forEach_compute(option); }
@Override public void computeFeatureMap() { Allocation frameAllocation = ((FeatureMap)featureMapInput[0]).getFeatureMap(); Script.LaunchOptions option = new Script.LaunchOptions(); option.setX(0, getOutputChannelAligned() / 4).setY(0, outputShape[1] * outputShape[2]); scriptScale.set_InputData(frameAllocation); scriptScale.forEach_compute_vector4(option); featureMapOutput = featureMapInput[0]; } }
protected Script.LaunchOptions getLaunchOptionVector4(){ Script.LaunchOptions options = new Script.LaunchOptions(); options.setX(0, getOutputChannelAligned() / 4) .setY(0, outputShape[1] * outputShape[2]); return options; }