Commit 1d0f8ead authored by Khalique Ahmed's avatar Khalique Ahmed
Browse files

remove eliminate workspace

parent c99be32c
...@@ -140,7 +140,6 @@ add_library(migraphx_gpu ...@@ -140,7 +140,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
......
#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
#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
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,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>
...@@ -128,7 +127,6 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti ...@@ -128,7 +127,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