pub fn transform_kernel(
  context: &mut Context,
  coordinate_features: u32,
  batch_count: u32,
  size: &[u32; 2],
  kernel: &Arc<CpuAccessibleBuffer<[f32]>>,
) -> Result<(), Box<dyn Error>> {
  // Configure kernel FFT
  let config = Config::builder()
    .physical_device(context.physical)
    .device(context.device.clone())
    .fence(&context.fence)
    .queue(context.queue.clone())
    .buffer(kernel.clone())
    .command_pool(context.pool.clone())
    .kernel_convolution()
    .normalize()
    .coordinate_features(coordinate_features)
    .batch_count(1)
    .r2c()
    .disable_reorder_four_step()
    .dim(&size)
    .build()?;

  // Allocate a command buffer
  let primary_cmd_buffer = context.alloc_primary_cmd_buffer()?;

  // Create command buffer handle
  let builder =
    unsafe { UnsafeCommandBufferBuilder::new(&primary_cmd_buffer, Kind::primary(), Flags::None)? };

  // Configure FFT launch parameters
  let mut params = LaunchParams::builder().command_buffer(&builder).build()?;

  // Construct FFT "Application"
  let mut app = App::new(config)?;

  // Run forward FFT
  app.forward(&mut params)?;
  // app.inverse(&mut params)?;

  // Dispatch command buffer and wait for completion
  let command_buffer = builder.build()?;
  context.submit(command_buffer)?;

  Ok(())
}
/// Transform a kernel from spatial data to frequency data
Transform a kernel from spatial data to frequency data
Transform a kernel from spatial data to frequency data
pub fn transform_kernel(
  context: &mut Context,
  coordinate_features: u32,
  batch_count: u32,
  size: &[u32; 2],
  kernel: &Arc<CpuAccessibleBuffer<[f32]>>,
) -> Result<(), Box<dyn Error>> {
  // Configure kernel FFT
  let config = Config::builder()
    .physical_device(context.physical)
    .device(context.device.clone())
    .fence(&context.fence)
    .queue(context.queue.clone())
    .buffer(kernel.clone())
    .command_pool(context.pool.clone())
    .kernel_convolution()
    .normalize()
    .coordinate_features(coordinate_features)
    .batch_count(1)
    .r2c()
    .disable_reorder_four_step()
    .dim(&size)
    .build()?;
  // Allocate a command buffer
  let primary_cmd_buffer = context.alloc_primary_cmd_buffer()?;
  // Create command buffer handle
  let builder =
    unsafe { UnsafeCommandBufferBuilder::new(&primary_cmd_buffer, Kind::primary(), Flags::None)? };
  // Configure FFT launch parameters
  let mut params = LaunchParams::builder().command_buffer(&builder).build()?;
  // Construct FFT "Application"
  let mut app = App::new(config)?;
  // Run forward FFT
  app.forward(&mut params)?;
  // app.inverse(&mut params)?;
  // Dispatch command buffer and wait for completion
  let command_buffer = builder.build()?;
  context.submit(command_buffer)?;
  Ok(())
}
pub fn transform_kernel ( context : & mut Context , coordinate_features : u32 , batch_count : u32 , size : & [ u32 ; 2 ] , kernel : & Arc < CpuAccessibleBuffer < [ f32 ] > > , ) -> Result < ( ) , Box < dyn Error > > { // Configure kernel FFT let config = Config :: builder ( ) . physical_device ( context . physical ) . device ( context . device . clone ( ) ) . fence ( & context . fence ) . queue ( context . queue . clone ( ) ) . buffer ( kernel . clone ( ) ) . command_pool ( context . pool . clone ( ) ) . kernel_convolution ( ) . normalize ( ) . coordinate_features ( coordinate_features ) . batch_count ( 1 ) . r2c ( ) . disable_reorder_four_step ( ) . dim ( & size ) . build ( ) ? ; // Allocate a command buffer let primary_cmd_buffer = context . alloc_primary_cmd_buffer ( ) ? ; // Create command buffer handle let builder = unsafe { UnsafeCommandBufferBuilder :: new ( & primary_cmd_buffer , Kind :: primary ( ) , Flags :: None ) ? } ; // Configure FFT launch parameters let mut params = LaunchParams :: builder ( ) . command_buffer ( & builder ) . build ( ) ? ; // Construct FFT "Application" let mut app = App :: new ( config ) ? ; // Run forward FFT app . forward ( & mut params ) ? ; // app.inverse(&mut params)?; // Dispatch command buffer and wait for completion let command_buffer = builder . build ( ) ? ; context . submit ( command_buffer ) ? ; Ok ( ( ) ) }
Transform a kernel from spatial data to frequency data
Transform a kernel from spatial data to frequency data
context
&mut Context
coordinate_features
u32
batch_count
u32
size
&[u32; 2]
kernel
&Arc<CpuAccessibleBuffer<[f32]>>
context
&mut Context
coordinate_features
u32
batch_count
u32
size
&[u32; 2]
kernel
&Arc<CpuAccessibleBuffer<[f32]>>