Unverified Commit f57edddd authored by Charlie Lin's avatar Charlie Lin Committed by GitHub
Browse files

Fix normalize attributes docs (#1554)

Expands on the documentation and corrects default option documentation error.
parent 41bf982d
...@@ -31,18 +31,30 @@ namespace migraphx { ...@@ -31,18 +31,30 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace op { namespace op {
// different attributes /**
// 1) use_input(default)/use_output * `normalize_attribute` settings:
// 2) use_rank(default)/use_len * Note that default options are not included as enums.
// 3) clip_min(default)/not_clip_min * 1. `use_input` (default) vs. `use_output`:
// 3.1) include_min(default)/exclude_min * Affects the rank of the attribute.
// 4) clip_max(default)/not_clip_max * `use_input -> lens.size()`, `use_output -> lens.size() + vec.size()`.
// 4.1) exclude_max(default)/include_max * 2. use_rank (default) vs use_len:
// 5) normalize padding * `use_rank` sets the max value/index of the attribute as the rank of lens.
* `use_lens` sets the max value/index as the corresponding value in lens at the axes index.
* 3. `clip_min` vs. `not_clip_min` (default):
* Clip values less than the minimum to the minimum or not.
* 4. `include_min` vs. `exclude_min` (default):
* Include or exclude the minimum value/index for range checking and clipping.
* 5. `clip_max` vs. `not_clip_max` (default):
* Clip values greater than the maximum or not.
* 6. `include_max` vs. `exclude_max` (default):
* Include or exclude the maximum value/index for range checking and clipping.
* 7. `normalize_padding`:
* To normalize the padding to `2*(pad ndim)` dimensions.
*/
enum class normalize_attribute enum class normalize_attribute
{ {
use_len,
use_output, use_output,
use_len,
clip_max, clip_max,
clip_min, clip_min,
include_max, include_max,
......
...@@ -30,13 +30,16 @@ ...@@ -30,13 +30,16 @@
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
// different attributes /**
// 1) use_input(default)/use_output * Parameters:
// 2) use_rank(default)/use_len * vec: the vector attribute to normalize
// 3) clip_min(default)/not_clip_min * axes: the operator's axes attribute if it exists, empty otherwise
// 3.1) include_min(default)/exclude_min * val: the normalize_axes key and options. Ex: normalize["axes"] =
// 4) clip_max(default)/not_clip_max * value::array{normalize_attribute::include_min}; lens: shape dimensions passed when calling
// 4.1) exclude_max(default)/include_max * normalize_attributes(op&, lens)
*
* See normalize_attribute.hpp for explaining the options.
*/
auto tune_attribute(const std::vector<int64_t>& vec, auto tune_attribute(const std::vector<int64_t>& vec,
const std::vector<int64_t>& axes, const std::vector<int64_t>& axes,
const value& val, const value& val,
...@@ -151,6 +154,11 @@ auto tune_pad_attribute(const value& val) ...@@ -151,6 +154,11 @@ auto tune_pad_attribute(const value& val)
return result; return result;
} }
/**
* Assumptions:
* Dimensions to pad start from the third dimension (index 2).
* Called by compute_shape_op() with the `lens` of the first input.
*/
bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens) bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens)
{ {
bool tuned = false; bool tuned = false;
...@@ -158,9 +166,8 @@ bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens) ...@@ -158,9 +166,8 @@ bool normalize_attributes(operation& op, const std::vector<std::size_t>& lens)
auto val = op.to_value(); auto val = op.to_value();
if(attrs.contains("normalize_padding")) if(attrs.contains("normalize_padding"))
{ {
auto padding = val.at(attrs.at("normalize_padding").to<std::string>()); auto padding = val.at(attrs.at("normalize_padding").to<std::string>());
auto padding_size = padding.size(); auto padding_size = padding.size();
// for now, assume the dimensions to pad start at dim 2
auto padding_start = 2; auto padding_start = 2;
if(padding_size == 2 * (lens.size() - padding_start)) if(padding_size == 2 * (lens.size() - padding_start))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment