Cos#

  • Domain: ai.onnx

  • Since version: 22

Computes the Cos value of the input tensor element-wise.

Inputs

  • input (T): Input tensor

Outputs

  • output (T): The cosine of the input tensor computed element-wise

Type Constraints

  • T: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16).

Examples#

test_cc_cos

Node:
  Cos(x) -> (y)
Inputs:
  x: shape=(2, 3), dtype=float32
    [[-1.  , -0.5 ,  0.  ],
     [ 0.25,  0.5 ,  1.  ]]

Outputs:
  y: shape=(2, 3), dtype=float32
    [[0.5403023 , 0.87758255, 1.        ],
     [0.9689124 , 0.87758255, 0.5403023 ]]

test_cos

Node:
  Cos(x) -> (y)
Inputs:
  x: shape=(3, 4, 5), dtype=float32
    [[[ 1.4243481 , -0.61890423, -0.5907667 ,  1.4329695 ,  0.5837956 ],
      [-1.3854368 ,  1.2791865 ,  0.32735094,  0.6038593 ,  0.24222691],
      [-0.89236253, -1.1303798 , -0.09180629, -0.12591071, -1.2615176 ],
      [-0.55638343, -0.747256  , -0.59118223, -0.9279915 , -0.73401135]],

     [[ 1.1054384 , -0.69560546, -2.1534553 ,  0.11396561, -0.8268097 ],
      [ 1.2137318 , -0.22223468,  0.32949635, -0.21049212,  1.3518724 ],
      [ 0.01262847,  0.6841954 , -1.2623075 ,  0.20052178, -1.1255072 ],
      [-0.6395738 ,  1.5355366 , -1.1466801 , -0.42676184, -0.74427605]],

     [[-1.5989435 ,  2.3646672 , -1.0641551 ,  0.90345967, -0.24993172],
      [-1.784248  , -0.47239977,  0.09873669, -0.36464727,  0.6651279 ],
      [-1.01641   , -0.39525023,  0.45574856, -0.3439513 , -0.5487247 ],
      [ 0.06280329, -0.14411083, -1.1603392 ,  0.49200374, -0.16951095]]]

Outputs:
  y: shape=(3, 4, 5), dtype=float32
    [[[ 0.1459253 ,  0.81451464,  0.83051383,  0.13739093,  0.8343766 ],
      [ 0.18429995,  0.28749448,  0.94689745,  0.82315034,  0.97080624],
      [ 0.6275744 ,  0.4263163 ,  0.99578875,  0.9920837 ,  0.30437163],
      [ 0.8491706 ,  0.73355657,  0.83028233,  0.59944284,  0.7424934 ]],

     [[ 0.44874275,  0.76766586, -0.5502461 ,  0.9935129 ,  0.67722654],
      [ 0.34952545,  0.97540736,  0.94620544,  0.9779282 ,  0.21717931],
      [ 0.99992025,  0.77492785,  0.30361912,  0.97996277,  0.4307188 ],
      [ 0.8023502 ,  0.03525237,  0.41151544,  0.91031086,  0.73557854]],

     [[-0.02814343, -0.7130724 ,  0.48524314,  0.6188962 ,  0.9689293 ],
      [-0.21183449,  0.8904789 ,  0.99512947,  0.93424964,  0.7868379 ],
      [ 0.52642167,  0.92290026,  0.8979318 ,  0.9414296 ,  0.8531904 ],
      [ 0.9980285 ,  0.989634  ,  0.39902848,  0.88138807,  0.9856674 ]]]

test_cos_example

Node:
  Cos(x) -> (y)
Inputs:
  x: shape=(3,), dtype=float32
    [-1.,  0.,  1.]

Outputs:
  y: shape=(3,), dtype=float32
    [0.5403023, 1.       , 0.5403023]

Differences with previous version (7)#

SchemaDiff: Cos (domain 'ai.onnx')

  • old version: 7

  • new version: 22

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(bfloat16)’]

Version History#