android.renderscript.Allocation.copyFrom()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中android.renderscript.Allocation.copyFrom()方法的一些代码示例,展示了Allocation.copyFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Allocation.copyFrom()方法的具体详情如下:
包路径:android.renderscript.Allocation
类名称:Allocation
方法名:copyFrom

Allocation.copyFrom介绍

暂无

代码示例

代码示例来源:origin: chuanqi305/rscnn

private static void copyToAllocation(float[][] input, Allocation allocation)
{
  int n = input.length;
  int c = input[0].length;
  float[] output = new float[n * c];
  int count = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<c;j++){
      output[count++] = input[i][j];
    }
  }
  allocation.copyFrom(output);
}

代码示例来源:origin: chuanqi305/rscnn

kernelAllocation.copyFrom(weight);
biasAllocation.copyFrom(bias);

代码示例来源:origin: chuanqi305/rscnn

kernelAllocation.copyFrom(kernelMatrix);
biasAllocation.copyFrom(biasArray);

代码示例来源:origin: chuanqi305/rscnn

private static void copyToAllocation(float[][][][] input, Allocation allocation)
{
  int n = input.length;
  int h = input[0].length;
  int w = input[0][0].length;
  int c = input[0][0][0].length;
  float[] output = new float[n * h * w * c];
  int count = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<h;j++){
      for(int k=0;k<w;k++){
        for(int l=0;l<c;l++){
          output[count++] = input[i][j][k][l];
        }
      }
    }
  }
  allocation.copyFrom(output);
}

代码示例来源:origin: chuanqi305/rscnn

kernelAllocation.copyFrom(kernelMatrix);
biasAllocation.copyFrom(biasMatrix);
  biasAllocation.copyFrom(new float[getOutputChannelAligned()]);

代码示例来源:origin: chuanqi305/rscnn

private static void copyToAllocationVector4(float[][][][] input, Allocation allocation)
{
  int n = input.length;
  int h = input[0].length;
  int w = input[0][0].length;
  int c = input[0][0][0].length;
  int channelAlign = c;
  int skip = 0;
  if(channelAlign % 4 !=0) {
    channelAlign = c + 4 - c % 4;
    skip = 4 - c % 4;
  }
  float[] output = new float[n * h * w * channelAlign];
  int count = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<h;j++){
      for(int k=0;k<w;k++){
        for(int l=0;l<c;l++){
          output[count++] = input[i][j][k][l];
        }
        count += skip;
      }
    }
  }
  allocation.copyFrom(output);
}

代码示例来源:origin: chuanqi305/rscnn

@Override
public void computeFeatureMap(){
  float[] bmp = (float[])featureMapInput[0];
  FeatureMap featureMap = (FeatureMap) featureMapOutput;
  featureMap.getFeatureMap().copyFrom(bmp);
}

代码示例来源:origin: eventtus/photo-editor-android

protected void blur(Bitmap bitmapToBlur, Bitmap blurredBitmap) {
  mBlurInput.copyFrom(bitmapToBlur);
  mBlurScript.setInput(mBlurInput);
  mBlurScript.forEach(mBlurOutput);
  mBlurOutput.copyTo(blurredBitmap);
}

代码示例来源:origin: stackoverflow.com

mScript = new ScriptC_Square(mRS, getResources(), R.raw.square);
mInAllocation.copyFrom(input);

代码示例来源:origin: chuanqi305/rscnn

meanAllocation.copyFrom(meanArray);
rstdAllocation.copyFrom(rstdArray);

代码示例来源:origin: chuanqi305/rscnn

@Override
public void setup()
{
  int channel = outputShape[3];
  int channelAlign = channel;
  if(channel % 4 != 0){
    channelAlign = channel + 4 - channel % 4;
  }
  scriptScale = new ScriptC_Scale(renderScript);
  float[] scaleArray = new float[channelAlign];
  float[] biasArray = new float[channelAlign];
  for(int i=0;i<channel;i++){
    scaleArray[i] = scale[i];
    biasArray[i] = bias[i];
  }
  Allocation scaleAllocation;
  Allocation biasAllocation;
  Type scaleType = Type.createX(renderScript, Element.F32_4(renderScript), channelAlign / 4);
  Type biasType = Type.createX(renderScript, Element.F32_4(renderScript), channelAlign / 4);
  scaleAllocation = Allocation.createTyped(renderScript, scaleType, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
  scaleAllocation.copyFrom(scaleArray);
  biasAllocation = Allocation.createTyped(renderScript, biasType, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_SCRIPT);
  biasAllocation.copyFrom(biasArray);
  scriptScale.set_scale(scaleAllocation);
  scriptScale.set_bias(biasAllocation);
}

相关文章