Skip to main content

Computational Backend

In deep learning services, it is not enough to only support model acceleration. Therefore, we have built-in some commonly used fine-grained backends.

Built-in Backends

NameDescription
DecodeMatJPEG decoding
cvtColorMatColor space conversion
ResizeMatImage resizing
PillowResizeMatResize that strictly matches Pillow's results
More...

The default backend is Identity:

NameInitialization ParametersInput/TypeOutput/TypeRemarks
IdentityNonedata/anyresult/anyAssigns the value of data to result.

Usage Example:

import torchpipe as tp
import numpy as np

# Set up configuration for single-node scheduler and DecodeMat backend
config = {
"instance_num": 2,
"backend": "DecodeMat",
}

# Initialize models
models = tp.pipe(config)

# Read image data from file
with open("../test/assets/norm_jpg/dog.jpg", "rb") as f:
data = f.read()

# Perform forward pass on input data
input = {"data": data}
models(input)
result: np.ndarray = input["result"]
assert(result.shape == (576, 768, 3))