|
|
@ -73,36 +73,35 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
MulOpMaker(OpProto* proto, OpAttrChecker* op_checker)
|
|
|
|
MulOpMaker(OpProto* proto, OpAttrChecker* op_checker)
|
|
|
|
: OpProtoAndCheckerMaker(proto, op_checker) {
|
|
|
|
: OpProtoAndCheckerMaker(proto, op_checker) {
|
|
|
|
AddInput("X", "The first input tensor of the mul op.");
|
|
|
|
AddInput("X", "(Tensor), The first input tensor of mul op.");
|
|
|
|
AddInput("Y", "The second input tensor of the mul op.");
|
|
|
|
AddInput("Y", "(Tensor), The second input tensor of mul op.");
|
|
|
|
AddOutput("Out", "The output tensor of the mul op.");
|
|
|
|
AddOutput("Out", "(Tensor), The output tensor of mul op.");
|
|
|
|
AddAttr<int>(
|
|
|
|
AddAttr<int>(
|
|
|
|
"x_num_col_dims",
|
|
|
|
"x_num_col_dims",
|
|
|
|
"(int, default 1) "
|
|
|
|
R"DOC((int, default 1), The mul_op can take tensors with more than two
|
|
|
|
R"DOC(The mul_op can take tensors with more than two dimensions as its
|
|
|
|
dimensions as its inputs. If the input $X$ is a tensor with more
|
|
|
|
inputs. If the input `X` is a tensor with more than two
|
|
|
|
than two dimensions, $X$ will be flattened into a two-dimensional
|
|
|
|
dimensions, `X` will be flattened into a two-dimensional matrix
|
|
|
|
matrix first. The flattening rule is: the first `num_col_dims`
|
|
|
|
first. The flattening rule is: the first `num_col_dims` will be
|
|
|
|
will be flattened to form the first dimension of the final matrix
|
|
|
|
flattened to form the first dimension of the final matrix (height
|
|
|
|
(the height of the matrix), and the rest `rank(X) - num_col_dims`
|
|
|
|
of the matrix), and the rest `rank(X) - num_col_dims` dimensions
|
|
|
|
dimensions are flattened to form the second dimension of the final
|
|
|
|
are flattened to form the second dimension of the final matrix (
|
|
|
|
matrix (the width of the matrix). As a result, height of the
|
|
|
|
width of the matrix). As a result, height of the flattened matrix
|
|
|
|
flattened matrix is equal to the product of $X$'s first
|
|
|
|
is equal to the product of `X`'s first `x_num_col_dims` dimensions'
|
|
|
|
`x_num_col_dims` dimensions' sizes, and width of the flattened
|
|
|
|
sizes, and width of the flattened matrix is equal to the product
|
|
|
|
matrix is equal to the product of $X$'s last `rank(x) - num_col_dims`
|
|
|
|
of `X`'s last `rank(x) - num_col_dims` dimensions' size.
|
|
|
|
dimensions' size. For example, suppose $X$ is a 6-dimensional
|
|
|
|
For example, suppose `X` is a 6-dimensional tensor with the shape
|
|
|
|
tensor with the shape [2, 3, 4, 5, 6], and `x_num_col_dims` = 3.
|
|
|
|
[2, 3, 4, 5, 6], and `x_num_col_dims` = 3. Then, the flattened
|
|
|
|
Thus, the flattened matrix will have a shape [2 x 3 x 4, 5 x 6] =
|
|
|
|
matrix will have a shape [2 x 3 x 4, 5 x 6] = [24, 30].
|
|
|
|
[24, 30].
|
|
|
|
)DOC")
|
|
|
|
)DOC")
|
|
|
|
.SetDefault(1)
|
|
|
|
.SetDefault(1)
|
|
|
|
.EqualGreaterThan(1);
|
|
|
|
.EqualGreaterThan(1);
|
|
|
|
AddAttr<int>(
|
|
|
|
AddAttr<int>(
|
|
|
|
"y_num_col_dims",
|
|
|
|
"y_num_col_dims",
|
|
|
|
"(int, default 1) "
|
|
|
|
R"DOC((int, default 1), The mul_op can take tensors with more than two,
|
|
|
|
R"DOC(The mul_op can take tensors with more than two dimensions as its
|
|
|
|
dimensions as its inputs. If the input $Y$ is a tensor with more
|
|
|
|
inputs. If the input `Y` is a tensor with more than two
|
|
|
|
than two dimensions, $Y$ will be flattened into a two-dimensional
|
|
|
|
dimensions, `Y` will be flatten into a two-dimensional matrix
|
|
|
|
matrix first. The attribute `y_num_col_dims` determines how $Y$ is
|
|
|
|
first. The attribute `y_num_col_dims` determines how `Y` is
|
|
|
|
|
|
|
|
flattened. See comments of `x_num_col_dims` for more details.
|
|
|
|
flattened. See comments of `x_num_col_dims` for more details.
|
|
|
|
)DOC")
|
|
|
|
)DOC")
|
|
|
|
.SetDefault(1)
|
|
|
|
.SetDefault(1)
|
|
|
@ -110,14 +109,14 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker {
|
|
|
|
AddComment(R"DOC(
|
|
|
|
AddComment(R"DOC(
|
|
|
|
Mul Operator.
|
|
|
|
Mul Operator.
|
|
|
|
|
|
|
|
|
|
|
|
This operator is used to perform matrix multiplication for input X and Y.
|
|
|
|
This operator is used to perform matrix multiplication for input $X$ and $Y$.
|
|
|
|
|
|
|
|
|
|
|
|
The equation is:
|
|
|
|
The equation is:
|
|
|
|
|
|
|
|
|
|
|
|
$$Out = X * Y$$
|
|
|
|
$$Out = X * Y$$
|
|
|
|
|
|
|
|
|
|
|
|
Both the input `X` and `Y` can carry the LoD (Level of Details) information,
|
|
|
|
Both the input $X$ and $Y$ can carry the LoD (Level of Details) information,
|
|
|
|
or not. But the output only shares the LoD information with input `X`.
|
|
|
|
or not. But the output only shares the LoD information with input $X$.
|
|
|
|
|
|
|
|
|
|
|
|
)DOC");
|
|
|
|
)DOC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|