Skip to content

Commit

Permalink
Apply comments
Browse files Browse the repository at this point in the history
  • Loading branch information
echuraev committed Jun 8, 2022
1 parent 3976a93 commit edd94cb
Show file tree
Hide file tree
Showing 9 changed files with 536 additions and 765 deletions.
378 changes: 6 additions & 372 deletions python/tvm/topi/adreno/conv2d_nchw_winograd.py

Large diffs are not rendered by default.

377 changes: 6 additions & 371 deletions python/tvm/topi/adreno/conv2d_nhwc_winograd.py

Large diffs are not rendered by default.

513 changes: 513 additions & 0 deletions python/tvm/topi/adreno/conv2d_winograd_common.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion python/tvm/topi/adreno/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def get_texture_storage(shape):


def infer_tile_size(data, layout):
"""Compute the tile size
"""Compute the tile size for Winograd algorithm
Parameters
----------
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/opencl/texture_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace tvm {
namespace runtime {

void* Pool::Alloc(Device dev, DeviceAPI* device, size_t width, size_t height,
void* Pool2D::Alloc(Device dev, DeviceAPI* device, size_t width, size_t height,
DLDataType type_hint) {
Entry e;
Entry new_mem;
Expand Down Expand Up @@ -107,7 +107,7 @@ void* Pool::Alloc(Device dev, DeviceAPI* device, size_t width, size_t height,
return e.data;
}

void Pool::Free(void* data) {
void Pool2D::Free(void* data) {
Entry e;
if (allocated_.back().data == data) {
// quick path, last allocated.
Expand All @@ -125,7 +125,7 @@ void Pool::Free(void* data) {
}

// Release all resources immediately
void Pool::Release(Device dev, DeviceAPI* device) {
void Pool2D::Release(Device dev, DeviceAPI* device) {
for (auto& e : allocated_) {
device->FreeDataSpace(dev, e.data);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ void* TexturePool::AllocTexture(Device dev, size_t width, size_t height, DLDataT
array_.resize(dev.device_id + 1, nullptr);
}
if (array_[dev.device_id] == nullptr) {
array_[dev.device_id] = new Pool();
array_[dev.device_id] = new Pool2D();
}
return array_[dev.device_id]->Alloc(dev, device_, width, height, type_hint);
}
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ inline bool IsTextureStorage(std::string scope) {
return scope.find("texture") != std::string::npos;
}

class TVM_DLL Pool {
class TVM_DLL Pool2D {
public:
Pool() = default;
Pool2D() = default;
void* Alloc(Device dev, DeviceAPI* device, size_t width, size_t height, DLDataType type_hint);
void Free(void* data);
// Release all resources immediately
Expand Down Expand Up @@ -156,7 +156,7 @@ class TVM_DLL TexturePool {

private:
/*! \brief pool of device local array */
std::vector<Pool*> array_;
std::vector<Pool2D*> array_;
/*! \brief device type this pool support */
DLDeviceType device_type_;
/*! \brief The device API */
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp-runtime/opencl/opencl_texture_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
using namespace tvm::runtime;
using namespace tvm::runtime::cl;

// PoolWrapper is necessary because in class Pool we don't have an access to
// PoolWrapper is necessary because in class Pool2D we don't have an access to
// its protected members. In this class we add new methods which allow us to
// get and check internal state of class Pool
class PoolWrapper : public Pool {
class PoolWrapper : public Pool2D {
public:
inline size_t FreeListSize() const { return free_list_.size(); }
inline size_t AllocatedListSize() const { return allocated_.size(); }
Expand Down
2 changes: 1 addition & 1 deletion tests/python/relay/test_conv2d_nhwc_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import numpy as np
from tvm import relay
from tvm.relay import testing
from utils.adreno_utils import gpu_preprocess, build_run_compare, gpu_preprocess_nhwc
from utils.adreno_utils import gpu_preprocess, build_run_compare


@tvm.testing.requires_opencl
Expand Down
11 changes: 0 additions & 11 deletions tests/python/relay/utils/adreno_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,3 @@ def gpu_preprocess(tvm_mod):
mod = tvm.IRModule.from_expr(tvm_mod)
tvm_mod_nchwc = seq(mod)
return tvm_mod_nchwc


def gpu_preprocess_nhwc(tvm_mod):
layout_config = relay.transform.LayoutConfig()
desired_layouts = {"nn.conv2d": ["NHWC4c", "HWIO4o"]}
with layout_config:
seq = tvm.transform.Sequential([relay.transform.ConvertLayout(desired_layouts)])
with tvm.transform.PassContext(opt_level=3):
mod = tvm.IRModule.from_expr(tvm_mod)
tvm_mod_nhwcc = seq(mod)
return tvm_mod_nhwcc

0 comments on commit edd94cb

Please sign in to comment.