Source code

Revision control

Copy as Markdown

Other Tools

{ // hardSigmoid: Calculate the non-smooth function used in place of a sigmoid function on the input tensor.
"tests": [
{
"name": "hardSigmoid float32 positive 1D constant tensor default options", // default options: {alpha: 0.2, beta: 0.5}
"inputs": {
"x": {
"shape": [24],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32",
"constant": true
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 1D tensor default options", // default options: {alpha: 0.2, beta: 0.5}
"inputs": {
"x": {
"shape": [24],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [24],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 2D tensor default options",
"inputs": {
"x": {
"shape": [4, 6],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [4, 6],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 3D tensor default options",
"inputs": {
"x": {
"shape": [2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [2, 3, 4],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 4D tensor default options",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 5D tensor default options",
"inputs": {
"x": {
"shape": [1, 2, 1, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"expected": {
"name": "output",
"shape": [1, 2, 1, 3, 4],
"data": [
0.5118141174316406,
0.6415218114852905,
0.6045681238174438,
0.5846202969551086,
0.6328738331794739,
0.6900588274002075,
0.5218378305435181,
0.5025954246520996,
0.5951059460639954,
0.6064510345458984,
0.6368615627288818,
0.5932421684265137,
0.5609799027442932,
0.6605174541473389,
0.5497192740440369,
0.6327379941940308,
0.6109522581100464,
0.6108517050743103,
0.6462276577949524,
0.5976191759109497,
0.6553369164466858,
0.669111430644989,
0.6110604405403137,
0.6120688915252686
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 4D tensor specified positive options.alpha default options.beta",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": 0.7854232544278235
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.546395480632782,
1,
0.9106510877609253,
0.8323138356208801,
1,
1,
0.5857596397399902,
0.5101925134658813,
0.8734921216964722,
0.9180455803871155,
1,
0.8661727905273438,
0.7394752502441406,
1,
0.6952533721923828,
1,
0.9357223510742188,
0.9353274703025818,
1,
0.8833619952201843,
1,
1,
0.936147153377533,
0.9401075839996338
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 negative 4D tensor specified negative options.alpha default options.beta",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
-0.05907066981577147,
-0.7076089198897,
-0.5228405296259637,
-0.42310158753617455,
-0.6643692569867639,
-0.9502940424761401,
-0.10918906453593258,
-0.012977113903015258,
-0.4755297159390164,
-0.5322551665299613,
-0.684307857800798,
-0.4662107602754757,
-0.3048996433987061,
-0.8025872652109942,
-0.2485963985673023,
-0.6636898942337357,
-0.554761182646025,
-0.5542584257213008,
-0.7311381962152534,
-0.48809603333206986,
-0.7766845231174959,
-0.8455570201933926,
-0.5553020911955322,
-0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": -0.7854232544278235
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.546395480632782,
1,
0.9106510877609253,
0.8323138356208801,
1,
1,
0.5857596397399902,
0.5101925134658813,
0.8734921216964722,
0.9180455803871155,
1,
0.8661727905273438,
0.7394752502441406,
1,
0.6952533721923828,
1,
0.9357223510742188,
0.9353274703025818,
1,
0.8833619952201843,
1,
1,
0.936147153377533,
0.9401075839996338
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 4D tensor specified positive options.beta default options.alpha",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"options": {
"beta": 0.4361860418530341
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.4480001926422119,
0.577707827091217,
0.5407541394233704,
0.5208063721656799,
0.5690599083900452,
0.626244843006134,
0.4580238461494446,
0.4387814700603485,
0.5312919616699219,
0.5426371097564697,
0.5730476379394531,
0.5294281840324402,
0.4971659779548645,
0.5967035293579102,
0.48590531945228577,
0.5689240097999573,
0.5471382737159729,
0.5470377206802368,
0.5824136734008789,
0.533805251121521,
0.5915229320526123,
0.6052974462509155,
0.5472464561462402,
0.5482549667358398
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 negative 4D tensor specified negative options.beta default options.alpha",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
-0.05907066981577147,
-0.7076089198897,
-0.5228405296259637,
-0.42310158753617455,
-0.6643692569867639,
-0.9502940424761401,
-0.10918906453593258,
-0.012977113903015258,
-0.4755297159390164,
-0.5322551665299613,
-0.684307857800798,
-0.4662107602754757,
-0.3048996433987061,
-0.8025872652109942,
-0.2485963985673023,
-0.6636898942337357,
-0.554761182646025,
-0.5542584257213008,
-0.7311381962152534,
-0.48809603333206986,
-0.7766845231174959,
-0.8455570201933926,
-0.5553020911955322,
-0.5603444395469193
],
"type": "float32"
}
},
"options": {
"beta": -0.436186041853034
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 4D tensor specified all options (positive options.alpha and positive options.beta)",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": 0.7854232544278235,
"beta": 0.4361860418530341
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.4825815260410309,
0.9919585585594177,
0.8468371629714966,
0.7684998512268066,
0.9579971432685852,
1,
0.5219456553459167,
0.44637855887413025,
0.8096781373023987,
0.8542316555976868,
0.9736573696136475,
0.8023588061332703,
0.6756613254547119,
1,
0.6314394474029541,
0.9574635624885559,
0.8719083666801453,
0.8715134859085083,
1,
0.8195480108261108,
1,
1,
0.8723332285881042,
0.8762935996055603
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 positive 4D tensor specified all options (negative options.alpha and negative options.beta)",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
0.05907066981577147,
0.7076089198897,
0.5228405296259637,
0.42310158753617455,
0.6643692569867639,
0.9502940424761401,
0.10918906453593258,
0.012977113903015258,
0.4755297159390164,
0.5322551665299613,
0.684307857800798,
0.4662107602754757,
0.3048996433987061,
0.8025872652109942,
0.2485963985673023,
0.6636898942337357,
0.554761182646025,
0.5542584257213008,
0.7311381962152534,
0.48809603333206986,
0.7766845231174959,
0.8455570201933926,
0.5553020911955322,
0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": -0.7854232544278235,
"beta": -0.4361860418530341
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 negative 4D tensor all options (positive options.alpha and negative options.beta)",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
-0.05907066981577147,
-0.7076089198897,
-0.5228405296259637,
-0.42310158753617455,
-0.6643692569867639,
-0.9502940424761401,
-0.10918906453593258,
-0.012977113903015258,
-0.4755297159390164,
-0.5322551665299613,
-0.684307857800798,
-0.4662107602754757,
-0.3048996433987061,
-0.8025872652109942,
-0.2485963985673023,
-0.6636898942337357,
-0.554761182646025,
-0.5542584257213008,
-0.7311381962152534,
-0.48809603333206986,
-0.7766845231174959,
-0.8455570201933926,
-0.5553020911955322,
-0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": 0.7854232544278235,
"beta": -0.4361860418530341
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"type": "float32"
}
},
{
"name": "hardSigmoid float32 negative 4D tensor specified all options (negative options.alpha and positive options.beta)",
"inputs": {
"x": {
"shape": [1, 2, 3, 4],
"data": [
-0.05907066981577147,
-0.7076089198897,
-0.5228405296259637,
-0.42310158753617455,
-0.6643692569867639,
-0.9502940424761401,
-0.10918906453593258,
-0.012977113903015258,
-0.4755297159390164,
-0.5322551665299613,
-0.684307857800798,
-0.4662107602754757,
-0.3048996433987061,
-0.8025872652109942,
-0.2485963985673023,
-0.6636898942337357,
-0.554761182646025,
-0.5542584257213008,
-0.7311381962152534,
-0.48809603333206986,
-0.7766845231174959,
-0.8455570201933926,
-0.5553020911955322,
-0.5603444395469193
],
"type": "float32"
}
},
"options": {
"alpha": -0.7854232544278235,
"beta": 0.4361860418530341
},
"expected": {
"name": "output",
"shape": [1, 2, 3, 4],
"data": [
0.4825815260410309,
0.9919585585594177,
0.8468371629714966,
0.7684998512268066,
0.9579971432685852,
1,
0.5219456553459167,
0.44637855887413025,
0.8096781373023987,
0.8542316555976868,
0.9736573696136475,
0.8023588061332703,
0.6756613254547119,
1,
0.6314394474029541,
0.9574635624885559,
0.8719083666801453,
0.8715134859085083,
1,
0.8195480108261108,
1,
1,
0.8723332285881042,
0.8762935996055603
],
"type": "float32"
}
}
]
}