Caffe2 - C++ API
A deep learning, cross platform ML framework
ceil_op.cc
1 #include "caffe2/operators/ceil_op.h"
2 
3 #include "caffe2/utils/math.h"
4 
5 namespace caffe2 {
6 
7 REGISTER_CPU_OPERATOR(Ceil, CeilOp<float, CPUContext>);
8 
9 OPERATOR_SCHEMA(Ceil)
10  .NumInputs(1)
11  .NumOutputs(1)
12  .AllowInplace({{0, 0}})
13  .SetDoc(R"DOC(
14 Element-wise application of the ceil function ($y=ceil(x)$) to the input tensor
15 `X`. Output tensor shape is the same as the input tensor.
16 
17 Github Link:
18 - https://github.com/pytorch/pytorch/blob/master/caffe2/operators/ceil_op.cc
19 
20 <details>
21 
22 <summary> <b>Example</b> </summary>
23 
24 **Code**
25 
26 ```
27 
28 workspace.ResetWorkspace()
29 
30 op = core.CreateOperator(
31  "Ceil",
32  ["X"],
33  ["X"],
34 )
35 
36 workspace.FeedBlob("X", (np.random.uniform(-10, 10, (5,5))).astype(np.float32))
37 print("X before running op:", workspace.FetchBlob("X"))
38 workspace.RunOperatorOnce(op)
39 print("X after running op:", workspace.FetchBlob("X"))
40 
41 ```
42 
43 **Result**
44 
45 ```
46 
47 X before running op:
48 [[ 8.44598 -6.5098248 -2.2993476 -7.6859694 0.58566964]
49  [-7.846551 -0.03689406 6.9362907 -4.0521703 4.4969673 ]
50  [ 0.33355865 -7.895527 -8.393201 9.374202 -2.3930092 ]
51  [-6.3061996 3.1403487 3.782099 -8.516556 -2.8387244 ]
52  [-2.0164998 4.7663913 -3.422966 0.3636999 8.75713 ]]
53 X after running op:
54 [[ 9. -6. -2. -7. 1.]
55  [-7. -0. 7. -4. 5.]
56  [ 1. -7. -8. 10. -2.]
57  [-6. 4. 4. -8. -2.]
58  [-2. 5. -3. 1. 9.]]
59 
60 ```
61 
62 </details>
63 
64 )DOC")
65  .Input(0, "X", "*(type: Tensor`<float>`)* Input tensor.")
66  .Output(0, "Y", "*(type: Tensor`<float>`)* Output tensor.");
67 
68 // TODO: Write gradient for this when needed
69 GRADIENT_NOT_IMPLEMENTED_YET(Ceil);
70 
71 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13