"test/conv2d_fwd/conv2d_fwd.cpp" did not exist on "7e9a9d32c7a9259a1bd57b0b461c36d089d26fe8"
Unverified Commit f5760e21 authored by kahmed10's avatar kahmed10 Committed by GitHub
Browse files

remove eliminate_workspace pass (#1254)

* remove eliminate workspace
* remove sync device and other tags
parent e95b875f
...@@ -200,7 +200,6 @@ hip::copy_from_gpu ...@@ -200,7 +200,6 @@ hip::copy_from_gpu
hip::copy_to_gpu hip::copy_to_gpu
hip::hip_allocate_memory hip::hip_allocate_memory
hip::hip_copy_literal hip::hip_copy_literal
hip::sync_device
identity identity
im2col im2col
leaky_relu leaky_relu
......
...@@ -163,7 +163,6 @@ add_library(migraphx_gpu ...@@ -163,7 +163,6 @@ add_library(migraphx_gpu
convolution.cpp convolution.cpp
deconvolution.cpp deconvolution.cpp
device_name.cpp device_name.cpp
eliminate_workspace.cpp
elu.cpp elu.cpp
fuse_ops.cpp fuse_ops.cpp
gather.cpp gather.cpp
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 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/eliminate_workspace.hpp>
#include <migraphx/gpu/hip.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/pass_config.hpp>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
void eliminate_workspace::apply(module& m) const
{
std::size_t n = 0;
std::vector<instruction_ref> allocs;
for(auto ins : iterator_for(m))
{
if(ins->outputs().size() != 1)
continue;
if(ins->name() != "hip::allocate")
continue;
auto&& a = any_cast<hip_allocate>(ins->get_operator());
if(a.tag == "workspace")
{
n = std::max(n, ins->get_shape().bytes());
allocs.push_back(ins);
}
}
if(n > 0)
{
auto ws = m.add_parameter("workspace", shape{shape::int8_type, {n}});
for(auto&& a : allocs)
{
m.replace_instruction(a, ws);
m.remove_instruction(a);
}
}
}
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
...@@ -37,7 +37,6 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -37,7 +37,6 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
MIGRAPHX_REGISTER_OP(hip_allocate) MIGRAPHX_REGISTER_OP(hip_allocate)
MIGRAPHX_REGISTER_OP(hip_sync_device)
MIGRAPHX_REGISTER_OP(hip_sync_stream) MIGRAPHX_REGISTER_OP(hip_sync_stream)
MIGRAPHX_REGISTER_OP(hip_copy_to_gpu) MIGRAPHX_REGISTER_OP(hip_copy_to_gpu)
MIGRAPHX_REGISTER_OP(hip_copy_from_gpu) MIGRAPHX_REGISTER_OP(hip_copy_from_gpu)
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 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_ELIMINATE_WORKSPACE_HPP
#define MIGRAPHX_GUARD_RTGLIB_ELIMINATE_WORKSPACE_HPP
#include <string>
#include <migraphx/instruction_ref.hpp>
#include <migraphx/config.hpp>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
struct module;
namespace gpu {
struct eliminate_workspace
{
std::string name() const { return "eliminate_workspace"; }
void apply(module& m) const;
};
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
#endif
...@@ -59,12 +59,11 @@ argument get_preallocation(context& ctx, const std::string& id); ...@@ -59,12 +59,11 @@ argument get_preallocation(context& ctx, const std::string& id);
struct hip_allocate struct hip_allocate
{ {
shape s; shape s;
std::string tag{};
template <class Self, class F> template <class Self, class F>
static auto reflect(Self& self, F f) static auto reflect(Self& self, F f)
{ {
return pack(f(self.s, "shape"), f(self.tag, "tag")); return pack(f(self.s, "shape"));
} }
std::string name() const { return "hip::allocate"; } std::string name() const { return "hip::allocate"; }
...@@ -79,42 +78,8 @@ struct hip_allocate ...@@ -79,42 +78,8 @@ struct hip_allocate
} }
}; };
struct hip_sync_device
{
std::string tag{};
template <class Self, class F>
static auto reflect(Self& self, F f)
{
return pack(f(self.tag, "tag"));
}
std::string name() const { return "hip::sync_device"; }
shape compute_shape(const std::vector<shape>& inputs) const
{
if(inputs.empty())
return {};
return inputs.front();
}
argument compute(context&, const shape&, const std::vector<argument>& args) const
{
gpu_sync();
if(args.empty())
return {};
return args.front();
}
};
struct hip_sync_stream struct hip_sync_stream
{ {
std::string tag{};
template <class Self, class F>
static auto reflect(Self& self, F f)
{
return pack(f(self.tag, "tag"));
}
std::string name() const { return "hip::sync_stream"; } std::string name() const { return "hip::sync_stream"; }
shape compute_shape(const std::vector<shape>& inputs) const shape compute_shape(const std::vector<shape>& inputs) const
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#include <migraphx/gpu/compile_ops.hpp> #include <migraphx/gpu/compile_ops.hpp>
#include <migraphx/gpu/concat_gpu_opt.hpp> #include <migraphx/gpu/concat_gpu_opt.hpp>
#include <migraphx/gpu/context.hpp> #include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/eliminate_workspace.hpp>
#include <migraphx/gpu/fuse_ops.hpp> #include <migraphx/gpu/fuse_ops.hpp>
#include <migraphx/gpu/prefuse_ops.hpp> #include <migraphx/gpu/prefuse_ops.hpp>
#include <migraphx/gpu/lowering.hpp> #include <migraphx/gpu/lowering.hpp>
...@@ -151,7 +150,6 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti ...@@ -151,7 +150,6 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
sync_device{}, sync_device{},
preallocate_param{"scratch", gpu_allocation_model{}}, preallocate_param{"scratch", gpu_allocation_model{}},
dead_code_elimination{}, dead_code_elimination{},
eliminate_workspace{},
eliminate_allocation{"hip::allocate"}, eliminate_allocation{"hip::allocate"},
check_context<context>{}, check_context<context>{},
normalize_ops{}, normalize_ops{},
......
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