MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / InferSGDUpdateTensorDesc

Function InferSGDUpdateTensorDesc

oneflow/user/ops/model_update_ops.cpp:94–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94Maybe<void> InferSGDUpdateTensorDesc(user_op::InferContext* ctx) {
95 const user_op::TensorDesc& model = ctx->InputTensorDesc("model", 0);
96 const Shape& shape = model.shape();
97 const user_op::TensorDesc& model_diff = ctx->InputTensorDesc("model_diff", 0);
98 if (shape.NumAxes() > 0 && model_diff.shape().NumAxes() > 0) {
99 CHECK_EQ_OR_RETURN(model_diff.shape(), shape);
100 }
101 JUST(CheckLearningRateShape(ctx));
102 if (ctx->has_input("model_copy", 0)) {
103 CHECK_EQ_OR_RETURN(ctx->InputTensorDesc("model_copy", 0).shape(), shape)
104 << "Model copy shape should be equal to Model shape. ";
105 }
106 if (ctx->has_input("scale_by_tensor", 0)) {
107 const auto& scale_by_tensor = ctx->InputTensorDesc("scale_by_tensor", 0);
108 JUST(CheckScalarShape(&scale_by_tensor));
109 }
110 return Maybe<void>::Ok();
111}
112Maybe<void> InferSGDUpdateDataType(user_op::InferContext* ctx) {
113 JUST(CheckLearningRateDataType(ctx));
114 if (ctx->has_input("scale_by_tensor", 0)) {

Callers 1

Calls 5

CheckLearningRateShapeFunction · 0.70
CheckScalarShapeFunction · 0.70
shapeMethod · 0.45
NumAxesMethod · 0.45
has_inputMethod · 0.45

Tested by

no test coverage detected