跳转至

5. 模型构造工具

1 构造模型工具sgs_chalk

1.1 sgs_chalk基本介绍

sgs_chalk是一款能够快速构建模型的工具,使用方法类似于开源深度学习框架pytorch和tensorflow,将支持的算子封装成API,通过用户调用API构建脚本,生成最原始的debug.sim,并且通过设置相关参数,能够一步生成到float.sim和fixed.sim。下面会介绍具体的使用方法。

chalkflow


1.2 sgs_chalk使用方法

(1) 使用前首先需要在脚本开头添加以下语句

from calibrator_custom import sgs_chalk
(2) 构建tensor

构建tensor调用的接口为sgs_chalk.Tensor,下面对传入参数进行介绍:

data: 传入tensor的具体数据,需要是np.array格式

shape: 传入tensor的shape

dtype: 传入tensor的data的数据类型,不传的话默认是’ float32’,支持传入的数据类型为uint8/int16/float32/int32/int64/complex64

name: 传入tensor的name,如果不传的话会默认以prefix_数字命名,并且内部有检查机制,遇到重名tensor会进行重新命名

prefix: 设置默认tensor命名的前缀

在sgs_chalk中,构建tensor主要分为以下两种,variable tensor会在构建operator时返回,一般无需用户创建

创建模型input tensor,调用sgs_chalk.Input接口

in0 = sgs_chalk.Input((1,28,28,1),name='input')

创建const tensor示例

weight1 = np.load("mnist_gen_weights/conv2d_4_kernel.npy")
weight1_tensor = sgs_chalk.Tensor(data=weight1,name='conv2d_4/kernel')
(3)构建operator 构建operator的接口是根据每个算子来的,创建每个算子需要传入的参数也不相同,会返回output tensor。具体可以参考1.4.3节,下面举几个简单的例子:

创建add

in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Add(in0,in1,name='output')

创建conv2d

in0 = sgs_chalk.Input((1,28,28,4),name='input0')
in1 = sgs_chalk.Input((8,3,3,4),name='input1')
out0 = sgs_chalk.Conv2d(in0,in1,name='output')

(4)构建model 构建model调用的接口为sgs_chalk.Model,下面对传入参数进行介绍: input_tensors: 传入输入tensor名称,集合为list形式 output_tensors: 传入输出tensor名称,集合为list形式

model = sgs_chalk.Model([in0],[out0])

(4)导出模型 导出模型应该在构建模型之后,调用接口如下:

model.save(model_path, input_config=None, convert_fixed=False, inputs=None)
该API有以下几种用法:

  • 仅保存debug模型:

    model.save('test.sim')
    
    会生成debug_test.sim模型

  • 会保存debug和float模型,需要配置input_config.ini

    model.save('test.sim',input_config='./input_config.ini')
    
    会生成Debug_test.sim和test.sim

  • 保存fixed模型,convert_fixed=True,添加inputs参数,将会自动生成模型前处理文件,并按照inputs的内容即用户传入的图片等数据走sigmastar内部统计量化流程生成fixed.sim模型:

    model.save('test.sim', input_config='./input_config.ini', convert_fixed=True, inputs='0.jpg')
    
    会读入inputs参数,根据input_config.ini的配置自动生成模型前处理脚本,量化生成fixed.sim模型

inputs参数有如下几种用法:

  • inputs=/path/to/img_dir 或 inputs=/path/to/img.jpg 如果input_config.ini中有模型输入的training_input_formats为RGB / BGR / GRAY,可以选用此用模式。

  • inputs=/path/to/npy_dir 或 inputs=/path/to/data.npy 如果input_config.ini中模型输入均为RAWDATA_S16_NHWC / RAWDATA_F32_NHWC / RAWDATA_COMPLEX64,可以选用此用模式。需要注意的是输入数据必须为numpy的npy格式

  • inputs=/path/to/img.txt  input_config.ini中有多个输入时,可以选用此用模式

  • inputs='RAWDATA' 如果input_config.ini中所有模型输入均为RAWDATA_S16_NHWC / RAWDATA_F32_NHWC / RAWDATA_COMPLEX64,可以选用此用模式。‘RAWDATA’模式提前配置好模型输入的min/max,保存模型是会生成基于模型输入配置的min/max输入文件和前处理,并转换生成fixed模型。此模式仅被用来测试构造出的模型能否按照sigmastar内部统计的量化流程生成到fixed模型。


1.3 使用sgs_chalk构建后处理模型

下面以Quick_Start_Demo/onnx_yolov8s/onnx_yolov8s_postprocess.py为例,介绍如何使用sgs_chalk构建后处理模型。

1.3.1 YOLOv8后处理优化思路

onnx_yolov8s.onnx模型输出信息如下图所示,通常YOLOv8转换出来的模型输出维度为 (1, 84, 8400),其中 8400 是候选框的数量,84包括4个边界框坐标和80个类别概率。获取到模型输出的候选框后,需要对所有候选框的类别进行判断以及NMS非极大值抑制操作后才能输出正确的坐标框。

YOLOv8 Output

官方的YOLOv8转换出来的offline模型cpu占用率较高。其根本原因在于YOLOv8默认输出8400个候选检测框(Bounding Box),在COCO数据集80类别检测场景下,每个候选框需执行80次类别置信度计算,即总计算量达到672,000次/帧(8400×80),会导致CPU的loading一直处在一个较高的状态。

通过TopK筛选出类别,通过Score_Filter筛选出满足置信度要求的框,再由NMS处理的数量就会大幅减少,可以降低CPU的loading。通过sgs_chalk构建的模型如下图所示:

YOLOv8 Postprocess


1.3.2 YOLOv8后处理模型构建

使用sgs_chalk构建YOLOv8s后处理模型的完整代码如下:

from calibrator_custom import sgs_chalk


IN_WIDTH = 640
IN_HEIGHT = 640
LAYER_STRIDES = [8, 16, 32]
LAYER_GRIDS = [int((IN_WIDTH / stride) * (IN_HEIGHT / stride)) for stride in LAYER_STRIDES]
ALL_LAYER_GRIDS = 0
for r_grid in LAYER_GRIDS:
    ALL_LAYER_GRIDS += r_grid
CONF_THRESHOLD = 0.27


def buildGraph(model_config):
    inputs = sgs_chalk.Input(shape=model_config['shape'], name=model_config['input'][0])
    [box, score] = sgs_chalk.Split_V(
        inputs,
        [4, model_config['num_classes']],
        axis=1,
        name=['box', 'confidence']
    )

    [cx, cy, w, h] = sgs_chalk.Split(box, 4, axis=1, name=['cx', 'cy', 'w', 'h'])
    w_ = sgs_chalk.Mul(w, 0.5)
    h_ = sgs_chalk.Mul(h, 0.5)

    x1 = sgs_chalk.Sub(cx, w_)
    y1 = sgs_chalk.Sub(cy, h_)
    x2 = sgs_chalk.Add(cx, w_)
    y2 = sgs_chalk.Add(cy, h_)

    concat = sgs_chalk.Concatenation([x1, y1, x2, y2], axis=1)
    bboxes = sgs_chalk.Transpose(concat, (0, 2, 1), name='boxes')

    score = sgs_chalk.Transpose(score, (0, 2, 1))

    [max_score, max_index] = sgs_chalk.TopK(score, k=1, name=['max_score', 'classes'])
    reshape_score = sgs_chalk.Squeeze(max_score, axis=-1, name='scores')

    out_score_index, out_score_num = sgs_chalk.Score_Filter(
        reshape_score,
        threshold=CONF_THRESHOLD,
        input_element_count=ALL_LAYER_GRIDS,
        name=['score_index', 'score_number']
    )

    outfilename = model_config['name'] + '_postprocess.sim'
    model = sgs_chalk.Model(
        [inputs],
        [bboxes, max_index, reshape_score, out_score_index, out_score_num]
    )
    buf = model.save_buf()
    with open(outfilename, 'wb') as f:
        f.write(buf)

    print('\nWell Done! ' + outfilename  + ' generated!\n')
    return outfilename


def get_postprocess():
    model_config = {
        'name': 'onnx_yolov8s',
        'input' : ['output0'],
        'shape': [1, 84, 8400],
        'num_classes': 80,
    }

    outfilename = buildGraph(model_config)

    return outfilename


def model_postprocess():
    return get_postprocess()

使用须知

  • 通过sgs_chalk的API可以快速构建所需的模型结构,其他API详见sgs_chalk模块API

  • 模型构建好后,需要声明model_postprocess()来调用,可返回模型的buf或者保存的模型路径。

  • 后处理模型仅保存Debug即可。转换时会在浮点模型阶段合并成一个模型。


1.3.3 YOLOv8s带后处理模型转换

初始化SGS_IPU_Toolchain

cd SGS_IPU_Toolchain
source cfg_env.sh

进入onnx_yolov8s目录

cd Quick_Start_Demo/onnx_yolov8s

运行如下命令转换

python3 SGS_IPU_Toolchain/Scripts/ConvertTool/SGS_converter.py onnx \
-i coco2017_calibration_set32 \
--model_file onnx_yolov8s.onnx \
--input_shape 1,3,640,640 \
--input_config input_config.ini \
-n onnx_yolov8s_preprocess.py
--output_file onnx_yolov8s_CHIP.img \
--export_models \
--postprocess onnx_yolov8s_postprocess.py \
--soc_version CHIP

