"ts/webui/src/vscode:/vscode.git/clone" did not exist on "06001775d587dbf478a19a7a9292933201626626"
Commit b50aa56c authored by charlie's avatar charlie
Browse files

progress

parent 32b1f924
......@@ -33,7 +33,6 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace op {
// Make this work just for exact matches
// can get rid of the other attributes and just check all the parameters are the same
// GPU version of this might have to deal with output parameters
......@@ -41,8 +40,7 @@ namespace op {
// Can have multiple inputs but only one output?
struct select_module
{
// output shape of the dynamic model
shape output_dyn_shape;
shape output_dyn_shapes;
template <class Self, class F>
static auto reflect(Self& self, F f)
......@@ -52,11 +50,7 @@ struct select_module
std::string name() const { return "select_module"; }
shape compute_shape(std::vector<shape> inputs) const
{
check_shapes{inputs, *this, true};
return shape{output_dyn_shape};
}
shape compute_shape(std::vector<shape>) const { return shape{output_dyn_shapes}; }
argument compute(const shape&,
const std::vector<argument>& args,
......@@ -64,21 +58,23 @@ struct select_module
const std::function<std::vector<argument>(
module_ref&, const std::unordered_map<std::string, argument>&)>& run) const
{
// find submodule with parameter shapes exactly the same as the input arguments
// assuming arguments are in the same order as the parameters
auto module_to_run = std::find_if(submodule_list.begin(), submodule_list.end(), [&](module_ref mr) {
auto param_names = mr.get_parameter_names();
std::equal(args.cbegin(), args.cend(), param_names.cbegin(), [&](auto a, auto p_name) {
return a.get_shape() == mr.get_parameter_shape(p_name);
});
});
// find submodule with parameter shapes exactly the same as the input arguments
// assuming arguments are in the same order as the parameters
auto module_iter =
std::find_if(submodule_list.cbegin(), submodule_list.cend(), [&](module_ref mr) {
auto param_names = mr->get_parameter_names();
std::equal(
args.cbegin(), args.cend(), param_names.cbegin(), [&](auto a, auto p_name) {
return a.get_shape() == mr->get_parameter_shape(p_name);
});
});
if(module_to_run == submodule_list.end())
if(module_iter == submodule_list.end())
{
MIGRAPHX_THROW("SELECT_MODULE: no compatible submodules found for given input shapes");
}
auto param_names = module_to_run.get_parameter_names();
auto module_to_run = *module_iter;
auto param_names = module_to_run->get_parameter_names();
assert(pnames.size() <= args.size());
std::unordered_map<std::string, argument> params;
std::transform(param_names.begin(),
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* 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.
*/
#ifndef MIGRAPHX_GUARD_RTGLIB_SELECT_MODULE_HPP
#define MIGRAPHX_GUARD_RTGLIB_SELECT_MODULE_HPP
#include <migraphx/argument.hpp>
#include <migraphx/module.hpp>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
struct context;
struct hip_select_module
{
std::string name() const { return "gpu::select_module"; }
shape compute_shape(std::vector<shape> inputs, std::vector<module_ref> mods) const;
argument
compute(context& ctx,
const shape& output_shape,
const std::vector<argument>& args,
const std::vector<module_ref>& mods,
const std::function<std::vector<argument>(
module_ref&, const std::unordered_map<std::string, argument>&)>& run) const;
std::ptrdiff_t output_alias(const std::vector<shape>& shapes) const
{
return shapes.size() - 1;
}
};
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
#endif
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* 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 <migraphx/gpu/select_module.hpp>
#include <migraphx/gpu/context.hpp>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......@@ -2293,17 +2293,21 @@ TEST_CASE(rnn)
TEST_CASE(select_module_dyn)
{
migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {3, 3}, {255, 255}, {255, 255}}};
migraphx::shape out_attr = migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}};
std::vector<migraphx::shape> sub_shapes = {};
sub_shapes.push_back(migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}});
migraphx::shape out_attr = migraphx::shape{sub_shapes};
expect_shape(
migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}},
migraphx::make_op("select_module", {{"output_dyn_shape", migraphx::to_value(out_attr)}}),
migraphx::make_op("select_module", {{"output_dyn_shapes", migraphx::to_value(out_attr)}}),
input);
}
TEST_CASE(select_module_static)
{
migraphx::shape input{migraphx::shape::float_type, {3, 3, 255, 255}};
migraphx::shape out_attr = migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}};
std::vector<migraphx::shape> sub_shapes = {};
sub_shapes.push_back(migraphx::shape{migraphx::shape::float_type, {{1, 4}, {1000, 1000}}});
migraphx::shape out_attr = migraphx::shape{sub_shapes};
expect_shape(migraphx::shape{migraphx::shape::float_type, {3, 1000}},
migraphx::make_op("select_module",
{{"output_dyn_shape", migraphx::to_value(out_attr)},
......
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