jwfromm commented on a change in pull request #4417: [TOPI][RELAY][OP] add op
crop_and_resize
URL: https://github.com/apache/incubator-tvm/pull/4417#discussion_r350341893
##########
File path: include/tvm/relay/attrs/image.h
##########
@@ -60,6 +60,34 @@ struct ResizeAttrs : public tvm::AttrsNode<ResizeAttrs> {
}
};
+/*! \brief Attributes used in image crop_and_resize operator */
+struct CropAndResizeAttrs : public tvm::AttrsNode<CropAndResizeAttrs> {
+ Array<IndexExpr> crop_size;
+ std::string layout;
+ std::string method;
+ double extrapolation_value;
+ DataType out_dtype;
+
+ TVM_DECLARE_ATTRS(CropAndResizeAttrs, "relay.attrs.CropAndResizeAttrs") {
+ TVM_ATTR_FIELD(crop_size).set_default(NullValue<Array<IndexExpr> >())
+ .describe("Target Size.");
+ TVM_ATTR_FIELD(layout).set_default("NCHW")
+ .describe("Dimension ordering of input data. Can be 'NCHW', 'NHWC',
etc."
+ "'N', 'C', 'H', 'W' stands for batch, channel, height, and
width"
+ "dimensions respectively. Resize is applied on the 'H' and"
+ "'W' dimensions.");
+ TVM_ATTR_FIELD(method).set_default("bilinear")
+ .describe("Specify the mode to use for scaling."
+ "nearest_neighbor - Nearest Neighbor"
+ "bilinear - Bilinear Interpolation");
+ TVM_ATTR_FIELD(extrapolation_value).set_default(0.0)
+ .describe("Specify value for extrapolation.");
+ TVM_ATTR_FIELD(out_dtype)
Review comment:
It's actually useful to be able to specify it. Most images you'd be applying
this to have datatype uint8. Bilinear or Bicubic resizing will by default
output floats due to their interpolation but there may be cases where you'd
like to stay as an integer type. Similarly, nearest nearest neighbor wont
change the output type to float since it has no interpolation. Being able to
specify a fixed output type improves the predictability of the function.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services