| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thanks Bruce.
if (input_tensor_info.dimensions.size() == 5 ||(minor) Consider `> 4` rather than specifically `== 5`, since that semantically reflects the limit of the underlying API (rank 4) allows code to be more generic (not that rank 6 will be hit anyway, since op support limits prevents it).
},Since [prelu](https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-prelu) is bidirectionally broadcastable, consider also a 1D input and 5D slope.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
(minor) Consider `> 4` rather than specifically `== 5`, since that semantically reflects the limit of the underlying API (rank 4) allows code to be more generic (not that rank 6 will be hit anyway, since op support limits prevents it).
👍
Updated. Please take another look. Thanks!
Since [prelu](https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-prelu) is bidirectionally broadcastable, consider also a 1D input and 5D slope.
Thanks @dwa...@microsoft.com!
I filed a separate issue https://issues.chromium.org/issues/503402055 to track it.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// TFLite's native PReLU path is used for lower-rank tensors, and
// SerializePrelu emulates rank-5 cases with element-wise ops to preserve
// WebNN broadcasting semantics for the 5D conformance coverage.
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/tflite/src/tensorflow/lite/kernels/internal/reference/prelu.hinconsistent indentation.
ASSIGN_OR_RETURN(const TensorIndex zero_value_tensor_index,
SerializeTensorWithBuffer<float>(
/*buffer=*/std::array<float, 1>{0.0f},
/*dimensions=*/{}));Worth adding a comment explaining why only create float32 zero tensor, e.g. "Prelu input tensors are already dequantized to float32 by SerializeInputTensorInfo."
ASSIGN_OR_RETURN(const TensorIndex scaled_negative_tensor_index,
SerializeTemporaryTensorWithByteSizeCheck(
input_tensor_info.dimensions,
input_tensor_info.data_type));The `scaled_negative_tensor_index` temporary is allocated with `input_tensor_info.dimensions`, but after slope * min(x, 0), the result shape may be the broadcast of `slope_tensor_info.dimensions`. If the slope has a dimension larger than 1 where input has 1, the intermediate tensor shape would be wrong. Consider using `output_tensor_info.dimensions` and adding a test case.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// TFLite's native PReLU path is used for lower-rank tensors, and
// SerializePrelu emulates rank-5 cases with element-wise ops to preserve
// WebNN broadcasting semantics for the 5D conformance coverage.
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/tflite/src/tensorflow/lite/kernels/internal/reference/prelu.hDai, Fenginconsistent indentation.
Done.
Please take another look at the new commit, thanks!
ASSIGN_OR_RETURN(const TensorIndex zero_value_tensor_index,
SerializeTensorWithBuffer<float>(
/*buffer=*/std::array<float, 1>{0.0f},
/*dimensions=*/{}));Worth adding a comment explaining why only create float32 zero tensor, e.g. "Prelu input tensors are already dequantized to float32 by SerializeInputTensorInfo."
Thanks @ningx...@intel.com!
I added such explanation comment here.
Please take another look at the new commit, thanks!
ASSIGN_OR_RETURN(const TensorIndex scaled_negative_tensor_index,
SerializeTemporaryTensorWithByteSizeCheck(
input_tensor_info.dimensions,
input_tensor_info.data_type));The `scaled_negative_tensor_index` temporary is allocated with `input_tensor_info.dimensions`, but after slope * min(x, 0), the result shape may be the broadcast of `slope_tensor_info.dimensions`. If the slope has a dimension larger than 1 where input has 1, the intermediate tensor shape would be wrong. Consider using `output_tensor_info.dimensions` and adding a test case.
Good catch! 👍
Updated in new commit, please take another look, thanks!
If the slope has a dimension larger than 1 where input has 1, the intermediate tensor shape would be wrong. Consider using `output_tensor_info.dimensions` and adding a test case.
Added such a test case "prelu float32 broadcast 5D x 5D slope with expanded output shape" using input of `[2, 1, 1, 2, 3]` shape with slope of `[1, 2, 1, 1, 1]` shape, current this test would run `Fail`, since there's this issue https://issues.chromium.org/issues/503402055 -
Support bidirectionally broadcast the shapes of input and slope for prelu operator, I will fix it in another following CL later.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
ASSIGN_OR_RETURN(const TensorIndex zero_value_tensor_index,
SerializeTensorWithBuffer<float>(
/*buffer=*/std::array<float, 1>{0.0f},
/*dimensions=*/{}));Dai, FengWorth adding a comment explaining why only create float32 zero tensor, e.g. "Prelu input tensors are already dequantized to float32 by SerializeInputTensorInfo."
Thanks @ningx...@intel.com!
I added such explanation comment here.
Please take another look at the new commit, thanks!
Acknowledged
ASSIGN_OR_RETURN(const TensorIndex scaled_negative_tensor_index,
SerializeTemporaryTensorWithByteSizeCheck(
input_tensor_info.dimensions,
input_tensor_info.data_type));Dai, FengThe `scaled_negative_tensor_index` temporary is allocated with `input_tensor_info.dimensions`, but after slope * min(x, 0), the result shape may be the broadcast of `slope_tensor_info.dimensions`. If the slope has a dimension larger than 1 where input has 1, the intermediate tensor shape would be wrong. Consider using `output_tensor_info.dimensions` and adding a test case.
Good catch! 👍
Updated in new commit, please take another look, thanks!If the slope has a dimension larger than 1 where input has 1, the intermediate tensor shape would be wrong. Consider using `output_tensor_info.dimensions` and adding a test case.
Added such a test case "prelu float32 broadcast 5D x 5D slope with expanded output shape" using input of `[2, 1, 1, 2, 3]` shape with slope of `[1, 2, 1, 1, 1]` shape, current this test would run `Fail`, since there's this issue https://issues.chromium.org/issues/503402055 -
Support bidirectionally broadcast the shapes of input and slope for prelu operator, I will fix it in another following CL later.
Acknowledged
input_tensor_info.data_type));Use `output_tensor_info` as well.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
input_tensor_info.data_type));| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Gentle ping @rei...@chromium.org Please take a review when you're available. Thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Commit-Queue | +2 |
Thanks all for your reviewing!
I'm going to submit this CL.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
Last there're trybot's failures when submitting CL, then I rebasline and rebase code to make all trybots pass. Now the failure results in expected files are due to this issue [#503402055 - Support bidirectionally broadcast the shapes of input and slope for prelu operator](https://issues.chromium.org/issues/503402055) that I'm working on a follow-up CL.
@ningx...@intel.com @rei...@chromium.org Please take another look, thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |