Skip to content

Commit

Permalink
fixup: src: introduce quant_entry_t and refactor arg_scales_t to rely…
Browse files Browse the repository at this point in the history
… on it
  • Loading branch information
dzarukin committed Feb 6, 2025
1 parent bf0017b commit 7193163
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
9 changes: 2 additions & 7 deletions src/gpu/amd/miopen_binary.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2020-2024 Intel Corporation
* Copyright 2020-2025 Intel Corporation
* Copyright 2020 Codeplay Software Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -66,12 +66,7 @@ struct miopen_binary_t : public gpu::primitive_t {
|| has_zero_dims(dst_md()->dims, dst_md()->ndims);
}

bool check_scales_mask() const {
for (const auto &s : attr()->scales_.scales_) {
if (s.second.mask_ != 0) return false;
}
return true;
}
bool check_scales_mask() const { return attr_scales_ok(); }

bool check_no_blocking() const {
// Blocking is not supported by MIOPENOpTensor, return false if any
Expand Down
21 changes: 12 additions & 9 deletions src/gpu/amd/miopen_reorder.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2020-2024 Intel Corporation
* Copyright 2020-2025 Intel Corporation
* Copyright 2020-2022 Codeplay Software Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -71,14 +71,17 @@ struct miopen_reorder_t : public gpu::primitive_t {
return ok;
}

bool scales_ok() const {
const auto &scales = attr()->scales_;
const auto &supported_args = {DNNL_ARG_FROM, DNNL_ARG_TO};
if (!scales.has_default_values(supported_args)) return false;
// MIOpen does not support scaling per dimension.
for (auto arg : supported_args)
if (scales.get(arg).mask_ != 0) return false;
return true;
bool scales_ok(const std::vector<int> &supported_args
= {DNNL_ARG_FROM, DNNL_ARG_TO}) const {
bool ok = attr()->scales_.has_default_values(supported_args);
for (int arg : supported_args) {
if (attr()->scales_.has_default_values(arg)) continue;

const auto &mask = attr()->scales_.get_mask(arg);
// MIOpen does not support scaling per dimension.
ok = ok && (mask == 0);
}
return ok;
}

bool post_ops_ok() const {
Expand Down

0 comments on commit 7193163

Please sign in to comment.