1 #include "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h" 5 GivenTensorByteStringToUInt8Fill,
6 GivenTensorByteStringToUInt8FillOp<CPUContext>);
8 NO_GRADIENT(GivenTensorByteStringToUInt8Fill);
10 OPERATOR_SCHEMA(GivenTensorByteStringToUInt8Fill)
13 .AllowInplace({{0, 0}})
15 This op fills a uint8 output tensor with the data specified by the *value* argument. The data must previously be serialized as a byte string. 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. 17 This op allows us to write uint8 tensors to Protobuf as byte strings and read them back as uint8 tensors in order to avoid the Protobuf uint32_t varint encoding size penalty. 21 <summary> <b>Example</b> </summary> 27 workspace.ResetWorkspace() 29 val = np.array([1, 2, 3], dtype=np.uint8) 30 op = core.CreateOperator( 31 "GivenTensorByteStringToUInt8Fill", 34 values=[val.tobytes()], 38 workspace.RunOperatorOnce(op) 39 print("Out:\n", workspace.FetchBlob("out")) 57 "The value for the elements of the output tensor.",
61 "The shape of the output tensor." 62 "Cannot set the shape argument and pass in an input at the same time.")
65 "The additional dimensions appended at the end of the shape indicated" 67 "Cannot set the extra_shape argument when there is no input blob.")
70 "1D tensor containing the desired output shape. First input must be in CPU context.")
71 .TensorInferenceFunction(
72 FillerTensorInference<TensorProto_DataType_STRING>);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...