MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / GetAxis

Function GetAxis

paddle/fluid/framework/data_layout_transform.cc:23–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace paddle::framework {
22
23std::vector<int> GetAxis(const DataLayout& from, const DataLayout& to) {
24 PADDLE_ENFORCE_NE(
25 from,
26 to,
27 common::errors::InvalidArgument(
28 "Layout transform should transform between different layout."));
29 if (from == DataLayout::NCHW && to == DataLayout::NHWC) {
30 return {0, 2, 3, 1};
31 } else if (from == DataLayout::NHWC && to == DataLayout::NCHW) {
32 return {0, 3, 1, 2};
33 } else {
34 PADDLE_THROW(
35 common::errors::InvalidArgument("Unsupported layout transform."));
36 }
37}
38
39template <typename T>
40void CastDataLayout::apply() {

Callers 1

TransDataLayoutFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected