Source code

Revision control

Copy as Markdown

Other Tools

{
"tests": [
// default options
{
"name": "clamp float32 1D constant tensor default options",
"inputs": {
"x": { // use 'x' for input operand name
"shape": [24],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
{
"name": "clamp float32 1D tensor default options",
"inputs": {
"x": { // use 'x' for input operand name
"shape": [24],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
{
"name": "clamp float32 2D tensor default options",
"inputs": {
"x": {
"shape": [4, 6],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [4, 6],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
{
"name": "clamp float32 3D tensor default options",
"inputs": {
"x": {
"shape": [2, 3, 4],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 3, 4],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
{
"name": "clamp float32 4D tensor default options",
"inputs": {
"x": {
"shape": [3, 2, 2, 2],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [3, 2, 2, 2],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
{
"name": "clamp float32 5D tensor default options",
"inputs": {
"x": {
"shape": [4, 1, 1, 2, 3],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [4, 1, 1, 2, 3],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1.537420630455017,
-7.34310245513916,
7.880751132965088,
-2.0564088821411133,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
9.280223846435547,
-2.3130595684051514,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-2.123614549636841
],
"type": "float32"
}
},
// default options.maxValue and specified options.minValue
{
"name": "clamp float32 4D tensor default options.maxValue and specified negative options.minValue",
"inputs": {
"x": {
"shape": [2, 1, 4, 3],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 1, 4, 3],
"data": [
-1,
-1,
-1,
-1,
-1,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
-1,
-1,
7.880751132965088,
-1,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
-1,
-1,
9.280223846435547,
-1,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
-1
],
"type": "float32"
},
"options": {
"minValue": -1.0
}
},
{
"name": "clamp float32 3D tensor default options.maxValue and specified options.minValue=0.0",
"inputs": {
"x": {
"shape": [6, 2, 2],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [6, 2, 2],
"data": [
0,
0,
0,
0,
0,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
0,
0,
7.880751132965088,
0,
6.3438639640808105,
5.525737762451172,
0.8433118462562561,
0,
0,
9.280223846435547,
0,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
0
],
"type": "float32"
},
"options": {
"minValue": 0.0
}
},
{
"name": "clamp float32 2D tensor default options.maxValue and specified positive options.minValue",
"inputs": {
"x": {
"shape": [3, 8],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [3, 8],
"data": [
1,
1,
1,
1,
1,
9.524681091308594,
3.7292487621307373,
6.481687068939209,
1,
1,
7.880751132965088,
1,
6.3438639640808105,
5.525737762451172,
1,
1,
1,
9.280223846435547,
1,
9.549695014953613,
5.788925647735596,
5.549378395080566,
7.409400463104248,
1
],
"type": "float32"
},
"options": {
"minValue": 1.0
}
},
// default options.minValue and specified options.maxValue
{
"name": "clamp float32 5D tensor default options.minValue and specified negative options.maxValue",
"inputs": {
"x": {
"shape": [2, 2, 1, 2, 3],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 2, 1, 2, 3],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
-2,
-2,
-2,
-2,
-7.34310245513916,
-2,
-2.0564088821411133,
-2,
-2,
-2,
-8.199960708618164,
-7.786487102508545,
-2,
-2.3130595684051514,
-2,
-2,
-2,
-2,
-2.123614549636841
],
"type": "float32"
},
"options": {
"maxValue": -2.0
}
},
{
"name": "clamp float32 1D tensor default options.minValue and specified options.maxValue=0.0",
"inputs": {
"x": {
"shape": [24],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
0,
0,
0,
-1.537420630455017,
-7.34310245513916,
0,
-2.0564088821411133,
0,
0,
0,
-8.199960708618164,
-7.786487102508545,
0,
-2.3130595684051514,
0,
0,
0,
0,
-2.123614549636841
],
"type": "float32"
},
"options": {
"maxValue": 0.0
}
},
{
"name": "clamp float32 3D tensor default options.minValue and specified positive options.maxValue",
"inputs": {
"x": {
"shape": [3, 4, 2],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [3, 4, 2],
"data": [
-9.817828178405762,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
3,
3,
3,
-1.537420630455017,
-7.34310245513916,
3,
-2.0564088821411133,
3,
3,
0.8433118462562561,
-8.199960708618164,
-7.786487102508545,
3,
-2.3130595684051514,
3,
3,
3,
3,
-2.123614549636841
],
"type": "float32"
},
"options": {
"maxValue": 3.0
}
},
// specified both options.minValue and options.maxValue
{
"name": "clamp float32 5D tensor specified both negative options.minValue and options.maxValue",
"inputs": {
"x": {
"shape": [3, 2, 1, 1, 4],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [3, 2, 1, 1, 4],
"data": [
-8,
-6.024064064025879,
-4.0725626945495605,
-6.575078010559082,
-7.755683898925781,
-1,
-1,
-1,
-1.537420630455017,
-7.34310245513916,
-1,
-2.0564088821411133,
-1,
-1,
-1,
-8,
-7.786487102508545,
-1,
-2.3130595684051514,
-1,
-1,
-1,
-1,
-2.123614549636841
],
"type": "float32"
},
"options": {
"minValue": -8.0,
"maxValue": -1.0
}
},
{
"name": "clamp float32 4D tensor specified negative options.minValue and options.maxValue=0.0",
"inputs": {
"x": {
"shape": [1, 4, 3, 2],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [1, 4, 3, 2],
"data": [
-6,
-6,
-4.0725626945495605,
-6,
-6,
0,
0,
0,
-1.537420630455017,
-6,
0,
-2.0564088821411133,
0,
0,
0,
-6,
-6,
0,
-2.3130595684051514,
0,
0,
0,
0,
-2.123614549636841
],
"type": "float32"
},
"options": {
"minValue": -6.0,
"maxValue": 0.0
}
},
{
"name": "clamp float32 3D tensor specified negative options.minValue and positive options.maxValue",
"inputs": {
"x": {
"shape": [2, 6, 2],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 6, 2],
"data": [
-3,
-3,
-3,
-3,
-3,
4,
3.7292487621307373,
4,
-1.537420630455017,
-3,
4,
-2.0564088821411133,
4,
4,
0.8433118462562561,
-3,
-3,
4,
-2.3130595684051514,
4,
4,
4,
4,
-2.123614549636841
],
"type": "float32"
},
"options": {
"minValue": -3.0,
"maxValue": 4.0
}
},
{
"name": "clamp float32 2D tensor specified options.minValue=0.0 and positive options.maxValue",
"inputs": {
"x": {
"shape": [6, 4],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [6, 4],
"data": [
0,
0,
0,
0,
0,
6,
3.7292487621307373,
6,
0,
0,
6,
0,
6,
5.525737762451172,
0.8433118462562561,
0,
0,
6,
0,
6,
5.788925647735596,
5.549378395080566,
6,
0
],
"type": "float32"
},
"options": {
"minValue": 0.0,
"maxValue": 6.0
}
},
{
"name": "clamp float32 1D tensor specified both positive options.minValue and options.maxValue",
"inputs": {
"x": {
"shape": [24],
"data": [
-9.817828475355284,
-6.024063916325786,
-4.072562498632983,
-6.575078191902692,
-7.7556836912181915,
9.524681107378463,
3.7292487446449307,
6.4816868736447475,
-1.5374205904252634,
-7.343102426698445,
7.880751290929794,
-2.056408790509967,
6.34386375786449,
5.52573787183,
0.8433118207347725,
-8.19996033345526,
-7.786487326213716,
9.280223823954241,
-2.31305948485121,
9.549695091037119,
5.788925460130297,
5.549378312916486,
7.409400528051194,
-2.1236145770503745
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
2,
2,
2,
2,
2,
7,
3.7292487621307373,
6.481687068939209,
2,
2,
7,
2,
6.3438639640808105,
5.525737762451172,
2,
2,
2,
7,
2,
7,
5.788925647735596,
5.549378395080566,
7,
2
],
"type": "float32"
},
"options": {
"minValue": 2.0,
"maxValue": 7.0
}
}
]
}