使用须知

  • 与不加后处理的转换命令区别仅在于多增加了--postprocess参数。 增加--postprocess参数后,会生成autogen_开头的input_config.ini,其中修改了[OUTPUT_CONFIG]的outputs参数为后处理模型的输出,但是dequantizations都设为TRUE。

  • 如果需要自定义其他输出格式,可以独立配置新的input_config.ini,增加--postprocess_input_config参数指定。


1.3.4 YOLOv8s带后处理模型推理

Quick_Start_Demo/onnx_yolov8s/yolov8_simulator.py提供了带后处理和不带后处理YOLOv8s的推理方法。

运行命令示例:

python3 yolov8_simulator.py \
--image 000000562557.jpg \
--model /path/to/float.sim / fixed.sim / offline.img \
-n onnx_yolov8s_preprocess.py \
--draw_result output \
--soc_version CHIP

通过Score_Filter筛选出满足置信度要求的框,整理后送入只需要计算IoU的NMS处理。 具体可以参考Quick_Start_Demo/onnx_yolov8s/yolov8_simulator.pypostprocess_lite函数的处理流程:

def postprocess_lite(model_outputs, **kwargs):
    num_detect = int(model_outputs[4][0])
    predictions = []
    for i in range(num_detect):
        index = int(model_outputs[3][0, i])
        prediction = np.concatenate(
            [
                model_outputs[0][:, index, :],
                model_outputs[2][:, index: index + 1],
                model_outputs[1][:, index, :]
            ],
            axis=-1
        )  # box(x1, y1, x2, y2) + score + cls
        predictions.append(prediction)
    if num_detect > 0:
        predictions = np.concatenate(predictions, axis=0)
        boxes = torch.from_numpy(predictions[:, :4])
        score = torch.from_numpy(predictions[:, 4: 5]).squeeze(1)
        kept = torchvision.ops.nms(boxes, score, kwargs.get('iou_thres', 0.7))
        predictions = predictions[kept.numpy().tolist()]
    else:
        predictions = np.array([])
    return predictions

1.4 sgs_chalk模块API

  • Abs:

Computes the absolute value of a tensor.

Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input.

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.
Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Abs(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Add:

Returns x + y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Add(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Add(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Alpha_Blending:

output = [alpha * input0 + (1 - alpha) * input1] ==> output = [alpha * (input0 - input1) + input1]

Args:

x1: A `Tensor`
x2: A `Tensor`
alpha: A `Tensor`
name: A name for the model output tensor (optional).

Returns:

A `Tensor`

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = sgs_chalk.Input((1,1,36,2048), name='input0')
input2 = sgs_chalk.Input((1,1,36,2048), name='input1')
alpha = sgs_chalk.Input((1,1,36,2048), name='alpha')
out = sgs_chalk.Alpha_Blending(input1,input2,alpha, name='output')
model = sgs_chalk.Model([input1,input2,alpha], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • ArgMin:

Returns the indices of the minimum values along an axis.

Args:

x: A `Tensor`. Must be Variable Tensor.
axis: int
keep_dim: bool
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. It has the same shape as `x.shape`
    with the dimension along `axis` removed.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1, 80, 512),name='input0')
out0 = sgs_chalk.ArgMin(in0, 1, name='output')
model.save('test.sim')
  • Argmax:

Returns the indices of the maximum values along an axis.

Args:

x: A `Tensor`. Must be Variable Tensor.
axis: int
keep_dim: bool
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. It has the same shape as `x.shape`
    with the dimension along `axis` removed.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1, 80, 512),name='input0')
out0 = sgs_chalk.Argmax(in0, 1, name='output')
model.save('test.sim')
  • Atan:

Args:

input: x `Tensor`. Must be Variable Tensor.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,224,224,3),name='input')
out = sgs_chalk.Atan(input,name='output')
model = sgs_chalk.Model([input,], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Atan2:

Element-wise arctangent of input0 and input1 with consideration of the quadrant. Returns a new tensor with the signed angles in radians between (-pi, pi)

Args:

input:0 A `Tensor`. Must be Variable Tensor.
input1: A `Tensor`. Must be Variable Tensor.
name: A name for the model Output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
input0 = sgs_chalk.Input((1, 22535), name='input0')
input1 = sgs_chalk.Input((1, 22535), name='input1')
out = sgs_chalk.Atan2(input0, input1, name='output')
model = sgs_chalk.Model([input0, input1], out)
model.save('atan2.sim', input_config='./input_config.ini', convert_fixed=True)
  • AveragePool2d:

Performs the average pooling on the input. Each entry in output is the mean of the corresponding size ksize window in value.

Args:

x: A 4-D `Tensor` of shape `[batch, height, width, channels]`
ksize: A list of `ints` that has length `2`. The size of
the window for each dimension of the input tensor.
strides: An int or list of `ints` that has length `2`. The
stride of the sliding window for each dimension of the input tensor.
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight).
padding_type: str, only support [SAME, VALID, CAFFE, ONNXINSIDE, ONNXOUTSIDE], default is CAFFE.
 SAME or VALID padding_type will not use padding value.
name: Optional name for the operation.

Returns:

The average pooled output tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
out0 = sgs_chalk.AveragePool2d(in0,[2,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,112,112,3),name='input0')
out0 = sgs_chalk.AveragePool2d(in0,[2,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • AveragePool3d:

Performs the average pooling on the input. Each entry in output is the mean of the corresponding size ksize window in value.

Args:

x: A 5D `Tensor` of shape `[batch, height, width, channels]`
ksize: A list of `ints` that has length `3`. The size of
the window for each dimension of the input tensor.
strides: An int or list of `ints` that has length `3`. The
stride of the sliding window for each dimension of the input tensor.
padding: a tuple (paddingI,paddingT,paddingL,paddingO,paddingB,paddingR).
name: Optional name for the operation.

Returns:

The average pooled output tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,3,28,28,4),name='input0')
out0 = sgs_chalk.AveragePool3d(in0, (2,2,2), name='output')
model = sgs_chalk.Model(in0, out0)
model.save('test.sim')
  • BatchMatMul:

Multiplies matrix a by matrix b, producing a * b.

The inputs must be tensors of rank >= 2 where the inner 2 dimensions specify valid matrix multiplication arguments, and any further outer dimensions match.

Args:

