@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); } }
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);
Script.LaunchOptions options = new Script.LaunchOptions(); int outputChannelAligned = getOutputChannelAligned(); options.setX(0, outputChannelAligned / 4).setY(0, outputShape[1] * outputShape[2]);
@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 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; 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() { 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; }