Change loop order to major to minor instead of minor to major.
This matches the comment, and it should make the memory access potentially faster. PiperOrigin-RevId: 241304479
This commit is contained in:
parent
9ccf10c72a
commit
b06f06148e
@ -113,6 +113,7 @@ cc_library(
|
|||||||
"//tensorflow/compiler/xla:types",
|
"//tensorflow/compiler/xla:types",
|
||||||
"//tensorflow/compiler/xla:xla_data_proto",
|
"//tensorflow/compiler/xla:xla_data_proto",
|
||||||
"//tensorflow/core:lib",
|
"//tensorflow/core:lib",
|
||||||
|
"@com_google_absl//absl/algorithm:container",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
"@com_google_absl//absl/types:span",
|
"@com_google_absl//absl/types:span",
|
||||||
"@llvm//:core",
|
"@llvm//:core",
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/algorithm/container.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/Function.h"
|
#include "llvm/IR/Function.h"
|
||||||
@ -261,11 +262,13 @@ std::vector<llvm::Value*> ForLoopNest::EmitOperandArrayLoopNest(
|
|||||||
// 'dimension_to_skip' dimension.
|
// 'dimension_to_skip' dimension.
|
||||||
std::vector<int64> dimensions;
|
std::vector<int64> dimensions;
|
||||||
const Shape& shape = operand_array.GetShape();
|
const Shape& shape = operand_array.GetShape();
|
||||||
|
// Initially get the dimensions in minor to major order, then reverse them.
|
||||||
for (int64 dimension : LayoutUtil::MinorToMajor(shape)) {
|
for (int64 dimension : LayoutUtil::MinorToMajor(shape)) {
|
||||||
if (dimension != dimension_to_skip) {
|
if (dimension != dimension_to_skip) {
|
||||||
dimensions.push_back(dimension);
|
dimensions.push_back(dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
absl::c_reverse(dimensions);
|
||||||
|
|
||||||
// Create loop nest with one for-loop for each dimension of the
|
// Create loop nest with one for-loop for each dimension of the
|
||||||
// output.
|
// output.
|
||||||
|
Loading…
Reference in New Issue
Block a user