1 #include "caffe2/operators/given_tensor_fill_op.h" 5 REGISTER_CPU_OPERATOR(
GivenTensorFill, GivenTensorFillOp<float, CPUContext>);
8 GivenTensorFillOp<double, CPUContext>);
9 REGISTER_CPU_OPERATOR(GivenTensorBoolFill, GivenTensorFillOp<bool, CPUContext>);
10 REGISTER_CPU_OPERATOR(GivenTensorIntFill, GivenTensorFillOp<int, CPUContext>);
11 REGISTER_CPU_OPERATOR(
13 GivenTensorFillOp<int64_t, CPUContext>);
14 REGISTER_CPU_OPERATOR(
15 GivenTensorStringFill,
16 GivenTensorFillOp<std::string, CPUContext>);
19 NO_GRADIENT(GivenTensorDoubleFill);
20 NO_GRADIENT(GivenTensorBoolFill);
21 NO_GRADIENT(GivenTensorIntFill);
22 NO_GRADIENT(GivenTensorInt64Fill);
23 NO_GRADIENT(GivenTensorStringFill);
28 .AllowInplace({{0, 0}})
30 This op fills an output tensor with the data specified by the *value* and *dtype* arguments. The output tensor shape is specified by the *shape* argument. Beware, when using this argument *value* should have a value for every element of the *output*, as missing values will not be initialized automatically. If *input_as_shape* is set to *true*, then the *input* should be a 1D tensor containing the desired output shape (the dimensions specified in *extra_shape* will also be appended). In this case, the *shape* argument should **not** be set. 32 *Note: Do not set the shape argument and pass in an input at the same time.* 35 - https://github.com/caffe2/caffe2/blob/master/caffe2/operators/given_tensor_fill_op.h 36 - https://github.com/caffe2/caffe2/blob/master/caffe2/operators/given_tensor_fill_op.cc 40 <summary> <b>Example</b> </summary> 46 workspace.ResetWorkspace() 48 op = core.CreateOperator( 56 workspace.RunOperatorOnce(op) 57 print("Out:\n", workspace.FetchBlob("out")) 75 "*(type depends on dtype, Required=True)* The value of the elements to go in the *output* tensor.",
79 "The data type for the elements of the output tensor. Strictly must be one of the types from DataType enum in TensorProto.")
82 "*(type: [int])* Desired shape of the *output* tensor.")
85 "*(type: [int])* The additional dimensions appended at the end of the *shape* indicated by the input blob. Cannot set the *extra_shape* argument when there is no input blob.")
88 "*(type: bool; default: False)* set to *True* to use the *input* as shape. First, input must be in CPU context.")
92 "(Optional) 1D tensor specifying the shape of the output. Must be used with *input_as_shape=True*")
96 "Output tensor with desired dimension filled with specified data. If the shape argument is set, this is the shape specified, and if the *input* exists and *input_as_shape=True*, it is the shape specified by the *input* tensor.")
97 .TensorInferenceFunction(FillerTensorInference<>);
99 OPERATOR_SCHEMA(GivenTensorDoubleFill)
102 .AllowInplace({{0, 0}})
105 "The value for the elements of the output tensor.",
109 "The shape of the output tensor." 110 "Cannot set the shape argument and pass in an input at the same time.")
113 "The additional dimensions appended at the end of the shape indicated" 115 "Cannot set the extra_shape argument when there is no input blob.")
118 "1D tensor containing the desired output shape. First input must be in CPU context.")
119 .TensorInferenceFunction(
120 FillerTensorInference<TensorProto_DataType_DOUBLE>);
122 OPERATOR_SCHEMA(GivenTensorBoolFill)
125 .AllowInplace({{0, 0}})
128 "The value for the elements of the output tensor.",
132 "The shape of the output tensor." 133 "Cannot set the shape argument and pass in an input at the same time.")
136 "The additional dimensions appended at the end of the shape indicated" 138 "Cannot set the extra_shape argument when there is no input blob.")
141 "1D tensor containing the desired output shape. First input must be in CPU context.")
142 .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_BOOL>);
144 OPERATOR_SCHEMA(GivenTensorIntFill)
147 .AllowInplace({{0, 0}})
150 "The value for the elements of the output tensor.",
154 "The shape of the output tensor." 155 "Cannot set the shape argument and pass in an input at the same time.")
158 "The additional dimensions appended at the end of the shape indicated" 160 "Cannot set the extra_shape argument when there is no input blob.")
163 "1D tensor containing the desired output shape. First input must be in CPU context.")
164 .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_INT32>);
166 OPERATOR_SCHEMA(GivenTensorInt64Fill)
169 .AllowInplace({{0, 0}})
172 "The value for the elements of the output tensor.",
176 "The shape of the output tensor." 177 "Cannot set the shape argument and pass in an input at the same time.")
180 "The additional dimensions appended at the end of the shape indicated" 182 "Cannot set the extra_shape argument when there is no input blob.")
185 "1D tensor containing the desired output shape. First input must be in CPU context.")
186 .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_INT64>);
188 OPERATOR_SCHEMA(GivenTensorStringFill)
191 .AllowInplace({{0, 0}})
194 "The value for the elements of the output tensor.",
198 "The shape of the output tensor." 199 "Cannot set the shape argument and pass in an input at the same time.")
202 "The additional dimensions appended at the end of the shape indicated" 204 "Cannot set the extra_shape argument when there is no input blob.")
207 "1D tensor containing the desired output shape. First input must be in CPU context.")
208 .TensorInferenceFunction(
209 FillerTensorInference<TensorProto_DataType_STRING>);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...