#include <metal_stdlib>

using namespace metal;
uint2 textureDimensions_378a65(texture2d<int, access::write> tint_symbol) {
  uint2 res = uint2(tint_symbol.get_width(), tint_symbol.get_height());
  return res;
}

fragment void fragment_main(device uint2* tint_symbol_1 [[buffer(0)]], texture2d<int, access::write> tint_symbol_2 [[texture(0)]]) {
  *(tint_symbol_1) = textureDimensions_378a65(tint_symbol_2);
  return;
}

kernel void compute_main(device uint2* tint_symbol_3 [[buffer(0)]], texture2d<int, access::write> tint_symbol_4 [[texture(0)]]) {
  *(tint_symbol_3) = textureDimensions_378a65(tint_symbol_4);
  return;
}

