Skip to content

feat(aten::floor): Adds floor.int evaluator #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2021
Merged

Conversation

narendasan
Copy link
Collaborator

Description

Adds floor.int evaluator

Fixes #117
(partially addresses #252)

Type of change

Please delete options that are not relevant and/or add your own.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

@narendasan narendasan requested a review from peri044 April 17, 2021 03:24
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: evaluators Issues re: Specific op evaluators component: tests Issues re: Tests labels Apr 17, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/cpp/ptq/training/vgg16/export_ckpt.py
Reformatting /workspace/cpp/ptq/training/vgg16/vgg16.py
Reformatting /workspace/cpp/ptq/training/vgg16/main.py

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/core/conversion/var/Var.cpp b/tmp/changes.txt
index 71b77f5..8356934 100644
--- a/workspace/core/conversion/var/Var.cpp
+++ b/tmp/changes.txt
@@ -89,7 +89,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
  if (isIValue()) {
    LOG_DEBUG(ctx->logger, "Found IValue containing object of type " << *(ptr_.ivalue->type()));
  }
-  
+
  TRTORCH_CHECK(
      isITensor() || (isIValue() && (ptr_.ivalue->isTensor() || ptr_.ivalue->isCustomClass())),
      "Requested either IValue containing a Tensor, or ITensor, however Var type is " << type_name());
@@ -100,8 +100,10 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
    if (ptr_.ivalue->isTensor()) {
      auto weights = converters::Weights();
      auto tensor = ptr_.ivalue->toTensor();
-      if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) && !ctx->settings.truncate_long_and_double) {
-        TRTORCH_THROW_ERROR("Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
+      if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) &&
+          !ctx->settings.truncate_long_and_double) {
+        TRTORCH_THROW_ERROR(
+            "Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
      } else if (tensor.scalar_type() == at::kLong && ctx->settings.truncate_long_and_double) {
        weights = converters::Weights(ctx, tensor.toType(at::kInt));
        LOG_WARNING("Truncating weight (constant in the graph) from Int64 to Int32");
@@ -111,7 +113,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
      } else {
        weights = converters::Weights(ctx, tensor);
      }
-      
+
      auto const_layer = ctx->net->addConstant(weights.shape, weights.data);
      TRTORCH_CHECK(const_layer, "Unable to freeze tensor into constant layer");
      out = const_layer->getOutput(0);
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/core/conversion/var/Var.cpp b/tmp/changes.txt
index 71b77f5..8356934 100644
--- a/workspace/core/conversion/var/Var.cpp
+++ b/tmp/changes.txt
@@ -89,7 +89,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
  if (isIValue()) {
    LOG_DEBUG(ctx->logger, "Found IValue containing object of type " << *(ptr_.ivalue->type()));
  }
-  
+
  TRTORCH_CHECK(
      isITensor() || (isIValue() && (ptr_.ivalue->isTensor() || ptr_.ivalue->isCustomClass())),
      "Requested either IValue containing a Tensor, or ITensor, however Var type is " << type_name());
@@ -100,8 +100,10 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
    if (ptr_.ivalue->isTensor()) {
      auto weights = converters::Weights();
      auto tensor = ptr_.ivalue->toTensor();
-      if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) && !ctx->settings.truncate_long_and_double) {
-        TRTORCH_THROW_ERROR("Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
+      if ((tensor.scalar_type() == at::kLong || tensor.scalar_type() == at::kDouble) &&
+          !ctx->settings.truncate_long_and_double) {
+        TRTORCH_THROW_ERROR(
+            "Unable to freeze tensor of type Int64/Float64 into constant layer, try to compile model with truncate_long_and_double enabled");
      } else if (tensor.scalar_type() == at::kLong && ctx->settings.truncate_long_and_double) {
        weights = converters::Weights(ctx, tensor.toType(at::kInt));
        LOG_WARNING("Truncating weight (constant in the graph) from Int64 to Int32");
@@ -111,7 +113,7 @@ nvinfer1::ITensor* Var::ITensorOrFreeze(ConversionCtx* ctx) {
      } else {
        weights = converters::Weights(ctx, tensor);
      }
-      
+
      auto const_layer = ctx->net->addConstant(weights.shape, weights.data);
      TRTORCH_CHECK(const_layer, "Unable to freeze tensor into constant layer");
      out = const_layer->getOutput(0);
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

Reformatting /workspace/cpp/ptq/training/vgg16/export_ckpt.py
Reformatting /workspace/cpp/ptq/training/vgg16/vgg16.py
Reformatting /workspace/cpp/ptq/training/vgg16/main.py

@narendasan narendasan linked an issue Apr 19, 2021 that may be closed by this pull request
Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

@narendasan narendasan merged commit eb967ae into master Apr 22, 2021
@narendasan narendasan deleted the int_to_int_floor branch April 22, 2021 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: evaluators Issues re: Specific op evaluators component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

❓ [Question] How to solve aten::floor converter not found? Converter for aten::floor
1 participant