1 #include "caffe2/operators/sqr_op.h" 10 UnaryElementwiseOp<TensorTypes<float>, CPUContext, SqrFunctor<CPUContext>>);
15 .AllowInplace({{0, 0}})
16 .IdenticalTypeAndShape()
18 Performs element-wise squaring ($x^2$) of input tensor. 21 - https://github.com/pytorch/pytorch/blob/master/caffe2/operators/sqr_op.cc 25 <summary> <b>Example</b> </summary> 31 workspace.ResetWorkspace() 33 op = core.CreateOperator( 39 workspace.FeedBlob("X", (np.random.randint(10, size=(3,3))).astype(np.float32)) 40 print("X:", workspace.FetchBlob("X")) 41 workspace.RunOperatorOnce(op) 42 print("Y:", workspace.FetchBlob("Y")) 64 .Input(0, "X",
"*(type: Tensor`<float>`)* Input data tensor.")
65 .Output(0,
"Y",
"*(type: Tensor`<float>`)* Output tensor.");
69 class GetSqrGradient :
public GradientMakerBase {
70 using GradientMakerBase::GradientMakerBase;
71 std::vector<OperatorDef> GetGradientDefs()
override {
73 scale_arg.set_name(
"scale");
75 return std::vector<OperatorDef>{CreateOperatorDef(
78 std::vector<std::string>{GO(0)},
79 std::vector<std::string>{GO(0)},
80 std::vector<Argument>{scale_arg}),
84 std::vector<std::string>{GO(0), I(0)},
85 std::vector<std::string>{GI(0)})};
91 REGISTER_GRADIENT(Sqr, GetSqrGradient);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...