# AttributeError: module 'tvm.relay' has no attribute 'ir\_pass'

**URL:** <https://discuss.tvm.apache.org/t/attributeerror-module-tvm-relay-has-no-attribute-ir-pass/13567>\
**Category:** Troubleshooting\
**Created:** [September 23, 2022, 2:56am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-tvm-relay-has-no-attribute-ir-pass/13567 "2022-09-23T02:56:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learneruestc](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/learneruestc/32/4217_2.png) [@Learneruestc](https://discuss.tvm.apache.org/u/Learneruestc)\
**Post date:** [September 23, 2022, 2:56am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-tvm-relay-has-no-attribute-ir-pass/13567/1 "2022-09-23T02:56:53Z")

</div>

AttributeError: module ‘tvm.relay’ has no attribute ‘ir\_pass’

from tvm import relay def make\_dataset(graph, size=100): args = relay.ir\_pass.infer\_type(graph).params def create\_arr(var): ttype = var.type\_annotation np\_arr = np.random.uniform(-1.0, 1.0, size=ttype.concrete\_shape).astype(ttype.dtype) return tvm.ndarray.array(np\_arr) n, c, h, w = 1, 3, 224, 224 def make\_graph(data): weight = relay.var(“conv\_weight”) out = relay.nn.conv2d(data, weight, kernel\_size=(3, 3), padding=(1, 1), channels=c) out = relay.Function(relay.ir\_pass.free\_vars(out), out)

Anyone can solve this problem?

---

<div class="post-metadata">

**Author:** ![Learneruestc](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/learneruestc/32/4217_2.png) [@Learneruestc](https://discuss.tvm.apache.org/u/Learneruestc)\
**Post date:** [September 23, 2022, 3:14am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-tvm-relay-has-no-attribute-ir-pass/13567/2 "2022-09-23T03:14:48Z")

</div>

```
import tvm
from tvm import relay
import tvm.relay.testing
from tvm.relay.expr_functor import ExprMutator

class ScheduleConv2d(ExprMutator):
    def __init__ (self, device):
        self.device = device
        super(). __init__ ()

    def visit_call(self, expr):
        visit = super().visit_call(expr)
        if expr.op == tvm.relay.op.get("nn.conv2d"):
            return relay.annotation.on_device(visit, self.device)
        else:
            return visit

# def schedule_conv2d_on_gpu(expr):
# sched = ScheduleConv2d(tvm.gpu(0))
# return sched.visit(expr)

def schedule_conv2d_on_gpu(expr):
    sched = ScheduleConv2d(tvm.cpu(0))
    return sched.visit(expr)

resnet, params = relay.testing.resnet.get_workload()
print(resnet)
# resnet = schedule_conv2d_on_gpu(resnet)
# print(resnet)
resnet = relay.ir_pass.rewrite_annotated_ops(resnet, 0)
print(resnet)

```

This is a another case…

---

<div class="post-metadata">

**Author:** ![Learneruestc](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/learneruestc/32/4217_2.png) [@Learneruestc](https://discuss.tvm.apache.org/u/Learneruestc)\
**Post date:** [September 23, 2022, 9:56am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-tvm-relay-has-no-attribute-ir-pass/13567/3 "2022-09-23T09:56:28Z")

</div>

ok… There had a same post…

> [@\[Relay\] tvm.relay.ir\_pass is gone?](https://discuss.tvm.apache.org/t/relay-tvm-relay-ir-pass-is-gone/4077):
>
> Hi after I sync tvm to master version I couldn’t find ir\_pass under tvm.relay. I’m also un-able to use function like ir\_pass.free\_vars or ir\_pass.infer\_type. However I couldn’t find alternative to replace them from document. Any idea of where should I use to replace those two mentioned functions? Thanks!
