msdnet.gpuoperations module

Module implementing network operations on GPU using Numba.

msdnet.gpuoperations.get1dgridsize(sz, tpb=1024)[source]

Return CUDA grid size for 1d arrays.

Parameters
  • sz – input array size

  • tpb – (optional) threads per block

msdnet.gpuoperations.get2dgridsize(sz, tpb=(8, 8))[source]

Return CUDA grid size for 2d arrays.

Parameters
  • sz – input array size

  • tpb – (optional) threads per block

class msdnet.gpuoperations.GPUImageData(shape, dl, nin)[source]

Bases: object

Object that represents a set of 2D images on GPU.

Parameters
  • shape – total shape of all images

  • dl – list of dilations in the network

  • nin – number of input images of network

set_block_size(imshape)[source]

Set CUDA grid sizes to be used.

setimages(ims)[source]

Set data to set of images.

Parameters

ims – set of images

setscalars(scl, start=0)[source]

Set each image to a scalar.

Parameters

scl – scalar values

fill(val, start=None, end=None)[source]

Set image data to single scalar value.

Parameters

val – scalar value

copy(start=None, end=None)[source]

Return copy of image data.

get(start=None, end=None)[source]

Return image data.

add(val, i)[source]

Add scalar to single image.

Parameters
  • val – scalar to add

  • i – index of image to add value to

mult(val, i)[source]

Multiply single image with value.

Parameters
  • val – value

  • i – index of image to multiply

prepare_forw_conv(f)[source]

Prepare for forward convolutions.

Parameters

f – convolution filters

forw_conv(i, outidx, dl)[source]

Perform forward convolutions

Parameters
  • i – image index to compute

  • outidx – image index to write output to

  • dl – dilation list

prepare_back_conv(f)[source]

Prepare for backward convolutions.

Parameters

f – convolution filters

back_conv(outidx, dl)[source]

Perform backward convolutions

Parameters
  • outidx – image index to write output to

  • dl – dilation list

relu(i)[source]

Apply ReLU to single image.

relu2(i, dat, j)[source]

Apply backpropagation ReLU to single image.

combine_all_all(dat, w)[source]

Compute linear combinations of images.

prepare_gradient()[source]

Prepare for gradient computation.

filtergradientfull(ims)[source]

Compute gradients for filters.

weightgradientall(delta)[source]

Compute gradients for weights.

sumall()[source]

Compute image sums.

softmax()[source]

Compute softmax.

msdnet.gpuoperations.fastmult_impl(a, b, out)[source]
msdnet.gpuoperations.fastsumall_impl(a, out)[source]