-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into asm_igemm_nhwc_fwd_bwd
# RESOLVED Conflicts: # src/solver.cpp
- Loading branch information
Showing
25 changed files
with
830 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/******************************************************************************* | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Advanced Micro Devices, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
|
||
#include <miopen/activ/problem_description.hpp> | ||
#include <miopen/names.hpp> | ||
|
||
#include <sstream> | ||
|
||
namespace miopen { | ||
|
||
namespace activ { | ||
|
||
NetworkConfig ProblemDescription::MakeNetworkConfig() const | ||
{ | ||
// short cut for packed tensors and 2D tensors with stride != width | ||
const auto& x_lens = xDesc.GetLengths(); | ||
|
||
const auto x_elem_sz = xDesc.GetElementSize(); | ||
|
||
const auto x_width2D = | ||
((x_lens.size() == 2) ? x_lens[1] : (x_lens.size() == 3) ? x_lens[2] : (x_lens.size() == 4) | ||
? x_lens[3] | ||
: x_lens[4]); | ||
|
||
const auto height = | ||
(x_lens.size() == 2) ? x_lens[0] : (x_lens.size() == 3) ? x_lens[1] : (x_lens.size() == 4) | ||
? x_lens[2] | ||
: x_lens[3]; | ||
|
||
const auto packed = xDesc.IsPacked() && yDesc.IsPacked(); | ||
|
||
const auto read_len = (packed) ? x_elem_sz : x_width2D; | ||
|
||
const auto read_unit = (read_len % 4 == 0) ? 4 : (read_len % 2 == 0) ? 2 : 1; | ||
const auto MAP_RD = read_len / read_unit; | ||
|
||
std::ostringstream ss; | ||
|
||
ss << "activ-"; | ||
ss << ((packed) ? "11" : "10"); // + lite bit | ||
ss << xDesc.GetType(); | ||
ss << activDesc.GetMode(); | ||
ss << read_unit; | ||
ss << MAP_RD; | ||
ss << height; | ||
|
||
return NetworkConfig{ss.str()}; | ||
} | ||
|
||
} // namespace activ | ||
|
||
} // namespace miopen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************* | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Advanced Micro Devices, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <miopen/invoke_params.hpp> | ||
#include <miopen/tensor.hpp> | ||
|
||
namespace miopen { | ||
namespace activ { | ||
|
||
struct InvokeParams : public miopen::InvokeParams | ||
{ | ||
InvokeParams() = default; | ||
|
||
double alpha = 0; | ||
TensorDescriptor x_desc; | ||
ConstData_t x = nullptr; | ||
double beta = 0; | ||
TensorDescriptor y_desc; | ||
Data_t y = nullptr; | ||
double gamma = 0; | ||
size_t x_offset = 0; | ||
size_t y_offset = 0; | ||
}; | ||
|
||
} // namespace activ | ||
|
||
} // namespace miopen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/******************************************************************************* | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Advanced Micro Devices, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <miopen/activ.hpp> | ||
#include <miopen/tensor.hpp> | ||
|
||
#include <string> | ||
|
||
namespace miopen { | ||
|
||
struct NetworkConfig; | ||
|
||
namespace activ { | ||
|
||
enum class Direction | ||
{ | ||
Forward, | ||
Backward, | ||
}; | ||
|
||
struct ProblemDescription | ||
{ | ||
ProblemDescription(Direction direction_, | ||
const ActivationDescriptor& activ, | ||
const TensorDescriptor& xDesc_, | ||
const TensorDescriptor& yDesc_) | ||
: direction(direction_), activDesc(activ), xDesc(xDesc_), yDesc(yDesc_) | ||
{ | ||
} | ||
|
||
Direction GetDirection() const { return direction; } | ||
const ActivationDescriptor& GetActivDesc() const { return activDesc; } | ||
const TensorDescriptor& GetXDesc() const { return xDesc; } | ||
const TensorDescriptor& GetYDesc() const { return yDesc; } | ||
|
||
NetworkConfig MakeNetworkConfig() const; | ||
|
||
void Serialize(std::ostream& stream) const; | ||
|
||
friend std::ostream& operator<<(std::ostream& os, const ProblemDescription& obj) | ||
{ | ||
obj.Serialize(os); | ||
return os; | ||
} | ||
|
||
private: | ||
Direction direction; | ||
ActivationDescriptor activDesc; | ||
TensorDescriptor xDesc; | ||
TensorDescriptor yDesc; | ||
}; | ||
|
||
} // namespace activ | ||
|
||
} // namespace miopen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Advanced Micro Devices, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <miopen/solver.hpp> | ||
|
||
namespace miopen { | ||
|
||
namespace activ { | ||
struct ProblemDescription; | ||
} // namespace activ | ||
|
||
namespace solver { | ||
|
||
namespace activ { | ||
|
||
struct ActivFwdSolver0 : public SolverBase<ProblemDescription> | ||
{ | ||
bool IsApplicable(const ExecutionContext& context, | ||
const miopen::activ::ProblemDescription& problem) const; | ||
ConvSolution GetSolution(const ExecutionContext& context, | ||
const miopen::activ::ProblemDescription& problem) const; | ||
}; | ||
|
||
} // namespace activ | ||
|
||
} // namespace solver | ||
|
||
} // namespace miopen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.