x: input variable tensor and rank > 1.
y: input tensor with same type and rank as x,can be variable or const tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
in1 = sgs_chalk.Input((1,28,28,4),name='input1')
out0 = sgs_chalk.BatchMatMul(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.ones((1,28,28,4), dtype=np.float32)
in0 = sgs_chalk.Input((1,28,512,4),name='input0')
out0 = sgs_chalk.BatchMatMul(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • BatchToSpaceND:

BatchToSpace for 4-D tensors of type T.

This operation reshapes the "batch" dimension 0 into M + 1 dimensions of shape block_shape + [batch], interleaves these blocks back into the grid defined by the spatial dimensions [1, ..., M], to obtain a result with the same rank as the input. The spatial dimensions of this intermediate result are then optionally cropped according to crops to produce the output. This is the reverse of SpaceToBatch (see tf.space_to_batch).

Args:

x: A `Tensor`
block_size: Must be `Tensor` or `ndarray` or `list`
crops: A  2-D `Tensor` with shape `[2,2]`. Must be one of the
       following types: `int32`, `int64`. All values must be >= 0.
       `crops[i] = [crop_start, crop_end]` specifies the amount to crop from
       input dimension `i + 1`, which corresponds to spatial dimension `i`.

Returns:

A `Tensor` of same type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((4,28,28,512),name='input0')
out0 = sgs_chalk.BatchToSpaceND(in0,2,[[2,2],[2,2]],name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • BoxDecoder:

postprocess BoxDecoder

Args:

unpacked_box: a list of tensors which are unpacked

Return:

a list of tensors decoded

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
box_num = 9
side_x = 19
side_y = 19
ppw = anchor.ones(3249)
px = anchor.index_div_linear(1,1,0,box_num ,side_x,side_y)
pph = anchor.ones(3249)
py = anchor.index_div_linear(1,1,0,side_x*box_num,side_y,1)
pw = anchor.ones(3249)
ph = anchor.ones(3249)

sx = anchor.ns(3249,1.0/19)
sy = anchor.ns(3249,1.0/19)

biases= [[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5]]
sw = [x[0]/(2*19) for x in biases ]*(19*19)
sh = [x[1]/(2*19) for x in biases ]*(19*19)
config = {"shape" : [1,3249],
      "tx_func" : (tflite.BuiltinOperator.BuiltinOperator().LOGISTIC,None),#None or 'x_scale'
      "ty_func" : (tflite.BuiltinOperator.BuiltinOperator().LOGISTIC,None),#None or 'y_scale'
      "tw_func" : (tflite.BuiltinOperator.BuiltinOperator().RESHAPE,None),#None or 'w_scale'
      "th_func" : (tflite.BuiltinOperator.BuiltinOperator().RESHAPE,None),#None or 'h_scale'
      "x_scale" : 0.1,
      "y_scale" : 0.1,
      "w_scale" : 1,
      "h_scale" : 1,
      "anchor_selector" : "constant",
      "pw" : pw,
      "ph" : ph,
      "pw_func" : (None,None),
      "ph_func" : (None,None),
      "ppw" : ppw,
      "px" : px,
      "pph" : pph,
      "py" : py,
      "sx" : sx,
      "sy" : sy,
      "sw" : sw,
      "sh" : sh
      }
in0 = sgs_chalk.Input(model_config["input_shape"][0], name = model_config["input"][0])
unpack_out_tensors1 = []
for i in range(7):
    unpack_out_tensors1.append("SGS_unpack1_"+str(i))
output_list = sgs_chalk.PostProcess_Unpack(in0,name=unpack_out_tensors1)

bosdecoder_output_list = sgs_chalk.BoxDecoder(config,output_list)
model = sgs_chalk.Model([in0],bosdecoder_output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • BoxDecoder2:

postprocess BoxDecoder2

Args:

unpacked_box: a list of tensors which are unpacked

Return:

:return:a list of tensors decoded

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
box_num = 9
side_x = 19
side_y = 19
ppw = anchor.ones(3249)
px = anchor.index_div_linear(1,1,0,box_num ,side_x,side_y)
pph = anchor.ones(3249)
py = anchor.index_div_linear(1,1,0,side_x*box_num,side_y,1)
pw = anchor.ones(3249)
ph = anchor.ones(3249)

sx = anchor.ns(3249,1.0/19)
sy = anchor.ns(3249,1.0/19)

biases= [[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5],[9.5,9.5]]
sw = [x[0]/(2*19) for x in biases ]*(19*19)
sh = [x[1]/(2*19) for x in biases ]*(19*19)
config = {"shape" : [1,3249],
    "tx_func" : (tflite.BuiltinOperator.BuiltinOperator().LOGISTIC,None),#None or 'x_scale'
    "ty_func" : (tflite.BuiltinOperator.BuiltinOperator().LOGISTIC,None),#None or 'y_scale'
    "tw_func" : (tflite.BuiltinOperator.BuiltinOperator().RESHAPE,None),#None or 'w_scale'
    "th_func" : (tflite.BuiltinOperator.BuiltinOperator().RESHAPE,None),#None or 'h_scale'
    "x_scale" : 0.1,
    "y_scale" : 0.1,
    "w_scale" : 1,
    "h_scale" : 1,
    "anchor_selector" : "constant",
    "pw" : pw,
    "ph" : ph,
    "pw_func" : (None,None),
    "ph_func" : (None,None),
    "ppw" : ppw,
    "px" : px,
    "pph" : pph,
    "py" : py,
    "sx" : sx,
    "sy" : sy,
    "sw" : sw,
    "sh" : sh
    }
in0 = sgs_chalk.Input(model_config["input_shape"][0], name = model_config["input"][0])
unpack_out_tensors1 = []
for i in range(7):
    unpack_out_tensors1.append("SGS_unpack1_"+str(i))
output_list = sgs_chalk.PostProcess_Unpack(in0,name=unpack_out_tensors1)

bosdecoder_output_list = sgs_chalk.BoxDecoder(config,output_list)
model = sgs_chalk.Model([in0],bosdecoder_output_list)
#model.save('test.sim')
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Cast:

Casts a tensor to a new type.

Args:

x: A `Tensor`. Must be Variable Tensor.
dtype: The destination type.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor` with same shape as `x` and same type as `dtype`.

Examples:

case0
from calibrator_custom import sgs_chalk
in0 = sgs_chalk.Input((28,512,1), dtype='float32', name='input')
out = sgs_chalk.Cast(in0, 'int32', name='output')
model = sgs_chalk.Model(in0, out)
model.save('test.sim')
  • Ceil:

Ceil the values of a tensor to the nearest integer, element-wise.

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Ceil(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Clip:

Clips tensor values to a specified min and max.

Given a tensor x, this operation returns a tensor of the same type and shape as x with its values clipped to min_value and max_value. Any values less than min_value are set to min_value. Any values greater than max_value are set to max_value.

Args:

x: A `Tensor`. Must be Variable Tensor.
min_value: A value.
max_value: A value.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,36,2048), name='input')
output = sgs_chalk.Clip(input,0,1, name='output')
model = sgs_chalk.Model([input,], output)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Concatenation:

Concatenates the list of tensors values along dimension axis. If values[i].shape = [D0, D1, ... Daxis(i), ...Dn], the concatenated result has shape [D0, D1, ... Raxis, ...Dn] where Raxis = sum(Daxis(i)) That is, the data from the input tensors is joined along the axis dimension. The number of dimensions of the input tensors must match, and all dimensions except axis must be equal.

Args:

values: A list of `Tensor` objects or a single `Tensor`.
axis: 0-D `int32` `Tensor`.  Dimension along which to concatenate. Must be
    in the range `[-rank(values), rank(values))`. As in Python, indexing for
    axis is 0-based. Positive axis in the rage of `[0, rank(values))` refers
    to `axis`-th dimension. And negative axis refers to `axis +
    rank(values)`-th dimension.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,1),name='input0')
in1 = sgs_chalk.Input((28,512,2),name='input1')
in2 = sgs_chalk.Input((28,512,3),name='input2')
x = [in0, in1, in2]
out0 = sgs_chalk.Concatenation(x,axis=2,name='output')
model = sgs_chalk.Model(x,out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,1,512),name='input0')
in1 = sgs_chalk.Input((28,2,512),name='input1')
in2 = sgs_chalk.Input((28,3,512),name='input2')
x = [in0, in1, in2]
out0 = sgs_chalk.Concatenation(x,axis=1,name='output')
model = sgs_chalk.Model(x,out0)
model.save('test.sim')
  • CondGreat:

x0[i] > x1 ? x3:x2[i]

Args:

x0: `Tensor`. Must be Variable Tensor.
x1: A value.
x2: `Tensor`. Must be Variable Tensor, has same shape as x0.
x3: A value
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input x0.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
input1 = sgs_chalk.Input((1,224,224,3),name='input1')
out = sgs_chalk.CondGreat(input0,2.0,input1,1.0,name='output')
model = sgs_chalk.Model([input0,input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True,inputs='RAWDATA')
  • CondLess:

x0[i] < x1 ? x3:x2[i]

Args:

x0: `Tensor`. Must be Variable Tensor.
x1: A value.
x2: `Tensor`. Must be Variable Tensor, has same shape as x0.
x3: A value
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input x0.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
input1 = sgs_chalk.Input((1,224,224,3),name='input1')
out = sgs_chalk.CondLess(input0,2.0,input1,1.0,name='output')
model = sgs_chalk.Model([input0,input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True,inputs='RAWDATA')
  • Conv2d:

Conv2d

Args:

x : input tensor of shape(1, iH, iW,in_channels)
weight: filters of shape(out_channels, kH, kW, in_channels)
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sH,sW).Default: 1
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight) or a str `SAME`/ `VALID`.
dilation: the spacing between kernel elements. Can be a single number or a tuple(dH,dW).Default: 1
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
in1 = sgs_chalk.Input((8,3,3,4),name='input1')
out0 = sgs_chalk.Conv2d(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((8,3,3,4), dtype=np.float32)
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
out0 = sgs_chalk.Conv2d(in0,input1, Activation = 'RELU',name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Conv3d:

Args:

x : input tensor of shape(n, iD, iH, iW,in_channels)
weight: filters of shape(kD, kH, kW, in_channels, out_channels)
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sD,sH,sW).Default: 1
padding: a tuple (paddingI,paddingT,paddingL,paddingO,paddingB,paddingR).
dilation: the spacing between kernel elements. Can be a single number or a tuple(dD,dH,dW).Default: 1
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6

Returns:

The conv3d output tensor(n, oD, oH, oW, out_channels)

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((3,3,3,64,64), dtype=np.float32)
in0 = sgs_chalk.Input((1,16,56,56,64),name='input0')
out0 = sgs_chalk.Add(in0,0.4)
out1 = sgs_chalk.Conv3d(out0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Conv3dImageConcat:

Args:

x : input tensor of shape(n, iD, iH, iW,in_channels)
weight: filters of shape(kD, kH, kW, in_channels, out_channels)
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sD,sH,sW).Default: 1
padding: a tuple (paddingI,paddingT,paddingL,paddingO,paddingB,paddingR).
dilation: the spacing between kernel elements. Can be a single number or a tuple(dD,dH,dW).Default: 1
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6

Returns:

The conv3d output tensor(n, oD, oH, oW, out_channels)

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((3,3,3,64,64), dtype=np.float32)
in0 = sgs_chalk.Input((1,16,56,56,64),name='input0')
out0 = sgs_chalk.Add(in0,0.4)
out1 = sgs_chalk.Conv3d(out0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Cos:

Returns Cos(x) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.

Returns:
```text
A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Sin(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Cumsum:

Cumsum

Args:

input: A `Tensor` or 'Array'. Must be Variable Tensor if it's a Tensor.
asix: A 'Tensor' or 'Array'. Must be Const Tensor if it's a Tensor.
exclusive: Let first sum as 0.
reverse: Reverse the output.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np

input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
square_out = sgs_chalk.Square(input, name='softplus_out')
model = sgs_chalk.Model([input,], square_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • CustomNotEqual:

FLT_EPSILON = (1.192092896e-07F) if (fabs(x0 - value) < FLT_EPSILON) Output = x0 else Output = x1

Args:

x0: `Tensor`. Must be Variable Tensor.
x1: `Tensor`. Must be Variable Tensor, has same shape as x0.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input x0.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
input1 = sgs_chalk.Input((1,224,224,3),name='input1')
out = sgs_chalk.CustomNotEqual(input0,input1,1.0,name='output')
model = sgs_chalk.Model([input0,input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True,inputs='RAWDATA')
  • CustomPow:

Args:

input: x `Tensor`. Must be Variable Tensor.
input: y `Tensor`. Must be Constant Scaler.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
input1 = sgs_chalk.Tensor(0.3333333333333333, name='input1')
customPow_out = sgs_chalk.CustomPow(input,input1, name='customPow_out')
model = sgs_chalk.Model([input,], customPow_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • CustomizedMaxpool2d:

Performs the max pooling on the input. Each entry in output is the mean of the corresponding size ksize window in value and index.

Args:

x: A 4-D `Tensor` of shape `[batch, height, width, channels]`
ksize: A list of `ints` that has length `1`, `2` or `4`. The size of
the window for each dimension of the input tensor.
strides: An int or list of `ints` that has length `1`, `2` or `4`. The
stride of the sliding window for each dimension of the input tensor.
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight).
name: Optional name for the operation.

Returns:

The max pooled output tensor
index tensor

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
output_list = sgs_chalk.CustomizedMaxpool2d(in0,[2,2],name=['output','index'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim')
  • DepthWiseConv2d:

DepthWiseConv2D

Args:

x : input tensor of shape(1, iH, iW,in_channels)
weight: filters of shape(1, kH, kW, out_channels) in_channels = out_channels
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sH,sW).Default: 1
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight) or a str `SAME`/ `VALID`.
dilation: the spacing between kernel elements. Can be a single number or a tuple(dH,dW).Default: 1
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
in1 = sgs_chalk.Input((1,3,3,4),name='input1')
out0 = sgs_chalk.DepthWiseConv2D(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((1,3,3,4), dtype=np.float32)
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
out0 = sgs_chalk.DepthWiseConv2D(in0,input1,bias = None, Activation = 'RELU',name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Dilation:

Dilation a tensor.

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Dilation(in0,[2,1,0,0],[2,0],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Div:

Returns x / y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Div(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Div(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.ones((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Div(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Elu:

Args:

x: A `Tensor`. Must be Variable Tensor.
name: A name for the model Input tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as settings.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Elu(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Equal:

Returns the truth value of (x == y) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Equal(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Equal(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Equal(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Erf:

Computes the Gauss error function of x element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,36,2048), name='input')
output = sgs_chalk.Erf(input,name='output')
model = sgs_chalk.Model([input,], output)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Exp:

Computes exponential of x element-wise. (y = e^x).

Args:

x: A `Tensor`. Must be Variable Tensor.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Exp(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Expand_dims:

Expand the shape of a tensor.

Insert a new axis that will appear at the axis position in the expanded tensor shape.

Args:

x: A `Tensor`..
axis: An int or a `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Output tensor. The number of dimensions is one greater than that of the input tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4), name='input0')
out0 = sgs_chalk.Expand_dims(in0, axis=0, name='output')
model = sgs_chalk.Model(in0, out0)
model.save('test.sim')
</details>

- Fill:

Creates a tensor filled with a scalar value.

Fill creates a tensor of shape `dims` and fills it with `value`.

Args:
```text
dims: A `Tensor`. Must be one of the following types: `int32`, `int64`. 1-D. Represents the shape of the output tensor.
value: A `Tensor`. 0-D (scalar). Value to fill the returned tensor.
name: A name for the output tensor (optional).
Returns:
returns: A `Tensor`. Has the same type as `value`.
Examples:
case0
from calibrator_custom import sgs_chalk

in0 = sgs_chalk.Input((28,4,4),name='input0')
out = sgs_chalk.Shape(in0)
out0 = sgs_chalk.Fill(out, 1.0)
model = sgs_chalk.Model(in0, out0)
model.save('test.sim')
- Floor: Floor the values of a tensor to the nearest integer, element-wise. Args:
x: A `Tensor`
Returns:
A `Tensor` of same shape and type as `x`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Floor(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
- Fullyconnected: `fully_connected` creates a variable called `weights`, representing a fully connected weight matrix, which is multiplied by the `inputs` to produce a `Tensor` of hidden units. Args:
x : input tensor of shape 2 dims
weight: filters of shape 2 dims
bias: optional bias tensor of shape(out_channels). Default:None
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((1000,112), dtype=np.float32)
in0 = sgs_chalk.Input((3,112),name='input0')
out0 = sgs_chalk.Fullyconnected(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((1000,112), dtype=np.float32)
in0 = sgs_chalk.Input((3,112),name='input0')
out0 = sgs_chalk.Fullyconnected(in0,input1,bias = None, Activation = 'RELU',name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- GRU: Applies a multi-layer gated recurrent unit (GRU) RNN to an input sequence. Args:
x: A `Tensor`,shape is (L,1,N,input_size)  N=batch size  L=sequence length
h0:tensor of shape(1,1,1,hidden_size),containing the initial hidden state for each element in the input sequence.
hidden_size : The number of features in the hidden state h
W: A `Tensor`, shape is [1,3*hidden_size,input_size]
R: A `Tensor`, shape is [1,3*hidden_size,hidden_size]
B: A `Tensor`, shape is [1,6*hidden_size]
Returns:
A `Tensor` list,usually concatenate op should be add after GRU
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,6,2))
R_1 = np.ones((1,6,2))
B_1 = np.ones((1,12))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out = sgs_chalk.GRU(in0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name='gru_output')
model = sgs_chalk.Model([in0],out)
model.save('test.sim')
case1
W_1 = np.ones((1,6,2))
R_1 = np.ones((1,6,2))
B_1 = np.ones((1,12))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out= sgs_chalk.GRU(in0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name='gru_output')
out1= sgs_chalk.GRU(out,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name='gru_output2')
model = sgs_chalk.Model([in0],output_tensor_list_1[0])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
case2
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,6,2))
R_1 = np.ones((1,6,2))
B_1 = np.ones((1,12))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out = sgs_chalk.GRU(in0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name='gru_output')
hn = sgs_chalk.Slice(out,[1,0,0,0],[1,1,1,2],name='gru_hn')
model = sgs_chalk.Model([in0],[out,hn])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
- Gather: Gather slices from `x` axis `axis` according to `indices`. `indices` must be an integer tensor of any dimension (usually 0-D or 1-D). Produces an output tensor with shape `params.shape[:axis] + indices.shape + params.shape[axis + 1:]` Args:
x: A variable `Tensor`. The tensor from which to gather values.
indices: A `Tensor`.  Must be in range `[0, params.shape[axis])`.
axis: A `Tensor`. The axis in `params` to gather `indices` from. Defaults to the first
      dimension.
name: A name for the output tensor (optional).
Returns:
A `Tensor`. Has the same type as `value`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.Gather(in0,[0,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.Gather(in0,[[0,1],[0,1]],axis=1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- GatherElements: GatherElements slices from `x` axis `axis` according to `indices`. `indices` must be an integer tensor of any dimension (usually 0-D or 1-D). Produces an output tensor with shape `params.shape[:axis] + indices.shape + params.shape[axis + 1:]` Args:
x: A variable `Tensor`. The tensor from which to GatherElements values.
indices: A `Tensor`.  Must be in range `[0, params.shape[axis])`.
axis: A `Tensor`. The axis in `params` to GatherElements `indices` from. Defaults to the first
      dimension.
name: A name for the output tensor (optional).
Returns:
A `Tensor`. Has the same type as `value`.
Examples:
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.GatherElements(in0,[[0,1],[0,1]],axis=1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • GatherND:

Args:

input: A `Tensor`. Must be Variable Tensor whose rank r >= 1.
indices: A const Tensor or numpy.array whose rank q >= 1.
batch_dims: The number of batch dimensions. The gather of indexing starts from dimension of data[batch_dims:]
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Tensor of rank q + r - indices_shape[-1] - 1.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,64,80,200), name='input')
indices = sgs_chalk.Input((1,64,80,1,1), name='indices')
gatherND_out = sgs_chalk.GatherND(input, indices, 3, name='gatherND_out')
model = sgs_chalk.Model([input,update], gatherND_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Gelu:

out = input*0.5*(1.0+erff(input/sqrtf(2.0)))

Args:

x1: A `Tensor`
name: A name for the model output tensor (optional).

Returns:

A `Tensor`
Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = sgs_chalk.Input((1,224,224,3), name='input0')
out = sgs_chalk.Gelu(input1,name='output')
model = sgs_chalk.Model([input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Greater:

greater(x, y, name=None) Returns the truth value of (x > y) element-wise.

Args:
x: A `Tensor`.
y: A `Tensor`. Must have the same type as `x`.
name: A name for the output tensor (optional).

Returns:

A `Tensor` of type `bool`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Greater(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Greater(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Greater(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • GreaterEqual:

Returns the truth value of (x >= y) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.GreaterEqual(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.GreaterEqual(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.GreaterEqual(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • GroupConv2d:

GroupConv

Args:

x : input tensor of shape(1, iH, iW, in_channels)
weight: filters of shape(out_channels, kH, kW, in_channels)
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sH,sW).Default: 1
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight) or a str `SAME`/ `VALID`.
dilation: the spacing between kernel elements. Can be a single number or a tuple(dH,dW).Default: 1
group: controls the connections between inputs and outputs. in_channels and out_channels must both be divisible by groups. Default: 1
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((8,3,3,2), dtype=np.float32)
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
out0 = sgs_chalk.GroupConv(in0,input1,group=2,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • HardSwish:

Args:

input: x `Tensor`. Must be Variable Tensor.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,224,224,3),name='input')
out = sgs_chalk.HardSwish(input,name='output')
model = sgs_chalk.Model([input,], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Input:

As an entry point into a graph.

Args:

shape: `Tuple`.
name: A name for the model Input tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as settings.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),datatype='complex64', name='input0')
  • Instancenorm:

Instancenorm

Args:

x: A `Tensor`
axis: Dimension along which to normalize.  A scalar or a vector of
    integers.
epsilon: A lower bound value for the norm.
weight: One dim,The value is  x.shape[-1]
bias: One dim,The value is  x.shape[-1]

Returns:

A `Tensor`,has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
import pdb


#in0 = sgs_chalk.Input((4,256,96),name='input0')
weight = nr.uniform(-1, 1, (96)).astype('float32')
bias = nr.uniform(-1, 1, (96)).astype('float32')
in0 = sgs_chalk.Input((4,256,96),name='input0')
# weight = np.ones((96), dtype=np.float32)
# bias = np.ones((96), dtype=np.float32)
out0 = sgs_chalk.Instancenorm(in0,axis=[1],weight=weight,bias=bias,name='output')
model = sgs_chalk.Model([in0],[out0])
#model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • L2Norm:

Normalizes along dimension axis using an L2 norm.

For a 1-D tensor with axis = 0, computes

output = x / sqrt(max(sum(x**2), epsilon))

For x with more dimensions, independently normalizes each 1-D slice along dimension axis.

Args:

x: A `Tensor`
axis: Dimension along which to normalize.  A scalar or a vector of
    integers.

Returns:

A `Tensor`

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,224,224,3),name='input0')
out0 = sgs_chalk.L2Norm(in0,[1,2],name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True,inputs='RAWDATA')
  • LSTM:

Applies a multi-layer long short-term memory (LSTM) RNN to an input sequence.

Args:

x: A `Tensor`,shape is (L,1,N,input_size)  N=batch size  L=sequence length
h0:tensor of shape(1,1,1,hidden_size),containing the initial hidden state for each element in the input sequence.
c0:tensor of shape(1,1,1,hidden_size),containing the initial cell state for each element in the input sequence.
hidden_size : The number of features in the hidden state h
cn_output: whether output cn ,default false.
W: A `Tensor`, shape is [1,4*hidden_size,input_size]
R: A `Tensor`, shape is [1,4*hidden_size,hidden_size]
B: A `Tensor`, shape is [1,8*hidden_size]

Returns:

A `Tensor` list,usually concatenate op should be add after LSTM

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,128,48))
R_1 = np.ones((1,128,32))
B_1 = np.ones((1,256))

W_2 = np.ones((1,64,32))
R_2 = np.ones((1,64,16))
B_2 = np.ones((1,128))

in0 = sgs_chalk.Input((2,1,1,48),name='input0')
input1 = np.zeros((1,1,1,32), dtype=np.float32)
input2 = np.zeros((1,1,1,32), dtype=np.float32)
input3 = np.zeros((1,1,1,16), dtype=np.float32)
input4 = np.zeros((1,1,1,16), dtype=np.float32)
output_tensor_list = sgs_chalk.LSTM(in0,input1,input2,hidden_size=32,W=W_1,R=R_1,B=B_1,name='lstm_output')

output_tensor_list_1 = sgs_chalk.LSTM(output_tensor_list[0],input3,input4,hidden_size=16,W=W_2,R=R_2,B=B_2,name='lstm1_output')
model = sgs_chalk.Model([in0],output_tensor_list_1[0])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
case1
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,128,48))
R_1 = np.ones((1,128,32))
B_1 = np.ones((1,256))

in0 = sgs_chalk.Input((2,1,1,48),name='input0')
input1 = np.zeros((1,1,1,32), dtype=np.float32)
input2 = np.zeros((1,1,1,32), dtype=np.float32)
output_tensor_list= sgs_chalk.LSTM(in0,input1,input2,hidden_size=32,cn_output=True,W=W_1,R=R_1,B=B_1,name='lstm_output')
model = sgs_chalk.Model([in0],output_tensor_list)
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • LSTM_caffe:
  • Layernorm:

Layernorm

Args:

x: A `Tensor`
axis: Dimension along which to normalize.  A scalar or a vector of
    integers.
epsilon: A lower bound value for the norm.
weight: One dim,The value is  multiplied by the shape of the corresponding dimension on the axis
bias: One dim,The value is  multiplied by the shape of the corresponding dimension on the axis

Returns:

A `Tensor`,has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
import pdb


#in0 = sgs_chalk.Input((4,256,96),name='input0')
weight = nr.uniform(-1, 1, (96)).astype('float32')
bias = nr.uniform(-1, 1, (96)).astype('float32')
in0 = sgs_chalk.Input((4,256,96),name='input0')
# weight = np.ones((96), dtype=np.float32)
# bias = np.ones((96), dtype=np.float32)
out0 = sgs_chalk.Layernorm(in0,axis=[2],weight=weight,bias=bias,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
#model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • LeakyRelu:

Compute the Leaky ReLU activation function.

Args:

tensor: A `Tensor`.
alpha: Slope of the activation function at x < 0.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LeakyRelu(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Less:

greater(x, y, name=None) Returns the truth value of (x < y) element-wise.

Args:

x: A `Tensor`.
y: A `Tensor`. Must have the same type as `x`.
name: A name for the output tensor (optional).

Returns:

A `Tensor` of type `bool`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Less(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Less(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Less(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • LessEqual:

greater(x, y, name=None) Returns the truth value of (x < y) element-wise.

Args:

x: A `Tensor`.
y: A `Tensor`. Must have the same type as `x`.
name: A name for the output tensor (optional).

Returns:

A `Tensor` of type `bool`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.LessEqual(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
  • Log:

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Log(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • LogicalAnd:

Returns the truth value of x AND y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).sss

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.LogicalAnd(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LogicalAnd(in0,1.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LogicalAnd(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • LogicalNot:

Returns the truth value of NOT x element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LogicalNot(in0,name='output')
model = sgs_chalk.Model(in0,out0)
model.save('test.sim')
  • LogicalOr:

Returns the truth value of x OR y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).sss

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.LogicalOr(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LogicalOr(in0,1.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.LogicalOr(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Logistic:

output = 1 / (1 + exp(-x))

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Logistic(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • MaxPool2d:

Performs the max pooling on the input. Each entry in output is the max of the corresponding size ksize window in value.

Args:

x: A 4-D `Tensor` of shape `[batch, height, width, channels]`
ksize: A list of `ints` that has length `2`. The size of
the window for each dimension of the input tensor.
strides: An int or list of `ints` that has length `2`. The
stride of the sliding window for each dimension of the input tensor.
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight) or a str `SAME`/ `VALID`.
name: Optional name for the operation.

Returns:

The max pooled output tensor

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,112,112,3),name='input0')
out0 = sgs_chalk.MaxPool2d(in0, (2,2), name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • MaxPool3d:

Performs the average pooling on the input. Each entry in output is the mean of the corresponding size ksize window in value.

Args:

x: A 5D `Tensor` of shape `[batch, height, width, channels]`
ksize: A list of `ints` that has length `3`. The size of
the window for each dimension of the input tensor.
strides: An int or list of `ints` that has length `3`. The
stride of the sliding window for each dimension of the input tensor.
padding: a tuple (paddingI,paddingT,paddingL,paddingO,paddingB,paddingR).
name: Optional name for the operation.

Returns:

The average pooled output tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,3,28,28,4),name='input0')
out0 = sgs_chalk.MaxPool3d(in0,[2,2,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Maximum:

Returns the max of x and y (i.e. x > y ? x : y) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Maximum(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Maximum(in0,1.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Maximum(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Mean:

Computes the mean of elements across dimensions of a tensor.

Reduces input_tensor along the dimensions given in axis.

Args:

tensor: A `Tensor`.
axis: The dimensions to reduce.
keep_dim:whether keep dim or not
name: A name for the output tensor (optional).

Returns:

A `Tensor`. The reduced tensor.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,512),name='input0')
out0 = sgs_chalk.Mean(in0,[1,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • MeanVarianceNorm:

MeanVarianceNorm

Args:

x: A `Tensor`
axis: Dimension along which to normalize.  A scalar or a vector of
    integers.
epsilon: A lower bound value for the norm.
normalize_variance: Whether to do normalization

Returns:

A `Tensor`,has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
import pdb


in0 = sgs_chalk.Input((1,3,4,4),name='input0')
out0 = sgs_chalk.MeanVarianceNorm(in0,axis=[2], normalize_variance=1,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
#model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • Minimum:

Returns the min of x and y (i.e. x < y ? x : y) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Minimum(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Minimum(in0,1.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Minimum(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • MirrorPad:

MirrorPads a tensor.

This operation pads a tensor according to the paddings you specify. paddings is an integer tensor with shape [n, 2], where n is the rank of tensor. For each dimension D of input, paddings[D, 0] indicates how many values to add before the contents of tensor in that dimension, and paddings[D, 1] indicates how many values to add after the contents of tensor in that dimension.

The padded size of each dimension D of the output is: paddings[D, 0] + tensor.dim_size(D) + paddings[D, 1]

Args:

tensor: A `Tensor`.
paddings: A `Tensor` of type `int32`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Pad(in0,[[0,0],[10,10]],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Mod:

Returns x * y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Mul(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')


</details>

<details>
<summary>case1</summary>

```python
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Mod(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Mul:

Returns x * y element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Mul(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')


</details>

<details>
<summary>case1</summary>

```python
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Mul(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • MultiplyAdd:

output = input*multiply + add

Args:

x1: A `Tensor`
multiply_value: A `Value`
add_value: A `Value`
name: A name for the model output tensor (optional).

Returns:

A `Tensor`
Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input1 = sgs_chalk.Input((1,1,36,2048), name='input0')
out = sgs_chalk.MultiplyAdd(input1,1.0,1.0,name='output')
model = sgs_chalk.Model([input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Negative:

Computes the negative value of a tensor.

Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input.

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Negative(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • NotEqual:

Returns the truth value of (x != y) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `x`.Tensor` of type `bool

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.NotEqual(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.NotEqual(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.NotEqual(in0,input1,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Pack:

Stacks a list of rank-R tensors into one rank-(R+1) tensor.

Packs the list of tensors in values into a tensor with rank one higher than each tensor in values, by packing them along the axis dimension. Given a list of length N of tensors of shape (A, B, C);

if axis == 0 then the output tensor will have the shape (N, A, B, C). if axis == 1 then the output tensor will have the shape (A, N, B, C). Etc.

Args:

x: A list of `Tensor` objects with the same shape and type. Must be Variable Tensor.
axis: An `int`. The axis to stack along. Defaults to the first dimension.
      Negative values wrap around, so the valid range is `[-(R+1), R+1)`.
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,1),name='input0')
in1 = sgs_chalk.Input((28,512,1),name='input1')
in2 = sgs_chalk.Input((28,512,1),name='input2')
x = [in0, in1, in2]
out0 = sgs_chalk.Pack(x,axis=2,name='output')
model = sgs_chalk.Model(x,out0)
model.save('test.sim')
  • Pad:

Pads a tensor.

This operation pads a tensor according to the paddings you specify. paddings is an integer tensor with shape [n, 2], where n is the rank of tensor. For each dimension D of input, paddings[D, 0] indicates how many values to add before the contents of tensor in that dimension, and paddings[D, 1] indicates how many values to add after the contents of tensor in that dimension.

The padded size of each dimension D of the output is: paddings[D, 0] + tensor.dim_size(D) + paddings[D, 1]

Args:

tensor: A `Tensor`.
paddings: A `Tensor` of type `int32`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Pad(in0,[[0,0],[10,10]],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,512,4),name='input0')
out0 = sgs_chalk.Pad(in0,[[1,1],[2,2],[3,3],[4,4]],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • PhaseModify:

if x0 > x1[0] Output = x0 + x1[1] else if x0 < x1[2] Output = x0 + x1[3]; else Output = x0

Args:

x0: `Tensor`. Must be Variable Tensor.
x1: A list. must include 4 elements.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input x0.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
out = sgs_chalk.PhaseModify(input0,[1.0,2.0,3.0,4.0],name='output')
model = sgs_chalk.Model([input0], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • PostProcess_Max:

postprocess max

Args:

num_classes: number of classes
is_skip_background: please note background must be the first one

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
mbox_conf_softmax = sgs_chalk.Tensor(shape=model_config["input_shape"][1],name = model_config["input"][1])
cus_options = [(b"scores_lengh",21,"int"),
            (b"skip",1,"int")]
postprocess_max_output_list = sgs_chalk.PostProcess_Max(mbox_conf_softmax,num_classes=21,skip=1)
model = sgs_chalk.Model([mbox_conf_softmax],postprocess_max_output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • PostProcess_Unpack:

postprocess unpack

Args:

num_classes: number of classes

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,3249,6), name = 'x')
unpack_out_tensors1 = []
for i in range(4):
    unpack_out_tensors1.append("SGS_unpack1_"+str(i))
output_list = sgs_chalk.PostProcess_Unpack(in0,scores_lengh=80,name=unpack_out_tensors1)
model = sgs_chalk.Model([in0],output_list)
#model.save('test.sim')
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Prelu:

Parametric Rectified Linear Unit.

It follows: f(x) = alpha * x for x < 0, f(x) = x for x >= 0, where alpha is a learned array with the same shape as x.

Args:

tensor: A `Tensor`.
slope: Slope of the activation function at x < 0.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Prelu(in0,5,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((512,), dtype=np.float32)
in0 = sgs_chalk.Input((3,28,512),name='input0')
out0 = sgs_chalk.Prelu(in0,5,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • RNN:

Applies a multi-layer gated recurrent unit RNN to an input sequence.

Args:

x: A `Tensor`,shape is (L,1,N,input_size)  N=batch size  L=sequence length
h0:tensor of shape(1,1,1,hidden_size),containing the initial hidden state for each element in the input sequence.
hidden_size : The number of features in the hidden state h
W: A `Tensor`, shape is [1,hidden_size,input_size]
R: A `Tensor`, shape is [1,hidden_size,hidden_size]
B: A `Tensor`, shape is [1,2*hidden_size]

Returns:

A `Tensor` list,usually concatenate op should be add after RNN

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,2,2))
R_1 = np.ones((1,2,2))
B_1 = np.ones((1,4))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out_1 = sgs_chalk.RNN(in0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name=['rnn_output'])
model = sgs_chalk.Model([in0],[out_1])
model.save('test.sim')
case1
W_1 = np.ones((1,2,2))
R_1 = np.ones((1,2,2))
B_1 = np.ones((1,4))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out0 = sgs_chalk.RNN(in0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name=['rnn_output0'])
out1 = sgs_chalk.RNN(out0,input1,hidden_size=2,W=W_1,R=R_1,B=B_1,name=['rnn_output1'])
model = sgs_chalk.Model([in0], [out1])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
case2
from calibrator_custom import sgs_chalk
import numpy as np

W_1 = np.ones((1,2,2))
R_1 = np.ones((1,2,2))
B_1 = np.ones((1,4))

in0 = sgs_chalk.Input((2,1,1,2),name='input0')
input1 = np.zeros((1,1,1,2), dtype=np.float32)
out1= sgs_chalk.RNN(in0,input1,hidden_size=2,hn_output=True,W=W_1,R=R_1,B=B_1,name=['rnn_output0'])
hn = sgs_chalk.Slice(out,[1,0,0,0],[1,1,1,2],name='rnn_hn')
model = sgs_chalk.Model([in0],[out1,hn])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • RSqrt:

Computes square root of x element-wise. I.e., (y = rsqrt{x} ).

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.RSqrt(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Range:

Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit.

Args:

start: A 0-D `Tensor` (scalar). Acts as first entry in the range.
limit: A 0-D `Tensor` (scalar). Upper limit of sequence, exclusive.
delta: A 0-D `Tensor` (scalar). Number that increments `start`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((), name='input')
out0 = sgs_chalk.Range(0.0, in0, 1.0, name='output')
model = sgs_chalk.Model(in0, out0)
model.save('test.sim')
  • Reciprocal:

Computes the Reciprocal value of a tensor.

Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input.

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Reciprocal(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • ReduceMax:

Computes the maxmum of elements across dimensions of a tensor.

Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1.

Args:

input:A `Tensor` or 'Array'. Must be Variable Tensor if it's a Tensor.
asix: A `Tensor` or 'Array'. Must be Const Tensor if it's a Tensor.
keepdims: A one dimension array or list.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,512,33),name='input0')
axis = np.array([-2,1],dtype=np.int32)
out0 = sgs_chalk.ReduceMax(in0, axis, keepdims=1, name='output')
model = sgs_chalk.Model([in0],out0)
model.save('reducemax.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • ReduceMin:

Computes the minimum of elements across dimensions of a tensor.

Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1.

Args:

input: A `Tensor` or 'Array'. Must be Variable Tensor if it's a Tensor.
asix: A `Tensor` or 'Array'. Must be Const Tensor if it's a Tensor.
keepdims: A one dimension array or list.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,512,33),name='input0')
axis = np.array([-2,1],dtype=np.int32)
out0 = sgs_chalk.ReduceMin(in0, axis, keepdims=1, name='output')
model = sgs_chalk.Model([in0],out0)
model.save('reducemin.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • Relu:

Computes rectified linear: max(x, 0).

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Relu(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Relu1:

Clips tensor values to a specified min and max.

Given a tensor x, this operation returns a tensor of the same type and shape as x with its values clipped to min_value and max_value. Any values less than min_value are set to min_value. Any values greater than max_value are set to max_value.

Args:

x: A `Tensor`. Must be Variable Tensor.

Returns:

A Variable `Tensor`. has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,36,2048), name='input')
output = sgs_chalk.Relu1(input,name='output')
model = sgs_chalk.Model([input], output)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Relu6:

Computes Rectified Linear 6: `min(max(features, 0), 6)

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Relu6(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Relu_N1_TO_1:

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Relu_N1_TO_1(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Reshape:

As an entry point into a graph. reshape(a, newshape, order='C') Gives a new shape to an array without changing its data.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Reshape(in0,(28,256,2),name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Reshape(in0,(28,256,-1),name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • ResizeBilinear:

ResizeBilinear

Args:

x: A `Tensor`
size : output H W size

Returns:

A `Tensor`

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,224,224,3),name='input0')
out0 = sgs_chalk.ResizeBilinear(in0,[1120,1120],name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • ResizeNearestNeighbor:

ResizeNearestNeighbor

Args:

x: A `Tensor`
size : output H w size

Returns:

A `Tensor`

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,224,224,3),name='input0')
out0 = sgs_chalk.ResizeNearestNeighbor(in0,[1120,1120],name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True,inputs='RAWDATA')
  • RootSumSquares2:

Output = sqrt(x0 * x0 + x1 * x1)

Args:

x0: `Tensor`. Must be Variable Tensor.only support int
x1:  `Tensor`. Must be Variable Tensor,has same shape as x0.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input x0.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
input1 = sgs_chalk.Input((1,224,224,3),name='input1')
out = sgs_chalk.RootSumSquares2(input0,input1,name='output')
model = sgs_chalk.Model([input0,input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Round:

Rounds the values of a tensor to the nearest integer, element-wise.

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Round(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • ScatterElements:

ScatterElements

Args:

x: A `Tensor`
indices: Tensor of rank q >= 1.
updates: Tensor of rank q + r - indices_shape[-1] - 1.
reduction: none (default), add, mul, max, min.
axis:int,Which axis to scatter on.

Returns:

A `Tensor`,has the same shape as x

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
from numpy import random as nr
import pdb


in0 = sgs_chalk.Input((1,1,500,11),name='input0')
data0 = np.random.randint(0, high=10, size=(1,1,500,1,4))
data0_tensor = sgs_chalk.Tensor(data=data0)
data1 = np.random.randint(0, high=10, size=(1,1,500,1))
data1_tensor = sgs_chalk.Tensor(data=data1)
out0 = sgs_chalk.ScatterElements(in0,data0_tensor,data1_tensor,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
#model.save('test.sim',input_config='./input_config.ini', convert_fixed=True, inputs='RAWDATA')
  • ScatterND:

Args:

input: A `Tensor`. Must be Variable Tensor whose rank r >= 1.
indices: A const Tensor or numpy.array whose rank q >= 1.
update: A Tensor whose rank is q+r-indices.shape[-1]-1
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
indices = np.array([[5, 0, 1], [10, 2, 33]])
update = sgs_chalk.Input((2,2,1,2,3,5), name='update')
scatterND_out = sgs_chalk.ScatterND(input, indices, update, 0, name='scatterND_out')
model = sgs_chalk.Model([input,update], scatterND_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Score_Filter:

Score_Filter

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Score index
A `Tensor`. valid box number

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,7875),name='input0')
out0,out1 = sgs_chalk.Score_Filter(in0,threshold=0.5,input_element_count=7875,name='output')
model = sgs_chalk.Model([in0],[out0,out1])
model.save('test.sim',input_config='./input_config.ini', convert_fixed=True)
  • Select:

where(condition, x=None, y=None, name=None)

Return the elements, either from x or y, depending on the condition. (deprecated) If both x and y are None, then this operation returns the coordinates of true elements of condition. The coordinates are returned in a 2-D tensor where the first dimension (rows) represents the number of true elements, and the second dimension (columns) represents the coordinates of the true elements. Keep in mind, the shape of the output tensor can vary depending on how many true values there are in input. Indices are output in row-major order.

If both non-None, x and y must have the same shape. The condition tensor must be a scalar if x and y are scalar. If x and y are vectors of higher rank, then condition must be either a vector with size matching the first dimension of x, or must have the same shape as x.

The condition tensor acts as a mask that chooses, based on the value at each element, whether the corresponding element / row in the output should be taken from x (if true) or y (if false).

If condition is a vector and x and y are higher rank matrices, then it chooses which row (outer dimension) to copy from x and y. If condition has the same shape as x and y, then it chooses which element to copy from x and y.

Args:

condition: A `Tensor` of type `float32`
x: A Tensor which may have the same shape as `condition`. If `condition` is
rank 1, `x` may have higher rank, but its first dimension must match the
size of `condition`.
y: A `tensor` with the same shape and type as `x`.
name: A name of the operation (optional)

Returns:

A `Tensor` with the same type and shape as `x`, `y` if they are non-None.
Otherwise, a `Tensor` with shape `(num_true, rank(condition))`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
in2 = sgs_chalk.Input((28,512),name='input2')
out0 = sgs_chalk.Select(in0,in1,in2,name='output')
model = sgs_chalk.Model([in0,in1,in2],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Select(in0,5.0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case2
from calibrator_custom import sgs_chalk
import numpy as np
input1 = np.zeros((28,512), dtype=np.float32)
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Select(input1,in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
  • Shape:

Computes the shape of a tensor.

Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input.

Args:

x: A `Tensor`
dtype: Output data type. Only support int32 or int64

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Shape(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Sign:

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Sign(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Silu:

Args:

input: A `Tensor`. Must be Variable Tensor.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
silu_out = sgs_chalk.Silu(input, name='silu_out')
model = sgs_chalk.Model([input,], silu_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Sin:

Returns sin(x) element-wise.

Args:

x: A `Tensor`. Must be Variable Tensor.

Returns:
```text
A Variable `Tensor`. Has the same shape as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Sin(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Slice:

Extracts a slice from a tensor.

This operation extracts a slice of size size from a tensor input starting at the location specified by begin. The slice size is represented as a tensor shape, where size[i] is the number of elements of the 'i'th dimension of input that you want to slice. The starting location (begin) for the slice is represented as an offset in each dimension of input. In other words, begin[i] is the offset into the 'i'th dimension of input that you want to slice from.

Args:

x: A `Tensor`. Must be Variable Tensor.
begin: const Tensor
size: const Tensor
name: A name for the output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as `size`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Slice(in0,[0,0],[28,512],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Slice(in0,[0,0],[14,510],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Softmax:

Computes softmax activations.

Args:

tensor: A `Tensor`.
name: A name for the output tensor (optional).

Returns:

A `Tensor`. Has the same type as `tensor`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Softmax(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
  • Softplus:

Args:

input: A `Tensor`. Must be Variable Tensor.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
softplus_out = sgs_chalk.Softplus(input, name='softplus_out')
model = sgs_chalk.Model([input,], softplus_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • SpaceToBatchND:

SpaceToBatch for 4-D tensors of type T.

This operation divides "spatial" dimensions [1, ..., M] of the input into a grid of blocks of shape block_size, and interleaves these blocks with the "batch" dimension (0) such that in the output, the spatial dimensions [1, ..., M] correspond to the position within the grid, and the batch dimension combines both the position within a spatial block and the original batch position. Prior to division into blocks, the spatial dimensions of the input are optionally zero padded according to paddings.

Args:

x: A `Tensor`
block_size: Must be `Tensor` or `ndarray` or `list`
paddings: A  2-D `Tensor` with shape `[2,2]`. Must be one of the
       following types: `int32`, `int64`. All values must be >= 0.
       `paddings[i] = [pad_start, pad_end]` specifies the amount to crop from
       input dimension `i + 1`, which corresponds to spatial dimension `i`.

Returns:

A `Tensor` of same type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,512),name='input0')
in1 = sgs_chalk.Add(in0,1.0)
out0 = sgs_chalk.SpaceToBatchND(in1,2,[[2,2],[2,2]],name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Split:

Splits a tensor into sub tensors.

NumSplits is an integer, then value is split along dimension axis into NumSplits smaller tensors. This requires that NumSplits evenly divides value.shape[axis].

Args:

input: A `Tensor`. 1-D or higher.
NumSplits: an integer indicating the number of splits along split_dim
axis: An integer or scalar `int32` `Tensor`. The dimension along which to
      split. Must be in the range `[-rank(value), rank(value))`. Defaults to 0.
name: A name for the output tensor (optional).

Returns:

returns `num_or_size_splits` `Tensor` objects;

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,4,4),name='input0')
output_list = sgs_chalk.Split(in0,NumSplits=2, axis=2,name=['output0','output1'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Split_V:

Splits a tensor into sub tensors.

Sizesplits is a 1-D Tensor (or list), and value is split into len(size_splits) elements. The shape of the i-th element has the same size as the value except along dimension axis where the size is size_splits[i].

Args:

input: A `Tensor`. 1-D or higher.
SizeSplits: Python list containing the sizes of each output tensor along split_dim.
            the sum of sizes along the split dimension must match that of x
axis: An integer or scalar `int32` `Tensor`. The dimension along which to
      split. Must be in the range `[-rank(value), rank(value))`. Defaults to 0.
name: A name for the output tensor (optional).

Returns:

returns `size_splits` `Tensor` objects;

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,4,4),name='input0')
output_list = sgs_chalk.Split_V(in0,SizeSplits=[1,2,1], axis=2,name=['output0','output1','output2'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,4,3),name='input0')
output_list = sgs_chalk.Split_V(in0,SizeSplits=[2,2], axis=1,name=['output0','output1'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Sqrt:

Computes square root of x element-wise. I.e., (y = sqrt{x} = x^{½}).

Args:

x: A `Tensor`

Returns:

A `Tensor` of same shape and type as `x`.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Sqrt(in0,name='output')
model = sgs_chalk.Model([in0],[out0])
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
  • Square:

Args:

input: A `Tensor`. Must be Variable Tensor.
name: A name for the model output tensor (optional).

Returns:

A Variable `Tensor`. Has the same shape as input.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((14,3,41,2,1,2,3,5), name='input')
square_out = sgs_chalk.Square(input, name='softplus_out')
model = sgs_chalk.Model([input,], square_out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
  • Squeeze:

Remove single-dimensional entries from the shape of a tensor. Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than one, an error is raised.

Args:

x: A `Tensor`..
axis: int or list or tuple of ints
name: A name for the output tensor (optional).

Returns:

A `Tensor`. The input tensor, but with all or a subset of the
    dimensions of length 1 removed.

Examples:

case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,512,4), name='input0')
out0 = sgs_chalk.Squeeze(in0, axis=0, name='output')
model = sgs_chalk.Model(in0, out0)
model.save('test.sim')
</details>

- StridedSlice:

Extracts a strided slice of a tensor (generalized python array indexing).

Roughly speaking, this op extracts a slice of size `(end-begin)/stride`
from the given `input_` tensor. Starting at the location specified by `begin`
the slice continues by adding `stride` to the index until all dimensions are
not less than `end`.
Note that a stride can be negative, which causes a reverse slice.

Given a Python slice `input[spec0, spec1, ..., specn]`,
this function will be called as follows.

`begin`, `end`, and `strides` will be vectors of length n.
n in general is not equal to the rank of the `input_` tensor.


Args:
```text
x: A `Tensor`. Must be Variable Tensor.
begin: const Tensor
size: const Tensor
begin_mask: An `int32` mask.
end_mask: An `int32` mask.
ellipsis_mask: An `int32` mask.
new_axis_mask: An `int32` mask.
shrink_axis_mask: An `int32` mask.
name: A name for the output tensor (optional).
Returns:
A Variable `Tensor`. Has the same shape as `x`. (end-begin)/stride
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.StridedSlice(in0,[1,0,0],[28,512,4],[1,2,1],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- Sub: Returns x - y element-wise. Args:
x: A `Tensor`. Must be Variable Tensor.
y: A `Tensor` or `numpy.ndarray`. Must have the same type as `x`, can be Variable or Const Tensor.
   Support inner most dimension broadcasting.
name: A name for the output tensor (optional).
Returns:
A Variable `Tensor`. Has the same shape as `x`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
in1 = sgs_chalk.Input((28,512),name='input1')
out0 = sgs_chalk.Sub(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Sub(in0,5.0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- Sum: Computes the sum of elements across dimensions of a tensor. Reduces `input_tensor` along the dimensions given in `axis`. Args:
tensor: A `Tensor`.
axis: The dimensions to reduce.
keep_dim:whether keep dim or not
name: A name for the output tensor (optional).
Returns:
A `Tensor`. The reduced tensor.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,512),name='input0')
out0 = sgs_chalk.Sum(in0,[0,1,2,3],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,512),name='input0')
out0 = sgs_chalk.Sum(in0,[1,2],name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- TFLite_Detection_NMS: postprocess nms Args:
max_detection: max number pf output dectection bboxes
num_classes:number of classes
is_need_index : outputs include index or not
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
bosdecoder_output_list = sgs_chalk.BoxDecoder(config,output_list)
confidence_tensor = sgs_chalk.Logistic(output_list[4],name="confidence_tensor")
SGS_score0 = sgs_chalk.Logistic(output_list[5],name="score0_tensor")
SGS_score1 = sgs_chalk.Mul(confidence_tensor,SGS_score0,name="SGS_score1")
out1 = sgs_chalk.TFLite_Detection_NMS(bosdecoder_output_list[0],bosdecoder_output_list[1],bosdecoder_output_list[2],
                                    bosdecoder_output_list[3],confidence_tensor,SGS_score1,output_list[6],mode='YOLO',
                                    max_detections=100,nms_score_threshold=0.4,
                                    nms_iou_threshold=0.45,num_classes=80,is_need_index=False)
case1
from calibrator_custom import sgs_chalk
import numpy as np
bosdecoder_output_list = sgs_chalk.BoxDecoder(config,output_list)
mbox_conf_softmax = sgs_chalk.Input(model_config["input_shape"][1], name = model_config["input"][1])
postprocess_max_output_list = sgs_chalk.PostProcess_Max(mbox_conf_softmax,scores_lengh=21,skip=1)
out1 = sgs_chalk.TFLite_Detection_NMS(bosdecoder_output_list[0],bosdecoder_output_list[1],bosdecoder_output_list[2],
                                    bosdecoder_output_list[3],postprocess_max_output_list[0],postprocess_max_output_list[1],
                                    mode='SSD',max_detections=10,nms_score_threshold=0.01,
                                    nms_iou_threshold=0.45,num_classes=20,is_need_index=False)
- Tanh: Args:
tensor: A `Tensor`.
name: A name for the output tensor (optional).
Returns:
A `Tensor`. Has the same type as `tensor`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512),name='input0')
out0 = sgs_chalk.Tanh(in0,name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- Tile: Constructs a tensor by tiling a given tensor. This operation creates a new tensor by replicating `input` `multiples` times. The output tensor's i'th dimension has `input.dims(i) * multiples[i]` elements, and the values of `input` are replicated `multiples[i]` times along the 'i'th dimension. For example, tiling `[a b c d]` by `[2]` produces `[a b c d a b c d]`. Args:
input: A `Tensor`. 1-D or higher.
multiples: A `Tensor`.  Length must be the same as the number of dimensions in `input`
name: A name for the output tensor (optional).
Returns:
A `Tensor`. Has the same type as `input`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.Tile(in0,(1,1,2),name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
- TopK: Finds values and indices of the `k` largest elements for the last dimension. Args:
input: 1-D or higher `Tensor` with last dimension at least `k`.
k: 0-D `int32`.  Number of top elements to look for along the last dimension (along each row for matrices).
use_value: 0 or 1. Whether the value output tensor has consumers.
use_index: 0 or 1. Whether the index output tensor has consumers.
name: A name for the model output tensor (optional).
Returns:
values: The `k` largest elements along each last dimensional slice.
indices: The indices of `values` within the last dimension of `input`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
input = sgs_chalk.Input((1,36,2048), name='input')
output_list = sgs_chalk.TopK(input,k=[1], name=['value','index'])
model = sgs_chalk.Model([input,], output_list)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)
- Transpose: Transposes x. Permutes the dimensions according to `perm`. The returned tensor's dimension i will correspond to the input dimension `perm[i]`. If `perm` is not given, it is set to (n-1...0), where n is the rank of the input tensor. Hence by default, this operation performs a regular matrix transpose on 2-D input Tensors. Args:
input: A `Tensor`. 1-D or higher.
perm: A permutation of the dimensions of `a`.
name: A name for the output tensor (optional).
Returns:
A transposed `Tensor`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
out0 = sgs_chalk.Transpose(in0,(0,2,1),name='output')
model = sgs_chalk.Model([in0],out0)
model.save('test.sim')
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,512,4),name='input0')
in1 = sgs_chalk.Input((28,512,4),name='input1')
out0 = sgs_chalk.Add(in0,in1)
out1 = sgs_chalk.Transpose(out0,(0,2,1),name='output')
model = sgs_chalk.Model([in0,in1],out1)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
- TransposeConv2d: Conv2d Args:
x : input tensor of shape(1, iH, iW,in_channels)
weight: filters of shape(out_channels, kH, kW, in_channels)
bias: optional bias tensor of shape(out_channels).Default:None
stride: the stride of the convolving kernel. Can be a single number or a tuple(sH,sW).Default: 1
padding: a tuple (paddingTop, paddingBottom, paddingLeft, paddingRight)
Activation: only support NONE/RELU/RELU_N1_TO_1/RELU6
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((1,28,28,4),name='input0')
in1 = sgs_chalk.Input((8,3,3,4),name='input1')
out0 = sgs_chalk.TransposeConv2d(in0,in1,name='output')
model = sgs_chalk.Model([in0,in1],out0)
model.save('test.sim')
- Unpack: Unpacks the given dimension of a rank-`R` tensor into rank-`(R-1)` tensors. Unpacks `num` tensors from `value` by chipping it along the `axis` dimension. If `num` is not specified (the default), it is inferred from `value`'s shape. If `value.shape[axis]` is not known, `ValueError` is raised. For example, given a tensor of shape `(A, B, C, D)`; If `axis == 0` then the i'th tensor in `output` is the slice `value[i, :, :, :]` and each tensor in `output` will have shape `(B, C, D)`. (Note that the dimension unpacked along is gone, unlike `split`). If `axis == 1` then the i'th tensor in `output` is the slice `value[:, i, :, :]` and each tensor in `output` will have shape `(A, C, D)`. Etc. Args:
x: A `Tensor`. Must be Variable Tensor.
axis: An `int`. The axis to unstack along. Defaults to the first dimension.
    Negative values wrap around, so the valid range is `[-R, R)
num:  An `int`. The length of the dimension `axis`. Automatically inferred if
    `None` (the default).
name: A name for the output tensor (optional).
Returns:
The list of `Tensor` objects unstacked from `value`.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,4,3),name='input0')
output_list = sgs_chalk.Unpack(in0,axis=2,name=['output0','output1','output2'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
case1
from calibrator_custom import sgs_chalk
import numpy as np
in0 = sgs_chalk.Input((28,4,3),name='input0')
output_list = sgs_chalk.Unpack(in0,axis=1,name=['output0','output1','output2','output3'])
model = sgs_chalk.Model([in0],output_list)
model.save('test.sim',input_config='./input_config.ini',convert_fixed=True)
- WiggleErr: Out = x2[0] * cos(2*atanx) + x2[1] * sin(2*atanx) + x2[2] * cos(4*atanx) + x2[3] * sin(4*atanx) + x2[4]; atanx can be 0 or 1.5707 Args:
x0: `Tensor`. Must be Variable Tensor.only support int
x1:  `Tensor`. Must be Variable Tensor,has same shape as x0.only support int
x2: A list. must include 5 elements.
name: A name for the model output tensor (optional).
Returns:
A Variable `Tensor`. Has the same shape as input x0.
Examples:
case0
from calibrator_custom import sgs_chalk
import numpy as np
input0 = sgs_chalk.Input((1,224,224,3),name='input0')
input1 = sgs_chalk.Input((1,224,224,3),name='input1')
out = sgs_chalk.WiggleErr(input0,input1,[1.0,2.0,3.0,4.0,5.0],name='output')
model = sgs_chalk.Model([input0,input1], out)
model.save('test.sim', input_config='./input_config.ini', convert_fixed=True)