未验证 提交 73632dee 编写于 作者: A Abhinav Arora 提交者: GitHub

Polish the documentation for uniform_random and top_k ops (#5353)

上级 83c22816
...@@ -48,20 +48,20 @@ class TopkOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -48,20 +48,20 @@ class TopkOpMaker : public framework::OpProtoAndCheckerMaker {
public: public:
TopkOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker) TopkOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker)
: OpProtoAndCheckerMaker(proto, op_checker) { : OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", "The input of Topk op"); AddInput("X", "(Tensor) The input of Topk op");
AddOutput("Out", "The output tensor of Topk op"); AddOutput("Out", "(Tensor) The output tensor of Topk op");
AddOutput("Indices", "The indices of Topk elements of input"); AddOutput("Indices", "(Tensor) The indices of Topk elements of input");
AddComment( AddComment(R"DOC(
R"DOC(If the input is a vector (1d tensor), Top K operator
finds the k largest entries in the vector
and outputs their values and indices as vectors.
Thus values[j] is the j-th largest entry in input,
and its index is indices[j].
For matrices, computes the top k entries in each row. )DOC"); If the input is a vector (1d tensor), this operator finds the k largest
entries in the vector and outputs their values and indices as vectors.
Thus values[j] is the j-th largest entry in input, and its index is indices[j].
For matrices, this operator computes the top k entries in each row. )DOC");
AddAttr<int>("k", AddAttr<int>("k",
"Number of top elements to look for along the last " "(int, default 1) Number of top elements to look for along "
"dimension (along each row for matrices).") "the last dimension (along each row for matrices).")
.SetDefault(1); .SetDefault(1);
} }
}; };
......
...@@ -74,18 +74,30 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -74,18 +74,30 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker {
UniformRandomOpMaker(framework::OpProto* proto, UniformRandomOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: framework::OpProtoAndCheckerMaker(proto, op_checker) { : framework::OpProtoAndCheckerMaker(proto, op_checker) {
AddOutput("Out", "The output tensor of uniform random op"); AddOutput("Out", "(Tensor) The output tensor of uniform random op");
AddComment(R"DOC(Uniform random operator. AddComment(R"DOC(
Used to initialize tensor with uniform random generator. Uniform random operator.
This operator initializes a tensor with random values sampled from a
uniform distribution.
)DOC"); )DOC");
AddAttr<std::vector<int>>("shape", "the dimension of random tensor"); AddAttr<std::vector<int>>("shape",
AddAttr<float>("min", "Minimum value of uniform random").SetDefault(-1.0f); "(vector<int>) The shape of the output tensor");
AddAttr<float>("max", "Maximun value of uniform random").SetDefault(1.0f); AddAttr<float>("min",
"(float, default -1.0) "
"Minimum value of uniform random")
.SetDefault(-1.0f);
AddAttr<float>("max",
"(float, default 1.0) "
"Maximun value of uniform random")
.SetDefault(1.0f);
AddAttr<int>("seed", AddAttr<int>("seed",
"Random seed of uniform random. " "(int, default 0) "
"0 means generate a seed by system") "Random seed used for generating samples. "
"0 means use a seed generated by the system.")
.SetDefault(0); .SetDefault(0);
AddAttr<int>("data_type", "output tensor data type") AddAttr<int>("data_type", "(int, default 5(FP32)) Output tensor data type")
.SetDefault(framework::DataType::FP32); .SetDefault(framework::DataType::FP32);
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册